summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kabc/converter/opie/opieconverter.cpp69
-rw-r--r--kabc/converter/opie/opieconverter.h11
-rw-r--r--kaddressbook/xxport/opie/opie_xxport.cpp14
-rw-r--r--kaddressbook/xxport/opie/opie_xxportE.pro3
4 files changed, 77 insertions, 20 deletions
diff --git a/kabc/converter/opie/opieconverter.cpp b/kabc/converter/opie/opieconverter.cpp
index d785fbc..b4e9f1c 100644
--- a/kabc/converter/opie/opieconverter.cpp
+++ b/kabc/converter/opie/opieconverter.cpp
@@ -31,18 +31,44 @@ $Id$
31 31
32#include "opieconverter.h" 32#include "opieconverter.h"
33 33
34#include <qpe/categories.h> 34#include <qpe/categories.h>
35#include <qpe/categoryselect.h>
35 36
36 37
37using namespace KABC; 38using namespace KABC;
38 39
39OpieConverter::OpieConverter() 40OpieConverter::OpieConverter() : catDB(0)
40{ 41{
41} 42}
42 43
43OpieConverter::~OpieConverter() 44OpieConverter::~OpieConverter()
44{ 45{
46 deinit();
47}
48
49bool OpieConverter::init()
50{
51 catDB = new Categories();
52 if (catDB)
53 {
54 catDB->load( categoryFileName() );
55 return true;
56 }
57 else
58 {
59 return false;
60 }
61
62}
63
64void OpieConverter::deinit()
65{
66 if (catDB)
67 {
68 delete catDB;
69 catDB = 0;
70 }
45} 71}
46 72
47bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr ) 73bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
48{ 74{
@@ -60,11 +86,18 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
60 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 86 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
61 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); 87 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) );
62 } 88 }
63 89
90 if (!contact.defaultEmail().isEmpty())
64 addr.insertEmail(contact.defaultEmail(), true); 91 addr.insertEmail(contact.defaultEmail(), true);
65 92
66 // home 93 // home
94 if ((!contact.homeStreet().isEmpty()) ||
95 (!contact.homeCity().isEmpty()) ||
96 (!contact.homeState().isEmpty()) ||
97 (!contact.homeZip().isEmpty()) ||
98 (!contact.homeCountry().isEmpty()))
99 {
67 Address homeaddress; 100 Address homeaddress;
68 homeaddress.setType(Address::Home); 101 homeaddress.setType(Address::Home);
69//US homeaddress.setPostOfficeBox( "" ); 102//US homeaddress.setPostOfficeBox( "" );
70//US homeaddress.setExtended( "" ); 103//US homeaddress.setExtended( "" );
@@ -74,8 +107,9 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
74 homeaddress.setPostalCode( contact.homeZip() ); 107 homeaddress.setPostalCode( contact.homeZip() );
75 homeaddress.setCountry( contact.homeCountry() ); 108 homeaddress.setCountry( contact.homeCountry() );
76 109
77 addr.insertAddress( homeaddress ); 110 addr.insertAddress( homeaddress );
111 }
78 112
79 if (!contact.homePhone().isEmpty()) 113 if (!contact.homePhone().isEmpty())
80 { 114 {
81 PhoneNumber homephone; 115 PhoneNumber homephone;
@@ -103,8 +137,14 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
103 addr.setUrl( contact.homeWebpage() ); 137 addr.setUrl( contact.homeWebpage() );
104 138
105 139
106 // business 140 // business
141 if ((!contact.businessStreet().isEmpty()) ||
142 (!contact.businessCity().isEmpty()) ||
143 (!contact.businessState().isEmpty()) ||
144 (!contact.businessZip().isEmpty()) ||
145 (!contact.businessCountry().isEmpty()))
146 {
107 Address businessaddress; 147 Address businessaddress;
108 businessaddress.setType(Address::Work); 148 businessaddress.setType(Address::Work);
109//US businessaddress.setPostOfficeBox( "" ); 149//US businessaddress.setPostOfficeBox( "" );
110//US businessaddress.setExtended( "" ); 150//US businessaddress.setExtended( "" );
@@ -114,8 +154,10 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
114 businessaddress.setPostalCode( contact.businessZip() ); 154 businessaddress.setPostalCode( contact.businessZip() );
115 businessaddress.setCountry( contact.businessCountry() ); 155 businessaddress.setCountry( contact.businessCountry() );
116 156
117 addr.insertAddress( businessaddress ); 157 addr.insertAddress( businessaddress );
158 }
159
118 160
119 if (!contact.businessPhone().isEmpty()) 161 if (!contact.businessPhone().isEmpty())
120 { 162 {
121 PhoneNumber businessphone; 163 PhoneNumber businessphone;
@@ -160,14 +202,11 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
160 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() ); 202 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() );
161 addr.insertCustom( "KADDRESSBOOK", "X-Gender", contact.gender() ); 203 addr.insertCustom( "KADDRESSBOOK", "X-Gender", contact.gender() );
162 204
163 if (contact.anniversary().isValid()) { 205 if (contact.anniversary().isValid()) {
164 int orgformat = KGlobal::locale()->getIntDateFormat(); 206 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate);
165 KGlobal::locale()->setIntDateFormat( 2 ); // = Qt::ISODate
166 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true);
167//US 207//US
168 qDebug("OpieConverter::opieToAddressee found:%s", dt.latin1()); 208 qDebug("OpieConverter::opieToAddressee found:%s", dt.latin1());
169 KGlobal::locale()->setIntDateFormat(orgformat );
170 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 209 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
171 } 210 }
172 211
173 addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); 212 addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() );
@@ -189,11 +228,11 @@ bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
189//US QStringList groupList() const; 228//US QStringList groupList() const;
190 229
191 230
192 QStringList cats = contact.categoryNames("Contacts"); 231 QStringList cats = contact.categoryNames("Contacts");
193 for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { 232// for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) {
194 qDebug("Cat: %s", (*it).latin1()); 233// qDebug("Cat: %s", (*it).latin1());
195 } 234// }
196 235
197 236
198 addr.setCategories( contact.categoryNames("Contacts") ); 237 addr.setCategories( contact.categoryNames("Contacts") );
199// qDebug("Groups: %s", contact.groups().latin1()); 238// qDebug("Groups: %s", contact.groups().latin1());
@@ -322,17 +361,15 @@ bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact )
322 contact.setCategories( cat ); 361 contact.setCategories( cat );
323*/ 362*/
324 363
325 Categories catDB; 364 Categories catDB;
326 catDB.dump(); 365 catDB.load( categoryFileName() );
327//US catDB.load( contact.categoryFileName() );
328 catDB.load( "contact" );
329
330 QStringList cats = addr.categories(); 366 QStringList cats = addr.categories();
331 for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) {
332 qDebug("categories: %s", (*it).latin1());
333// contact.setCategories(catDB.id(*it));
334 }
335 367
368 QArray<int> iar;
369 if ( !cats.isEmpty() ) {
370 QArray<int> iar = catDB.ids("contact", cats);
371 contact.setCategories(iar);
372 }
336 373
337 return true; 374 return true;
338} 375}
diff --git a/kabc/converter/opie/opieconverter.h b/kabc/converter/opie/opieconverter.h
index ef7300b..7d2ad85 100644
--- a/kabc/converter/opie/opieconverter.h
+++ b/kabc/converter/opie/opieconverter.h
@@ -32,8 +32,10 @@ $Id$
32 32
33#include "addressee.h" 33#include "addressee.h"
34#include <opie/ocontact.h> 34#include <opie/ocontact.h>
35 35
36class Categories;
37
36namespace KABC { 38namespace KABC {
37 39
38class OpieConverter 40class OpieConverter
39{ 41{
@@ -46,9 +48,12 @@ public:
46 48
47 /** 49 /**
48 * Destructor. 50 * Destructor.
49 */ 51 */
50 ~OpieConverter(); 52 virtual ~OpieConverter();
53
54 virtual bool init();
55 virtual void deinit();
51 56
52 /** 57 /**
53 * Converts a vcard string to an addressee. 58 * Converts a vcard string to an addressee.
54 * 59 *
@@ -64,8 +69,12 @@ public:
64 * @param contact The opie contact. 69 * @param contact The opie contact.
65 */ 70 */
66 bool addresseeToOpie( const Addressee &addr, OContact &contact ); 71 bool addresseeToOpie( const Addressee &addr, OContact &contact );
67 72
73 private:
74 Categories* catDB;
75
76
68}; 77};
69 78
70} 79}
71#endif 80#endif
diff --git a/kaddressbook/xxport/opie/opie_xxport.cpp b/kaddressbook/xxport/opie/opie_xxport.cpp
index d1def18..8ee0725 100644
--- a/kaddressbook/xxport/opie/opie_xxport.cpp
+++ b/kaddressbook/xxport/opie/opie_xxport.cpp
@@ -106,8 +106,20 @@ bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString
106 addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); 106 addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) );
107 return false; 107 return false;
108 } 108 }
109 109
110 KABC::OpieConverter mConverter;
111
112 bool res = mConverter.init();
113 if (!res)
114 {
115 QString text( i18n( "Unable to initialize opie converter.<br>Most likely a problem with the category file." ) );
116 qDebug(text);
117 KMessageBox::error( parentWidget(), text );
118 delete access;
119 return false;
120 }
121
110 //Now check if the file has already entries, and ask the user if he wants to delete them first. 122 //Now check if the file has already entries, and ask the user if he wants to delete them first.
111 OContactAccess::List contactList = access->allRecords(); 123 OContactAccess::List contactList = access->allRecords();
112 if (contactList.count() > 0) 124 if (contactList.count() > 0)
113 { 125 {
@@ -117,10 +129,8 @@ bool OpieXXPort::exportContacts( const KABC::AddresseeList &list, const QString
117 access->clear(); 129 access->clear();
118 } 130 }
119 } 131 }
120 132
121 KABC::OpieConverter mConverter;
122 bool res;
123 133
124 KABC::Addressee::List::ConstIterator it; 134 KABC::Addressee::List::ConstIterator it;
125 for ( it = list.begin(); it != list.end(); ++it ) { 135 for ( it = list.begin(); it != list.end(); ++it ) {
126 OContact c; 136 OContact c;
diff --git a/kaddressbook/xxport/opie/opie_xxportE.pro b/kaddressbook/xxport/opie/opie_xxportE.pro
index a660a48..c373e37 100644
--- a/kaddressbook/xxport/opie/opie_xxportE.pro
+++ b/kaddressbook/xxport/opie/opie_xxportE.pro
@@ -7,10 +7,11 @@ MOC_DIR = moc/$(PLATFORM)
7DESTDIR = $(QPEDIR)/lib 7DESTDIR = $(QPEDIR)/lib
8 8
9DEFINES += KAB_EMBEDDED 9DEFINES += KAB_EMBEDDED
10 10
11INCLUDEPATH += ../.. ../../.. ../../../kabc ../../../kabc/converter/opie ../../../microkde ../../../microkde/kdeui ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat $(QPEDIR)/include 11INCLUDEPATH += ../.. ../../.. ../../../kabc ../../../kabc/converter/opie ../../../microkde ../../../microkde/kdeui ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat $(OPIEDIR)/include
12LIBS += -L$(QPEDIR)/lib 12LIBS += -L$(QPEDIR)/lib
13LIBS += -L$(OPIEDIR)/lib
13LIBS += -lmicrokde 14LIBS += -lmicrokde
14LIBS += -lmicrokabc 15LIBS += -lmicrokabc
15LIBS += -lopie 16LIBS += -lopie
16LIBS += -lqpe 17LIBS += -lqpe