author | zautrix <zautrix> | 2004-10-30 00:27:02 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-30 00:27:02 (UTC) |
commit | af857a738da80e9eb68cf311832d44ecb9caf1dd (patch) (unidiff) | |
tree | 7e45bdfeb5d2f70f8125f5fed20c28366de91c9a | |
parent | 84afedde379f67982d96dc9efa7abf9d200734e4 (diff) | |
download | kdepimpi-af857a738da80e9eb68cf311832d44ecb9caf1dd.zip kdepimpi-af857a738da80e9eb68cf311832d44ecb9caf1dd.tar.gz kdepimpi-af857a738da80e9eb68cf311832d44ecb9caf1dd.tar.bz2 |
fixed DTM sync cat handling
-rw-r--r-- | bin/kdepim/WhatsNew.txt | 11 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.cpp | 4 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/sharpdtmconverter.cpp | 154 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/sharpdtmconverter.h | 1 |
4 files changed, 109 insertions, 61 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index 756ccc1..f38dd70 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt | |||
@@ -1,98 +1,105 @@ | |||
1 | Info about the changes in new versions of KDE-Pim/Pi | 1 | Info about the changes in new versions of KDE-Pim/Pi |
2 | 2 | ||
3 | ********** VERSION 1.9.11 ************ | 3 | ********** VERSION 1.9.11 ************ |
4 | 4 | ||
5 | Fixed several problems in PWM/Pi, like | 5 | Fixed several problems in PWM/Pi, like |
6 | asking the user, if unsaved changed are pending | 6 | asking the user, if unsaved changed are pending |
7 | when closing the app. | 7 | when closing the app. |
8 | And PwM/Pi handles now different texts for the | ||
9 | fields Description, Username, Password, configurable per category. | ||
8 | 10 | ||
9 | Fixed a crash in KO/Pi , when importing/loading vcs files | 11 | Fixed a crash in KO/Pi , when importing/loading vcs files |
10 | which have an entry with an attendee with state: | 12 | which have an entry with an attendee with state: |
11 | NEEDS ACTION | 13 | NEEDS ACTION |
12 | 14 | ||
13 | Fixed some problems in the German translation of OM/Pi, | 15 | Fixed some problems in the German translation of OM/Pi, |
14 | which makes some dialogs not fitting on the screen | 16 | which makes some dialogs not fitting on the screen |
15 | of the Z 5500. | 17 | of the Z 5500. |
16 | 18 | ||
17 | Fixed Qtopia crash, when disabling/deinstalling | 19 | Fixed Qtopia crash, when disabling/deinstalling |
18 | KO/Pi alarm applet. | 20 | KO/Pi alarm applet. |
19 | 21 | ||
20 | Implemented direct KDE<->KA/Pi sync for KA/Pi running | 22 | Implemented direct KDE<->KA/Pi sync for KA/Pi running |
21 | on Linux desktop. | 23 | on Linux desktop. |
22 | 24 | ||
23 | Added feature "remove sync info" to sync menu. | 25 | Added feature "remove sync info" to sync menu. |
24 | 26 | ||
25 | Tweaked the KO/Pi What's next view a bit, added | 27 | Tweaked the KO/Pi What's next view a bit, added |
26 | setting to hide events that are done. | 28 | setting to hide events that are done. |
27 | 29 | ||
28 | Disabled "beam receive enabled" on startup to | 30 | Disabled "beam receive enabled" on startup to |
29 | avoid problems if Fastload is enabled. | 31 | avoid problems if Fastload is enabled. |
30 | Please set "beam receive enabled", | 32 | Please set "beam receive enabled", |
31 | if you want to receive data via IR. | 33 | if you want to receive data via IR. |
32 | 34 | ||
33 | Fixed bug in direct KDE<->KO/Pi sync for KO/Pi running | 35 | Fixed bug in direct KDE<->KO/Pi sync for KO/Pi running |
34 | on Linux desktop. | 36 | on Linux desktop. |
35 | 37 | ||
36 | Made in KA/Pi scrolling possible, if details view is selected. | 38 | Made in KA/Pi scrolling possible, if details view is selected. |
37 | (The keyboard focus is set automatically to the search line) | 39 | (The keyboard focus is set automatically to the search line) |
38 | 40 | ||
39 | Fixed a bug in DMT sync, that a new entry in DTM was added | 41 | Fixed a bug in DMT sync, that a new entry in DTM was added |
40 | on every sync to Kx/Pi. | 42 | on every sync to Kx/Pi. |
41 | 43 | ||
42 | Fixed a bug in DMT sync with todos created in KO/Pi containing | 44 | Fixed a bug in DMT sync with todos created in KO/Pi containing |
43 | non-latin1 characters. | 45 | non-latin1 characters. |
44 | 46 | ||
45 | Rearranged package contents of Sharp-ipks and made all | 47 | Rearranged package contents of Sharp-ipks and made all |
46 | packages installable on SD again. | 48 | packages installable on SD again. |
47 | 49 | ||
48 | PwM/Pi handles now different texts for the | 50 | Fixed the writing of addressbook data in DTM sync. |
49 | fields Description, Username, Password, configurable per category. | 51 | Empty fields in KA/Pi were not removed. |
50 | 52 | ||
53 | Added better category handling in KA/Pi: | ||
54 | Menu "change selected has now" | ||
55 | Set Categories and | ||
56 | Add Categories option. | ||
57 | Possible to configure a view to display categories. | ||
51 | 58 | ||
52 | 59 | ||
53 | ********** VERSION 1.9.10 ************ | 60 | ********** VERSION 1.9.10 ************ |
54 | 61 | ||
55 | Many internal small bugfixes. | 62 | Many internal small bugfixes. |
56 | And fix of the "big" bug in KO/Pi, | 63 | And fix of the "big" bug in KO/Pi, |
57 | that after Syncing the appointments had an offset by several hours. | 64 | that after Syncing the appointments had an offset by several hours. |
58 | That was a problem with the internal timezone setting, | 65 | That was a problem with the internal timezone setting, |
59 | introduced by the changed timezone configuration settings. | 66 | introduced by the changed timezone configuration settings. |
60 | 67 | ||
61 | German translation for OM/Pi is now available. | 68 | German translation for OM/Pi is now available. |
62 | 69 | ||
63 | 70 | ||
64 | ********** VERSION 1.9.9 ************ | 71 | ********** VERSION 1.9.9 ************ |
65 | 72 | ||
66 | KDE-Pim/Pi has a new Member! | 73 | KDE-Pim/Pi has a new Member! |
67 | It is called PWM/Pi (Passwordmanager/platform-independent) | 74 | It is called PWM/Pi (Passwordmanager/platform-independent) |
68 | and it is available for the Zaurus. | 75 | and it is available for the Zaurus. |
69 | It is planned, that it will be available later for Windows. | 76 | It is planned, that it will be available later for Windows. |
70 | (And for Linux, of course). | 77 | (And for Linux, of course). |
71 | It is a port of the Passwordmanager of KDE. | 78 | It is a port of the Passwordmanager of KDE. |
72 | It will need the MicroKDElibs to run. | 79 | It will need the MicroKDElibs to run. |
73 | 80 | ||
74 | Made loading of addressbooks in KA/Pi up to 7 times faster! | 81 | Made loading of addressbooks in KA/Pi up to 7 times faster! |
75 | The bigger your addressbook file, the more starting speed | 82 | The bigger your addressbook file, the more starting speed |
76 | will you gain. (relatively) | 83 | will you gain. (relatively) |
77 | 84 | ||
78 | The Qtopia addressbook connector is now platform independend | 85 | The Qtopia addressbook connector is now platform independend |
79 | as well and should work on any platform for importing/exporting | 86 | as well and should work on any platform for importing/exporting |
80 | Qtopia and Opie XML files. | 87 | Qtopia and Opie XML files. |
81 | 88 | ||
82 | Added a +30min feature to the timezone settings to make | 89 | Added a +30min feature to the timezone settings to make |
83 | KDE-Pim/Pi useable in Australia and other parts on the | 90 | KDE-Pim/Pi useable in Australia and other parts on the |
84 | world with strange timezones ;-) | 91 | world with strange timezones ;-) |
85 | 92 | ||
86 | German "Umlaute" should now be sorted correctly on the Z in KA/Pi. | 93 | German "Umlaute" should now be sorted correctly on the Z in KA/Pi. |
87 | 94 | ||
88 | It is now possible to disable the | 95 | It is now possible to disable the |
89 | "receive data via infrared" feature, such that syncing with | 96 | "receive data via infrared" feature, such that syncing with |
90 | Outlook is now possible again with Kx/Pi runing. | 97 | Outlook is now possible again with Kx/Pi runing. |
91 | Please disable it, before syncing Sharp DTM with Outlook. | 98 | Please disable it, before syncing Sharp DTM with Outlook. |
92 | For your convenience, the "receive data via infrared" feature | 99 | For your convenience, the "receive data via infrared" feature |
93 | is disabled automatically, if you sync Kx/Pi with DTM. | 100 | is disabled automatically, if you sync Kx/Pi with DTM. |
94 | You have to enable it again manually after syncing. | 101 | You have to enable it again manually after syncing. |
95 | Enabling this feature makes it impossible to start the | 102 | Enabling this feature makes it impossible to start the |
96 | Sharp DTM apps. If this feature is enabled, you will only get the | 103 | Sharp DTM apps. If this feature is enabled, you will only get the |
97 | alarm notification from KO/Pi and not from the Sharp calendar. | 104 | alarm notification from KO/Pi and not from the Sharp calendar. |
98 | This is very useful if you sync KO/Pi with Sharp DTM, | 105 | This is very useful if you sync KO/Pi with Sharp DTM, |
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp index 7069f5d..6413b42 100644 --- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp +++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp | |||
@@ -155,124 +155,126 @@ bool ResourceSharpDTM::load() | |||
155 | { | 155 | { |
156 | addressee.setResource( this ); | 156 | addressee.setResource( this ); |
157 | addressBook()->insertAddressee( addressee ); | 157 | addressBook()->insertAddressee( addressee ); |
158 | } | 158 | } |
159 | } | 159 | } |
160 | if(mAccess != 0) | 160 | if(mAccess != 0) |
161 | delete mAccess; | 161 | delete mAccess; |
162 | mAccess = 0; | 162 | mAccess = 0; |
163 | 163 | ||
164 | return true; | 164 | return true; |
165 | } | 165 | } |
166 | 166 | ||
167 | bool ResourceSharpDTM::save( Ticket *ticket ) | 167 | bool ResourceSharpDTM::save( Ticket *ticket ) |
168 | { | 168 | { |
169 | if (!mConverter) | 169 | if (!mConverter) |
170 | return false; | 170 | return false; |
171 | QString fileN = SlZDataBase::addressbookFileName(); | 171 | QString fileN = SlZDataBase::addressbookFileName(); |
172 | if ( ! mAccess ) { | 172 | if ( ! mAccess ) { |
173 | mAccess = new SlZDataBase(fileN, | 173 | mAccess = new SlZDataBase(fileN, |
174 | SlZDataBase::addressbookItems(), | 174 | SlZDataBase::addressbookItems(), |
175 | 0, false); | 175 | 0, false); |
176 | } | 176 | } |
177 | if(mAccess == 0) | 177 | if(mAccess == 0) |
178 | return false; | 178 | return false; |
179 | qDebug("ResourceSharpDTM::save: %s", fileName().latin1()); | 179 | qDebug("ResourceSharpDTM::save: %s", fileName().latin1()); |
180 | KABC::AddressBook::Iterator it; | 180 | KABC::AddressBook::Iterator it; |
181 | bool res; | 181 | bool res; |
182 | KABC::Addressee::List changedAddressees; | 182 | KABC::Addressee::List changedAddressees; |
183 | typedef QMap<int,QString> AddresseeMap; | 183 | typedef QMap<int,QString> AddresseeMap; |
184 | AddresseeMap map; | 184 | AddresseeMap map; |
185 | CardId id ; | 185 | CardId id ; |
186 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { | 186 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { |
187 | 187 | ||
188 | if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 188 | if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
189 | QString uid = (*it).originalExternalUID(); | 189 | QString uid = (*it).originalExternalUID(); |
190 | bool res; | 190 | bool res; |
191 | if ( uid.isEmpty() ) | 191 | if ( uid.isEmpty() ) |
192 | id = 0; | 192 | id = 0; |
193 | else | 193 | else |
194 | id = uid.toUInt(); | 194 | id = uid.toUInt(); |
195 | KABC::Addressee addressee = (*it); | 195 | KABC::Addressee addressee = (*it); |
196 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { | 196 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { |
197 | res = mAccess->startEditCard(id); | 197 | res = mAccess->startEditCard(id); |
198 | if (res == true) | 198 | if (res == true) |
199 | { | 199 | { |
200 | res = mConverter->addresseeToSharp( (*it), mAccess, id ); | 200 | res = mConverter->addresseeToSharp( (*it), mAccess, id ); |
201 | if (res == true) | 201 | if (res == true) |
202 | { | 202 | { |
203 | res = mAccess->finishEditCard(&id);; | 203 | res = mAccess->finishEditCard(&id);; |
204 | mConverter->setCategories( (*it), mAccess, id ); | ||
204 | map.insert(id,(*it).uid()); | 205 | map.insert(id,(*it).uid()); |
205 | if (res == false) | 206 | if (res == false) |
206 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); | 207 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); |
207 | 208 | ||
208 | } | 209 | } |
209 | else | 210 | else |
210 | { | 211 | { |
211 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); | 212 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); |
212 | mAccess->cancelEditCard(); | 213 | mAccess->cancelEditCard(); |
213 | } | 214 | } |
214 | } | 215 | } |
215 | 216 | ||
216 | } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 217 | } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
217 | res = mAccess->deleteCard(&id); | 218 | res = mAccess->deleteCard(&id); |
218 | if ( !res ) | 219 | if ( !res ) |
219 | qDebug("delete error "); | 220 | qDebug("delete error "); |
220 | 221 | ||
221 | 222 | ||
222 | } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 223 | } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
223 | //changed | 224 | //changed |
224 | res = mAccess->startEditCard(id); | 225 | res = mAccess->startEditCard(id); |
225 | if (res == true) | 226 | if (res == true) |
226 | { | 227 | { |
227 | res = mConverter->addresseeToSharp( (*it), mAccess, id ); | 228 | res = mConverter->addresseeToSharp( (*it), mAccess, id ); |
228 | if (res == true) | 229 | if (res == true) |
229 | { | 230 | { |
230 | res = mAccess->finishEditCard(&id); | 231 | res = mAccess->finishEditCard(&id); |
232 | mConverter->setCategories( (*it), mAccess, id ); | ||
231 | map.insert(id,(*it).uid()); | 233 | map.insert(id,(*it).uid()); |
232 | if (res == false) | 234 | if (res == false) |
233 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); | 235 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); |
234 | } | 236 | } |
235 | else | 237 | else |
236 | { | 238 | { |
237 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); | 239 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); |
238 | mAccess->cancelEditCard(); | 240 | mAccess->cancelEditCard(); |
239 | } | 241 | } |
240 | } | 242 | } |
241 | } | 243 | } |
242 | } | 244 | } |
243 | 245 | ||
244 | } | 246 | } |
245 | AddresseeMap::Iterator itam; | 247 | AddresseeMap::Iterator itam; |
246 | for ( res=mAccess->first(); res == true; res=mAccess->next()) | 248 | for ( res=mAccess->first(); res == true; res=mAccess->next()) |
247 | { | 249 | { |
248 | id = mAccess->cardId(); | 250 | id = mAccess->cardId(); |
249 | int idint = id; | 251 | int idint = id; |
250 | itam = map.find( idint ); | 252 | itam = map.find( idint ); |
251 | if ( itam != map.end() ) { | 253 | if ( itam != map.end() ) { |
252 | KABC::Addressee addressee; | 254 | KABC::Addressee addressee; |
253 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); | 255 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); |
254 | 256 | ||
255 | if ( !addressee.isEmpty() && res ) | 257 | if ( !addressee.isEmpty() && res ) |
256 | { | 258 | { |
257 | addressee.setResource( this ); | 259 | addressee.setResource( this ); |
258 | addressee.setUid( itam.data() ); | 260 | addressee.setUid( itam.data() ); |
259 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 261 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
260 | addressBook()->insertAddressee( addressee , false ); | 262 | addressBook()->insertAddressee( addressee , false ); |
261 | } | 263 | } |
262 | } | 264 | } |
263 | } | 265 | } |
264 | delete ticket; | 266 | delete ticket; |
265 | if(mAccess != 0) | 267 | if(mAccess != 0) |
266 | delete mAccess; | 268 | delete mAccess; |
267 | mAccess = 0; | 269 | mAccess = 0; |
268 | return true; | 270 | return true; |
269 | } | 271 | } |
270 | 272 | ||
271 | bool ResourceSharpDTM::lock( const QString &lockfileName ) | 273 | bool ResourceSharpDTM::lock( const QString &lockfileName ) |
272 | { | 274 | { |
273 | return true; | 275 | return true; |
274 | } | 276 | } |
275 | 277 | ||
276 | void ResourceSharpDTM::unlock( const QString &fileName ) | 278 | void ResourceSharpDTM::unlock( const QString &fileName ) |
277 | { | 279 | { |
278 | 280 | ||
diff --git a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp index 396be0a..ae4cfbb 100644 --- a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp +++ b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp | |||
@@ -262,183 +262,221 @@ bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBa | |||
262 | 262 | ||
263 | //qDebug("SharpDTMConverter::sharpToAddressee please check that the categories will be converted" ); | 263 | //qDebug("SharpDTMConverter::sharpToAddressee please check that the categories will be converted" ); |
264 | QArray<int> catArray = db->readCategories(); | 264 | QArray<int> catArray = db->readCategories(); |
265 | QString cat; | 265 | QString cat; |
266 | 266 | ||
267 | for ( unsigned int i=0; i < catArray.size(); i++ ) { | 267 | for ( unsigned int i=0; i < catArray.size(); i++ ) { |
268 | cat = catDB->label(catArray[i]); | 268 | cat = catDB->label(catArray[i]); |
269 | if ( cat.isEmpty() ) | 269 | if ( cat.isEmpty() ) |
270 | addr.insertCategory(QString::number(catArray[i])); | 270 | addr.insertCategory(QString::number(catArray[i])); |
271 | else | 271 | else |
272 | addr.insertCategory( cat ); | 272 | addr.insertCategory( cat ); |
273 | } | 273 | } |
274 | 274 | ||
275 | return true; | 275 | return true; |
276 | } | 276 | } |
277 | 277 | ||
278 | bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ) | 278 | bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ) |
279 | { | 279 | { |
280 | bool cellHome = false, cellWork = false; | 280 | bool cellHome = false, cellWork = false; |
281 | // name | 281 | // name |
282 | database->writeField(ZdbAdrs::LastName, addr.familyName()); | 282 | database->writeField(ZdbAdrs::LastName, addr.familyName()); |
283 | database->writeField(ZdbAdrs::FirstName, addr.givenName()); | 283 | database->writeField(ZdbAdrs::FirstName, addr.givenName()); |
284 | database->writeField(ZdbAdrs::MiddleName, addr.additionalName()); | 284 | database->writeField(ZdbAdrs::MiddleName, addr.additionalName()); |
285 | database->writeField(ZdbAdrs::Title, addr.prefix()); | 285 | database->writeField(ZdbAdrs::Title, addr.prefix()); |
286 | database->writeField(ZdbAdrs::Suffix, addr.suffix()); | 286 | database->writeField(ZdbAdrs::Suffix, addr.suffix()); |
287 | 287 | ||
288 | //qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() ); | 288 | //qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() ); |
289 | QString formattedName = addr.formattedName(); | 289 | QString formattedName = addr.formattedName(); |
290 | if ( formattedName.isEmpty() ) { | 290 | if ( formattedName.isEmpty() ) { |
291 | if ( !addr.familyName().isEmpty() ) { | 291 | if ( !addr.familyName().isEmpty() ) { |
292 | formattedName = addr.familyName(); | 292 | formattedName = addr.familyName(); |
293 | if ( !addr.givenName().isEmpty() ) { | 293 | if ( !addr.givenName().isEmpty() ) { |
294 | formattedName += ", "; | 294 | formattedName += ", "; |
295 | formattedName += addr.givenName(); | 295 | formattedName += addr.givenName(); |
296 | } | 296 | } |
297 | } else | 297 | } else |
298 | formattedName = addr.givenName(); | 298 | formattedName = addr.givenName(); |
299 | } | 299 | } |
300 | database->writeField(ZdbAdrs::FileAs, formattedName); | 300 | database->writeField(ZdbAdrs::FileAs, formattedName); |
301 | database->writeField(ZdbAdrs::FullName, formattedName); | 301 | database->writeField(ZdbAdrs::FullName, formattedName); |
302 | 302 | ||
303 | 303 | ||
304 | //qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!"); | 304 | //qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!"); |
305 | //qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee"); | 305 | //qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee"); |
306 | QString emails = addr.emails().join(" "); | 306 | QString emails = addr.emails().join(" "); |
307 | database->writeField(ZdbAdrs::Emails, emails ); | 307 | database->writeField(ZdbAdrs::Emails, emails ); |
308 | 308 | ||
309 | database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() ); | 309 | database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() ); |
310 | |||
311 | |||
312 | // home | 310 | // home |
313 | const Address homeaddress = addr.address(Address::Home); | 311 | const Address homeaddress = addr.address(Address::Home); |
314 | if (!homeaddress.isEmpty()) { | 312 | database->writeField(ZdbAdrs::HomeStreet, homeaddress.street()); |
315 | //qDebug("write home address "); | 313 | database->writeField(ZdbAdrs::HomeCity, homeaddress.locality()); |
316 | database->writeField(ZdbAdrs::HomeStreet, homeaddress.street()); | 314 | database->writeField(ZdbAdrs::HomeState, homeaddress.region()); |
317 | database->writeField(ZdbAdrs::HomeCity, homeaddress.locality()); | 315 | database->writeField(ZdbAdrs::HomeZip, homeaddress.postalCode()); |
318 | database->writeField(ZdbAdrs::HomeState, homeaddress.region()); | 316 | database->writeField(ZdbAdrs::HomeCountry, homeaddress.country()); |
319 | database->writeField(ZdbAdrs::HomeZip, homeaddress.postalCode()); | 317 | |
320 | database->writeField(ZdbAdrs::HomeCountry, homeaddress.country()); | ||
321 | } | ||
322 | |||
323 | PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); | 318 | PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); |
324 | if (!homephone.number().isEmpty()) | 319 | database->writeField(ZdbAdrs::HomePhone, homephone.number()); |
325 | database->writeField(ZdbAdrs::HomePhone, homephone.number()); | ||
326 | |||
327 | PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); | 320 | PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); |
328 | if (!homefax.number().isEmpty()) | 321 | database->writeField(ZdbAdrs::HomeFax, homefax.number()); |
329 | database->writeField(ZdbAdrs::HomeFax, homefax.number()); | ||
330 | |||
331 | PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); | 322 | PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); |
323 | database->writeField(ZdbAdrs::HomeMobile, homemobile.number()); | ||
332 | if (!homemobile.number().isEmpty()) { | 324 | if (!homemobile.number().isEmpty()) { |
333 | database->writeField(ZdbAdrs::HomeMobile, homemobile.number()); | ||
334 | cellHome = true; | 325 | cellHome = true; |
335 | } | 326 | } |
336 | |||
337 | database->writeField(ZdbAdrs::HomeWebPage, addr.url().url()); | 327 | database->writeField(ZdbAdrs::HomeWebPage, addr.url().url()); |
338 | |||
339 | |||
340 | // business | 328 | // business |
341 | const Address businessaddress = addr.address(Address::Work); | 329 | const Address businessaddress = addr.address(Address::Work); |
342 | if (!businessaddress.isEmpty()) { | ||
343 | //qDebug("write business address "); | 330 | //qDebug("write business address "); |
344 | database->writeField(ZdbAdrs::BusinessStreet, businessaddress.street()); | 331 | database->writeField(ZdbAdrs::BusinessStreet, businessaddress.street()); |
345 | database->writeField(ZdbAdrs::BusinessCity, businessaddress.locality()); | 332 | database->writeField(ZdbAdrs::BusinessCity, businessaddress.locality()); |
346 | database->writeField(ZdbAdrs::BusinessState, businessaddress.region()); | 333 | database->writeField(ZdbAdrs::BusinessState, businessaddress.region()); |
347 | database->writeField(ZdbAdrs::BusinessZip, businessaddress.postalCode()); | 334 | database->writeField(ZdbAdrs::BusinessZip, businessaddress.postalCode()); |
348 | database->writeField(ZdbAdrs::BusinessCountry, businessaddress.country()); | 335 | database->writeField(ZdbAdrs::BusinessCountry, businessaddress.country()); |
349 | } | 336 | |
350 | |||
351 | PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); | 337 | PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); |
352 | if (!businessphone.number().isEmpty()) | 338 | database->writeField(ZdbAdrs::BusinessPhone, businessphone.number()); |
353 | database->writeField(ZdbAdrs::BusinessPhone, businessphone.number()); | ||
354 | 339 | ||
355 | PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); | 340 | PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); |
356 | if (!businessfax.number().isEmpty()) | 341 | database->writeField(ZdbAdrs::BusinessFax, businessfax.number()); |
357 | database->writeField(ZdbAdrs::BusinessFax, businessfax.number()); | ||
358 | 342 | ||
359 | PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); | 343 | PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); |
344 | database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number()); | ||
360 | if (!businessmobile.number().isEmpty()) { | 345 | if (!businessmobile.number().isEmpty()) { |
361 | cellWork = true; | 346 | cellWork = true; |
362 | database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number()); | ||
363 | } | 347 | } |
364 | PhoneNumber mobile = addr.phoneNumber( PhoneNumber::Cell ); | 348 | PhoneNumber mobile = addr.phoneNumber( PhoneNumber::Cell ); |
365 | if (! mobile.number().isEmpty()) { | 349 | if (! mobile.number().isEmpty()) { |
366 | if ( ! cellHome ) | 350 | if ( ! cellHome ) |
367 | database->writeField(ZdbAdrs::HomeMobile, mobile.number()); | 351 | database->writeField(ZdbAdrs::HomeMobile, mobile.number()); |
368 | else if (! cellWork ) | 352 | else if (! cellWork ) |
369 | database->writeField(ZdbAdrs::BusinessMobile, mobile.number()); | 353 | database->writeField(ZdbAdrs::BusinessMobile, mobile.number()); |
370 | } | 354 | } |
371 | 355 | ||
372 | PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); | 356 | PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); |
373 | if (!businesspager.number().isEmpty()) | 357 | database->writeField(ZdbAdrs::BusinessPager, businesspager.number()); |
374 | database->writeField(ZdbAdrs::BusinessPager, businesspager.number()); | ||
375 | 358 | ||
376 | database->writeField(ZdbAdrs::JobTitle, addr.role()); | 359 | database->writeField(ZdbAdrs::JobTitle, addr.role()); |
377 | database->writeField(ZdbAdrs::Company, addr.organization()); | 360 | database->writeField(ZdbAdrs::Company, addr.organization()); |
378 | 361 | ||
379 | database->writeField(ZdbAdrs::Profession, addr.custom( "KADDRESSBOOK", "X-Profession" )); | 362 | database->writeField(ZdbAdrs::Profession, addr.custom( "KADDRESSBOOK", "X-Profession" )); |
380 | database->writeField(ZdbAdrs::Assistant, addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); | 363 | database->writeField(ZdbAdrs::Assistant, addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); |
381 | database->writeField(ZdbAdrs::Department, addr.custom( "KADDRESSBOOK", "X-Department" )); | 364 | database->writeField(ZdbAdrs::Department, addr.custom( "KADDRESSBOOK", "X-Department" )); |
382 | database->writeField(ZdbAdrs::Manager, addr.custom( "KADDRESSBOOK", "X-ManagersName" )); | 365 | database->writeField(ZdbAdrs::Manager, addr.custom( "KADDRESSBOOK", "X-ManagersName" )); |
383 | database->writeField(ZdbAdrs::Office, addr.custom( "KADDRESSBOOK", "X-Office" )); | 366 | database->writeField(ZdbAdrs::Office, addr.custom( "KADDRESSBOOK", "X-Office" )); |
384 | 367 | ||
385 | //personal | 368 | //personal |
386 | database->writeField(ZdbAdrs::Spouse, addr.custom( "KADDRESSBOOK", "X-Spouse" )); | 369 | database->writeField(ZdbAdrs::Spouse, addr.custom( "KADDRESSBOOK", "X-Spouse" )); |
387 | 370 | ||
388 | QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); | 371 | QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); |
389 | //qDebug("SharpDTMConverter::addresseeToSharp please check that gender works!! : Gender: %s", gt.latin1()); | 372 | //qDebug("SharpDTMConverter::addresseeToSharp please check that gender works!! : Gender: %s", gt.latin1()); |
390 | //qDebug("SharpDTMConverter::addresseeToSharp: may be writeField(\"ZdbAdrs::Gender\", ushort) is here better suited?"); | 373 | //qDebug("SharpDTMConverter::addresseeToSharp: may be writeField(\"ZdbAdrs::Gender\", ushort) is here better suited?"); |
391 | //qDebug("SharpDTMConverter::addresseeToSharp: check also the reverse functionality in sharpToAddressee"); | 374 | //qDebug("SharpDTMConverter::addresseeToSharp: check also the reverse functionality in sharpToAddressee"); |
392 | if (gt == "male") | 375 | if (gt == "male") |
393 | database->writeField(ZdbAdrs::Gender, "male"); | 376 | database->writeField(ZdbAdrs::Gender, "male"); |
394 | else if (gt == "female") | 377 | else if (gt == "female") |
395 | database->writeField(ZdbAdrs::Gender, "female"); | 378 | database->writeField(ZdbAdrs::Gender, "female"); |
396 | else | 379 | else |
397 | database->writeField(ZdbAdrs::Gender, ""); | 380 | database->writeField(ZdbAdrs::Gender, ""); |
398 | 381 | ||
399 | 382 | QString dateS ; | |
400 | QDate dt = KGlobal::locale()->readDate( | 383 | QDate dt = KGlobal::locale()->readDate(addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate |
401 | addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate | ||
402 | if ( dt.isValid() ) { | 384 | if ( dt.isValid() ) { |
403 | QString dateS = KGlobal::locale()->formatDate(dt, true ); | 385 | dateS = KGlobal::locale()->formatDate(dt, true ); |
404 | database->writeField(ZdbAdrs::Anniversary, dateS ); | ||
405 | } | 386 | } |
387 | database->writeField(ZdbAdrs::Anniversary, dateS ); | ||
406 | database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" )); | 388 | database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" )); |
407 | dt = addr.birthday().date(); | 389 | dt = addr.birthday().date(); |
390 | dateS = ""; | ||
408 | if ( dt.isValid() ) { | 391 | if ( dt.isValid() ) { |
409 | QString dateS = KGlobal::locale()->formatDate(dt, true ); | 392 | dateS = KGlobal::locale()->formatDate(dt, true ); |
410 | database->writeField(ZdbAdrs::Birthday, dateS); | ||
411 | } | 393 | } |
394 | database->writeField(ZdbAdrs::Birthday, dateS); | ||
412 | database->writeField(ZdbAdrs::Nickname, addr.nickName()); | 395 | database->writeField(ZdbAdrs::Nickname, addr.nickName()); |
413 | 396 | ||
414 | // other | 397 | // other |
415 | database->writeField(ZdbAdrs::Notes, addr.note()); | 398 | database->writeField(ZdbAdrs::Notes, addr.note()); |
416 | 399 | ||
417 | //US QString groups() const { return find( Qtopia::Groups ); } | 400 | //US QString groups() const { return find( Qtopia::Groups ); } |
418 | //US QStringList groupList() const; | 401 | //US QStringList groupList() const; |
419 | 402 | ||
420 | 403 | ||
421 | //qDebug("SharpDTMConverter::addresseeToSharp please check if category transformation works"); | 404 | //qDebug("SharpDTMConverter::addresseeToSharp please check if category transformation works"); |
422 | 405 | ||
423 | QStringList cats = addr.categories(); | ||
424 | int ii; | ||
425 | for ( ii = 0; ii < cats.count() ;++ii ) { | ||
426 | if ( !catDB->exists( cats[ii] )) | ||
427 | catDB->addCategory(cats[ii]); | ||
428 | } | ||
429 | QArray<int> iar; | ||
430 | if ( !cats.isEmpty() ) { | ||
431 | QArray<int> iar = catDB->ids(cats); | ||
432 | //qDebug("***cat count is %d ", iar.count()); | ||
433 | database->updateCategories(contact, iar); | ||
434 | } | ||
435 | |||
436 | return true; | 406 | return true; |
437 | } | 407 | } |
438 | 408 | ||
409 | |||
410 | bool SharpDTMConverter::setCategories( const Addressee &addr, SlZDataBase* database , const CardId &contact ) | ||
411 | { | ||
412 | QStringList list = addr.categories(); | ||
413 | |||
414 | QArray<int> ids(list.count()); | ||
415 | uint index = 0; | ||
416 | for(uint i=0; i<ids.size(); i++){ | ||
417 | if(catDB->exists(list[i])){ | ||
418 | ids[index] = catDB->id(list[i]); | ||
419 | qDebug("set ex cat %d %s ",ids[index] , list[i].latin1()); | ||
420 | index++; | ||
421 | } else { | ||
422 | ids[index] = catDB->addCategory(list[i]); | ||
423 | qDebug("add new cat %d %s ",ids[index] , list[i].latin1()); | ||
424 | index++; | ||
425 | } | ||
426 | } | ||
427 | bool res ; | ||
428 | if ( res = database->updateCategories(contact, ids) ) | ||
429 | qDebug("cat updated "); | ||
430 | else | ||
431 | qDebug("error cat updating "); | ||
432 | |||
433 | return res; | ||
434 | } | ||
435 | |||
436 | #if 0 | ||
437 | m_pCategories = new SlCategories; | ||
438 | catDB | ||
439 | |||
440 | if(categories == QString::null) return true; | ||
441 | QStringList list = CSVParser::parse(categories); | ||
442 | QArray<int> ids(list.count()); | ||
443 | uint index = 0; | ||
444 | for(uint i=0; i<ids.size(); i++){ | ||
445 | #if 0 | ||
446 | bool ok; | ||
447 | ids[index] = list[i].toInt(&ok); | ||
448 | if(ok){ | ||
449 | index++; | ||
450 | } else { | ||
451 | if(m_pCategories->exists(list[i])){ | ||
452 | ids[index] = m_pCategories->id(list[i]); | ||
453 | index++; | ||
454 | } | ||
455 | } | ||
456 | #else | ||
457 | if(m_pCategories->exists(list[i])){ | ||
458 | ids[index] = m_pCategories->id(list[i]); | ||
459 | index++; | ||
460 | } else if(m_addCategory){ | ||
461 | ids[index] = m_pCategories->addCategory(list[i]); | ||
462 | index++; | ||
463 | } | ||
464 | #endif | ||
465 | } | ||
466 | if(ids.size() > 0 && index == 0){ | ||
467 | return true; | ||
468 | } else if(index != ids.size()){ | ||
469 | ids.resize(index); | ||
470 | } | ||
471 | if(!m_pZdb->updateCategories(id, ids)){ | ||
472 | return false; | ||
473 | } | ||
474 | return true; | ||
475 | #endif | ||
476 | |||
439 | QDate SharpDTMConverter::convertDate( QString s) | 477 | QDate SharpDTMConverter::convertDate( QString s) |
440 | { | 478 | { |
441 | QDate dt = KGlobal::locale()->readDate( s ); | 479 | QDate dt = KGlobal::locale()->readDate( s ); |
442 | return dt; | 480 | return dt; |
443 | return QDate (); | 481 | return QDate (); |
444 | } | 482 | } |
diff --git a/kabc/plugins/sharpdtm/sharpdtmconverter.h b/kabc/plugins/sharpdtm/sharpdtmconverter.h index a04083e..db1bf2d 100644 --- a/kabc/plugins/sharpdtm/sharpdtmconverter.h +++ b/kabc/plugins/sharpdtm/sharpdtmconverter.h | |||
@@ -30,58 +30,59 @@ $Id$ | |||
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 | ||
36 | namespace SlCategory { | 36 | namespace SlCategory { |
37 | class SlCategories; | 37 | class SlCategories; |
38 | } | 38 | } |
39 | 39 | ||
40 | class SlZDataBase; | 40 | class SlZDataBase; |
41 | 41 | ||
42 | namespace KABC { | 42 | namespace KABC { |
43 | 43 | ||
44 | class SharpDTMConverter | 44 | class SharpDTMConverter |
45 | { | 45 | { |
46 | public: | 46 | public: |
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, SlZDataBase* database , const CardId &contact ); | 77 | bool addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ); |
78 | bool setCategories( const Addressee &addr, SlZDataBase* database , const CardId &contact ); | ||
78 | 79 | ||
79 | private: | 80 | private: |
80 | SlCategory::SlCategories* catDB; | 81 | SlCategory::SlCategories* catDB; |
81 | QDate convertDate( QString ); | 82 | QDate convertDate( QString ); |
82 | 83 | ||
83 | 84 | ||
84 | }; | 85 | }; |
85 | 86 | ||
86 | } | 87 | } |
87 | #endif | 88 | #endif |