kaddressbook

pab_mapihd.h
1 /***************************************************************************
2  mapihd.h - description
3  -------------------
4  begin : Tue Jul 25 2000
5  copyright : (C) 2000 by Hans Dijkema
6  email : kmailcvt@hum.org
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef _MAPIHD_H_
19 #define _MAPIHD_H_
20 
21 #include <tqmemarray.h>
22 
23 #include "pab_xxport.h"
24 
25 #define T_MS_ARRAY 0x1100 // Some sort of array
26 #define T_MS_STRING ((unsigned long) 0x1e) // definitely a string
27 
28  typedef unsigned long adr_t;
29  typedef unsigned long content_t;
30  typedef unsigned short pabsize_t;
31  typedef unsigned char byte_t;
32  typedef unsigned short word_t;
33  typedef byte_t byte;
34 
35  class pab;
36 
37  class pabrec {
38  private:
39  char entry[1024];
40  byte *_mem;
41  word_t m_N;
42  word_t *m_W;
43  public:
44  pabrec(pab &); // expects record the begin at reading point (ftell).
45  ~pabrec();
46  public:
47  word_t N(void) { return m_N; }
48  word_t operator[](int i) { return m_W[i]; }
49  const char *getEntry(int i);
50  public:
51  content_t read(word_t offset);
52  };
53 
54  typedef enum {
55  pr_unknown,pr_notused,
56  pr_givenname,pr_email,
57  pr_firstname,pr_additionalname,pr_lastname,pr_title,
58  pr_address,pr_town,pr_state,pr_zip,pr_country,
59  pr_organization,pr_department,pr_subdep,pr_job,
60  pr_tel,pr_fax,pr_modem,pr_mobile,pr_url,pr_talk,
61  pr_notes,pr_birthday
62  }
63  pabrec_entry;
64 
65  class mapitag_t
66  {
67  friend bool operator < (mapitag_t &,mapitag_t &);
68  friend bool operator > (mapitag_t &,mapitag_t &);
69  friend bool operator == (mapitag_t &,mapitag_t &);
70  private:
71  word_t _tag;
72  word_t _type;
73  content_t _order;
74  public:
75  mapitag_t(content_t tag,content_t order) { _tag=(word_t) tag;_type=(word_t) (tag>>16);_order=order; }
76  mapitag_t() { _tag=0;_type=0;_order=0; }
77  public:
78  mapitag_t & operator = (mapitag_t & t) { _tag=t._tag;_type=t._type;_order=t._order;return *this; }
79  public:
80  bool isUsed(void) { return (_type==T_MS_STRING || (_type&T_MS_ARRAY)!=0) && _order!=0; }
81  word_t literal(void) { return _tag; }
82  content_t order(void) { return _order; }
83  pabrec_entry matchTag(void);
84  };
85 
86  bool operator < (mapitag_t & a,mapitag_t & b);
87  bool operator > (mapitag_t & a,mapitag_t & b);
88  bool operator == (mapitag_t & a,mapitag_t & b);
89 
90  class pabfields_t
91  {
92  private:
93  TQMemArray<mapitag_t> tags,context_tags;
94  pabrec *m_R;
95  TQString givenName,email,
96  title,firstName,additionalName,lastName,
97  address,town,state,zip,country,
98  organization,department,subDep,job,
99  tel,fax,modem,mobile,homepage,talk,
100  comment,birthday;
101  bool OK;
102  private:
103  bool isUsed(int k);
104  pabrec_entry isWhat(int k);
105  word_t literal(int k);
106  content_t order(int k);
107  public:
108  pabfields_t(pabrec & R, TQWidget *parent);
109  public:
110  TDEABC::Addressee get( );
111  bool isOK(void) { return OK; }
112  bool isUsable(void) { return givenName!=""; }
113  };
114 
115 
116 #endif
117