summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/converter/sharpdtm/sharpdtmconverter.cpp98
1 files changed, 49 insertions, 49 deletions
diff --git a/kabc/converter/sharpdtm/sharpdtmconverter.cpp b/kabc/converter/sharpdtm/sharpdtmconverter.cpp
index b3e2ee1..4cf2eb3 100644
--- a/kabc/converter/sharpdtm/sharpdtmconverter.cpp
+++ b/kabc/converter/sharpdtm/sharpdtmconverter.cpp
@@ -49,24 +49,24 @@ SharpDTMConverter::~SharpDTMConverter()
49bool SharpDTMConverter::init() 49bool SharpDTMConverter::init()
50{ 50{
51 catDB = new SlCategory::SlCategories(); 51 catDB = new SlCategory::SlCategories();
52 52
53 if (!catDB) 53 if (!catDB)
54 return false; 54 return false;
55 55
56// catDB->load( categoryFileName() ); 56// catDB->load( categoryFileName() );
57 return true; 57 return true;
58} 58}
59 59
60void SharpDTMConverter::deinit() 60void SharpDTMConverter::deinit()
61{ 61{
62 if (catDB) 62 if (catDB)
63 { 63 {
64 delete catDB; 64 delete catDB;
65 catDB = 0; 65 catDB = 0;
66 } 66 }
67} 67}
68 68
69bool SharpDTMConverter::sharpToAddressee( const PimContact &contact, Addressee &addr ) 69bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr )
70{ 70{
71/*US 71/*US
72 // name 72 // name
@@ -76,17 +76,17 @@ bool SharpDTMConverter::sharpToAddressee( const PimContact &contact, Addressee &
76 addr.setAdditionalName( contact.middleName() ); 76 addr.setAdditionalName( contact.middleName() );
77 addr.setPrefix( contact.nameTitle() ); 77 addr.setPrefix( contact.nameTitle() );
78 addr.setSuffix( contact.suffix() ); 78 addr.setSuffix( contact.suffix() );
79 79
80 80
81 // email 81 // email
82 QStringList emails = contact.emailList(); 82 QStringList emails = contact.emailList();
83 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 83 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
84 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); 84 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) );
85 } 85 }
86 86
87 if (!contact.defaultEmail().isEmpty()) 87 if (!contact.defaultEmail().isEmpty())
88 addr.insertEmail(contact.defaultEmail(), true); 88 addr.insertEmail(contact.defaultEmail(), true);
89 89
90 // home 90 // home
91 if ((!contact.homeStreet().isEmpty()) || 91 if ((!contact.homeStreet().isEmpty()) ||
92 (!contact.homeCity().isEmpty()) || 92 (!contact.homeCity().isEmpty()) ||
@@ -103,10 +103,10 @@ bool SharpDTMConverter::sharpToAddressee( const PimContact &contact, Addressee &
103 homeaddress.setRegion( contact.homeState() ); 103 homeaddress.setRegion( contact.homeState() );
104 homeaddress.setPostalCode( contact.homeZip() ); 104 homeaddress.setPostalCode( contact.homeZip() );
105 homeaddress.setCountry( contact.homeCountry() ); 105 homeaddress.setCountry( contact.homeCountry() );
106 106
107 addr.insertAddress( homeaddress ); 107 addr.insertAddress( homeaddress );
108 } 108 }
109 109
110 if (!contact.homePhone().isEmpty()) 110 if (!contact.homePhone().isEmpty())
111 { 111 {
112 PhoneNumber homephone; 112 PhoneNumber homephone;
@@ -114,7 +114,7 @@ bool SharpDTMConverter::sharpToAddressee( const PimContact &contact, Addressee &
114 homephone.setNumber( contact.homePhone() ); 114 homephone.setNumber( contact.homePhone() );
115 addr.insertPhoneNumber( homephone ); 115 addr.insertPhoneNumber( homephone );
116 } 116 }
117 117
118 if (!contact.homeFax().isEmpty()) 118 if (!contact.homeFax().isEmpty())
119 { 119 {
120 PhoneNumber homefax; 120 PhoneNumber homefax;
@@ -122,7 +122,7 @@ bool SharpDTMConverter::sharpToAddressee( const PimContact &contact, Addressee &
122 homefax.setNumber( contact.homeFax() ); 122 homefax.setNumber( contact.homeFax() );
123 addr.insertPhoneNumber( homefax ); 123 addr.insertPhoneNumber( homefax );
124 } 124 }
125 125
126 if (!contact.homeMobile().isEmpty()) 126 if (!contact.homeMobile().isEmpty())
127 { 127 {
128 PhoneNumber homemobile; 128 PhoneNumber homemobile;
@@ -130,9 +130,9 @@ bool SharpDTMConverter::sharpToAddressee( const PimContact &contact, Addressee &
130 homemobile.setNumber( contact.homeMobile() ); 130 homemobile.setNumber( contact.homeMobile() );
131 addr.insertPhoneNumber( homemobile ); 131 addr.insertPhoneNumber( homemobile );
132 } 132 }
133 133
134 addr.setUrl( contact.homeWebpage() ); 134 addr.setUrl( contact.homeWebpage() );
135 135
136 136
137 // business 137 // business
138 if ((!contact.businessStreet().isEmpty()) || 138 if ((!contact.businessStreet().isEmpty()) ||
@@ -150,11 +150,11 @@ bool SharpDTMConverter::sharpToAddressee( const PimContact &contact, Addressee &
150 businessaddress.setRegion( contact.businessState() ); 150 businessaddress.setRegion( contact.businessState() );
151 businessaddress.setPostalCode( contact.businessZip() ); 151 businessaddress.setPostalCode( contact.businessZip() );
152 businessaddress.setCountry( contact.businessCountry() ); 152 businessaddress.setCountry( contact.businessCountry() );
153 153
154 addr.insertAddress( businessaddress ); 154 addr.insertAddress( businessaddress );
155 } 155 }
156 156
157 157
158 if (!contact.businessPhone().isEmpty()) 158 if (!contact.businessPhone().isEmpty())
159 { 159 {
160 PhoneNumber businessphone; 160 PhoneNumber businessphone;
@@ -162,7 +162,7 @@ bool SharpDTMConverter::sharpToAddressee( const PimContact &contact, Addressee &
162 businessphone.setNumber( contact.businessPhone() ); 162 businessphone.setNumber( contact.businessPhone() );
163 addr.insertPhoneNumber( businessphone ); 163 addr.insertPhoneNumber( businessphone );
164 } 164 }
165 165
166 if (!contact.businessFax().isEmpty()) 166 if (!contact.businessFax().isEmpty())
167 { 167 {
168 PhoneNumber businessfax; 168 PhoneNumber businessfax;
@@ -170,7 +170,7 @@ bool SharpDTMConverter::sharpToAddressee( const PimContact &contact, Addressee &
170 businessfax.setNumber( contact.businessFax() ); 170 businessfax.setNumber( contact.businessFax() );
171 addr.insertPhoneNumber( businessfax ); 171 addr.insertPhoneNumber( businessfax );
172 } 172 }
173 173
174 if (!contact.businessMobile().isEmpty()) 174 if (!contact.businessMobile().isEmpty())
175 { 175 {
176 PhoneNumber businessmobile; 176 PhoneNumber businessmobile;
@@ -186,7 +186,7 @@ bool SharpDTMConverter::sharpToAddressee( const PimContact &contact, Addressee &
186 businesspager.setNumber( contact.businessPager() ); 186 businesspager.setNumber( contact.businessPager() );
187 addr.insertPhoneNumber( businesspager ); 187 addr.insertPhoneNumber( businesspager );
188 } 188 }
189 189
190 addr.setRole( contact.jobTitle() ); //? 190 addr.setRole( contact.jobTitle() ); //?
191 addr.setOrganization( contact.company() ); 191 addr.setOrganization( contact.company() );
192 addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() ); 192 addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() );
@@ -203,32 +203,32 @@ bool SharpDTMConverter::sharpToAddressee( const PimContact &contact, Addressee &
203 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); 203 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male");
204 else if (contact.gender() == PimContact::Female) 204 else if (contact.gender() == PimContact::Female)
205 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); 205 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female");
206 206
207 if (contact.anniversary().isValid()) { 207 if (contact.anniversary().isValid()) {
208 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate); 208 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate);
209//US 209//US
210// qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1()); 210// qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1());
211 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 211 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
212 } 212 }
213 213
214 addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); 214 addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() );
215 if (contact.birthday().isValid()) 215 if (contact.birthday().isValid())
216 addr.setBirthday( contact.birthday() ); 216 addr.setBirthday( contact.birthday() );
217 217
218 addr.setNickName( contact.nickname() ); 218 addr.setNickName( contact.nickname() );
219 219
220 // others 220 // others
221 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. 221 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available.
222 QString notes = contact.notes(); 222 QString notes = contact.notes();
223 notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n"; 223 notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n";
224 224
225 addr.setNote( contact.notes() ); 225 addr.setNote( contact.notes() );
226 226
227 227
228 228
229//US QString groups() const { return find( Qtopia::Groups ); } 229//US QString groups() const { return find( Qtopia::Groups ); }
230//US QStringList groupList() const; 230//US QStringList groupList() const;
231 231
232 QArray<int> catArray = contact.categories(); 232 QArray<int> catArray = contact.categories();
233 QString cat; 233 QString cat;
234 234
@@ -237,11 +237,11 @@ bool SharpDTMConverter::sharpToAddressee( const PimContact &contact, Addressee &
237 if ( !cat.isEmpty() ) 237 if ( !cat.isEmpty() )
238 addr.insertCategory( cat ); 238 addr.insertCategory( cat );
239 } 239 }
240*/ 240*/
241 return true; 241 return true;
242} 242}
243 243
244bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, PimContact &contact ) 244bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, const SlZDataBase* database , const CardId &contact )
245{ 245{
246/*US 246/*US
247 // name 247 // name
@@ -251,15 +251,15 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, PimContact &con
251 contact.setNameTitle(addr.prefix()); 251 contact.setNameTitle(addr.prefix());
252 contact.setSuffix(addr.suffix()); 252 contact.setSuffix(addr.suffix());
253 contact.setFileAs(); 253 contact.setFileAs();
254 254
255 255
256 // email 256 // email
257 QStringList emails = addr.emails(); 257 QStringList emails = addr.emails();
258 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 258 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
259 contact.insertEmail(*it); 259 contact.insertEmail(*it);
260 } 260 }
261 contact.setDefaultEmail( addr.preferredEmail() ); 261 contact.setDefaultEmail( addr.preferredEmail() );
262 262
263 263
264 // home 264 // home
265 const Address homeaddress = addr.address(Address::Home); 265 const Address homeaddress = addr.address(Address::Home);
@@ -274,17 +274,17 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, PimContact &con
274 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); 274 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home );
275 if (!homephone.number().isEmpty()) 275 if (!homephone.number().isEmpty())
276 contact.setHomePhone(homephone.number()); 276 contact.setHomePhone(homephone.number());
277 277
278 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); 278 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax );
279 if (!homefax.number().isEmpty()) 279 if (!homefax.number().isEmpty())
280 contact.setHomeFax(homefax.number()); 280 contact.setHomeFax(homefax.number());
281 281
282 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); 282 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell );
283 if (!homemobile.number().isEmpty()) 283 if (!homemobile.number().isEmpty())
284 contact.setHomeMobile(homemobile.number()); 284 contact.setHomeMobile(homemobile.number());
285 285
286 contact.setHomeWebpage(addr.url().url()); 286 contact.setHomeWebpage(addr.url().url());
287 287
288 288
289 // business 289 // business
290 const Address businessaddress = addr.address(Address::Work); 290 const Address businessaddress = addr.address(Address::Work);
@@ -299,15 +299,15 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, PimContact &con
299 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); 299 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work );
300 if (!businessphone.number().isEmpty()) 300 if (!businessphone.number().isEmpty())
301 contact.setBusinessPhone(businessphone.number()); 301 contact.setBusinessPhone(businessphone.number());
302 302
303 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); 303 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax );
304 if (!businessfax.number().isEmpty()) 304 if (!businessfax.number().isEmpty())
305 contact.setBusinessFax(businessfax.number()); 305 contact.setBusinessFax(businessfax.number());
306 306
307 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); 307 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell );
308 if (!businessmobile.number().isEmpty()) 308 if (!businessmobile.number().isEmpty())
309 contact.setBusinessMobile(businessmobile.number()); 309 contact.setBusinessMobile(businessmobile.number());
310 310
311 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); 311 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager );
312 if (!businesspager.number().isEmpty()) 312 if (!businesspager.number().isEmpty())
313 contact.setBusinessPager(businesspager.number()); 313 contact.setBusinessPager(businesspager.number());
@@ -333,30 +333,30 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, PimContact &con
333 else 333 else
334 contact.setGender(PimContact::UnspecifiedGender); 334 contact.setGender(PimContact::UnspecifiedGender);
335 335
336 336
337 QDate dt = KGlobal::locale()->readDate( 337 QDate dt = KGlobal::locale()->readDate(
338 addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate 338 addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate
339 contact.setAnniversary( dt ); 339 contact.setAnniversary( dt );
340 340
341 contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" )); 341 contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" ));
342 342
343 contact.setBirthday(addr.birthday().date()); 343 contact.setBirthday(addr.birthday().date());
344 contact.setNickname(addr.nickName()); 344 contact.setNickname(addr.nickName());
345 345
346 // other 346 // other
347 contact.setNotes(addr.note()); 347 contact.setNotes(addr.note());
348 348
349//US QString groups() const { return find( Qtopia::Groups ); } 349//US QString groups() const { return find( Qtopia::Groups ); }
350//US QStringList groupList() const; 350//US QStringList groupList() const;
351 351
352 352
353 QStringList cats = addr.categories(); 353 QStringList cats = addr.categories();
354 354
355 QArray<int> iar; 355 QArray<int> iar;
356 if ( !cats.isEmpty() ) { 356 if ( !cats.isEmpty() ) {
357 QArray<int> iar = catDB->ids("contact", cats); 357 QArray<int> iar = catDB->ids("contact", cats);
358 contact.setCategories(iar); 358 contact.setCategories(iar);
359 } 359 }
360*/ 360*/
361 return true; 361 return true;
362} 362}