author | zautrix <zautrix> | 2005-10-27 10:34:56 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-10-27 10:34:56 (UTC) |
commit | 29c7448b3c54e8d579732d10f144e12f7167c3c3 (patch) (unidiff) | |
tree | ae613037eaa897d2f7bc084d0b9e6954c630d985 /kabc/plugins | |
parent | eb83d8b5542de9ca0c421ad6aca2913b502bbe78 (diff) | |
download | kdepimpi-29c7448b3c54e8d579732d10f144e12f7167c3c3.zip kdepimpi-29c7448b3c54e8d579732d10f144e12f7167c3c3.tar.gz kdepimpi-29c7448b3c54e8d579732d10f144e12f7167c3c3.tar.bz2 |
commit
-rw-r--r-- | kabc/plugins/olaccess/olaccess.pro | 2 | ||||
-rw-r--r-- | kabc/plugins/olaccess/olaccessconverter.cpp | 54 | ||||
-rw-r--r-- | kabc/plugins/olaccess/olaccessconverter.h | 20 | ||||
-rw-r--r-- | kabc/plugins/olaccess/resourceolaccess.cpp | 69 | ||||
-rw-r--r-- | kabc/plugins/olaccess/resourceolaccess.h | 21 | ||||
-rw-r--r-- | kabc/plugins/olaccess/resourceolaccessconfig.cpp | 24 | ||||
-rw-r--r-- | kabc/plugins/olaccess/resourceolaccessconfig.h | 4 |
7 files changed, 94 insertions, 100 deletions
diff --git a/kabc/plugins/olaccess/olaccess.pro b/kabc/plugins/olaccess/olaccess.pro index ca0a6a8..4416d0c 100644 --- a/kabc/plugins/olaccess/olaccess.pro +++ b/kabc/plugins/olaccess/olaccess.pro | |||
@@ -1,23 +1,23 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | TARGET = microkabc_olaccess | 3 | TARGET = microkabc_olaccess |
4 | 4 | ||
5 | include( ../../../variables.pri ) | 5 | include( ../../../variables.pri ) |
6 | 6 | ||
7 | INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat | 7 | INCLUDEPATH += ../../.. ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat |
8 | 8 | ||
9 | INTERFACES = \ | 9 | INTERFACES = \ |
10 | 10 | ||
11 | HEADERS = \ | 11 | HEADERS = \ |
12 | resourceolaccess.h \ | 12 | resourceolaccess.h \ |
13 | resourceolaccessconfig.h \ | 13 | resourceolaccessconfig.h \ |
14 | olaccessconverter.h | 14 | olaccessconverter.h |
15 | 15 | ||
16 | SOURCES = \ | 16 | SOURCES = \ |
17 | resourceolaccess.cpp \ | 17 | resourceolaccess.cpp \ |
18 | resourceolaccessconfig.cpp \ | 18 | resourceolaccessconfig.cpp \ |
19 | olaccessconverter.cpp | 19 | olaccessconverter.cpp |
20 | 20 | ||
21 | unix : { | 21 | unix : { |
22 | OBJECTS_DIR = obj/unix | 22 | OBJECTS_DIR = obj/unix |
23 | MOC_DIR = moc/unix | 23 | MOC_DIR = moc/unix |
diff --git a/kabc/plugins/olaccess/olaccessconverter.cpp b/kabc/plugins/olaccess/olaccessconverter.cpp index 4adcae4..e95f3cb 100644 --- a/kabc/plugins/olaccess/olaccessconverter.cpp +++ b/kabc/plugins/olaccess/olaccessconverter.cpp | |||
@@ -16,98 +16,100 @@ | |||
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 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include "kglobal.h" | 28 | #include "kglobal.h" |
29 | #include <qregexp.h> | 29 | #include <qregexp.h> |
30 | 30 | ||
31 | 31 | ||
32 | #include "sharpdtmconverter.h" | 32 | #include "olaccessconverter.h" |
33 | 33 | ||
34 | #include <sl/slcategories.h> | ||
35 | #include <libkdepim/ksyncprofile.h> | 34 | #include <libkdepim/ksyncprofile.h> |
36 | //US #include <qpe/categoryselect.h> | 35 | //US #include <qpe/categoryselect.h> |
37 | 36 | ||
38 | 37 | ||
39 | using namespace KABC; | 38 | using namespace KABC; |
40 | using namespace SlCategory; | ||
41 | 39 | ||
42 | SharpDTMConverter::SharpDTMConverter() : catDB(0) | 40 | OlaccessConverter::OlaccessConverter() |
43 | { | 41 | { |
44 | } | 42 | } |
45 | 43 | ||
46 | SharpDTMConverter::~SharpDTMConverter() | 44 | OlaccessConverter::~OlaccessConverter() |
47 | { | 45 | { |
48 | deinit(); | 46 | deinit(); |
49 | } | 47 | } |
50 | 48 | ||
51 | bool SharpDTMConverter::init() | 49 | bool OlaccessConverter::init() |
52 | { | 50 | { |
51 | #if 0 | ||
53 | catDB = new SlCategory::SlCategories(); | 52 | catDB = new SlCategory::SlCategories(); |
54 | 53 | ||
55 | if (!catDB) | 54 | if (!catDB) |
56 | return false; | 55 | return false; |
57 | 56 | ||
58 | // catDB->load( categoryFileName() ); | 57 | // catDB->load( categoryFileName() ); |
58 | #endif | ||
59 | return true; | 59 | return true; |
60 | } | 60 | } |
61 | 61 | ||
62 | void SharpDTMConverter::deinit() | 62 | void OlaccessConverter::deinit() |
63 | { | 63 | { |
64 | #if 0 | ||
64 | if (catDB) | 65 | if (catDB) |
65 | { | 66 | { |
66 | delete catDB; | 67 | delete catDB; |
67 | catDB = 0; | 68 | catDB = 0; |
68 | } | 69 | } |
70 | #endif | ||
69 | } | 71 | } |
70 | 72 | #if 0 | |
71 | bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr ) | 73 | bool OlaccessConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr ) |
72 | { | 74 | { |
73 | SlZDataBase* db = (SlZDataBase*)database; | 75 | SlZDataBase* db = (SlZDataBase*)database; |
74 | 76 | ||
75 | // for syncing: we need setting of the two fields | 77 | // for syncing: we need setting of the two fields |
76 | addr.setExternalUID( QString::number( contact ) ); | 78 | addr.setExternalUID( QString::number( contact ) ); |
77 | addr.setOriginalExternalUID( QString::number( contact ) ); | 79 | addr.setOriginalExternalUID( QString::number( contact ) ); |
78 | addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 80 | addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
79 | 81 | ||
80 | 82 | ||
81 | // name | 83 | // name |
82 | //qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!"); | 84 | //qDebug("OlaccessConverter::sharpToAddressee check if the fileAs transformation works!!"); |
83 | addr.setFormattedName(db->readField(ZdbAdrs::FileAs)); | 85 | addr.setFormattedName(db->readField(ZdbAdrs::FileAs)); |
84 | //addr.setName(db->readField(ZdbAdrs::FullName)); | 86 | //addr.setName(db->readField(ZdbAdrs::FullName)); |
85 | 87 | ||
86 | addr.setFamilyName( db->readField(ZdbAdrs::LastName) ); | 88 | addr.setFamilyName( db->readField(ZdbAdrs::LastName) ); |
87 | addr.setGivenName( db->readField(ZdbAdrs::FirstName) ); | 89 | addr.setGivenName( db->readField(ZdbAdrs::FirstName) ); |
88 | addr.setAdditionalName( db->readField(ZdbAdrs::MiddleName) ); | 90 | addr.setAdditionalName( db->readField(ZdbAdrs::MiddleName) ); |
89 | addr.setPrefix( db->readField(ZdbAdrs::Title) ); | 91 | addr.setPrefix( db->readField(ZdbAdrs::Title) ); |
90 | addr.setSuffix( db->readField(ZdbAdrs::Suffix) ); | 92 | addr.setSuffix( db->readField(ZdbAdrs::Suffix) ); |
91 | 93 | ||
92 | 94 | ||
93 | QString emailstr = db->readField(ZdbAdrs::Emails); | 95 | QString emailstr = db->readField(ZdbAdrs::Emails); |
94 | emailstr.replace( QRegExp(","), " " ); | 96 | emailstr.replace( QRegExp(","), " " ); |
95 | emailstr.replace( QRegExp(";"), " " ); | 97 | emailstr.replace( QRegExp(";"), " " ); |
96 | emailstr.replace( QRegExp(":"), " " ); | 98 | emailstr.replace( QRegExp(":"), " " ); |
97 | //qDebug("SharpDTMConverter::sharpToAddressee whats the character to seperate the emailadresses? %s ", emailstr.latin1()); | 99 | //qDebug("OlaccessConverter::sharpToAddressee whats the character to seperate the emailadresses? %s ", emailstr.latin1()); |
98 | QStringList emails = QStringList::split(" ", emailstr.simplifyWhiteSpace()); | 100 | QStringList emails = QStringList::split(" ", emailstr.simplifyWhiteSpace()); |
99 | bool defE = false; | 101 | bool defE = false; |
100 | bool found = false; | 102 | bool found = false; |
101 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 103 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
102 | if (found ) | 104 | if (found ) |
103 | defE = false; | 105 | defE = false; |
104 | else | 106 | else |
105 | found = defE = ((*it).lower() == db->readField(ZdbAdrs::DefaultEmail).lower()); | 107 | found = defE = ((*it).lower() == db->readField(ZdbAdrs::DefaultEmail).lower()); |
106 | addr.insertEmail( *it, defE ); | 108 | addr.insertEmail( *it, defE ); |
107 | } | 109 | } |
108 | if ( ! found ) | 110 | if ( ! found ) |
109 | if (!db->readField(ZdbAdrs::DefaultEmail).isEmpty()) | 111 | if (!db->readField(ZdbAdrs::DefaultEmail).isEmpty()) |
110 | addr.insertEmail(db->readField(ZdbAdrs::DefaultEmail), true); | 112 | addr.insertEmail(db->readField(ZdbAdrs::DefaultEmail), true); |
111 | 113 | ||
112 | // home | 114 | // home |
113 | if ((!db->readField(ZdbAdrs::HomeStreet).isEmpty()) || | 115 | if ((!db->readField(ZdbAdrs::HomeStreet).isEmpty()) || |
@@ -208,34 +210,34 @@ bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBa | |||
208 | businesspager.setNumber( db->readField(ZdbAdrs::BusinessPager) ); | 210 | businesspager.setNumber( db->readField(ZdbAdrs::BusinessPager) ); |
209 | addr.insertPhoneNumber( businesspager ); | 211 | addr.insertPhoneNumber( businesspager ); |
210 | } | 212 | } |
211 | 213 | ||
212 | addr.setRole( db->readField(ZdbAdrs::JobTitle) ); | 214 | addr.setRole( db->readField(ZdbAdrs::JobTitle) ); |
213 | addr.setOrganization( db->readField(ZdbAdrs::Company) ); | 215 | addr.setOrganization( db->readField(ZdbAdrs::Company) ); |
214 | addr.insertCustom( "KADDRESSBOOK", "X-Profession", db->readField(ZdbAdrs::Profession) ); | 216 | addr.insertCustom( "KADDRESSBOOK", "X-Profession", db->readField(ZdbAdrs::Profession) ); |
215 | addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", db->readField(ZdbAdrs::Assistant) ); | 217 | addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", db->readField(ZdbAdrs::Assistant) ); |
216 | addr.insertCustom( "KADDRESSBOOK", "X-Department", db->readField(ZdbAdrs::Department) ); | 218 | addr.insertCustom( "KADDRESSBOOK", "X-Department", db->readField(ZdbAdrs::Department) ); |
217 | addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", db->readField(ZdbAdrs::Manager) ); | 219 | addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", db->readField(ZdbAdrs::Manager) ); |
218 | addr.insertCustom( "KADDRESSBOOK", "X-Office", db->readField(ZdbAdrs::Office) ); | 220 | addr.insertCustom( "KADDRESSBOOK", "X-Office", db->readField(ZdbAdrs::Office) ); |
219 | 221 | ||
220 | //personal | 222 | //personal |
221 | addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", db->readField(ZdbAdrs::Spouse) ); | 223 | addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", db->readField(ZdbAdrs::Spouse) ); |
222 | 224 | ||
223 | QString gen = db->readField(ZdbAdrs::Gender); | 225 | QString gen = db->readField(ZdbAdrs::Gender); |
224 | //qDebug("SharpDTMConverter::sharpToAddressee pleas check that gender works!! : Gender: %s", gen.latin1()); | 226 | //qDebug("OlaccessConverter::sharpToAddressee pleas check that gender works!! : Gender: %s", gen.latin1()); |
225 | //qDebug("SharpDTMConverter::sharpToAddressee: may be int db->readUshortField(\"ZdbAdrs::Gender\") is here better suited"); | 227 | //qDebug("OlaccessConverter::sharpToAddressee: may be int db->readUshortField(\"ZdbAdrs::Gender\") is here better suited"); |
226 | if (gen == "1") | 228 | if (gen == "1") |
227 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); | 229 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); |
228 | else if (gen == "2") | 230 | else if (gen == "2") |
229 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); | 231 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); |
230 | else | 232 | else |
231 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "undef"); | 233 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "undef"); |
232 | 234 | ||
233 | 235 | ||
234 | QDate ann = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Anniversary) ); | 236 | QDate ann = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Anniversary) ); |
235 | if (ann.isValid()) { | 237 | if (ann.isValid()) { |
236 | QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate); | 238 | QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate); |
237 | //qDebug("qtopiaToAddressee annyversary found:%s", dt.latin1()); | 239 | //qDebug("qtopiaToAddressee annyversary found:%s", dt.latin1()); |
238 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); | 240 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); |
239 | } else | 241 | } else |
240 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", " "); | 242 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", " "); |
241 | 243 | ||
@@ -251,75 +253,75 @@ bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBa | |||
251 | 253 | ||
252 | addr.setNickName( db->readField(ZdbAdrs::Nickname) ); | 254 | addr.setNickName( db->readField(ZdbAdrs::Nickname) ); |
253 | 255 | ||
254 | // others | 256 | // others |
255 | //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. | 257 | //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. |
256 | //QString notes = db->readField(ZdbAdrs::Notes); | 258 | //QString notes = db->readField(ZdbAdrs::Notes); |
257 | //notes += "\nBusinessWebPage: " + db->readField(ZdbAdrs::BusinessWebPage) + "\n"; | 259 | //notes += "\nBusinessWebPage: " + db->readField(ZdbAdrs::BusinessWebPage) + "\n"; |
258 | if ( addr.url().isEmpty() ) | 260 | if ( addr.url().isEmpty() ) |
259 | addr.setUrl( db->readField(ZdbAdrs::BusinessWebPage) ); | 261 | addr.setUrl( db->readField(ZdbAdrs::BusinessWebPage) ); |
260 | addr.setNote( db->readField(ZdbAdrs::Notes).replace( QRegExp("\\r"), "")); | 262 | addr.setNote( db->readField(ZdbAdrs::Notes).replace( QRegExp("\\r"), "")); |
261 | 263 | ||
262 | 264 | ||
263 | 265 | ||
264 | //US QString groups() const { return find( Qtopia::Groups ); } | 266 | //US QString groups() const { return find( Qtopia::Groups ); } |
265 | //US QStringList groupList() const; | 267 | //US QStringList groupList() const; |
266 | 268 | ||
267 | //qDebug("SharpDTMConverter::sharpToAddressee please check that the categories will be converted" ); | 269 | //qDebug("OlaccessConverter::sharpToAddressee please check that the categories will be converted" ); |
268 | QArray<int> catArray = db->readCategories(); | 270 | QArray<int> catArray = db->readCategories(); |
269 | QString cat; | 271 | QString cat; |
270 | 272 | ||
271 | for ( unsigned int i=0; i < catArray.size(); i++ ) { | 273 | for ( unsigned int i=0; i < catArray.size(); i++ ) { |
272 | cat = catDB->label(catArray[i]); | 274 | cat = catDB->label(catArray[i]); |
273 | if ( cat.isEmpty() ) | 275 | if ( cat.isEmpty() ) |
274 | addr.insertCategory(QString::number(catArray[i])); | 276 | addr.insertCategory(QString::number(catArray[i])); |
275 | else | 277 | else |
276 | addr.insertCategory( cat ); | 278 | addr.insertCategory( cat ); |
277 | } | 279 | } |
278 | 280 | ||
279 | return true; | 281 | return true; |
280 | } | 282 | } |
281 | 283 | ||
282 | bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ) | 284 | bool OlaccessConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ) |
283 | { | 285 | { |
284 | bool cellHome = false, cellWork = false; | 286 | bool cellHome = false, cellWork = false; |
285 | // name | 287 | // name |
286 | database->writeField(ZdbAdrs::LastName, addr.familyName()); | 288 | database->writeField(ZdbAdrs::LastName, addr.familyName()); |
287 | database->writeField(ZdbAdrs::FirstName, addr.givenName()); | 289 | database->writeField(ZdbAdrs::FirstName, addr.givenName()); |
288 | database->writeField(ZdbAdrs::MiddleName, addr.additionalName()); | 290 | database->writeField(ZdbAdrs::MiddleName, addr.additionalName()); |
289 | database->writeField(ZdbAdrs::Title, addr.prefix()); | 291 | database->writeField(ZdbAdrs::Title, addr.prefix()); |
290 | database->writeField(ZdbAdrs::Suffix, addr.suffix()); | 292 | database->writeField(ZdbAdrs::Suffix, addr.suffix()); |
291 | 293 | ||
292 | //qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() ); | 294 | //qDebug("OlaccessConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() ); |
293 | QString formattedName = addr.formattedName(); | 295 | QString formattedName = addr.formattedName(); |
294 | if ( formattedName.isEmpty() ) { | 296 | if ( formattedName.isEmpty() ) { |
295 | if ( !addr.familyName().isEmpty() ) { | 297 | if ( !addr.familyName().isEmpty() ) { |
296 | formattedName = addr.familyName(); | 298 | formattedName = addr.familyName(); |
297 | if ( !addr.givenName().isEmpty() ) { | 299 | if ( !addr.givenName().isEmpty() ) { |
298 | formattedName += ", "; | 300 | formattedName += ", "; |
299 | formattedName += addr.givenName(); | 301 | formattedName += addr.givenName(); |
300 | } | 302 | } |
301 | } else | 303 | } else |
302 | formattedName = addr.givenName(); | 304 | formattedName = addr.givenName(); |
303 | } | 305 | } |
304 | database->writeField(ZdbAdrs::FileAs, formattedName); | 306 | database->writeField(ZdbAdrs::FileAs, formattedName); |
305 | database->writeField(ZdbAdrs::FullName, formattedName); | 307 | database->writeField(ZdbAdrs::FullName, formattedName); |
306 | 308 | ||
307 | 309 | ||
308 | //qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!"); | 310 | //qDebug("OlaccessConverter::addresseeToSharp check which seperator we need here for the emails!!"); |
309 | //qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee"); | 311 | //qDebug("OlaccessConverter::addresseeToSharp its probably the same from sharpToAddressee"); |
310 | QString emails = addr.emails().join(" "); | 312 | QString emails = addr.emails().join(" "); |
311 | database->writeField(ZdbAdrs::Emails, emails ); | 313 | database->writeField(ZdbAdrs::Emails, emails ); |
312 | 314 | ||
313 | database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() ); | 315 | database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() ); |
314 | // home | 316 | // home |
315 | const Address homeaddress = addr.address(Address::Home); | 317 | const Address homeaddress = addr.address(Address::Home); |
316 | database->writeField(ZdbAdrs::HomeStreet, homeaddress.street()); | 318 | database->writeField(ZdbAdrs::HomeStreet, homeaddress.street()); |
317 | database->writeField(ZdbAdrs::HomeCity, homeaddress.locality()); | 319 | database->writeField(ZdbAdrs::HomeCity, homeaddress.locality()); |
318 | database->writeField(ZdbAdrs::HomeState, homeaddress.region()); | 320 | database->writeField(ZdbAdrs::HomeState, homeaddress.region()); |
319 | database->writeField(ZdbAdrs::HomeZip, homeaddress.postalCode()); | 321 | database->writeField(ZdbAdrs::HomeZip, homeaddress.postalCode()); |
320 | database->writeField(ZdbAdrs::HomeCountry, homeaddress.country()); | 322 | database->writeField(ZdbAdrs::HomeCountry, homeaddress.country()); |
321 | 323 | ||
322 | PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); | 324 | PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); |
323 | database->writeField(ZdbAdrs::HomePhone, homephone.number()); | 325 | database->writeField(ZdbAdrs::HomePhone, homephone.number()); |
324 | PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); | 326 | PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); |
325 | database->writeField(ZdbAdrs::HomeFax, homefax.number()); | 327 | database->writeField(ZdbAdrs::HomeFax, homefax.number()); |
@@ -360,85 +362,85 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* da | |||
360 | PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); | 362 | PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); |
361 | database->writeField(ZdbAdrs::BusinessPager, businesspager.number()); | 363 | database->writeField(ZdbAdrs::BusinessPager, businesspager.number()); |
362 | 364 | ||
363 | database->writeField(ZdbAdrs::JobTitle, addr.role()); | 365 | database->writeField(ZdbAdrs::JobTitle, addr.role()); |
364 | database->writeField(ZdbAdrs::Company, addr.organization()); | 366 | database->writeField(ZdbAdrs::Company, addr.organization()); |
365 | 367 | ||
366 | database->writeField(ZdbAdrs::Profession, addr.custom( "KADDRESSBOOK", "X-Profession" )); | 368 | database->writeField(ZdbAdrs::Profession, addr.custom( "KADDRESSBOOK", "X-Profession" )); |
367 | database->writeField(ZdbAdrs::Assistant, addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); | 369 | database->writeField(ZdbAdrs::Assistant, addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); |
368 | database->writeField(ZdbAdrs::Department, addr.custom( "KADDRESSBOOK", "X-Department" )); | 370 | database->writeField(ZdbAdrs::Department, addr.custom( "KADDRESSBOOK", "X-Department" )); |
369 | database->writeField(ZdbAdrs::Manager, addr.custom( "KADDRESSBOOK", "X-ManagersName" )); | 371 | database->writeField(ZdbAdrs::Manager, addr.custom( "KADDRESSBOOK", "X-ManagersName" )); |
370 | database->writeField(ZdbAdrs::Office, addr.custom( "KADDRESSBOOK", "X-Office" )); | 372 | database->writeField(ZdbAdrs::Office, addr.custom( "KADDRESSBOOK", "X-Office" )); |
371 | 373 | ||
372 | //personal | 374 | //personal |
373 | database->writeField(ZdbAdrs::Spouse, addr.custom( "KADDRESSBOOK", "X-Spouse" )); | 375 | database->writeField(ZdbAdrs::Spouse, addr.custom( "KADDRESSBOOK", "X-Spouse" )); |
374 | 376 | ||
375 | QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); | 377 | QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); |
376 | //qDebug("SharpDTMConverter::addresseeToSharp please check that gender works!! : Gender: %s", gt.latin1()); | 378 | //qDebug("OlaccessConverter::addresseeToSharp please check that gender works!! : Gender: %s", gt.latin1()); |
377 | //qDebug("SharpDTMConverter::addresseeToSharp: may be writeField(\"ZdbAdrs::Gender\", ushort) is here better suited?"); | 379 | //qDebug("OlaccessConverter::addresseeToSharp: may be writeField(\"ZdbAdrs::Gender\", ushort) is here better suited?"); |
378 | //qDebug("SharpDTMConverter::addresseeToSharp: check also the reverse functionality in sharpToAddressee"); | 380 | //qDebug("OlaccessConverter::addresseeToSharp: check also the reverse functionality in sharpToAddressee"); |
379 | if (gt == "male") | 381 | if (gt == "male") |
380 | database->writeField(ZdbAdrs::Gender, "1"); | 382 | database->writeField(ZdbAdrs::Gender, "1"); |
381 | else if (gt == "female") | 383 | else if (gt == "female") |
382 | database->writeField(ZdbAdrs::Gender, "2"); | 384 | database->writeField(ZdbAdrs::Gender, "2"); |
383 | else | 385 | else |
384 | database->writeField(ZdbAdrs::Gender, ""); | 386 | database->writeField(ZdbAdrs::Gender, ""); |
385 | 387 | ||
386 | QString dateS ; | 388 | QString dateS ; |
387 | QDate dt = KGlobal::locale()->readDate(addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate | 389 | QDate dt = KGlobal::locale()->readDate(addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate |
388 | if ( dt.isValid() ) { | 390 | if ( dt.isValid() ) { |
389 | dateS = KGlobal::locale()->formatDate(dt, true ); | 391 | dateS = KGlobal::locale()->formatDate(dt, true ); |
390 | } | 392 | } |
391 | database->writeField(ZdbAdrs::Anniversary, dateS ); | 393 | database->writeField(ZdbAdrs::Anniversary, dateS ); |
392 | database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" )); | 394 | database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" )); |
393 | dt = addr.birthday().date(); | 395 | dt = addr.birthday().date(); |
394 | dateS = ""; | 396 | dateS = ""; |
395 | if ( dt.isValid() ) { | 397 | if ( dt.isValid() ) { |
396 | dateS = KGlobal::locale()->formatDate(dt, true ); | 398 | dateS = KGlobal::locale()->formatDate(dt, true ); |
397 | } | 399 | } |
398 | database->writeField(ZdbAdrs::Birthday, dateS); | 400 | database->writeField(ZdbAdrs::Birthday, dateS); |
399 | database->writeField(ZdbAdrs::Nickname, addr.nickName()); | 401 | database->writeField(ZdbAdrs::Nickname, addr.nickName()); |
400 | 402 | ||
401 | // other | 403 | // other |
402 | database->writeField(ZdbAdrs::Notes, addr.note()); | 404 | database->writeField(ZdbAdrs::Notes, addr.note()); |
403 | 405 | ||
404 | //US QString groups() const { return find( Qtopia::Groups ); } | 406 | //US QString groups() const { return find( Qtopia::Groups ); } |
405 | //US QStringList groupList() const; | 407 | //US QStringList groupList() const; |
406 | 408 | ||
407 | 409 | ||
408 | //qDebug("SharpDTMConverter::addresseeToSharp please check if category transformation works"); | 410 | //qDebug("OlaccessConverter::addresseeToSharp please check if category transformation works"); |
409 | 411 | ||
410 | return true; | 412 | return true; |
411 | } | 413 | } |
412 | 414 | ||
413 | 415 | ||
414 | bool SharpDTMConverter::setCategories( const Addressee &addr, SlZDataBase* database , const CardId &contact ) | 416 | bool OlaccessConverter::setCategories( const Addressee &addr, SlZDataBase* database , const CardId &contact ) |
415 | { | 417 | { |
416 | QStringList list = addr.categories(); | 418 | QStringList list = addr.categories(); |
417 | 419 | ||
418 | QArray<int> ids(list.count()); | 420 | QArray<int> ids(list.count()); |
419 | uint index = 0; | 421 | uint index = 0; |
420 | for(uint i=0; i<ids.size(); i++){ | 422 | for(uint i=0; i<ids.size(); i++){ |
421 | if(catDB->exists(list[i])){ | 423 | if(catDB->exists(list[i])){ |
422 | ids[index] = catDB->id(list[i]); | 424 | ids[index] = catDB->id(list[i]); |
423 | //qDebug("set exist cat %d %s ",ids[index] , list[i].latin1()); | 425 | //qDebug("set exist cat %d %s ",ids[index] , list[i].latin1()); |
424 | index++; | 426 | index++; |
425 | } else { | 427 | } else { |
426 | ids[index] = catDB->addCategory(list[i]); | 428 | ids[index] = catDB->addCategory(list[i]); |
427 | //qDebug("add new cat %d %s ",ids[index] , list[i].latin1()); | 429 | //qDebug("add new cat %d %s ",ids[index] , list[i].latin1()); |
428 | index++; | 430 | index++; |
429 | } | 431 | } |
430 | } | 432 | } |
431 | bool res ; | 433 | bool res ; |
432 | 434 | ||
433 | if ( !(res = database->updateCategories(contact, ids) )) | 435 | if ( !(res = database->updateCategories(contact, ids) )) |
434 | qDebug("SharpDTMConverter::Error updating categories"); | 436 | qDebug("OlaccessConverter::Error updating categories"); |
435 | 437 | ||
436 | return res; | 438 | return res; |
437 | } | 439 | } |
438 | 440 | #endif | |
439 | QDate SharpDTMConverter::convertDate( QString s) | 441 | QDate OlaccessConverter::convertDate( QString s) |
440 | { | 442 | { |
441 | QDate dt = KGlobal::locale()->readDate( s ); | 443 | QDate dt = KGlobal::locale()->readDate( s ); |
442 | return dt; | 444 | return dt; |
443 | return QDate (); | 445 | return QDate (); |
444 | } | 446 | } |
diff --git a/kabc/plugins/olaccess/olaccessconverter.h b/kabc/plugins/olaccess/olaccessconverter.h index db1bf2d..48a255d 100644 --- a/kabc/plugins/olaccess/olaccessconverter.h +++ b/kabc/plugins/olaccess/olaccessconverter.h | |||
@@ -16,73 +16,67 @@ | |||
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 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (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> | ||
33 | 32 | ||
34 | #include "addressee.h" | 33 | #include "addressee.h" |
35 | 34 | ||
36 | namespace SlCategory { | ||
37 | class SlCategories; | ||
38 | } | ||
39 | |||
40 | class SlZDataBase; | ||
41 | 35 | ||
42 | namespace KABC { | 36 | namespace KABC { |
43 | 37 | ||
44 | class SharpDTMConverter | 38 | class OlaccessConverter |
45 | { | 39 | { |
46 | public: | 40 | public: |
47 | 41 | ||
48 | /** | 42 | /** |
49 | * Constructor. | 43 | * Constructor. |
50 | */ | 44 | */ |
51 | SharpDTMConverter(); | 45 | OlaccessConverter(); |
52 | 46 | ||
53 | /** | 47 | /** |
54 | * Destructor. | 48 | * Destructor. |
55 | */ | 49 | */ |
56 | virtual ~SharpDTMConverter(); | 50 | virtual ~OlaccessConverter(); |
57 | 51 | ||
58 | bool init(); | 52 | bool init(); |
59 | void deinit(); | 53 | void deinit(); |
60 | 54 | ||
61 | /** | 55 | /** |
62 | * Converts a given sharp card to an addressee. | 56 | * Converts a given sharp card to an addressee. |
63 | * | 57 | * |
64 | * @param contact The sharp card id, eventhough it might be 0, if the contact is a new one. | 58 | * @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 | 59 | * @param database The sharp database pointer we use for the conversion |
66 | * @param addr The addressee. | 60 | * @param addr The addressee. |
67 | */ | 61 | */ |
68 | bool sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr ); | 62 | //bool sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr ); |
69 | 63 | ||
70 | /** | 64 | /** |
71 | * Converts an addressee to a sharp dtm contact. | 65 | * Converts an addressee to a sharp dtm contact. |
72 | * | 66 | * |
73 | * @param addr The addressee. | 67 | * @param addr The addressee. |
74 | * @param database The sharp database pointer we use for the conversion | 68 | * @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. | 69 | * @param contact The sharp card id, eventhough it might be 0, if the contact is a new one. |
76 | */ | 70 | */ |
77 | bool addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ); | 71 | //bool addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ); |
78 | bool setCategories( const Addressee &addr, SlZDataBase* database , const CardId &contact ); | 72 | //bool setCategories( const Addressee &addr, SlZDataBase* database , const CardId &contact ); |
79 | 73 | ||
80 | private: | 74 | private: |
81 | SlCategory::SlCategories* catDB; | 75 | //SlCategory::SlCategories* catDB; |
82 | QDate convertDate( QString ); | 76 | QDate convertDate( QString ); |
83 | 77 | ||
84 | 78 | ||
85 | }; | 79 | }; |
86 | 80 | ||
87 | } | 81 | } |
88 | #endif | 82 | #endif |
diff --git a/kabc/plugins/olaccess/resourceolaccess.cpp b/kabc/plugins/olaccess/resourceolaccess.cpp index e8f8bdd..7113e0e 100644 --- a/kabc/plugins/olaccess/resourceolaccess.cpp +++ b/kabc/plugins/olaccess/resourceolaccess.cpp | |||
@@ -14,182 +14,182 @@ | |||
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 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <sys/types.h> | 28 | #include <sys/types.h> |
29 | #include <sys/stat.h> | 29 | #include <sys/stat.h> |
30 | #include <unistd.h> | ||
31 | 30 | ||
32 | #include <qdir.h> | 31 | #include <qdir.h> |
33 | #include <qfile.h> | 32 | #include <qfile.h> |
34 | #include <qfileinfo.h> | 33 | #include <qfileinfo.h> |
35 | #include <qregexp.h> | 34 | #include <qregexp.h> |
36 | //US #include <qtimer.h> | 35 | //US #include <qtimer.h> |
37 | 36 | ||
38 | #include <kapplication.h> | 37 | #include <kapplication.h> |
39 | #include <kconfig.h> | 38 | #include <kconfig.h> |
40 | #include <kdebug.h> | 39 | #include <kdebug.h> |
41 | #include <klocale.h> | 40 | #include <klocale.h> |
42 | //US #include <ksavefile.h> | 41 | //US #include <ksavefile.h> |
43 | #include <kstandarddirs.h> | 42 | #include <kstandarddirs.h> |
44 | #include <kmessagebox.h> | 43 | #include <kmessagebox.h> |
45 | 44 | ||
46 | #include <sl/slzdb.h> | ||
47 | 45 | ||
48 | #include <libkdepim/ksyncprofile.h> | 46 | #include <libkdepim/ksyncprofile.h> |
49 | 47 | ||
50 | #include "resourcesharpdtmconfig.h" | 48 | #include "resourceolaccessconfig.h" |
51 | #include "resourcesharpdtm.h" | 49 | #include "resourceolaccess.h" |
52 | 50 | ||
53 | #include "stdaddressbook.h" | 51 | #include "stdaddressbook.h" |
54 | 52 | ||
55 | #include "sharpdtmconverter.h" | 53 | #include "olaccessconverter.h" |
56 | //#define ALLOW_LOCKING | 54 | //#define ALLOW_LOCKING |
57 | using namespace KABC; | 55 | using namespace KABC; |
58 | extern "C" | 56 | extern "C" |
59 | { | 57 | { |
60 | void *init_microkabc_sharpdtm() | 58 | void *init_microkabc_olaccess() |
61 | { | 59 | { |
62 | return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig>(); | 60 | return new KRES::PluginFactory<Resourceolaccess,ResourceolaccessConfig>(); |
63 | } | 61 | } |
64 | } | 62 | } |
65 | 63 | ||
66 | ResourceSharpDTM::ResourceSharpDTM( const KConfig *config ) | 64 | Resourceolaccess::Resourceolaccess( const KConfig *config ) |
67 | : Resource( config ), mConverter (0) | 65 | : Resource( config ), mConverter (0) |
68 | { | 66 | { |
69 | // we can not choose the filename. Therefore use the default to display | 67 | // we can not choose the filename. Therefore use the default to display |
70 | mAccess = 0; | 68 | //mAccess = 0; |
71 | QString fileName = SlZDataBase::addressbookFileName(); | 69 | QString fileName;// = SlZDataBase::addressbookFileName(); |
72 | init( fileName ); | 70 | init( fileName ); |
73 | } | 71 | } |
74 | 72 | ||
75 | ResourceSharpDTM::ResourceSharpDTM( const QString &fileName ) | 73 | Resourceolaccess::Resourceolaccess( const QString &fileName ) |
76 | : Resource( 0 ) | 74 | : Resource( 0 ) |
77 | { | 75 | { |
78 | mAccess = 0; | 76 | //mAccess = 0; |
79 | init( fileName ); | 77 | init( fileName ); |
80 | } | 78 | } |
81 | 79 | ||
82 | void ResourceSharpDTM::init( const QString &fileName ) | 80 | void Resourceolaccess::init( const QString &fileName ) |
83 | { | 81 | { |
84 | if (mConverter == 0) { | 82 | if (mConverter == 0) { |
85 | mConverter = new SharpDTMConverter(); | 83 | mConverter = new OlaccessConverter(); |
86 | bool res = mConverter->init(); | 84 | bool res = mConverter->init(); |
87 | if ( !res ) | 85 | if ( !res ) |
88 | { | 86 | { |
89 | QString msg("Unable to initialize sharp converter. Most likely a problem with the category file"); | 87 | QString msg("Unable to initialize sharp converter. Most likely a problem with the category file"); |
90 | qDebug(msg); | 88 | qDebug(msg); |
91 | return; | 89 | return; |
92 | } | 90 | } |
93 | } | 91 | } |
94 | setFileName( fileName ); | 92 | setFileName( fileName ); |
95 | } | 93 | } |
96 | 94 | ||
97 | ResourceSharpDTM::~ResourceSharpDTM() | 95 | Resourceolaccess::~Resourceolaccess() |
98 | { | 96 | { |
99 | if (mConverter != 0) | 97 | if (mConverter != 0) |
100 | delete mConverter; | 98 | delete mConverter; |
101 | 99 | ||
102 | if(mAccess != 0) | 100 | //if(mAccess != 0) |
103 | delete mAccess; | 101 | //delete mAccess; |
104 | } | 102 | } |
105 | 103 | ||
106 | void ResourceSharpDTM::writeConfig( KConfig *config ) | 104 | void Resourceolaccess::writeConfig( KConfig *config ) |
107 | { | 105 | { |
108 | Resource::writeConfig( config ); | 106 | Resource::writeConfig( config ); |
109 | } | 107 | } |
110 | 108 | ||
111 | Ticket *ResourceSharpDTM::requestSaveTicket() | 109 | Ticket *Resourceolaccess::requestSaveTicket() |
112 | { | 110 | { |
113 | 111 | ||
114 | qDebug("ResourceSharpDTM::requestSaveTicket: %s", fileName().latin1()); | 112 | qDebug("Resourceolaccess::requestSaveTicket: %s", fileName().latin1()); |
115 | 113 | ||
116 | if ( !addressBook() ) return 0; | 114 | if ( !addressBook() ) return 0; |
117 | return createTicket( this ); | 115 | return createTicket( this ); |
118 | } | 116 | } |
119 | 117 | ||
120 | 118 | ||
121 | bool ResourceSharpDTM::doOpen() | 119 | bool Resourceolaccess::doOpen() |
122 | { | 120 | { |
123 | if (!mConverter) | 121 | if (!mConverter) |
124 | return false; | 122 | return false; |
125 | return true; | 123 | return true; |
126 | } | 124 | } |
127 | 125 | ||
128 | void ResourceSharpDTM::doClose() | 126 | void Resourceolaccess::doClose() |
129 | { | 127 | { |
130 | return; | 128 | return; |
131 | } | 129 | } |
132 | 130 | ||
133 | bool ResourceSharpDTM::load() | 131 | bool Resourceolaccess::load() |
134 | { | 132 | { |
135 | if (!mConverter) | 133 | if (!mConverter) |
136 | return false; | 134 | return false; |
137 | QString fileN = SlZDataBase::addressbookFileName(); | 135 | QString fileN ;//= SlZDataBase::addressbookFileName(); |
136 | #if 0 | ||
138 | if ( ! mAccess ) { | 137 | if ( ! mAccess ) { |
139 | mAccess = new SlZDataBase(fileN, | 138 | mAccess = new SlZDataBase(fileN, |
140 | SlZDataBase::addressbookItems(), | 139 | SlZDataBase::addressbookItems(), |
141 | 0, true); | 140 | 0, true); |
142 | } | 141 | } |
143 | if(mAccess == 0) | 142 | if(mAccess == 0) |
144 | return false; | 143 | return false; |
145 | 144 | ||
146 | qDebug("ResourceSharpDTM:: %x load: %s",this, fileName().latin1()); | 145 | qDebug("Resourceolaccess:: %x load: %s",this, fileName().latin1()); |
147 | bool res = false; | 146 | bool res = false; |
148 | CardId id; | 147 | CardId id; |
149 | for (bool res=mAccess->first(); res == true; res=mAccess->next()) | 148 | for (bool res=mAccess->first(); res == true; res=mAccess->next()) |
150 | { | 149 | { |
151 | id = mAccess->cardId(); | 150 | id = mAccess->cardId(); |
152 | KABC::Addressee addressee; | 151 | KABC::Addressee addressee; |
153 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); | 152 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); |
154 | if ( !addressee.isEmpty() && res ) | 153 | if ( !addressee.isEmpty() && res ) |
155 | { | 154 | { |
156 | addressee.setResource( this ); | 155 | addressee.setResource( this ); |
157 | addressBook()->insertAddressee( addressee ); | 156 | addressBook()->insertAddressee( addressee ); |
158 | } | 157 | } |
159 | } | 158 | } |
160 | if(mAccess != 0) | 159 | if(mAccess != 0) |
161 | delete mAccess; | 160 | delete mAccess; |
162 | mAccess = 0; | 161 | mAccess = 0; |
163 | 162 | #endif | |
164 | return true; | 163 | return true; |
165 | } | 164 | } |
166 | 165 | ||
167 | bool ResourceSharpDTM::save( Ticket *ticket ) | 166 | bool Resourceolaccess::save( Ticket *ticket ) |
168 | { | 167 | { |
168 | #if 0 | ||
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("Resourceolaccess::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); |
@@ -254,50 +254,51 @@ bool ResourceSharpDTM::save( Ticket *ticket ) | |||
254 | KABC::Addressee addressee; | 254 | KABC::Addressee addressee; |
255 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); | 255 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); |
256 | 256 | ||
257 | if ( !addressee.isEmpty() && res ) | 257 | if ( !addressee.isEmpty() && res ) |
258 | { | 258 | { |
259 | addressee.setResource( this ); | 259 | addressee.setResource( this ); |
260 | addressee.setUid( itam.data() ); | 260 | addressee.setUid( itam.data() ); |
261 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 261 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
262 | addressBook()->insertAddressee( addressee , false ); | 262 | addressBook()->insertAddressee( addressee , false ); |
263 | } | 263 | } |
264 | } | 264 | } |
265 | } | 265 | } |
266 | delete ticket; | 266 | delete ticket; |
267 | if(mAccess != 0) | 267 | if(mAccess != 0) |
268 | delete mAccess; | 268 | delete mAccess; |
269 | mAccess = 0; | 269 | mAccess = 0; |
270 | #endif | ||
270 | return true; | 271 | return true; |
271 | } | 272 | } |
272 | 273 | ||
273 | bool ResourceSharpDTM::lock( const QString &lockfileName ) | 274 | bool Resourceolaccess::lock( const QString &lockfileName ) |
274 | { | 275 | { |
275 | return true; | 276 | return true; |
276 | } | 277 | } |
277 | 278 | ||
278 | void ResourceSharpDTM::unlock( const QString &fileName ) | 279 | void Resourceolaccess::unlock( const QString &fileName ) |
279 | { | 280 | { |
280 | 281 | ||
281 | } | 282 | } |
282 | 283 | ||
283 | void ResourceSharpDTM::setFileName( const QString &newFileName ) | 284 | void Resourceolaccess::setFileName( const QString &newFileName ) |
284 | { | 285 | { |
285 | Resource::setFileName( newFileName ); | 286 | Resource::setFileName( newFileName ); |
286 | } | 287 | } |
287 | 288 | ||
288 | void ResourceSharpDTM::fileChanged() | 289 | void Resourceolaccess::fileChanged() |
289 | { | 290 | { |
290 | 291 | ||
291 | } | 292 | } |
292 | 293 | ||
293 | void ResourceSharpDTM::removeAddressee( const Addressee &addr ) | 294 | void Resourceolaccess::removeAddressee( const Addressee &addr ) |
294 | { | 295 | { |
295 | } | 296 | } |
296 | 297 | ||
297 | void ResourceSharpDTM::cleanUp() | 298 | void Resourceolaccess::cleanUp() |
298 | { | 299 | { |
299 | 300 | ||
300 | } | 301 | } |
301 | 302 | ||
302 | 303 | ||
303 | 304 | ||
diff --git a/kabc/plugins/olaccess/resourceolaccess.h b/kabc/plugins/olaccess/resourceolaccess.h index 64d06f9..0066331 100644 --- a/kabc/plugins/olaccess/resourceolaccess.h +++ b/kabc/plugins/olaccess/resourceolaccess.h | |||
@@ -13,75 +13,75 @@ | |||
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 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | 28 | ||
29 | #ifndef KABC_RESOURCESHARPDTM_H | 29 | |
30 | #define KABC_RESOURCESHARPDTM_H | 30 | |
31 | #ifndef KABC_RESOURCEolaccess_H | ||
32 | #define KABC_RESOURCEolaccess_H | ||
31 | 33 | ||
32 | #include <kconfig.h> | 34 | #include <kconfig.h> |
33 | #include <kdirwatch.h> | 35 | #include <kdirwatch.h> |
34 | 36 | ||
35 | #include <sys/types.h> | 37 | #include <sys/types.h> |
36 | 38 | ||
37 | #include "resource.h" | 39 | #include "resource.h" |
38 | 40 | ||
39 | 41 | ||
40 | class SlZDataBase; | ||
41 | |||
42 | namespace KABC { | 42 | namespace KABC { |
43 | 43 | ||
44 | class ResourceConfigWidget; | 44 | class ResourceConfigWidget; |
45 | class SharpDTMConverter; | 45 | class OlaccessConverter; |
46 | 46 | ||
47 | /** | 47 | /** |
48 | @internal | 48 | @internal |
49 | */ | 49 | */ |
50 | class ResourceSharpDTM : public Resource | 50 | class Resourceolaccess : public Resource |
51 | { | 51 | { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | public: | 54 | public: |
55 | 55 | ||
56 | /** | 56 | /** |
57 | Constructor. | 57 | Constructor. |
58 | 58 | ||
59 | @param cfg The config object where custom resource settings are stored. | 59 | @param cfg The config object where custom resource settings are stored. |
60 | */ | 60 | */ |
61 | ResourceSharpDTM( const KConfig *cfg ); | 61 | Resourceolaccess( const KConfig *cfg ); |
62 | 62 | ||
63 | /** | 63 | /** |
64 | Construct file resource on file @arg fileName using format @arg formatName. | 64 | Construct file resource on file @arg fileName using format @arg formatName. |
65 | */ | 65 | */ |
66 | ResourceSharpDTM( const QString &fileName ); | 66 | Resourceolaccess( const QString &fileName ); |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Destructor. | 69 | * Destructor. |
70 | */ | 70 | */ |
71 | ~ResourceSharpDTM(); | 71 | ~Resourceolaccess(); |
72 | 72 | ||
73 | /** | 73 | /** |
74 | Writes the config back. | 74 | Writes the config back. |
75 | */ | 75 | */ |
76 | virtual void writeConfig( KConfig *cfg ); | 76 | virtual void writeConfig( KConfig *cfg ); |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * Tries to open the file and checks for the proper format. | 79 | * Tries to open the file and checks for the proper format. |
80 | * This method should be called before @ref load(). | 80 | * This method should be called before @ref load(). |
81 | */ | 81 | */ |
82 | virtual bool doOpen(); | 82 | virtual bool doOpen(); |
83 | 83 | ||
84 | /** | 84 | /** |
85 | * Closes the file again. | 85 | * Closes the file again. |
86 | */ | 86 | */ |
87 | virtual void doClose(); | 87 | virtual void doClose(); |
@@ -120,27 +120,26 @@ public: | |||
120 | * This method is called by an error handler if the application | 120 | * This method is called by an error handler if the application |
121 | * crashed | 121 | * crashed |
122 | */ | 122 | */ |
123 | virtual void cleanUp(); | 123 | virtual void cleanUp(); |
124 | 124 | ||
125 | 125 | ||
126 | protected slots: | 126 | protected slots: |
127 | void fileChanged(); | 127 | void fileChanged(); |
128 | 128 | ||
129 | protected: | 129 | protected: |
130 | void init( const QString &fileName ); | 130 | void init( const QString &fileName ); |
131 | 131 | ||
132 | bool lock( const QString &fileName ); | 132 | bool lock( const QString &fileName ); |
133 | void unlock( const QString &fileName ); | 133 | void unlock( const QString &fileName ); |
134 | 134 | ||
135 | private: | 135 | private: |
136 | SlZDataBase* mAccess; | 136 | OlaccessConverter* mConverter; |
137 | SharpDTMConverter* mConverter; | ||
138 | 137 | ||
139 | QString mLockUniqueName; | 138 | QString mLockUniqueName; |
140 | 139 | ||
141 | KDirWatch mDirWatch; | 140 | KDirWatch mDirWatch; |
142 | }; | 141 | }; |
143 | 142 | ||
144 | } | 143 | } |
145 | 144 | ||
146 | #endif | 145 | #endif |
diff --git a/kabc/plugins/olaccess/resourceolaccessconfig.cpp b/kabc/plugins/olaccess/resourceolaccessconfig.cpp index 240f1d7..1fcf1b8 100644 --- a/kabc/plugins/olaccess/resourceolaccessconfig.cpp +++ b/kabc/plugins/olaccess/resourceolaccessconfig.cpp | |||
@@ -20,89 +20,87 @@ | |||
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | 30 | ||
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <klocale.h> | 32 | #include <klocale.h> |
33 | #include <kstandarddirs.h> | 33 | #include <kstandarddirs.h> |
34 | #include <kdialog.h> | 34 | #include <kdialog.h> |
35 | 35 | ||
36 | #include <unistd.h> | ||
37 | 36 | ||
38 | #include <qdir.h> | 37 | #include <qdir.h> |
39 | #include <qfile.h> | 38 | #include <qfile.h> |
40 | #include "resourcesharpdtm.h" | 39 | #include "resourceolaccess.h" |
41 | 40 | ||
42 | #include "resourcesharpdtmconfig.h" | 41 | #include "resourceolaccessconfig.h" |
43 | 42 | ||
44 | #include <sl/slzdb.h> | ||
45 | 43 | ||
46 | using namespace KABC; | 44 | using namespace KABC; |
47 | 45 | ||
48 | ResourceSharpDTMConfig::ResourceSharpDTMConfig( QWidget* parent, const char* name ) | 46 | ResourceolaccessConfig::ResourceolaccessConfig( QWidget* parent, const char* name ) |
49 | : ConfigWidget( parent, name ) | 47 | : ConfigWidget( parent, name ) |
50 | { | 48 | { |
51 | QGridLayout *mainLayout = new QGridLayout( this, 1, 2, 0, | 49 | QGridLayout *mainLayout = new QGridLayout( this, 1, 2, 0, |
52 | KDialog::spacingHint() ); | 50 | KDialog::spacingHint() ); |
53 | 51 | ||
54 | QLabel *label = new QLabel( i18n( "Location:" ), this ); | 52 | QLabel *label = new QLabel( i18n( "Location:" ), this ); |
55 | mFileNameEdit = new KURLRequester( this ); | 53 | mFileNameEdit = new KURLRequester( this ); |
56 | 54 | ||
57 | connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ), | 55 | connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ), |
58 | SLOT( checkFilePermissions( const QString & ) ) ); | 56 | SLOT( checkFilePermissions( const QString & ) ) ); |
59 | 57 | ||
60 | mainLayout->addWidget( label, 0, 0 ); | 58 | mainLayout->addWidget( label, 0, 0 ); |
61 | mainLayout->addWidget( mFileNameEdit, 0, 1 ); | 59 | mainLayout->addWidget( mFileNameEdit, 0, 1 ); |
62 | 60 | ||
63 | } | 61 | } |
64 | 62 | ||
65 | void ResourceSharpDTMConfig::loadSettings( KRES::Resource *res ) | 63 | void ResourceolaccessConfig::loadSettings( KRES::Resource *res ) |
66 | { | 64 | { |
67 | //US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); | 65 | //US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); |
68 | ResourceSharpDTM *resource = (ResourceSharpDTM*)( res ); | 66 | Resourceolaccess *resource = (Resourceolaccess*)( res ); |
69 | 67 | ||
70 | if ( !resource ) { | 68 | if ( !resource ) { |
71 | kdDebug(5700) << "ResourceSharpDTMConfig::loadSettings(): cast failed" << endl; | 69 | kdDebug(5700) << "ResourceolaccessConfig::loadSettings(): cast failed" << endl; |
72 | return; | 70 | return; |
73 | } | 71 | } |
74 | 72 | ||
75 | mFileNameEdit->setURL( resource->fileName() ); | 73 | mFileNameEdit->setURL( resource->fileName() ); |
76 | if ( mFileNameEdit->url().isEmpty() ) | 74 | if ( mFileNameEdit->url().isEmpty() ) |
77 | mFileNameEdit->setURL( SlZDataBase::addressbookFileName() ); | 75 | ;//mFileNameEdit->setURL( SlZDataBase::addressbookFileName() ); |
78 | 76 | ||
79 | //US Sharp DTM resources are ReadOnly by definition | 77 | //US Sharp DTM resources are ReadOnly by definition |
80 | emit setPersistentReadOnly( true ); | 78 | emit setPersistentReadOnly( true ); |
81 | 79 | ||
82 | //US we can not choose the filename for the sharp backend => make it readonly. | 80 | //US we can not choose the filename for the sharp backend => make it readonly. |
83 | mFileNameEdit->setEnabled( false ); | 81 | mFileNameEdit->setEnabled( false ); |
84 | 82 | ||
85 | } | 83 | } |
86 | 84 | ||
87 | void ResourceSharpDTMConfig::saveSettings( KRES::Resource *res ) | 85 | void ResourceolaccessConfig::saveSettings( KRES::Resource *res ) |
88 | { | 86 | { |
89 | //US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); | 87 | //US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); |
90 | ResourceSharpDTM *resource = (ResourceSharpDTM*)( res ); | 88 | Resourceolaccess *resource = (Resourceolaccess*)( res ); |
91 | 89 | ||
92 | if ( !resource ) { | 90 | if ( !resource ) { |
93 | kdDebug(5700) << "ResourceSharpDTMConfig::saveSettings(): cast failed" << endl; | 91 | kdDebug(5700) << "ResourceolaccessConfig::saveSettings(): cast failed" << endl; |
94 | return; | 92 | return; |
95 | } | 93 | } |
96 | 94 | ||
97 | resource->setFileName( mFileNameEdit->url() ); | 95 | resource->setFileName( mFileNameEdit->url() ); |
98 | } | 96 | } |
99 | 97 | ||
100 | void ResourceSharpDTMConfig::checkFilePermissions( const QString& fileName ) | 98 | void ResourceolaccessConfig::checkFilePermissions( const QString& fileName ) |
101 | { | 99 | { |
102 | // If file exist but is not writeable... | 100 | // If file exist but is not writeable... |
103 | /*US | 101 | /*US |
104 | if ( access( QFile::encodeName( fileName ), F_OK ) == 0 ) | 102 | if ( access( QFile::encodeName( fileName ), F_OK ) == 0 ) |
105 | emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 ); | 103 | emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 ); |
106 | */ | 104 | */ |
107 | } | 105 | } |
108 | 106 | ||
diff --git a/kabc/plugins/olaccess/resourceolaccessconfig.h b/kabc/plugins/olaccess/resourceolaccessconfig.h index 29765c8..38d47ba 100644 --- a/kabc/plugins/olaccess/resourceolaccessconfig.h +++ b/kabc/plugins/olaccess/resourceolaccessconfig.h | |||
@@ -22,37 +22,37 @@ | |||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef RESOURCESHARPDTMCONFIG_H | 29 | #ifndef RESOURCESHARPDTMCONFIG_H |
30 | #define RESOURCESHARPDTMCONFIG_H | 30 | #define RESOURCESHARPDTMCONFIG_H |
31 | 31 | ||
32 | #include <kurlrequester.h> | 32 | #include <kurlrequester.h> |
33 | 33 | ||
34 | #include <kresources/configwidget.h> | 34 | #include <kresources/configwidget.h> |
35 | 35 | ||
36 | namespace KABC { | 36 | namespace KABC { |
37 | 37 | ||
38 | class ResourceSharpDTMConfig : public KRES::ConfigWidget | 38 | class ResourceolaccessConfig : public KRES::ConfigWidget |
39 | { | 39 | { |
40 | Q_OBJECT | 40 | Q_OBJECT |
41 | 41 | ||
42 | public: | 42 | public: |
43 | ResourceSharpDTMConfig( QWidget* parent = 0, const char* name = 0 ); | 43 | ResourceolaccessConfig( QWidget* parent = 0, const char* name = 0 ); |
44 | 44 | ||
45 | public slots: | 45 | public slots: |
46 | void loadSettings( KRES::Resource *resource ); | 46 | void loadSettings( KRES::Resource *resource ); |
47 | void saveSettings( KRES::Resource *resource ); | 47 | void saveSettings( KRES::Resource *resource ); |
48 | 48 | ||
49 | protected slots: | 49 | protected slots: |
50 | void checkFilePermissions( const QString& fileName ); | 50 | void checkFilePermissions( const QString& fileName ); |
51 | 51 | ||
52 | private: | 52 | private: |
53 | KURLRequester* mFileNameEdit; | 53 | KURLRequester* mFileNameEdit; |
54 | }; | 54 | }; |
55 | 55 | ||
56 | } | 56 | } |
57 | 57 | ||
58 | #endif | 58 | #endif |