summaryrefslogtreecommitdiffabout
path: root/kabc
authorulf69 <ulf69>2004-07-19 20:02:38 (UTC)
committer ulf69 <ulf69>2004-07-19 20:02:38 (UTC)
commitd498ea750239bffa7ec811aa3e60befc6bae9608 (patch) (unidiff)
treebfb72103c930030cae150fb1fbe68557ca367183 /kabc
parentaea3eb6a96f971af49d4a75586c98cbcbb883a76 (diff)
downloadkdepimpi-d498ea750239bffa7ec811aa3e60befc6bae9608.zip
kdepimpi-d498ea750239bffa7ec811aa3e60befc6bae9608.tar.gz
kdepimpi-d498ea750239bffa7ec811aa3e60befc6bae9608.tar.bz2
the newest version of the sharp converter
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/converter/sharpdtm/sharpdtmconverter.cpp270
-rw-r--r--kabc/converter/sharpdtm/sharpdtmconverter.h2
2 files changed, 147 insertions, 125 deletions
diff --git a/kabc/converter/sharpdtm/sharpdtmconverter.cpp b/kabc/converter/sharpdtm/sharpdtmconverter.cpp
index 4cf2eb3..8f8334e 100644
--- a/kabc/converter/sharpdtm/sharpdtmconverter.cpp
+++ b/kabc/converter/sharpdtm/sharpdtmconverter.cpp
@@ -1,362 +1,384 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
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 29
30 30
31#include "sharpdtmconverter.h" 31#include "sharpdtmconverter.h"
32 32
33#include <sl/slcategories.h> 33#include <sl/slcategories.h>
34//US #include <qpe/categoryselect.h> 34//US #include <qpe/categoryselect.h>
35 35
36 36
37using namespace KABC; 37using namespace KABC;
38using namespace SlCategory; 38using namespace SlCategory;
39 39
40SharpDTMConverter::SharpDTMConverter() : catDB(0) 40SharpDTMConverter::SharpDTMConverter() : catDB(0)
41{ 41{
42} 42}
43 43
44SharpDTMConverter::~SharpDTMConverter() 44SharpDTMConverter::~SharpDTMConverter()
45{ 45{
46 deinit(); 46 deinit();
47} 47}
48 48
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 CardId &contact, const SlZDataBase* database, Addressee &addr ) 69bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr )
70{ 70{
71/*US 71 SlZDataBase* db = (SlZDataBase*)database;
72 // name 72 // name
73 addr.setFormattedName(contact.fileAs()); 73 qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!");
74 addr.setFamilyName( contact.lastName() ); 74 addr.setFormattedName(db->readField(ZdbAdrs::FileAs));
75 addr.setGivenName( contact.firstName() ); 75
76 addr.setAdditionalName( contact.middleName() ); 76 addr.setFamilyName( db->readField(ZdbAdrs::LastName) );
77 addr.setPrefix( contact.nameTitle() ); 77 addr.setGivenName( db->readField(ZdbAdrs::FirstName) );
78 addr.setSuffix( contact.suffix() ); 78 addr.setAdditionalName( db->readField(ZdbAdrs::MiddleName) );
79 addr.setPrefix( db->readField(ZdbAdrs::Title) );
80 addr.setSuffix( db->readField(ZdbAdrs::Suffix) );
79 81
80 82
81 // email 83 // email
82 QStringList emails = contact.emailList(); 84 QString emailstr = db->readField(ZdbAdrs::Emails);
85 qDebug("SharpDTMConverter::sharpToAddressee whats the character to seperate the emailadresses? %s ", emailstr.latin1());
86 QStringList emails = QStringList::split(",", emailstr);
87
83 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 88 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
84 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); 89 addr.insertEmail( *it, ((*it) == db->readField(ZdbAdrs::DefaultEmail)) );
85 } 90 }
86 91
87 if (!contact.defaultEmail().isEmpty()) 92 if (!db->readField(ZdbAdrs::DefaultEmail).isEmpty())
88 addr.insertEmail(contact.defaultEmail(), true); 93 addr.insertEmail(db->readField(ZdbAdrs::DefaultEmail), true);
89 94
90 // home 95 // home
91 if ((!contact.homeStreet().isEmpty()) || 96 if ((!db->readField(ZdbAdrs::HomeStreet).isEmpty()) ||
92 (!contact.homeCity().isEmpty()) || 97 (!db->readField(ZdbAdrs::HomeCity).isEmpty()) ||
93 (!contact.homeState().isEmpty()) || 98 (!db->readField(ZdbAdrs::HomeState).isEmpty()) ||
94 (!contact.homeZip().isEmpty()) || 99 (!db->readField(ZdbAdrs::HomeZip).isEmpty()) ||
95 (!contact.homeCountry().isEmpty())) 100 (!db->readField(ZdbAdrs::HomeCountry).isEmpty()))
96 { 101 {
97 Address homeaddress; 102 Address homeaddress;
98 homeaddress.setType(Address::Home); 103 homeaddress.setType(Address::Home);
99//US homeaddress.setPostOfficeBox( "" ); 104//US homeaddress.setPostOfficeBox( "" );
100//US homeaddress.setExtended( "" ); 105//US homeaddress.setExtended( "" );
101 homeaddress.setStreet( contact.homeStreet() ); 106 homeaddress.setStreet( db->readField(ZdbAdrs::HomeStreet) );
102 homeaddress.setLocality( contact.homeCity() ); 107 homeaddress.setLocality( db->readField(ZdbAdrs::HomeCity) );
103 homeaddress.setRegion( contact.homeState() ); 108 homeaddress.setRegion( db->readField(ZdbAdrs::HomeState) );
104 homeaddress.setPostalCode( contact.homeZip() ); 109 homeaddress.setPostalCode( db->readField(ZdbAdrs::HomeZip) );
105 homeaddress.setCountry( contact.homeCountry() ); 110 homeaddress.setCountry( db->readField(ZdbAdrs::HomeCountry) );
106 111
107 addr.insertAddress( homeaddress ); 112 addr.insertAddress( homeaddress );
108 } 113 }
109 114
110 if (!contact.homePhone().isEmpty()) 115 if (!db->readField(ZdbAdrs::HomePhone).isEmpty())
111 { 116 {
112 PhoneNumber homephone; 117 PhoneNumber homephone;
113 homephone.setType( PhoneNumber::Home ); 118 homephone.setType( PhoneNumber::Home );
114 homephone.setNumber( contact.homePhone() ); 119 homephone.setNumber( db->readField(ZdbAdrs::HomePhone) );
115 addr.insertPhoneNumber( homephone ); 120 addr.insertPhoneNumber( homephone );
116 } 121 }
117 122
118 if (!contact.homeFax().isEmpty()) 123 if (!db->readField(ZdbAdrs::HomeFax).isEmpty())
119 { 124 {
120 PhoneNumber homefax; 125 PhoneNumber homefax;
121 homefax.setType( PhoneNumber::Home | PhoneNumber::Fax ); 126 homefax.setType( PhoneNumber::Home | PhoneNumber::Fax );
122 homefax.setNumber( contact.homeFax() ); 127 homefax.setNumber( db->readField(ZdbAdrs::HomeFax) );
123 addr.insertPhoneNumber( homefax ); 128 addr.insertPhoneNumber( homefax );
124 } 129 }
125 130
126 if (!contact.homeMobile().isEmpty()) 131 if (!db->readField(ZdbAdrs::HomeMobile).isEmpty())
127 { 132 {
128 PhoneNumber homemobile; 133 PhoneNumber homemobile;
129 homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell ); 134 homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell );
130 homemobile.setNumber( contact.homeMobile() ); 135 homemobile.setNumber( db->readField(ZdbAdrs::HomeMobile) );
131 addr.insertPhoneNumber( homemobile ); 136 addr.insertPhoneNumber( homemobile );
132 } 137 }
133 138
134 addr.setUrl( contact.homeWebpage() ); 139 addr.setUrl( db->readField(ZdbAdrs::HomeWebPage) );
135 140
136 141
137 // business 142 // business
138 if ((!contact.businessStreet().isEmpty()) || 143 if ((!db->readField(ZdbAdrs::BusinessStreet).isEmpty()) ||
139 (!contact.businessCity().isEmpty()) || 144 (!db->readField(ZdbAdrs::BusinessCity).isEmpty()) ||
140 (!contact.businessState().isEmpty()) || 145 (!db->readField(ZdbAdrs::BusinessState).isEmpty()) ||
141 (!contact.businessZip().isEmpty()) || 146 (!db->readField(ZdbAdrs::BusinessZip).isEmpty()) ||
142 (!contact.businessCountry().isEmpty())) 147 (!db->readField(ZdbAdrs::BusinessCountry).isEmpty()))
143 { 148 {
144 Address businessaddress; 149 Address businessaddress;
145 businessaddress.setType(Address::Work); 150 businessaddress.setType(Address::Work);
146//US businessaddress.setPostOfficeBox( "" ); 151//US businessaddress.setPostOfficeBox( "" );
147//US businessaddress.setExtended( "" ); 152//US businessaddress.setExtended( "" );
148 businessaddress.setStreet( contact.businessStreet() ); 153 businessaddress.setStreet( db->readField(ZdbAdrs::BusinessStreet) );
149 businessaddress.setLocality( contact.businessCity() ); 154 businessaddress.setLocality( db->readField(ZdbAdrs::BusinessCity) );
150 businessaddress.setRegion( contact.businessState() ); 155 businessaddress.setRegion( db->readField(ZdbAdrs::BusinessState) );
151 businessaddress.setPostalCode( contact.businessZip() ); 156 businessaddress.setPostalCode( db->readField(ZdbAdrs::BusinessZip) );
152 businessaddress.setCountry( contact.businessCountry() ); 157 businessaddress.setCountry( db->readField(ZdbAdrs::BusinessCountry) );
153 158
154 addr.insertAddress( businessaddress ); 159 addr.insertAddress( businessaddress );
155 } 160 }
156 161
157 162
158 if (!contact.businessPhone().isEmpty()) 163 if (!db->readField(ZdbAdrs::BusinessPhone).isEmpty())
159 { 164 {
160 PhoneNumber businessphone; 165 PhoneNumber businessphone;
161 businessphone.setType( PhoneNumber::Work ); 166 businessphone.setType( PhoneNumber::Work );
162 businessphone.setNumber( contact.businessPhone() ); 167 businessphone.setNumber( db->readField(ZdbAdrs::BusinessPhone) );
163 addr.insertPhoneNumber( businessphone ); 168 addr.insertPhoneNumber( businessphone );
164 } 169 }
165 170
166 if (!contact.businessFax().isEmpty()) 171 if (!db->readField(ZdbAdrs::BusinessFax).isEmpty())
167 { 172 {
168 PhoneNumber businessfax; 173 PhoneNumber businessfax;
169 businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); 174 businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax );
170 businessfax.setNumber( contact.businessFax() ); 175 businessfax.setNumber( db->readField(ZdbAdrs::BusinessFax) );
171 addr.insertPhoneNumber( businessfax ); 176 addr.insertPhoneNumber( businessfax );
172 } 177 }
173 178
174 if (!contact.businessMobile().isEmpty()) 179 if (!db->readField(ZdbAdrs::BusinessMobile).isEmpty())
175 { 180 {
176 PhoneNumber businessmobile; 181 PhoneNumber businessmobile;
177 businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); 182 businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell );
178 businessmobile.setNumber( contact.businessMobile() ); 183 businessmobile.setNumber( db->readField(ZdbAdrs::BusinessMobile) );
179 addr.insertPhoneNumber( businessmobile ); 184 addr.insertPhoneNumber( businessmobile );
180 } 185 }
181 186
182 if (!contact.businessPager().isEmpty()) 187 if (!db->readField(ZdbAdrs::BusinessPager).isEmpty())
183 { 188 {
184 PhoneNumber businesspager; 189 PhoneNumber businesspager;
185 businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); 190 businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager );
186 businesspager.setNumber( contact.businessPager() ); 191 businesspager.setNumber( db->readField(ZdbAdrs::BusinessPager) );
187 addr.insertPhoneNumber( businesspager ); 192 addr.insertPhoneNumber( businesspager );
188 } 193 }
189 194
190 addr.setRole( contact.jobTitle() ); //? 195 addr.setRole( db->readField(ZdbAdrs::JobTitle) ); //?
191 addr.setOrganization( contact.company() ); 196 addr.setOrganization( db->readField(ZdbAdrs::Company) );
192 addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() ); 197 addr.insertCustom( "KADDRESSBOOK", "X-Profession", db->readField(ZdbAdrs::Profession) );
193 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() ); 198 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", db->readField(ZdbAdrs::Assistant) );
194 addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() ); 199 addr.insertCustom( "KADDRESSBOOK", "X-Department", db->readField(ZdbAdrs::Department) );
195 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() ); 200 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", db->readField(ZdbAdrs::Manager) );
196 addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() ); 201 addr.insertCustom( "KADDRESSBOOK", "X-Office", db->readField(ZdbAdrs::Office) );
197 202
198 //personal 203 //personal
199 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() ); 204 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", db->readField(ZdbAdrs::Spouse) );
200 // qtopia uses this categorization: 205
201 // enum GenderType { UnspecifiedGender=0, Male, Female }; 206 QString gen = db->readField(ZdbAdrs::Gender);
202 if (contact.gender() == PimContact::Male) 207 qDebug("SharpDTMConverter::sharpToAddressee pleas check that gender works!! : Gender: %s", gen.latin1());
208 qDebug("SharpDTMConverter::sharpToAddressee: may be int db->readUshortField(\"ZdbAdrs::Gender\") is here better suited");
209
210 if (gen == "male")
203 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); 211 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male");
204 else if (contact.gender() == PimContact::Female) 212 else if (gen == "female")
205 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); 213 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female");
206 214
207 if (contact.anniversary().isValid()) { 215
208 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate); 216 QDate ann = db->readDateField(ZdbAdrs::Anniversary);
217
218 if (ann.isValid()) {
219 QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate);
209//US 220//US
210// qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1()); 221// qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1());
211 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 222 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
212 } 223 }
213 224
214 addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); 225 addr.insertCustom( "KADDRESSBOOK", "X-Children", db->readField(ZdbAdrs::Children) );
215 if (contact.birthday().isValid()) 226
216 addr.setBirthday( contact.birthday() ); 227
228 QDate birthd = db->readDateField(ZdbAdrs::Birthday);
229 if (birthd.isValid())
230 addr.setBirthday( birthd );
217 231
218 addr.setNickName( contact.nickname() ); 232 addr.setNickName( db->readField(ZdbAdrs::Nickname) );
219 233
220 // others 234 // others
221 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. 235 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available.
222 QString notes = contact.notes(); 236 QString notes = db->readField(ZdbAdrs::Notes);
223 notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n"; 237 notes += "\nBusinessWebPage: " + db->readField(ZdbAdrs::BusinessWebPage) + "\n";
224 238
225 addr.setNote( contact.notes() ); 239 addr.setNote( db->readField(ZdbAdrs::Notes) );
226 240
227 241
228 242
229//US QString groups() const { return find( Qtopia::Groups ); } 243//US QString groups() const { return find( Qtopia::Groups ); }
230//US QStringList groupList() const; 244//US QStringList groupList() const;
231 245
232 QArray<int> catArray = contact.categories(); 246 qDebug("SharpDTMConverter::sharpToAddressee please check that the categories will be converted" );
247 QArray<int> catArray = db->readCategories();
233 QString cat; 248 QString cat;
234 249
235 for ( unsigned int i=0; i < catArray.size(); i++ ) { 250 for ( unsigned int i=0; i < catArray.size(); i++ ) {
236 cat = catDB->label("contact", catArray[i]); 251 cat = catDB->label(catArray[i]);
237 if ( !cat.isEmpty() ) 252 if ( cat.isEmpty() )
253 addr.insertCategory(QString::number(catArray[i]));
254 else
238 addr.insertCategory( cat ); 255 addr.insertCategory( cat );
239 } 256 }
240*/ 257
241 return true; 258 return true;
242} 259}
243 260
244bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, const SlZDataBase* database , const CardId &contact ) 261bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact )
245{ 262{
246/*US
247 // name 263 // name
248 contact.setLastName(addr.familyName()); 264 database->writeField(ZdbAdrs::LastName, addr.familyName());
249 contact.setFirstName(addr.givenName()); 265 database->writeField(ZdbAdrs::FirstName, addr.givenName());
250 contact.setMiddleName(addr.additionalName()); 266 database->writeField(ZdbAdrs::MiddleName, addr.additionalName());
251 contact.setNameTitle(addr.prefix()); 267 database->writeField(ZdbAdrs::Title, addr.prefix());
252 contact.setSuffix(addr.suffix()); 268 database->writeField(ZdbAdrs::Suffix, addr.suffix());
253 contact.setFileAs(); 269
270 qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!");
271 database->writeField(ZdbAdrs::FileAs, addr.formattedName());
254 272
255 273
256 // email 274 // email
257 QStringList emails = addr.emails(); 275 qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!");
258 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 276 qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee");
259 contact.insertEmail(*it); 277 QString emails = addr.emails().join(",");
260 } 278 database->writeField(ZdbAdrs::Emails, emails );
261 contact.setDefaultEmail( addr.preferredEmail() ); 279
280 database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() );
262 281
263 282
264 // home 283 // home
265 const Address homeaddress = addr.address(Address::Home); 284 const Address homeaddress = addr.address(Address::Home);
266 if (!homeaddress.isEmpty()) { 285 if (!homeaddress.isEmpty()) {
267 contact.setHomeStreet(homeaddress.street()); 286 database->writeField(ZdbAdrs::HomeStreet, homeaddress.street());
268 contact.setHomeCity(homeaddress.locality()); 287 database->writeField(ZdbAdrs::HomeCity, homeaddress.locality());
269 contact.setHomeState(homeaddress.region()); 288 database->writeField(ZdbAdrs::HomeState, homeaddress.region());
270 contact.setHomeZip(homeaddress.postalCode()); 289 database->writeField(ZdbAdrs::HomeZip, homeaddress.postalCode());
271 contact.setHomeCountry(homeaddress.country()); 290 database->writeField(ZdbAdrs::HomeCountry, homeaddress.country());
272 } 291 }
273 292
274 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); 293 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home );
275 if (!homephone.number().isEmpty()) 294 if (!homephone.number().isEmpty())
276 contact.setHomePhone(homephone.number()); 295 database->writeField(ZdbAdrs::HomePhone, homephone.number());
277 296
278 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); 297 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax );
279 if (!homefax.number().isEmpty()) 298 if (!homefax.number().isEmpty())
280 contact.setHomeFax(homefax.number()); 299 database->writeField(ZdbAdrs::HomeFax, homefax.number());
281 300
282 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); 301 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell );
283 if (!homemobile.number().isEmpty()) 302 if (!homemobile.number().isEmpty())
284 contact.setHomeMobile(homemobile.number()); 303 database->writeField(ZdbAdrs::HomeMobile, homemobile.number());
285 304
286 contact.setHomeWebpage(addr.url().url()); 305 database->writeField(ZdbAdrs::HomeWebPage, addr.url().url());
287 306
288 307
289 // business 308 // business
290 const Address businessaddress = addr.address(Address::Work); 309 const Address businessaddress = addr.address(Address::Work);
291 if (!businessaddress.isEmpty()) { 310 if (!businessaddress.isEmpty()) {
292 contact.setBusinessStreet(businessaddress.street()); 311 database->writeField(ZdbAdrs::BusinessStreet, businessaddress.street());
293 contact.setBusinessCity(businessaddress.locality()); 312 database->writeField(ZdbAdrs::BusinessCity, businessaddress.locality());
294 contact.setBusinessState(businessaddress.region()); 313 database->writeField(ZdbAdrs::BusinessState, businessaddress.region());
295 contact.setBusinessZip(businessaddress.postalCode()); 314 database->writeField(ZdbAdrs::BusinessZip, businessaddress.postalCode());
296 contact.setBusinessCountry(businessaddress.country()); 315 database->writeField(ZdbAdrs::BusinessCountry, businessaddress.country());
297 } 316 }
298 317
299 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); 318 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work );
300 if (!businessphone.number().isEmpty()) 319 if (!businessphone.number().isEmpty())
301 contact.setBusinessPhone(businessphone.number()); 320 database->writeField(ZdbAdrs::BusinessPhone, businessphone.number());
302 321
303 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); 322 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax );
304 if (!businessfax.number().isEmpty()) 323 if (!businessfax.number().isEmpty())
305 contact.setBusinessFax(businessfax.number()); 324 database->writeField(ZdbAdrs::BusinessFax, businessfax.number());
306 325
307 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); 326 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell );
308 if (!businessmobile.number().isEmpty()) 327 if (!businessmobile.number().isEmpty())
309 contact.setBusinessMobile(businessmobile.number()); 328 database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number());
310 329
311 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); 330 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager );
312 if (!businesspager.number().isEmpty()) 331 if (!businesspager.number().isEmpty())
313 contact.setBusinessPager(businesspager.number()); 332 database->writeField(ZdbAdrs::BusinessPager, businesspager.number());
314 333
315 contact.setJobTitle(addr.role()); 334 database->writeField(ZdbAdrs::JobTitle, addr.role());
316 contact.setCompany(addr.organization()); 335 database->writeField(ZdbAdrs::Company, addr.organization());
317 336
318 contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" )); 337 database->writeField(ZdbAdrs::Profession, addr.custom( "KADDRESSBOOK", "X-Profession" ));
319 contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); 338 database->writeField(ZdbAdrs::Assistant, addr.custom( "KADDRESSBOOK", "X-AssistantsName" ));
320 contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" )); 339 database->writeField(ZdbAdrs::Department, addr.custom( "KADDRESSBOOK", "X-Department" ));
321 contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" )); 340 database->writeField(ZdbAdrs::Manager, addr.custom( "KADDRESSBOOK", "X-ManagersName" ));
322 contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" )); 341 database->writeField(ZdbAdrs::Office, addr.custom( "KADDRESSBOOK", "X-Office" ));
323 342
324 //personal 343 //personal
325 contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" )); 344 database->writeField(ZdbAdrs::Spouse, addr.custom( "KADDRESSBOOK", "X-Spouse" ));
326 // qtopia uses this categorization: 345
327 // enum GenderType { UnspecifiedGender=0, Male, Female };
328 QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); 346 QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" );
347 qDebug("SharpDTMConverter::addresseeToSharp please check that gender works!! : Gender: %s", gt.latin1());
348 qDebug("SharpDTMConverter::addresseeToSharp: may be writeField(\"ZdbAdrs::Gender\", ushort) is here better suited?");
349 qDebug("SharpDTMConverter::addresseeToSharp: check also the reverse functionality in sharpToAddressee");
329 if (gt = "male") 350 if (gt = "male")
330 contact.setGender(PimContact::Male); 351 database->writeField(ZdbAdrs::Gender, "male");
331 else if (gt = "female") 352 else if (gt = "female")
332 contact.setGender(PimContact::Female); 353 database->writeField(ZdbAdrs::Gender, "female");
333 else 354 else
334 contact.setGender(PimContact::UnspecifiedGender); 355 database->writeField(ZdbAdrs::Gender, "");
335 356
336 357
337 QDate dt = KGlobal::locale()->readDate( 358 QDate dt = KGlobal::locale()->readDate(
338 addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate 359 addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate
339 contact.setAnniversary( dt ); 360 database->writeField(ZdbAdrs::Anniversary, dt );
340 361
341 contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" )); 362 database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" ));
342 363
343 contact.setBirthday(addr.birthday().date()); 364 database->writeField(ZdbAdrs::Birthday, addr.birthday().date());
344 contact.setNickname(addr.nickName()); 365 database->writeField(ZdbAdrs::Nickname, addr.nickName());
345 366
346 // other 367 // other
347 contact.setNotes(addr.note()); 368 database->writeField(ZdbAdrs::Notes, addr.note());
348 369
349//US QString groups() const { return find( Qtopia::Groups ); } 370//US QString groups() const { return find( Qtopia::Groups ); }
350//US QStringList groupList() const; 371//US QStringList groupList() const;
351 372
352 373
353 QStringList cats = addr.categories(); 374 qDebug("SharpDTMConverter::addresseeToSharp please check if category transformation works");
354 375
376 QStringList cats = addr.categories();
355 QArray<int> iar; 377 QArray<int> iar;
356 if ( !cats.isEmpty() ) { 378 if ( !cats.isEmpty() ) {
357 QArray<int> iar = catDB->ids("contact", cats); 379 QArray<int> iar = catDB->ids(cats);
358 contact.setCategories(iar); 380 database->updateCategories(contact, iar);
359 } 381 }
360*/ 382
361 return true; 383 return true;
362} 384}
diff --git a/kabc/converter/sharpdtm/sharpdtmconverter.h b/kabc/converter/sharpdtm/sharpdtmconverter.h
index 6a55431..99e0413 100644
--- a/kabc/converter/sharpdtm/sharpdtmconverter.h
+++ b/kabc/converter/sharpdtm/sharpdtmconverter.h
@@ -1,86 +1,86 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
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$Id$ 24$Id$
25*/ 25*/
26 26
27#ifndef KABC_SHARPDTMCONVERTER_H 27#ifndef KABC_SHARPDTMCONVERTER_H
28#define KABC_SHARPDTMCONVERTER_H 28#define KABC_SHARPDTMCONVERTER_H
29 29
30#include <qstring.h> 30#include <qstring.h>
31 31
32#include <sl/slzdb.h> 32#include <sl/slzdb.h>
33 33
34#include "addressee.h" 34#include "addressee.h"
35 35
36namespace SlCategory { 36namespace SlCategory {
37 class SlCategories; 37 class SlCategories;
38} 38}
39 39
40class SlZDataBase; 40class SlZDataBase;
41 41
42namespace KABC { 42namespace KABC {
43 43
44class SharpDTMConverter 44class SharpDTMConverter
45{ 45{
46public: 46public:
47 47
48 /** 48 /**
49 * Constructor. 49 * Constructor.
50 */ 50 */
51 SharpDTMConverter(); 51 SharpDTMConverter();
52 52
53 /** 53 /**
54 * Destructor. 54 * Destructor.
55 */ 55 */
56 virtual ~SharpDTMConverter(); 56 virtual ~SharpDTMConverter();
57 57
58 bool init(); 58 bool init();
59 void deinit(); 59 void deinit();
60 60
61 /** 61 /**
62 * Converts a given sharp card to an addressee. 62 * Converts a given sharp card to an addressee.
63 * 63 *
64 * @param contact The sharp card id, eventhough it might be 0, if the contact is a new one. 64 * @param contact The sharp card id, eventhough it might be 0, if the contact is a new one.
65 * @param database The sharp database pointer we use for the conversion 65 * @param database The sharp database pointer we use for the conversion
66 * @param addr The addressee. 66 * @param addr The addressee.
67 */ 67 */
68 bool sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr ); 68 bool sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr );
69 69
70 /** 70 /**
71 * Converts an addressee to a sharp dtm contact. 71 * Converts an addressee to a sharp dtm contact.
72 * 72 *
73 * @param addr The addressee. 73 * @param addr The addressee.
74 * @param database The sharp database pointer we use for the conversion 74 * @param database The sharp database pointer we use for the conversion
75 * @param contact The sharp card id, eventhough it might be 0, if the contact is a new one. 75 * @param contact The sharp card id, eventhough it might be 0, if the contact is a new one.
76 */ 76 */
77 bool addresseeToSharp( const Addressee &addr, const SlZDataBase* database , const CardId &contact ); 77 bool addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact );
78 78
79 private: 79 private:
80 SlCategory::SlCategories* catDB; 80 SlCategory::SlCategories* catDB;
81 81
82 82
83}; 83};
84 84
85} 85}
86#endif 86#endif