author | ulf69 <ulf69> | 2004-07-26 22:23:11 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-07-26 22:23:11 (UTC) |
commit | 509616d73f02830c2199b8ebf35425c218c9d217 (patch) (unidiff) | |
tree | 274fd1044ff0e431097d7b2af7512a8b6956f337 /kabc/plugins/sharpdtm | |
parent | ebbf4f7ac33ccaa1d1c46647b58a92da4a552615 (diff) | |
download | kdepimpi-509616d73f02830c2199b8ebf35425c218c9d217.zip kdepimpi-509616d73f02830c2199b8ebf35425c218c9d217.tar.gz kdepimpi-509616d73f02830c2199b8ebf35425c218c9d217.tar.bz2 |
converter moved to the resource plugin
-rw-r--r-- | kabc/plugins/sharpdtm/sharpdtmE.pro | 8 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/sharpdtmconverter.cpp | 384 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/sharpdtmconverter.h | 86 |
3 files changed, 475 insertions, 3 deletions
diff --git a/kabc/plugins/sharpdtm/sharpdtmE.pro b/kabc/plugins/sharpdtm/sharpdtmE.pro index a03454f..54ef083 100644 --- a/kabc/plugins/sharpdtm/sharpdtmE.pro +++ b/kabc/plugins/sharpdtm/sharpdtmE.pro | |||
@@ -1,29 +1,31 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | TARGET = microkabc_sharpdtm | 3 | TARGET = microkabc_sharpdtm |
4 | 4 | ||
5 | INCLUDEPATH += ../.. $(SHARPDTMSDK)/include ../../converter/sharpdtm ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat $(QPEDIR)/include | 5 | INCLUDEPATH += ../.. $(SHARPDTMSDK)/include ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat $(QPEDIR)/include |
6 | 6 | ||
7 | 7 | ||
8 | OBJECTS_DIR = obj/$(PLATFORM) | 8 | OBJECTS_DIR = obj/$(PLATFORM) |
9 | MOC_DIR = moc/$(PLATFORM) | 9 | MOC_DIR = moc/$(PLATFORM) |
10 | DESTDIR = $(QPEDIR)/lib | 10 | DESTDIR = $(QPEDIR)/lib |
11 | LIBS += -lmicrokde | 11 | LIBS += -lmicrokde |
12 | LIBS += -lmicrokabc | 12 | LIBS += -lmicrokabc |
13 | LIBS += -L$(QPEDIR)/lib | 13 | LIBS += -L$(QPEDIR)/lib |
14 | LIBS += -lqpe | 14 | LIBS += -lqpe |
15 | LIBS += -lqte | 15 | LIBS += -lqte |
16 | LIBS += -lzdtm | 16 | LIBS += -lzdtm |
17 | LIBS += -lmicrokabc_sharpdtmconverter | 17 | |
18 | 18 | ||
19 | 19 | ||
20 | INTERFACES = \ | 20 | INTERFACES = \ |
21 | 21 | ||
22 | HEADERS = \ | 22 | HEADERS = \ |
23 | resourcesharpdtm.h \ | 23 | resourcesharpdtm.h \ |
24 | resourcesharpdtmconfig.h \ | 24 | resourcesharpdtmconfig.h \ |
25 | sharpdtmconverter.h | ||
25 | 26 | ||
26 | SOURCES = \ | 27 | SOURCES = \ |
27 | resourcesharpdtm.cpp \ | 28 | resourcesharpdtm.cpp \ |
28 | resourcesharpdtmconfig.cpp \ | 29 | resourcesharpdtmconfig.cpp \ |
29 | 30 | sharpdtmconverter.cpp | |
31 | |||
diff --git a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp new file mode 100644 index 0000000..8f8334e --- a/dev/null +++ b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp | |||
@@ -0,0 +1,384 @@ | |||
1 | /* | ||
2 | This file is part of libkabc. | ||
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Library General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Library General Public License for more details. | ||
14 | |||
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 | ||
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /* | ||
22 | Enhanced Version of the file for platform independent KDE tools. | ||
23 | Copyright (c) 2004 Ulf Schenk | ||
24 | |||
25 | $Id$ | ||
26 | */ | ||
27 | |||
28 | #include "kglobal.h" | ||
29 | |||
30 | |||
31 | #include "sharpdtmconverter.h" | ||
32 | |||
33 | #include <sl/slcategories.h> | ||
34 | //US #include <qpe/categoryselect.h> | ||
35 | |||
36 | |||
37 | using namespace KABC; | ||
38 | using namespace SlCategory; | ||
39 | |||
40 | SharpDTMConverter::SharpDTMConverter() : catDB(0) | ||
41 | { | ||
42 | } | ||
43 | |||
44 | SharpDTMConverter::~SharpDTMConverter() | ||
45 | { | ||
46 | deinit(); | ||
47 | } | ||
48 | |||
49 | bool SharpDTMConverter::init() | ||
50 | { | ||
51 | catDB = new SlCategory::SlCategories(); | ||
52 | |||
53 | if (!catDB) | ||
54 | return false; | ||
55 | |||
56 | // catDB->load( categoryFileName() ); | ||
57 | return true; | ||
58 | } | ||
59 | |||
60 | void SharpDTMConverter::deinit() | ||
61 | { | ||
62 | if (catDB) | ||
63 | { | ||
64 | delete catDB; | ||
65 | catDB = 0; | ||
66 | } | ||
67 | } | ||
68 | |||
69 | bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr ) | ||
70 | { | ||
71 | SlZDataBase* db = (SlZDataBase*)database; | ||
72 | // name | ||
73 | qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!"); | ||
74 | addr.setFormattedName(db->readField(ZdbAdrs::FileAs)); | ||
75 | |||
76 | addr.setFamilyName( db->readField(ZdbAdrs::LastName) ); | ||
77 | addr.setGivenName( db->readField(ZdbAdrs::FirstName) ); | ||
78 | addr.setAdditionalName( db->readField(ZdbAdrs::MiddleName) ); | ||
79 | addr.setPrefix( db->readField(ZdbAdrs::Title) ); | ||
80 | addr.setSuffix( db->readField(ZdbAdrs::Suffix) ); | ||
81 | |||
82 | |||
83 | |||
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 | |||
88 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | ||
89 | addr.insertEmail( *it, ((*it) == db->readField(ZdbAdrs::DefaultEmail)) ); | ||
90 | } | ||
91 | |||
92 | if (!db->readField(ZdbAdrs::DefaultEmail).isEmpty()) | ||
93 | addr.insertEmail(db->readField(ZdbAdrs::DefaultEmail), true); | ||
94 | |||
95 | // home | ||
96 | if ((!db->readField(ZdbAdrs::HomeStreet).isEmpty()) || | ||
97 | (!db->readField(ZdbAdrs::HomeCity).isEmpty()) || | ||
98 | (!db->readField(ZdbAdrs::HomeState).isEmpty()) || | ||
99 | (!db->readField(ZdbAdrs::HomeZip).isEmpty()) || | ||
100 | (!db->readField(ZdbAdrs::HomeCountry).isEmpty())) | ||
101 | { | ||
102 | Address homeaddress; | ||
103 | homeaddress.setType(Address::Home); | ||
104 | //US homeaddress.setPostOfficeBox( "" ); | ||
105 | //US homeaddress.setExtended( "" ); | ||
106 | homeaddress.setStreet( db->readField(ZdbAdrs::HomeStreet) ); | ||
107 | homeaddress.setLocality( db->readField(ZdbAdrs::HomeCity) ); | ||
108 | homeaddress.setRegion( db->readField(ZdbAdrs::HomeState) ); | ||
109 | homeaddress.setPostalCode( db->readField(ZdbAdrs::HomeZip) ); | ||
110 | homeaddress.setCountry( db->readField(ZdbAdrs::HomeCountry) ); | ||
111 | |||
112 | addr.insertAddress( homeaddress ); | ||
113 | } | ||
114 | |||
115 | if (!db->readField(ZdbAdrs::HomePhone).isEmpty()) | ||
116 | { | ||
117 | PhoneNumber homephone; | ||
118 | homephone.setType( PhoneNumber::Home ); | ||
119 | homephone.setNumber( db->readField(ZdbAdrs::HomePhone) ); | ||
120 | addr.insertPhoneNumber( homephone ); | ||
121 | } | ||
122 | |||
123 | if (!db->readField(ZdbAdrs::HomeFax).isEmpty()) | ||
124 | { | ||
125 | PhoneNumber homefax; | ||
126 | homefax.setType( PhoneNumber::Home | PhoneNumber::Fax ); | ||
127 | homefax.setNumber( db->readField(ZdbAdrs::HomeFax) ); | ||
128 | addr.insertPhoneNumber( homefax ); | ||
129 | } | ||
130 | |||
131 | if (!db->readField(ZdbAdrs::HomeMobile).isEmpty()) | ||
132 | { | ||
133 | PhoneNumber homemobile; | ||
134 | homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell ); | ||
135 | homemobile.setNumber( db->readField(ZdbAdrs::HomeMobile) ); | ||
136 | addr.insertPhoneNumber( homemobile ); | ||
137 | } | ||
138 | |||
139 | addr.setUrl( db->readField(ZdbAdrs::HomeWebPage) ); | ||
140 | |||
141 | |||
142 | // business | ||
143 | if ((!db->readField(ZdbAdrs::BusinessStreet).isEmpty()) || | ||
144 | (!db->readField(ZdbAdrs::BusinessCity).isEmpty()) || | ||
145 | (!db->readField(ZdbAdrs::BusinessState).isEmpty()) || | ||
146 | (!db->readField(ZdbAdrs::BusinessZip).isEmpty()) || | ||
147 | (!db->readField(ZdbAdrs::BusinessCountry).isEmpty())) | ||
148 | { | ||
149 | Address businessaddress; | ||
150 | businessaddress.setType(Address::Work); | ||
151 | //US businessaddress.setPostOfficeBox( "" ); | ||
152 | //US businessaddress.setExtended( "" ); | ||
153 | businessaddress.setStreet( db->readField(ZdbAdrs::BusinessStreet) ); | ||
154 | businessaddress.setLocality( db->readField(ZdbAdrs::BusinessCity) ); | ||
155 | businessaddress.setRegion( db->readField(ZdbAdrs::BusinessState) ); | ||
156 | businessaddress.setPostalCode( db->readField(ZdbAdrs::BusinessZip) ); | ||
157 | businessaddress.setCountry( db->readField(ZdbAdrs::BusinessCountry) ); | ||
158 | |||
159 | addr.insertAddress( businessaddress ); | ||
160 | } | ||
161 | |||
162 | |||
163 | if (!db->readField(ZdbAdrs::BusinessPhone).isEmpty()) | ||
164 | { | ||
165 | PhoneNumber businessphone; | ||
166 | businessphone.setType( PhoneNumber::Work ); | ||
167 | businessphone.setNumber( db->readField(ZdbAdrs::BusinessPhone) ); | ||
168 | addr.insertPhoneNumber( businessphone ); | ||
169 | } | ||
170 | |||
171 | if (!db->readField(ZdbAdrs::BusinessFax).isEmpty()) | ||
172 | { | ||
173 | PhoneNumber businessfax; | ||
174 | businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); | ||
175 | businessfax.setNumber( db->readField(ZdbAdrs::BusinessFax) ); | ||
176 | addr.insertPhoneNumber( businessfax ); | ||
177 | } | ||
178 | |||
179 | if (!db->readField(ZdbAdrs::BusinessMobile).isEmpty()) | ||
180 | { | ||
181 | PhoneNumber businessmobile; | ||
182 | businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); | ||
183 | businessmobile.setNumber( db->readField(ZdbAdrs::BusinessMobile) ); | ||
184 | addr.insertPhoneNumber( businessmobile ); | ||
185 | } | ||
186 | |||
187 | if (!db->readField(ZdbAdrs::BusinessPager).isEmpty()) | ||
188 | { | ||
189 | PhoneNumber businesspager; | ||
190 | businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); | ||
191 | businesspager.setNumber( db->readField(ZdbAdrs::BusinessPager) ); | ||
192 | addr.insertPhoneNumber( businesspager ); | ||
193 | } | ||
194 | |||
195 | addr.setRole( db->readField(ZdbAdrs::JobTitle) ); //? | ||
196 | addr.setOrganization( db->readField(ZdbAdrs::Company) ); | ||
197 | addr.insertCustom( "KADDRESSBOOK", "X-Profession", db->readField(ZdbAdrs::Profession) ); | ||
198 | addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", db->readField(ZdbAdrs::Assistant) ); | ||
199 | addr.insertCustom( "KADDRESSBOOK", "X-Department", db->readField(ZdbAdrs::Department) ); | ||
200 | addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", db->readField(ZdbAdrs::Manager) ); | ||
201 | addr.insertCustom( "KADDRESSBOOK", "X-Office", db->readField(ZdbAdrs::Office) ); | ||
202 | |||
203 | //personal | ||
204 | addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", db->readField(ZdbAdrs::Spouse) ); | ||
205 | |||
206 | QString gen = db->readField(ZdbAdrs::Gender); | ||
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") | ||
211 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); | ||
212 | else if (gen == "female") | ||
213 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); | ||
214 | |||
215 | |||
216 | QDate ann = db->readDateField(ZdbAdrs::Anniversary); | ||
217 | |||
218 | if (ann.isValid()) { | ||
219 | QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate); | ||
220 | //US | ||
221 | // qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1()); | ||
222 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); | ||
223 | } | ||
224 | |||
225 | addr.insertCustom( "KADDRESSBOOK", "X-Children", db->readField(ZdbAdrs::Children) ); | ||
226 | |||
227 | |||
228 | QDate birthd = db->readDateField(ZdbAdrs::Birthday); | ||
229 | if (birthd.isValid()) | ||
230 | addr.setBirthday( birthd ); | ||
231 | |||
232 | addr.setNickName( db->readField(ZdbAdrs::Nickname) ); | ||
233 | |||
234 | // others | ||
235 | //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. | ||
236 | QString notes = db->readField(ZdbAdrs::Notes); | ||
237 | notes += "\nBusinessWebPage: " + db->readField(ZdbAdrs::BusinessWebPage) + "\n"; | ||
238 | |||
239 | addr.setNote( db->readField(ZdbAdrs::Notes) ); | ||
240 | |||
241 | |||
242 | |||
243 | //US QString groups() const { return find( Qtopia::Groups ); } | ||
244 | //US QStringList groupList() const; | ||
245 | |||
246 | qDebug("SharpDTMConverter::sharpToAddressee please check that the categories will be converted" ); | ||
247 | QArray<int> catArray = db->readCategories(); | ||
248 | QString cat; | ||
249 | |||
250 | for ( unsigned int i=0; i < catArray.size(); i++ ) { | ||
251 | cat = catDB->label(catArray[i]); | ||
252 | if ( cat.isEmpty() ) | ||
253 | addr.insertCategory(QString::number(catArray[i])); | ||
254 | else | ||
255 | addr.insertCategory( cat ); | ||
256 | } | ||
257 | |||
258 | return true; | ||
259 | } | ||
260 | |||
261 | bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ) | ||
262 | { | ||
263 | // name | ||
264 | database->writeField(ZdbAdrs::LastName, addr.familyName()); | ||
265 | database->writeField(ZdbAdrs::FirstName, addr.givenName()); | ||
266 | database->writeField(ZdbAdrs::MiddleName, addr.additionalName()); | ||
267 | database->writeField(ZdbAdrs::Title, addr.prefix()); | ||
268 | database->writeField(ZdbAdrs::Suffix, addr.suffix()); | ||
269 | |||
270 | qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!"); | ||
271 | database->writeField(ZdbAdrs::FileAs, addr.formattedName()); | ||
272 | |||
273 | |||
274 | |||
275 | qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!"); | ||
276 | qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee"); | ||
277 | QString emails = addr.emails().join(","); | ||
278 | database->writeField(ZdbAdrs::Emails, emails ); | ||
279 | |||
280 | database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() ); | ||
281 | |||
282 | |||
283 | // home | ||
284 | const Address homeaddress = addr.address(Address::Home); | ||
285 | if (!homeaddress.isEmpty()) { | ||
286 | database->writeField(ZdbAdrs::HomeStreet, homeaddress.street()); | ||
287 | database->writeField(ZdbAdrs::HomeCity, homeaddress.locality()); | ||
288 | database->writeField(ZdbAdrs::HomeState, homeaddress.region()); | ||
289 | database->writeField(ZdbAdrs::HomeZip, homeaddress.postalCode()); | ||
290 | database->writeField(ZdbAdrs::HomeCountry, homeaddress.country()); | ||
291 | } | ||
292 | |||
293 | PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); | ||
294 | if (!homephone.number().isEmpty()) | ||
295 | database->writeField(ZdbAdrs::HomePhone, homephone.number()); | ||
296 | |||
297 | PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); | ||
298 | if (!homefax.number().isEmpty()) | ||
299 | database->writeField(ZdbAdrs::HomeFax, homefax.number()); | ||
300 | |||
301 | PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); | ||
302 | if (!homemobile.number().isEmpty()) | ||
303 | database->writeField(ZdbAdrs::HomeMobile, homemobile.number()); | ||
304 | |||
305 | database->writeField(ZdbAdrs::HomeWebPage, addr.url().url()); | ||
306 | |||
307 | |||
308 | // business | ||
309 | const Address businessaddress = addr.address(Address::Work); | ||
310 | if (!businessaddress.isEmpty()) { | ||
311 | database->writeField(ZdbAdrs::BusinessStreet, businessaddress.street()); | ||
312 | database->writeField(ZdbAdrs::BusinessCity, businessaddress.locality()); | ||
313 | database->writeField(ZdbAdrs::BusinessState, businessaddress.region()); | ||
314 | database->writeField(ZdbAdrs::BusinessZip, businessaddress.postalCode()); | ||
315 | database->writeField(ZdbAdrs::BusinessCountry, businessaddress.country()); | ||
316 | } | ||
317 | |||
318 | PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); | ||
319 | if (!businessphone.number().isEmpty()) | ||
320 | database->writeField(ZdbAdrs::BusinessPhone, businessphone.number()); | ||
321 | |||
322 | PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); | ||
323 | if (!businessfax.number().isEmpty()) | ||
324 | database->writeField(ZdbAdrs::BusinessFax, businessfax.number()); | ||
325 | |||
326 | PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); | ||
327 | if (!businessmobile.number().isEmpty()) | ||
328 | database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number()); | ||
329 | |||
330 | PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); | ||
331 | if (!businesspager.number().isEmpty()) | ||
332 | database->writeField(ZdbAdrs::BusinessPager, businesspager.number()); | ||
333 | |||
334 | database->writeField(ZdbAdrs::JobTitle, addr.role()); | ||
335 | database->writeField(ZdbAdrs::Company, addr.organization()); | ||
336 | |||
337 | database->writeField(ZdbAdrs::Profession, addr.custom( "KADDRESSBOOK", "X-Profession" )); | ||
338 | database->writeField(ZdbAdrs::Assistant, addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); | ||
339 | database->writeField(ZdbAdrs::Department, addr.custom( "KADDRESSBOOK", "X-Department" )); | ||
340 | database->writeField(ZdbAdrs::Manager, addr.custom( "KADDRESSBOOK", "X-ManagersName" )); | ||
341 | database->writeField(ZdbAdrs::Office, addr.custom( "KADDRESSBOOK", "X-Office" )); | ||
342 | |||
343 | //personal | ||
344 | database->writeField(ZdbAdrs::Spouse, addr.custom( "KADDRESSBOOK", "X-Spouse" )); | ||
345 | |||
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"); | ||
350 | if (gt = "male") | ||
351 | database->writeField(ZdbAdrs::Gender, "male"); | ||
352 | else if (gt = "female") | ||
353 | database->writeField(ZdbAdrs::Gender, "female"); | ||
354 | else | ||
355 | database->writeField(ZdbAdrs::Gender, ""); | ||
356 | |||
357 | |||
358 | QDate dt = KGlobal::locale()->readDate( | ||
359 | addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate | ||
360 | database->writeField(ZdbAdrs::Anniversary, dt ); | ||
361 | |||
362 | database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" )); | ||
363 | |||
364 | database->writeField(ZdbAdrs::Birthday, addr.birthday().date()); | ||
365 | database->writeField(ZdbAdrs::Nickname, addr.nickName()); | ||
366 | |||
367 | // other | ||
368 | database->writeField(ZdbAdrs::Notes, addr.note()); | ||
369 | |||
370 | //US QString groups() const { return find( Qtopia::Groups ); } | ||
371 | //US QStringList groupList() const; | ||
372 | |||
373 | |||
374 | qDebug("SharpDTMConverter::addresseeToSharp please check if category transformation works"); | ||
375 | |||
376 | QStringList cats = addr.categories(); | ||
377 | QArray<int> iar; | ||
378 | if ( !cats.isEmpty() ) { | ||
379 | QArray<int> iar = catDB->ids(cats); | ||
380 | database->updateCategories(contact, iar); | ||
381 | } | ||
382 | |||
383 | return true; | ||
384 | } | ||
diff --git a/kabc/plugins/sharpdtm/sharpdtmconverter.h b/kabc/plugins/sharpdtm/sharpdtmconverter.h new file mode 100644 index 0000000..99e0413 --- a/dev/null +++ b/kabc/plugins/sharpdtm/sharpdtmconverter.h | |||
@@ -0,0 +1,86 @@ | |||
1 | /* | ||
2 | This file is part of libkabc. | ||
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Library General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Library General Public License for more details. | ||
14 | |||
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 | ||
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /* | ||
22 | Enhanced Version of the file for platform independent KDE tools. | ||
23 | Copyright (c) 2004 Ulf Schenk | ||
24 | $Id$ | ||
25 | */ | ||
26 | |||
27 | #ifndef KABC_SHARPDTMCONVERTER_H | ||
28 | #define KABC_SHARPDTMCONVERTER_H | ||
29 | |||
30 | #include <qstring.h> | ||
31 | |||
32 | #include <sl/slzdb.h> | ||
33 | |||
34 | #include "addressee.h" | ||
35 | |||
36 | namespace SlCategory { | ||
37 | class SlCategories; | ||
38 | } | ||
39 | |||
40 | class SlZDataBase; | ||
41 | |||
42 | namespace KABC { | ||
43 | |||
44 | class SharpDTMConverter | ||
45 | { | ||
46 | public: | ||
47 | |||
48 | /** | ||
49 | * Constructor. | ||
50 | */ | ||
51 | SharpDTMConverter(); | ||
52 | |||
53 | /** | ||
54 | * Destructor. | ||
55 | */ | ||
56 | virtual ~SharpDTMConverter(); | ||
57 | |||
58 | bool init(); | ||
59 | void deinit(); | ||
60 | |||
61 | /** | ||
62 | * Converts a given sharp card to an addressee. | ||
63 | * | ||
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 | ||
66 | * @param addr The addressee. | ||
67 | */ | ||
68 | bool sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr ); | ||
69 | |||
70 | /** | ||
71 | * Converts an addressee to a sharp dtm contact. | ||
72 | * | ||
73 | * @param addr The addressee. | ||
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. | ||
76 | */ | ||
77 | bool addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ); | ||
78 | |||
79 | private: | ||
80 | SlCategory::SlCategories* catDB; | ||
81 | |||
82 | |||
83 | }; | ||
84 | |||
85 | } | ||
86 | #endif | ||