18 #include "pab_pablib.h"
20 bool operator < (mapitag_t & a,mapitag_t & b) { return a._order<b._order; }
21 bool operator > (mapitag_t & a,mapitag_t & b) { return a._order>b._order; }
22 bool operator == (mapitag_t & a,mapitag_t & b) { return a._order==b._order; }
103 HP_OPENMAIL_ORGANIZATION,
109 HP_OPENMAIL_DEPARTMENT,
124 HP_OPENMAIL_LOCATION_OF_WORK,
130 static word_t *mapi_map[]={ map_givenname, map_email,
131 map_firstname, map_lastname, map_additionalname,map_title,
132 map_address, map_town, map_zip, map_state, map_country,
133 map_tel, map_mobile, map_fax,
134 map_organization, map_department, map_subdep, map_job,
140 pabrec_entry mapitag_t::matchTag( void)
143 pabrec_entry e=pr_unknown;
145 for(i=0;mapi_map[i]!=NULL && e==pr_unknown;i++) {
146 for(j=1;mapi_map[i][j]!=0 && _tag!=mapi_map[i][j];j++);
147 if (mapi_map[i][j]!=0) {
148 e=(pabrec_entry) mapi_map[i][0];
154 pabfields_t::pabfields_t(pabrec & R, TQWidget * )
162 content_t _tag,_order;
168 _tag=R.read(mb);mb+= sizeof(_tag);
169 _order=R.read(mb);mb+= sizeof(_order);
171 {mapitag_t mt(_tag,_order);
172 tags[tags.size()]=mt;
173 context_tags[context_tags.size()]=mt;
180 for(i=2,k=0;i<R.N() && k<tags.size();i++,k++) {
181 if (!isUsed(k)) { i-=1; }
182 else {pabrec_entry e;
188 s=s.stripWhiteSpace();
202 case pr_givenname: givenName=E;
204 case pr_email: email=E;
206 case pr_firstname: firstName=E;
208 case pr_additionalname: additionalName=E;
210 case pr_lastname: lastName=E;
212 case pr_title: title=E;
214 case pr_address: address=E;
216 case pr_town: town=E;
218 case pr_state: state=E;
222 case pr_country: country=E;
224 case pr_organization: organization=E;
226 case pr_department: department=E;
228 case pr_subdep: subDep=E;
236 case pr_modem: modem=E;
238 case pr_mobile: mobile=E;
240 case pr_url: homepage=E;
242 case pr_talk: talk=E;
244 case pr_notes: comment=E;
246 case pr_birthday: birthday=E;
260 if (!firstName.isEmpty() && !lastName.isEmpty()) {
261 givenName=lastName+ ", "+firstName;
269 bool pabfields_t::isUsed( int k)
271 return tags[k].isUsed();
274 pabrec_entry pabfields_t::isWhat( int k)
276 return tags[k].matchTag();
279 word_t pabfields_t::literal( int k)
281 return tags[k].literal();
284 content_t pabfields_t::order( int k)
286 return tags[k].order();
289 TDEABC::Addressee pabfields_t::get() {
291 if (!givenName.isEmpty()) a.setFormattedName(givenName);
292 if (!email.isEmpty()) a.insertEmail(email);
293 if (!title.isEmpty()) a.setTitle(title);
294 if (!firstName.isEmpty()) a.setName(firstName);
295 if (!additionalName.isEmpty()) a.setAdditionalName(additionalName);
296 if (!lastName.isEmpty()) a.setFamilyName(lastName);
298 TDEABC::Address addr;
299 if (!address.isEmpty()) addr.setStreet(address);
300 if (!town.isEmpty()) addr.setLocality(town);
301 if (!zip.isEmpty()) addr.setPostalCode(zip);
302 if (!state.isEmpty()) addr.setRegion(state);
303 if (!country.isEmpty()) addr.setCountry(country);
304 a.insertAddress(addr);
306 if (!organization.isEmpty()) a.setOrganization(organization);
307 if (!department.isEmpty()) a.setRole(department);
309 if (!tel.isEmpty()) a.insertPhoneNumber( TDEABC::PhoneNumber( tel, TDEABC::PhoneNumber::Voice ) );
310 if (!fax.isEmpty()) a.insertPhoneNumber( TDEABC::PhoneNumber( fax, TDEABC::PhoneNumber::Fax ) );
311 if (!mobile.isEmpty()) a.insertPhoneNumber( TDEABC::PhoneNumber( mobile, TDEABC::PhoneNumber::Cell ) );
312 if (!modem.isEmpty()) a.insertPhoneNumber( TDEABC::PhoneNumber( modem, TDEABC::PhoneNumber::Modem ) );
313 if (!homepage.isEmpty()) a.setUrl(KURL( homepage ));
315 if (!comment.isEmpty()) a.setNote(comment);
341 pabrec::pabrec(pab & P)
345 word_t offset,size,dummy;
357 m_W= new word_t[m_N+1];
360 for(i=0;i<=m_N;i++) {
372 content_t pabrec::read(word_t offset)
376 R<<=8;R+=_mem[offset+2];
377 R<<=8;R+=_mem[offset+1];
378 R<<=8;R+=_mem[offset];
382 const char *pabrec::getEntry( int i)
386 mb=m_W[i];me=m_W[i+1];
387 for(k=0;mb!=me;mb++) {
388 if (_mem[mb]>= ' ' || _mem[mb]== '\n' || _mem[mb]==13 || _mem[mb]== '\t') {
389 if (_mem[mb]==13) { entry[k]= '\n'; }
390 else { entry[k]=_mem[mb]; }
395 return ( const char *) entry;
|