summaryrefslogtreecommitdiffabout
path: root/kabc/plugins/sharpdtm/sharpdtmconverter.cpp
Unidiff
Diffstat (limited to 'kabc/plugins/sharpdtm/sharpdtmconverter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/sharpdtm/sharpdtmconverter.cpp119
1 files changed, 80 insertions, 39 deletions
diff --git a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp
index b065bf3..f3bf2c5 100644
--- a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp
+++ b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp
@@ -17,29 +17,31 @@
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include "kglobal.h" 28#include "kglobal.h"
29#include <qregexp.h>
29 30
30 31
31#include "sharpdtmconverter.h" 32#include "sharpdtmconverter.h"
32 33
33#include <sl/slcategories.h> 34#include <sl/slcategories.h>
35#include <libkdepim/ksyncprofile.h>
34//US #include <qpe/categoryselect.h> 36//US #include <qpe/categoryselect.h>
35 37
36 38
37using namespace KABC; 39using namespace KABC;
38using namespace SlCategory; 40using namespace SlCategory;
39 41
40SharpDTMConverter::SharpDTMConverter() : catDB(0) 42SharpDTMConverter::SharpDTMConverter() : catDB(0)
41{ 43{
42} 44}
43 45
44SharpDTMConverter::~SharpDTMConverter() 46SharpDTMConverter::~SharpDTMConverter()
45{ 47{
@@ -64,48 +66,56 @@ void SharpDTMConverter::deinit()
64 delete catDB; 66 delete catDB;
65 catDB = 0; 67 catDB = 0;
66 } 68 }
67} 69}
68 70
69bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr ) 71bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr )
70{ 72{
71 SlZDataBase* db = (SlZDataBase*)database; 73 SlZDataBase* db = (SlZDataBase*)database;
72 74
73 // for syncing: we need setting of the two fields 75 // for syncing: we need setting of the two fields
74 addr.setExternalUID( QString::number( contact ) ); 76 addr.setExternalUID( QString::number( contact ) );
75 addr.setOriginalExternalUID( QString::number( contact ) ); 77 addr.setOriginalExternalUID( QString::number( contact ) );
78 addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
76 79
77 80
78 // name 81 // name
79 qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!"); 82 //qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!");
80 addr.setFormattedName(db->readField(ZdbAdrs::FileAs)); 83 addr.setFormattedName(db->readField(ZdbAdrs::FileAs)); // needs fix
81 84
82 addr.setFamilyName( db->readField(ZdbAdrs::LastName) ); 85 addr.setFamilyName( db->readField(ZdbAdrs::LastName) );
83 addr.setGivenName( db->readField(ZdbAdrs::FirstName) ); 86 addr.setGivenName( db->readField(ZdbAdrs::FirstName) );
84 addr.setAdditionalName( db->readField(ZdbAdrs::MiddleName) ); 87 addr.setAdditionalName( db->readField(ZdbAdrs::MiddleName) );
85 addr.setPrefix( db->readField(ZdbAdrs::Title) ); 88 addr.setPrefix( db->readField(ZdbAdrs::Title) );
86 addr.setSuffix( db->readField(ZdbAdrs::Suffix) ); 89 addr.setSuffix( db->readField(ZdbAdrs::Suffix) );
87 90
88 91
89 // email
90 QString emailstr = db->readField(ZdbAdrs::Emails); 92 QString emailstr = db->readField(ZdbAdrs::Emails);
91 qDebug("SharpDTMConverter::sharpToAddressee whats the character to seperate the emailadresses? %s ", emailstr.latin1()); 93 emailstr.replace( QRegExp(","), " " );
92 QStringList emails = QStringList::split(",", emailstr); 94 emailstr.replace( QRegExp(";"), " " );
93 95 emailstr.replace( QRegExp(":"), " " );
96 //qDebug("SharpDTMConverter::sharpToAddressee whats the character to seperate the emailadresses? %s ", emailstr.latin1());
97 QStringList emails = QStringList::split(" ", emailstr.simplifyWhiteSpace());
98 bool defE = false;
99 bool found = false;
94 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 100 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
95 addr.insertEmail( *it, ((*it) == db->readField(ZdbAdrs::DefaultEmail)) ); 101 if (found )
102 defE = false;
103 else
104 found = defE = ((*it).lower() == db->readField(ZdbAdrs::DefaultEmail).lower());
105 addr.insertEmail( *it, defE );
96 } 106 }
97 107 if ( ! found )
98 if (!db->readField(ZdbAdrs::DefaultEmail).isEmpty()) 108 if (!db->readField(ZdbAdrs::DefaultEmail).isEmpty())
99 addr.insertEmail(db->readField(ZdbAdrs::DefaultEmail), true); 109 addr.insertEmail(db->readField(ZdbAdrs::DefaultEmail), true);
100 110
101 // home 111 // home
102 if ((!db->readField(ZdbAdrs::HomeStreet).isEmpty()) || 112 if ((!db->readField(ZdbAdrs::HomeStreet).isEmpty()) ||
103 (!db->readField(ZdbAdrs::HomeCity).isEmpty()) || 113 (!db->readField(ZdbAdrs::HomeCity).isEmpty()) ||
104 (!db->readField(ZdbAdrs::HomeState).isEmpty()) || 114 (!db->readField(ZdbAdrs::HomeState).isEmpty()) ||
105 (!db->readField(ZdbAdrs::HomeZip).isEmpty()) || 115 (!db->readField(ZdbAdrs::HomeZip).isEmpty()) ||
106 (!db->readField(ZdbAdrs::HomeCountry).isEmpty())) 116 (!db->readField(ZdbAdrs::HomeCountry).isEmpty()))
107 { 117 {
108 Address homeaddress; 118 Address homeaddress;
109 homeaddress.setType(Address::Home); 119 homeaddress.setType(Address::Home);
110//US homeaddress.setPostOfficeBox( "" ); 120//US homeaddress.setPostOfficeBox( "" );
111//US homeaddress.setExtended( "" ); 121//US homeaddress.setExtended( "" );
@@ -189,202 +199,233 @@ bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBa
189 businessmobile.setNumber( db->readField(ZdbAdrs::BusinessMobile) ); 199 businessmobile.setNumber( db->readField(ZdbAdrs::BusinessMobile) );
190 addr.insertPhoneNumber( businessmobile ); 200 addr.insertPhoneNumber( businessmobile );
191 } 201 }
192 202
193 if (!db->readField(ZdbAdrs::BusinessPager).isEmpty()) 203 if (!db->readField(ZdbAdrs::BusinessPager).isEmpty())
194 { 204 {
195 PhoneNumber businesspager; 205 PhoneNumber businesspager;
196 businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); 206 businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager );
197 businesspager.setNumber( db->readField(ZdbAdrs::BusinessPager) ); 207 businesspager.setNumber( db->readField(ZdbAdrs::BusinessPager) );
198 addr.insertPhoneNumber( businesspager ); 208 addr.insertPhoneNumber( businesspager );
199 } 209 }
200 210
201 addr.setRole( db->readField(ZdbAdrs::JobTitle) ); //? 211 addr.setRole( db->readField(ZdbAdrs::JobTitle) );
202 addr.setOrganization( db->readField(ZdbAdrs::Company) ); 212 addr.setOrganization( db->readField(ZdbAdrs::Company) );
203 addr.insertCustom( "KADDRESSBOOK", "X-Profession", db->readField(ZdbAdrs::Profession) ); 213 addr.insertCustom( "KADDRESSBOOK", "X-Profession", db->readField(ZdbAdrs::Profession) );
204 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", db->readField(ZdbAdrs::Assistant) ); 214 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", db->readField(ZdbAdrs::Assistant) );
205 addr.insertCustom( "KADDRESSBOOK", "X-Department", db->readField(ZdbAdrs::Department) ); 215 addr.insertCustom( "KADDRESSBOOK", "X-Department", db->readField(ZdbAdrs::Department) );
206 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", db->readField(ZdbAdrs::Manager) ); 216 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", db->readField(ZdbAdrs::Manager) );
207 addr.insertCustom( "KADDRESSBOOK", "X-Office", db->readField(ZdbAdrs::Office) ); 217 addr.insertCustom( "KADDRESSBOOK", "X-Office", db->readField(ZdbAdrs::Office) );
208 218
209 //personal 219 //personal
210 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", db->readField(ZdbAdrs::Spouse) ); 220 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", db->readField(ZdbAdrs::Spouse) );
211 221
212 QString gen = db->readField(ZdbAdrs::Gender); 222 QString gen = db->readField(ZdbAdrs::Gender);
213 qDebug("SharpDTMConverter::sharpToAddressee pleas check that gender works!! : Gender: %s", gen.latin1()); 223 //qDebug("SharpDTMConverter::sharpToAddressee pleas check that gender works!! : Gender: %s", gen.latin1());
214 qDebug("SharpDTMConverter::sharpToAddressee: may be int db->readUshortField(\"ZdbAdrs::Gender\") is here better suited"); 224 //qDebug("SharpDTMConverter::sharpToAddressee: may be int db->readUshortField(\"ZdbAdrs::Gender\") is here better suited");
215 225
216 if (gen == "male") 226 if (gen == "male")
217 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); 227 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male");
218 else if (gen == "female") 228 else if (gen == "female")
219 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); 229 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female");
220 230
221 231
222 QDate ann = db->readDateField(ZdbAdrs::Anniversary); 232 QDate ann = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Anniversary) );
223
224 if (ann.isValid()) { 233 if (ann.isValid()) {
225 QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate); 234 QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate);
226//US 235 //qDebug("qtopiaToAddressee annyversary found:%s", dt.latin1());
227// qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1());
228 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 236 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
229 } 237 }
238
230 239
231 addr.insertCustom( "KADDRESSBOOK", "X-Children", db->readField(ZdbAdrs::Children) ); 240 addr.insertCustom( "KADDRESSBOOK", "X-Children", db->readField(ZdbAdrs::Children) );
232 241
233 242
234 QDate birthd = db->readDateField(ZdbAdrs::Birthday); 243 QDate birthd = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Birthday) );
244 //qDebug("birtd %s ", birthd.toString().latin1());
235 if (birthd.isValid()) 245 if (birthd.isValid())
236 addr.setBirthday( birthd ); 246 addr.setBirthday( birthd );
237 247
238 addr.setNickName( db->readField(ZdbAdrs::Nickname) ); 248 addr.setNickName( db->readField(ZdbAdrs::Nickname) );
239 249
240 // others 250 // others
241 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. 251 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available.
242 QString notes = db->readField(ZdbAdrs::Notes); 252 QString notes = db->readField(ZdbAdrs::Notes);
243 notes += "\nBusinessWebPage: " + db->readField(ZdbAdrs::BusinessWebPage) + "\n"; 253 //notes += "\nBusinessWebPage: " + db->readField(ZdbAdrs::BusinessWebPage) + "\n";
244 254 if ( addr.url().isEmpty() )
255 addr.setUrl( db->readField(ZdbAdrs::BusinessWebPage) );
245 addr.setNote( db->readField(ZdbAdrs::Notes) ); 256 addr.setNote( db->readField(ZdbAdrs::Notes) );
246 257
247 258
248 259
249//US QString groups() const { return find( Qtopia::Groups ); } 260//US QString groups() const { return find( Qtopia::Groups ); }
250//US QStringList groupList() const; 261//US QStringList groupList() const;
251 262
252 qDebug("SharpDTMConverter::sharpToAddressee please check that the categories will be converted" ); 263 //qDebug("SharpDTMConverter::sharpToAddressee please check that the categories will be converted" );
253 QArray<int> catArray = db->readCategories(); 264 QArray<int> catArray = db->readCategories();
254 QString cat; 265 QString cat;
255 266
256 for ( unsigned int i=0; i < catArray.size(); i++ ) { 267 for ( unsigned int i=0; i < catArray.size(); i++ ) {
257 cat = catDB->label(catArray[i]); 268 cat = catDB->label(catArray[i]);
258 if ( cat.isEmpty() ) 269 if ( cat.isEmpty() )
259 addr.insertCategory(QString::number(catArray[i])); 270 addr.insertCategory(QString::number(catArray[i]));
260 else 271 else
261 addr.insertCategory( cat ); 272 addr.insertCategory( cat );
262 } 273 }
263 274
264 return true; 275 return true;
265} 276}
266 277
267bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ) 278bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact )
268{ 279{
280 bool cellHome = false, cellWork = false;
269 // name 281 // name
270 database->writeField(ZdbAdrs::LastName, addr.familyName()); 282 database->writeField(ZdbAdrs::LastName, addr.familyName());
271 database->writeField(ZdbAdrs::FirstName, addr.givenName()); 283 database->writeField(ZdbAdrs::FirstName, addr.givenName());
272 database->writeField(ZdbAdrs::MiddleName, addr.additionalName()); 284 database->writeField(ZdbAdrs::MiddleName, addr.additionalName());
273 database->writeField(ZdbAdrs::Title, addr.prefix()); 285 database->writeField(ZdbAdrs::Title, addr.prefix());
274 database->writeField(ZdbAdrs::Suffix, addr.suffix()); 286 database->writeField(ZdbAdrs::Suffix, addr.suffix());
275 287
276 qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!"); 288 //qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() );
277 database->writeField(ZdbAdrs::FileAs, addr.formattedName()); 289 database->writeField(ZdbAdrs::FileAs, addr.formattedName());
278 290 database->writeField(ZdbAdrs::FullName, addr.formattedName());
279 291
280 // email 292 // email
281 qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!"); 293 //qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!");
282 qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee"); 294 //qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee");
283 QString emails = addr.emails().join(","); 295 QString emails = addr.emails().join(" ");
284 database->writeField(ZdbAdrs::Emails, emails ); 296 database->writeField(ZdbAdrs::Emails, emails );
285 297
286 database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() ); 298 database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() );
287 299
288 300
289 // home 301 // home
290 const Address homeaddress = addr.address(Address::Home); 302 const Address homeaddress = addr.address(Address::Home);
291 if (!homeaddress.isEmpty()) { 303 if (!homeaddress.isEmpty()) {
292 database->writeField(ZdbAdrs::HomeStreet, homeaddress.street()); 304 database->writeField(ZdbAdrs::HomeStreet, homeaddress.street());
293 database->writeField(ZdbAdrs::HomeCity, homeaddress.locality()); 305 database->writeField(ZdbAdrs::HomeCity, homeaddress.locality());
294 database->writeField(ZdbAdrs::HomeState, homeaddress.region()); 306 database->writeField(ZdbAdrs::HomeState, homeaddress.region());
295 database->writeField(ZdbAdrs::HomeZip, homeaddress.postalCode()); 307 database->writeField(ZdbAdrs::HomeZip, homeaddress.postalCode());
296 database->writeField(ZdbAdrs::HomeCountry, homeaddress.country()); 308 database->writeField(ZdbAdrs::HomeCountry, homeaddress.country());
297 } 309 }
298 310
299 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); 311 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home );
300 if (!homephone.number().isEmpty()) 312 if (!homephone.number().isEmpty())
301 database->writeField(ZdbAdrs::HomePhone, homephone.number()); 313 database->writeField(ZdbAdrs::HomePhone, homephone.number());
302 314
303 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); 315 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax );
304 if (!homefax.number().isEmpty()) 316 if (!homefax.number().isEmpty())
305 database->writeField(ZdbAdrs::HomeFax, homefax.number()); 317 database->writeField(ZdbAdrs::HomeFax, homefax.number());
306 318
307 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); 319 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell );
308 if (!homemobile.number().isEmpty()) 320 if (!homemobile.number().isEmpty()) {
309 database->writeField(ZdbAdrs::HomeMobile, homemobile.number()); 321 database->writeField(ZdbAdrs::HomeMobile, homemobile.number());
322 cellHome = true;
323 }
310 324
311 database->writeField(ZdbAdrs::HomeWebPage, addr.url().url()); 325 database->writeField(ZdbAdrs::HomeWebPage, addr.url().url());
312 326
313 327
314 // business 328 // business
315 const Address businessaddress = addr.address(Address::Work); 329 const Address businessaddress = addr.address(Address::Work);
316 if (!businessaddress.isEmpty()) { 330 if (!businessaddress.isEmpty()) {
317 database->writeField(ZdbAdrs::BusinessStreet, businessaddress.street()); 331 database->writeField(ZdbAdrs::BusinessStreet, businessaddress.street());
318 database->writeField(ZdbAdrs::BusinessCity, businessaddress.locality()); 332 database->writeField(ZdbAdrs::BusinessCity, businessaddress.locality());
319 database->writeField(ZdbAdrs::BusinessState, businessaddress.region()); 333 database->writeField(ZdbAdrs::BusinessState, businessaddress.region());
320 database->writeField(ZdbAdrs::BusinessZip, businessaddress.postalCode()); 334 database->writeField(ZdbAdrs::BusinessZip, businessaddress.postalCode());
321 database->writeField(ZdbAdrs::BusinessCountry, businessaddress.country()); 335 database->writeField(ZdbAdrs::BusinessCountry, businessaddress.country());
322 } 336 }
323 337
324 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); 338 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work );
325 if (!businessphone.number().isEmpty()) 339 if (!businessphone.number().isEmpty())
326 database->writeField(ZdbAdrs::BusinessPhone, businessphone.number()); 340 database->writeField(ZdbAdrs::BusinessPhone, businessphone.number());
327 341
328 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); 342 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax );
329 if (!businessfax.number().isEmpty()) 343 if (!businessfax.number().isEmpty())
330 database->writeField(ZdbAdrs::BusinessFax, businessfax.number()); 344 database->writeField(ZdbAdrs::BusinessFax, businessfax.number());
331 345
332 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); 346 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell );
333 if (!businessmobile.number().isEmpty()) 347 if (!businessmobile.number().isEmpty()) {
334 database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number()); 348 cellWork = true;
349 database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number());
350 }
351 PhoneNumber mobile = addr.phoneNumber( PhoneNumber::Cell );
352 if (!businessmobile.number().isEmpty()) {
353 if ( ! cellHome )
354 database->writeField(ZdbAdrs::HomeMobile, mobile.number());
355 else if (! cellWork )
356 database->writeField(ZdbAdrs::BusinessMobile, mobile.number());
357 }
335 358
336 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); 359 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager );
337 if (!businesspager.number().isEmpty()) 360 if (!businesspager.number().isEmpty())
338 database->writeField(ZdbAdrs::BusinessPager, businesspager.number()); 361 database->writeField(ZdbAdrs::BusinessPager, businesspager.number());
339 362
340 database->writeField(ZdbAdrs::JobTitle, addr.role()); 363 database->writeField(ZdbAdrs::JobTitle, addr.role());
341 database->writeField(ZdbAdrs::Company, addr.organization()); 364 database->writeField(ZdbAdrs::Company, addr.organization());
342 365
343 database->writeField(ZdbAdrs::Profession, addr.custom( "KADDRESSBOOK", "X-Profession" )); 366 database->writeField(ZdbAdrs::Profession, addr.custom( "KADDRESSBOOK", "X-Profession" ));
344 database->writeField(ZdbAdrs::Assistant, addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); 367 database->writeField(ZdbAdrs::Assistant, addr.custom( "KADDRESSBOOK", "X-AssistantsName" ));
345 database->writeField(ZdbAdrs::Department, addr.custom( "KADDRESSBOOK", "X-Department" )); 368 database->writeField(ZdbAdrs::Department, addr.custom( "KADDRESSBOOK", "X-Department" ));
346 database->writeField(ZdbAdrs::Manager, addr.custom( "KADDRESSBOOK", "X-ManagersName" )); 369 database->writeField(ZdbAdrs::Manager, addr.custom( "KADDRESSBOOK", "X-ManagersName" ));
347 database->writeField(ZdbAdrs::Office, addr.custom( "KADDRESSBOOK", "X-Office" )); 370 database->writeField(ZdbAdrs::Office, addr.custom( "KADDRESSBOOK", "X-Office" ));
348 371
349 //personal 372 //personal
350 database->writeField(ZdbAdrs::Spouse, addr.custom( "KADDRESSBOOK", "X-Spouse" )); 373 database->writeField(ZdbAdrs::Spouse, addr.custom( "KADDRESSBOOK", "X-Spouse" ));
351 374
352 QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); 375 QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" );
353 qDebug("SharpDTMConverter::addresseeToSharp please check that gender works!! : Gender: %s", gt.latin1()); 376 //qDebug("SharpDTMConverter::addresseeToSharp please check that gender works!! : Gender: %s", gt.latin1());
354 qDebug("SharpDTMConverter::addresseeToSharp: may be writeField(\"ZdbAdrs::Gender\", ushort) is here better suited?"); 377 //qDebug("SharpDTMConverter::addresseeToSharp: may be writeField(\"ZdbAdrs::Gender\", ushort) is here better suited?");
355 qDebug("SharpDTMConverter::addresseeToSharp: check also the reverse functionality in sharpToAddressee"); 378 //qDebug("SharpDTMConverter::addresseeToSharp: check also the reverse functionality in sharpToAddressee");
356 if (gt = "male") 379 if (gt == "male")
357 database->writeField(ZdbAdrs::Gender, "male"); 380 database->writeField(ZdbAdrs::Gender, "male");
358 else if (gt = "female") 381 else if (gt == "female")
359 database->writeField(ZdbAdrs::Gender, "female"); 382 database->writeField(ZdbAdrs::Gender, "female");
360 else 383 else
361 database->writeField(ZdbAdrs::Gender, ""); 384 database->writeField(ZdbAdrs::Gender, "");
362 385
363 386
364 QDate dt = KGlobal::locale()->readDate( 387 QDate dt = KGlobal::locale()->readDate(
365 addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate 388 addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate
366 database->writeField(ZdbAdrs::Anniversary, dt ); 389 if ( dt.isValid() ) {
367 390 QString dateS = KGlobal::locale()->formatDate(dt, true );
391 database->writeField(ZdbAdrs::Anniversary, dateS );
392 }
368 database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" )); 393 database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" ));
369 394 dt = addr.birthday().date();
370 database->writeField(ZdbAdrs::Birthday, addr.birthday().date()); 395 if ( dt.isValid() ) {
396 QString dateS = KGlobal::locale()->formatDate(dt, true );
397 database->writeField(ZdbAdrs::Birthday, dateS);
398 }
371 database->writeField(ZdbAdrs::Nickname, addr.nickName()); 399 database->writeField(ZdbAdrs::Nickname, addr.nickName());
372 400
373 // other 401 // other
374 database->writeField(ZdbAdrs::Notes, addr.note()); 402 database->writeField(ZdbAdrs::Notes, addr.note());
375 403
376//US QString groups() const { return find( Qtopia::Groups ); } 404//US QString groups() const { return find( Qtopia::Groups ); }
377//US QStringList groupList() const; 405//US QStringList groupList() const;
378 406
379 407
380 qDebug("SharpDTMConverter::addresseeToSharp please check if category transformation works"); 408 //qDebug("SharpDTMConverter::addresseeToSharp please check if category transformation works");
381 409
382 QStringList cats = addr.categories(); 410 QStringList cats = addr.categories();
411 int ii;
412 for ( ii = 0; ii < cats.count() ;++ii ) {
413 if ( !catDB->exists( cats[ii] ))
414 catDB->addCategory(cats[ii]);
415 }
383 QArray<int> iar; 416 QArray<int> iar;
384 if ( !cats.isEmpty() ) { 417 if ( !cats.isEmpty() ) {
385 QArray<int> iar = catDB->ids(cats); 418 QArray<int> iar = catDB->ids(cats);
419 qDebug("***cat count is %d ", iar.count());
386 database->updateCategories(contact, iar); 420 database->updateCategories(contact, iar);
387 } 421 }
388 422
389 return true; 423 return true;
390} 424}
425
426QDate SharpDTMConverter::convertDate( QString s)
427{
428 QDate dt = KGlobal::locale()->readDate( s );
429 return dt;
430 return QDate ();
431}