-rw-r--r-- | kabc/converter/qtopia/qtopiaconverter.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/xxport/opie/opie_xxport.cpp | 11 | ||||
-rw-r--r-- | kaddressbook/xxport/qtopia/qtopia_xxport.cpp | 12 |
3 files changed, 22 insertions, 3 deletions
diff --git a/kabc/converter/qtopia/qtopiaconverter.cpp b/kabc/converter/qtopia/qtopiaconverter.cpp index f451b8b..498e89e 100644 --- a/kabc/converter/qtopia/qtopiaconverter.cpp +++ b/kabc/converter/qtopia/qtopiaconverter.cpp | |||
@@ -185,49 +185,49 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a | |||
185 | businesspager.setNumber( contact.businessPager() ); | 185 | businesspager.setNumber( contact.businessPager() ); |
186 | addr.insertPhoneNumber( businesspager ); | 186 | addr.insertPhoneNumber( businesspager ); |
187 | } | 187 | } |
188 | 188 | ||
189 | addr.setRole( contact.jobTitle() ); //? | 189 | addr.setRole( contact.jobTitle() ); //? |
190 | addr.setOrganization( contact.company() ); | 190 | addr.setOrganization( contact.company() ); |
191 | addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() ); | 191 | addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() ); |
192 | addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() ); | 192 | addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() ); |
193 | addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() ); | 193 | addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() ); |
194 | addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() ); | 194 | addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() ); |
195 | addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() ); | 195 | addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() ); |
196 | 196 | ||
197 | //personal | 197 | //personal |
198 | addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() ); | 198 | addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() ); |
199 | // qtopia uses this categorization: | 199 | // qtopia uses this categorization: |
200 | // enum GenderType { UnspecifiedGender=0, Male, Female }; | 200 | // enum GenderType { UnspecifiedGender=0, Male, Female }; |
201 | if (contact.gender() == PimContact::Male) | 201 | if (contact.gender() == PimContact::Male) |
202 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); | 202 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); |
203 | else if (contact.gender() == PimContact::Female) | 203 | else if (contact.gender() == PimContact::Female) |
204 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); | 204 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); |
205 | 205 | ||
206 | if (contact.anniversary().isValid()) { | 206 | if (contact.anniversary().isValid()) { |
207 | QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate); | 207 | QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate); |
208 | //US | 208 | //US |
209 | qDebug("OpieConverter::qtopiaToAddressee found:%s", dt.latin1()); | 209 | // qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1()); |
210 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); | 210 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); |
211 | } | 211 | } |
212 | 212 | ||
213 | addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); | 213 | addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); |
214 | if (contact.birthday().isValid()) | 214 | if (contact.birthday().isValid()) |
215 | addr.setBirthday( contact.birthday() ); | 215 | addr.setBirthday( contact.birthday() ); |
216 | 216 | ||
217 | addr.setNickName( contact.nickname() ); | 217 | addr.setNickName( contact.nickname() ); |
218 | 218 | ||
219 | // others | 219 | // others |
220 | //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. | 220 | //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. |
221 | QString notes = contact.notes(); | 221 | QString notes = contact.notes(); |
222 | notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n"; | 222 | notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n"; |
223 | 223 | ||
224 | addr.setNote( contact.notes() ); | 224 | addr.setNote( contact.notes() ); |
225 | 225 | ||
226 | 226 | ||
227 | 227 | ||
228 | //US QString groups() const { return find( Qtopia::Groups ); } | 228 | //US QString groups() const { return find( Qtopia::Groups ); } |
229 | //US QStringList groupList() const; | 229 | //US QStringList groupList() const; |
230 | 230 | ||
231 | QArray<int> catArray = contact.categories(); | 231 | QArray<int> catArray = contact.categories(); |
232 | QString cat; | 232 | QString cat; |
233 | 233 | ||
diff --git a/kaddressbook/xxport/opie/opie_xxport.cpp b/kaddressbook/xxport/opie/opie_xxport.cpp index 12c83af..db30d34 100644 --- a/kaddressbook/xxport/opie/opie_xxport.cpp +++ b/kaddressbook/xxport/opie/opie_xxport.cpp | |||
@@ -163,50 +163,59 @@ KABC::AddresseeList OpieXXPort::importContacts( const QString& ) const | |||
163 | 163 | ||
164 | QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; | 164 | QString name = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; |
165 | 165 | ||
166 | #ifndef KAB_EMBEDDED | 166 | #ifndef KAB_EMBEDDED |
167 | QString fileName = KFileDialog::getOpenFileName( name ); | 167 | QString fileName = KFileDialog::getOpenFileName( name ); |
168 | #else //KAB_EMBEDDED | 168 | #else //KAB_EMBEDDED |
169 | QString fileName = KFileDialog::getOpenFileName( name, i18n("Load file"), parentWidget() ); | 169 | QString fileName = KFileDialog::getOpenFileName( name, i18n("Load file"), parentWidget() ); |
170 | #endif //KAB_EMBEDDED | 170 | #endif //KAB_EMBEDDED |
171 | 171 | ||
172 | if ( fileName.isEmpty() ) | 172 | if ( fileName.isEmpty() ) |
173 | return KABC::AddresseeList(); | 173 | return KABC::AddresseeList(); |
174 | 174 | ||
175 | OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KA/Pi", fileName ); | 175 | OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KA/Pi", fileName ); |
176 | OContactAccess* access = new OContactAccess("KA/Pi", 0l, backend, false); | 176 | OContactAccess* access = new OContactAccess("KA/Pi", 0l, backend, false); |
177 | 177 | ||
178 | if ( !access ) { | 178 | if ( !access ) { |
179 | qDebug("Unable to access file() %s", fileName.latin1()); | 179 | qDebug("Unable to access file() %s", fileName.latin1()); |
180 | addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); | 180 | addressBook()->error( i18n( "Unable to access file '%1'." ).arg( fileName ) ); |
181 | return KABC::AddresseeList(); | 181 | return KABC::AddresseeList(); |
182 | } | 182 | } |
183 | 183 | ||
184 | access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available | 184 | access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available |
185 | 185 | ||
186 | KABC::OpieConverter mConverter; | 186 | KABC::OpieConverter mConverter; |
187 | bool res = false; | ||
188 | 187 | ||
188 | bool res = mConverter.init(); | ||
189 | if (!res) | ||
190 | { | ||
191 | QString text( i18n( "Unable to initialize opie converter.<br>Most likely a problem with the category file." ) ); | ||
192 | qDebug(text); | ||
193 | KMessageBox::error( parentWidget(), text ); | ||
194 | delete access; | ||
195 | return KABC::AddresseeList(); | ||
196 | } | ||
197 | |||
189 | 198 | ||
190 | OContactAccess::List::Iterator it; | 199 | OContactAccess::List::Iterator it; |
191 | OContactAccess::List allList = access->allRecords(); | 200 | OContactAccess::List allList = access->allRecords(); |
192 | for ( it = allList.begin(); it != allList.end(); ++it ) | 201 | for ( it = allList.begin(); it != allList.end(); ++it ) |
193 | { | 202 | { |
194 | OContact c = (*it); | 203 | OContact c = (*it); |
195 | 204 | ||
196 | KABC::Addressee addressee; | 205 | KABC::Addressee addressee; |
197 | 206 | ||
198 | res = mConverter.opieToAddressee( c, addressee ); | 207 | res = mConverter.opieToAddressee( c, addressee ); |
199 | 208 | ||
200 | if ( !addressee.isEmpty() && res ) { | 209 | if ( !addressee.isEmpty() && res ) { |
201 | adrlst.append( addressee ); | 210 | adrlst.append( addressee ); |
202 | } | 211 | } |
203 | 212 | ||
204 | // qDebug("found %s", c.fullName().latin1()); | 213 | // qDebug("found %s", c.fullName().latin1()); |
205 | } | 214 | } |
206 | 215 | ||
207 | delete access; | 216 | delete access; |
208 | //US the deletion of the access object deletes the backend object as well. | 217 | //US the deletion of the access object deletes the backend object as well. |
209 | 218 | ||
210 | return adrlst; | 219 | return adrlst; |
211 | 220 | ||
212 | } | 221 | } |
diff --git a/kaddressbook/xxport/qtopia/qtopia_xxport.cpp b/kaddressbook/xxport/qtopia/qtopia_xxport.cpp index 3d830df..bf39fdb 100644 --- a/kaddressbook/xxport/qtopia/qtopia_xxport.cpp +++ b/kaddressbook/xxport/qtopia/qtopia_xxport.cpp | |||
@@ -142,50 +142,60 @@ bool QtopiaXXPort::exportContacts( const KABC::AddresseeList &list, const QStrin | |||
142 | } | 142 | } |
143 | 143 | ||
144 | delete access; | 144 | delete access; |
145 | 145 | ||
146 | return true; | 146 | return true; |
147 | } | 147 | } |
148 | 148 | ||
149 | KABC::AddresseeList QtopiaXXPort::importContacts( const QString& ) const | 149 | KABC::AddresseeList QtopiaXXPort::importContacts( const QString& ) const |
150 | { | 150 | { |
151 | KABC::AddresseeList adrlst; | 151 | KABC::AddresseeList adrlst; |
152 | 152 | ||
153 | QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; | 153 | QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; |
154 | 154 | ||
155 | AddressBookAccess* access = new AddressBookAccess(); | 155 | AddressBookAccess* access = new AddressBookAccess(); |
156 | 156 | ||
157 | if ( !access ) { | 157 | if ( !access ) { |
158 | QString text( i18n( "Unable to access file '%1'." ).arg( fileName ) ); | 158 | QString text( i18n( "Unable to access file '%1'." ).arg( fileName ) ); |
159 | qDebug(text.latin1()); | 159 | qDebug(text.latin1()); |
160 | addressBook()->error( text ); | 160 | addressBook()->error( text ); |
161 | KMessageBox::error( parentWidget(), text ); | 161 | KMessageBox::error( parentWidget(), text ); |
162 | return KABC::AddresseeList(); | 162 | return KABC::AddresseeList(); |
163 | } | 163 | } |
164 | 164 | ||
165 | KABC::QtopiaConverter mConverter; | 165 | KABC::QtopiaConverter mConverter; |
166 | bool res = false; | ||
167 | 166 | ||
167 | bool res = mConverter.init(); | ||
168 | if (!res) | ||
169 | { | ||
170 | QString text( i18n( "Unable to initialize qtopia converter.<br>Most likely a problem with the category file." ) ); | ||
171 | qDebug(text); | ||
172 | KMessageBox::error( parentWidget(), text ); | ||
173 | delete access; | ||
174 | return KABC::AddresseeList(); | ||
175 | } | ||
176 | |||
177 | |||
168 | 178 | ||
169 | { //create a new scope | 179 | { //create a new scope |
170 | AddressBookIterator it(*access); | 180 | AddressBookIterator it(*access); |
171 | 181 | ||
172 | for (it.toFirst(); it.current(); ++it) { | 182 | for (it.toFirst(); it.current(); ++it) { |
173 | const PimContact*contact = it.current(); | 183 | const PimContact*contact = it.current(); |
174 | 184 | ||
175 | KABC::Addressee addressee; | 185 | KABC::Addressee addressee; |
176 | 186 | ||
177 | res = mConverter.qtopiaToAddressee( (*contact), addressee ); | 187 | res = mConverter.qtopiaToAddressee( (*contact), addressee ); |
178 | 188 | ||
179 | if ( !addressee.isEmpty() && res ) | 189 | if ( !addressee.isEmpty() && res ) |
180 | { | 190 | { |
181 | adrlst.append( addressee ); | 191 | adrlst.append( addressee ); |
182 | } | 192 | } |
183 | } | 193 | } |
184 | } | 194 | } |
185 | 195 | ||
186 | delete access; | 196 | delete access; |
187 | //US the deletion of the access object deletes the backend object as well. | 197 | //US the deletion of the access object deletes the backend object as well. |
188 | 198 | ||
189 | return adrlst; | 199 | return adrlst; |
190 | 200 | ||
191 | } | 201 | } |