summaryrefslogtreecommitdiffabout
path: root/kabc/plugins
Unidiff
Diffstat (limited to 'kabc/plugins') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/qtopia/qtopiaconverter.cpp8
-rw-r--r--kabc/plugins/sharpdtm/sharpdtmconverter.cpp10
2 files changed, 9 insertions, 9 deletions
diff --git a/kabc/plugins/qtopia/qtopiaconverter.cpp b/kabc/plugins/qtopia/qtopiaconverter.cpp
index 39d366b..9693a68 100644
--- a/kabc/plugins/qtopia/qtopiaconverter.cpp
+++ b/kabc/plugins/qtopia/qtopiaconverter.cpp
@@ -76,286 +76,286 @@ QString QtopiaConverter::categoriesToNumber( const QStringList &list, const QStr
76 bool found = false; 76 bool found = false;
77 for ( QStringList::ConstIterator listIt = list.begin(); listIt != list.end(); ++listIt ) { 77 for ( QStringList::ConstIterator listIt = list.begin(); listIt != list.end(); ++listIt ) {
78 /* skip empty category name */ 78 /* skip empty category name */
79 if ( (*listIt).isEmpty() ) continue; 79 if ( (*listIt).isEmpty() ) continue;
80 80
81 found = false; 81 found = false;
82 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 82 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
83 /* 83 /*
84 * We currently do not take app into account 84 * We currently do not take app into account
85 * if name matches and the id isn't already in dummy we'll add it 85 * if name matches and the id isn't already in dummy we'll add it
86 */ 86 */
87 if ( (*catIt).name() == (*listIt) && !dummy.contains(( *catIt).id() ) ) { // the same name 87 if ( (*catIt).name() == (*listIt) && !dummy.contains(( *catIt).id() ) ) { // the same name
88 found= true; 88 found= true;
89 dummy << (*catIt).id(); 89 dummy << (*catIt).id();
90 } 90 }
91 } 91 }
92 /* if not found and the category is not empty 92 /* if not found and the category is not empty
93 * 93 *
94 * generate a new category and start over again 94 * generate a new category and start over again
95 * ugly goto to reiterate 95 * ugly goto to reiterate
96 */ 96 */
97 97
98 if ( !found && !(*listIt).isEmpty() ){ 98 if ( !found && !(*listIt).isEmpty() ){
99 m_edit->addCategory( app, (*listIt) ); // generate a new category 99 m_edit->addCategory( app, (*listIt) ); // generate a new category
100 goto startover; 100 goto startover;
101 } 101 }
102 } 102 }
103 103
104 return dummy.join(";"); 104 return dummy.join(";");
105} 105}
106 106
107 107
108// FROM TT timeconversion.cpp GPLed 108// FROM TT timeconversion.cpp GPLed
109QDate QtopiaConverter::fromString( const QString &datestr ) 109QDate QtopiaConverter::fromString( const QString &datestr )
110{ 110{
111 if (datestr.isEmpty() ) 111 if (datestr.isEmpty() )
112 return QDate(); 112 return QDate();
113 113
114 int monthPos = datestr.find('.'); 114 int monthPos = datestr.find('.');
115 int yearPos = datestr.find('.', monthPos+1 ); 115 int yearPos = datestr.find('.', monthPos+1 );
116 if ( monthPos == -1 || yearPos == -1 ) { 116 if ( monthPos == -1 || yearPos == -1 ) {
117 return QDate(); 117 return QDate();
118 } 118 }
119 int d = datestr.left( monthPos ).toInt(); 119 int d = datestr.left( monthPos ).toInt();
120 int m = datestr.mid( monthPos+1, yearPos - monthPos - 1 ).toInt(); 120 int m = datestr.mid( monthPos+1, yearPos - monthPos - 1 ).toInt();
121 int y = datestr.mid( yearPos+1 ).toInt(); 121 int y = datestr.mid( yearPos+1 ).toInt();
122 QDate date ( y,m,d ); 122 QDate date ( y,m,d );
123 123
124 124
125 return date; 125 return date;
126} 126}
127 127
128QDate QtopiaConverter::dateFromString( const QString& s ) 128QDate QtopiaConverter::dateFromString( const QString& s )
129{ 129{
130 QDate date; 130 QDate date;
131 131
132 if ( s.isEmpty() ) 132 if ( s.isEmpty() )
133 return date; 133 return date;
134 134
135 // Be backward compatible to old Opie format: 135 // Be backward compatible to old Opie format:
136 // Try to load old format. If it fails, try new ISO-Format! 136 // Try to load old format. If it fails, try new ISO-Format!
137 date = fromString ( s ); 137 date = fromString ( s );
138 if ( date.isValid() ) 138 if ( date.isValid() )
139 return date; 139 return date;
140 140
141 // Read ISO-Format (YYYYMMDD) 141 // Read ISO-Format (YYYYMMDD)
142 int year = s.mid(0, 4).toInt(); 142 int year = s.mid(0, 4).toInt();
143 int month = s.mid(4,2).toInt(); 143 int month = s.mid(4,2).toInt();
144 int day = s.mid(6,2).toInt(); 144 int day = s.mid(6,2).toInt();
145 145
146 // do some quick sanity checking 146 // do some quick sanity checking
147 if ( year < 1900 || year > 3000 ) 147 if ( year < 1900 || year > 3000 )
148 return date; 148 return date;
149 149
150 if ( month < 0 || month > 12 ) 150 if ( month < 0 || month > 12 )
151 return date; 151 return date;
152 152
153 if ( day < 0 || day > 31 ) 153 if ( day < 0 || day > 31 )
154 return date; 154 return date;
155 155
156 156
157 date.setYMD( year, month, day ); 157 date.setYMD( year, month, day );
158 158
159 if ( !date.isValid() ) 159 if ( !date.isValid() )
160 return QDate(); 160 return QDate();
161 161
162 162
163 return date; 163 return date;
164} 164}
165QString QtopiaConverter::dateToString( const QDate &d ) 165QString QtopiaConverter::dateToString( const QDate &d )
166{ 166{
167 if ( d.isNull() || !d.isValid() ) 167 if ( d.isNull() || !d.isValid() )
168 return QString::null; 168 return QString::null;
169 169
170 // ISO format in year, month, day (YYYYMMDD); e.g. 20021231 170 // ISO format in year, month, day (YYYYMMDD); e.g. 20021231
171 QString year = QString::number( d.year() ); 171 QString year = QString::number( d.year() );
172 QString month = QString::number( d.month() ); 172 QString month = QString::number( d.month() );
173 month = month.rightJustify( 2, '0' ); 173 month = month.rightJustify( 2, '0' );
174 QString day = QString::number( d.day() ); 174 QString day = QString::number( d.day() );
175 day = day.rightJustify( 2, '0' ); 175 day = day.rightJustify( 2, '0' );
176 176
177 QString str = year + month + day; 177 QString str = year + month + day;
178 178
179 return str; 179 return str;
180} 180}
181 181
182bool QtopiaConverter::qtopiaToAddressee( const QDomElement& el, Addressee &adr ) 182bool QtopiaConverter::qtopiaToAddressee( const QDomElement& el, Addressee &adr )
183{ 183{
184 { //LR 184 { //LR
185 185
186 adr.setUid( el.attribute("Uid" ) ); 186 adr.setUid( el.attribute("Uid" ) );
187 adr.setFamilyName( el.attribute( "LastName" ) ); 187 adr.setFamilyName( el.attribute( "LastName" ) );
188 adr.setGivenName( el.attribute( "FirstName" ) ); 188 adr.setGivenName( el.attribute( "FirstName" ) );
189 adr.setAdditionalName( el.attribute( "MiddleName" ) ); 189 adr.setAdditionalName( el.attribute( "MiddleName" ) );
190 adr.setSuffix( el.attribute( "Suffix" ) ); 190 adr.setSuffix( el.attribute( "Suffix" ) );
191 adr.setNickName( el.attribute( "Nickname" ) ); 191 adr.setNickName( el.attribute( "Nickname" ) );
192 192
193 QDate date = dateFromString( el.attribute( "Birthday" ) ); 193 QDate date = dateFromString( el.attribute( "Birthday" ) );
194 if ( date.isValid() ) 194 if ( date.isValid() )
195 adr.setBirthday( date ); 195 adr.setBirthday( date );
196 196
197 adr.setRole( el.attribute( "JobTitle" ) ); 197 adr.setRole( el.attribute( "JobTitle" ) );
198 if ( !el.attribute( "FileAs" ).isEmpty() ) 198 if ( !el.attribute( "FileAs" ).isEmpty() )
199 adr.setFormattedName( el.attribute( "FileAs" ) ); 199 adr.setFormattedName( el.attribute( "FileAs" ) );
200 200
201 adr.setOrganization( el.attribute( "Company" ) ); 201 adr.setOrganization( el.attribute( "Company" ) );
202 202
203 KABC::PhoneNumber businessPhoneNum( el.attribute( "BusinessPhone" ), 203 KABC::PhoneNumber businessPhoneNum( el.attribute( "BusinessPhone" ),
204 KABC::PhoneNumber::Work ); 204 KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref );
205 KABC::PhoneNumber businessFaxNum( el.attribute( "BusinessFax" ), 205 KABC::PhoneNumber businessFaxNum( el.attribute( "BusinessFax" ),
206 KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax ); 206 KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax );
207 KABC::PhoneNumber businessMobile( el.attribute( "BusinessMobile" ), 207 KABC::PhoneNumber businessMobile( el.attribute( "BusinessMobile" ),
208 KABC::PhoneNumber::Work | KABC::PhoneNumber::Cell ); 208 KABC::PhoneNumber::Car );
209 KABC::PhoneNumber businessPager( el.attribute( "BusinessPager" ), 209 KABC::PhoneNumber businessPager( el.attribute( "BusinessPager" ),
210 KABC::PhoneNumber::Work | KABC::PhoneNumber::Pager ); 210 KABC::PhoneNumber::Pager );
211 if ( !businessPhoneNum.number().isEmpty() ) 211 if ( !businessPhoneNum.number().isEmpty() )
212 adr.insertPhoneNumber( businessPhoneNum ); 212 adr.insertPhoneNumber( businessPhoneNum );
213 if ( !businessFaxNum.number().isEmpty() ) 213 if ( !businessFaxNum.number().isEmpty() )
214 adr.insertPhoneNumber( businessFaxNum ); 214 adr.insertPhoneNumber( businessFaxNum );
215 if ( !businessMobile.number().isEmpty() ) 215 if ( !businessMobile.number().isEmpty() )
216 adr.insertPhoneNumber( businessMobile ); 216 adr.insertPhoneNumber( businessMobile );
217 if ( !businessPager.number().isEmpty() ) 217 if ( !businessPager.number().isEmpty() )
218 adr.insertPhoneNumber( businessPager ); 218 adr.insertPhoneNumber( businessPager );
219 219
220 // Handle multiple mail addresses 220 // Handle multiple mail addresses
221 QString DefaultEmail = el.attribute( "DefaultEmail" ); 221 QString DefaultEmail = el.attribute( "DefaultEmail" );
222 if ( !DefaultEmail.isEmpty() ) 222 if ( !DefaultEmail.isEmpty() )
223 adr.insertEmail( DefaultEmail, true ); // preferred 223 adr.insertEmail( DefaultEmail, true ); // preferred
224 224
225 QStringList Emails = QStringList::split(" ",el.attribute("Emails")); 225 QStringList Emails = QStringList::split(" ",el.attribute("Emails"));
226 int i; 226 int i;
227 for (i = 0;i < Emails.count();++i) { 227 for (i = 0;i < Emails.count();++i) {
228 if ( Emails[i] != DefaultEmail ) 228 if ( Emails[i] != DefaultEmail )
229 adr.insertEmail( Emails[i], false ); 229 adr.insertEmail( Emails[i], false );
230 } 230 }
231 231
232 KABC::PhoneNumber homePhoneNum( el.attribute( "HomePhone" ), 232 KABC::PhoneNumber homePhoneNum( el.attribute( "HomePhone" ),
233 KABC::PhoneNumber::Home ); 233 KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref);
234 KABC::PhoneNumber homeFax( el.attribute( "HomeFax" ), 234 KABC::PhoneNumber homeFax( el.attribute( "HomeFax" ),
235 KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax ); 235 KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax );
236 236
237 KABC::PhoneNumber homeMobile( el.attribute( "HomeMobile" ), 237 KABC::PhoneNumber homeMobile( el.attribute( "HomeMobile" ),
238 KABC::PhoneNumber::Cell ); 238 KABC::PhoneNumber::Cell );
239 239
240 if ( !homePhoneNum.number().isEmpty() ) 240 if ( !homePhoneNum.number().isEmpty() )
241 adr.insertPhoneNumber( homePhoneNum ); 241 adr.insertPhoneNumber( homePhoneNum );
242 if ( !homeFax.number().isEmpty() ) 242 if ( !homeFax.number().isEmpty() )
243 adr.insertPhoneNumber( homeFax ); 243 adr.insertPhoneNumber( homeFax );
244 if ( !homeMobile.number().isEmpty() ) 244 if ( !homeMobile.number().isEmpty() )
245 adr.insertPhoneNumber( homeMobile ); 245 adr.insertPhoneNumber( homeMobile );
246 246
247 KABC::Address business( KABC::Address::Work ); 247 KABC::Address business( KABC::Address::Work );
248 business.setStreet( el.attribute( "BusinessStreet" ) ); 248 business.setStreet( el.attribute( "BusinessStreet" ) );
249 business.setLocality( el.attribute( "BusinessCity" ) ); 249 business.setLocality( el.attribute( "BusinessCity" ) );
250 business.setRegion( el.attribute( "BusinessState" ) ); 250 business.setRegion( el.attribute( "BusinessState" ) );
251 business.setPostalCode( el.attribute( "BusinessZip" ) ); 251 business.setPostalCode( el.attribute( "BusinessZip" ) );
252 business.setCountry( el.attribute( "BusinessCountry" ) ); 252 business.setCountry( el.attribute( "BusinessCountry" ) );
253 253
254 if ( !business.isEmpty() ) 254 if ( !business.isEmpty() )
255 adr.insertAddress( business ); 255 adr.insertAddress( business );
256 256
257 KABC::Address home( KABC::Address::Home ); 257 KABC::Address home( KABC::Address::Home );
258 home.setStreet( el.attribute( "HomeStreet" ) ); 258 home.setStreet( el.attribute( "HomeStreet" ) );
259 home.setLocality( el.attribute( "HomeCity" ) ); 259 home.setLocality( el.attribute( "HomeCity" ) );
260 home.setRegion( el.attribute( "HomeState" ) ); 260 home.setRegion( el.attribute( "HomeState" ) );
261 home.setPostalCode( el.attribute( "HomeZip" ) ); 261 home.setPostalCode( el.attribute( "HomeZip" ) );
262 home.setCountry( el.attribute( "HomeCountry" ) ); 262 home.setCountry( el.attribute( "HomeCountry" ) );
263 263
264 if ( !home.isEmpty() ) 264 if ( !home.isEmpty() )
265 adr.insertAddress( home ); 265 adr.insertAddress( home );
266 266
267 adr.setNickName( el.attribute( "Nickname" ) ); 267 adr.setNickName( el.attribute( "Nickname" ) );
268 adr.setNote( el.attribute( "Notes" ) ); 268 adr.setNote( el.attribute( "Notes" ) );
269 269
270 { 270 {
271 QStringList categories = QStringList::split(";", el.attribute("Categories" ) ); 271 QStringList categories = QStringList::split(";", el.attribute("Categories" ) );
272 QString cat; 272 QString cat;
273 QStringList added; 273 QStringList added;
274 for ( uint i = 0; i < categories.count(); i++ ) { 274 for ( uint i = 0; i < categories.count(); i++ ) {
275 cat = m_edit->categoryById( categories[ i ], "Contacts" ); 275 cat = m_edit->categoryById( categories[ i ], "Contacts" );
276 276
277 // if name is not empty and we did not add the 277 // if name is not empty and we did not add the
278 // cat try to repair broken files 278 // cat try to repair broken files
279 if ( !cat.isEmpty() && !added.contains( cat ) ) { 279 if ( !cat.isEmpty() && !added.contains( cat ) ) {
280 adr.insertCategory( cat ); 280 adr.insertCategory( cat );
281 added << cat; 281 added << cat;
282 } 282 }
283 } 283 }
284 } 284 }
285 285
286 if ( !el.attribute( "Department" ).isEmpty() ) 286 if ( !el.attribute( "Department" ).isEmpty() )
287 adr.insertCustom( "KADDRESSBOOK", "X-Department", el.attribute( "Department" ) ); 287 adr.insertCustom( "KADDRESSBOOK", "X-Department", el.attribute( "Department" ) );
288 if ( !el.attribute( "HomeWebPage" ).isEmpty() ) 288 if ( !el.attribute( "HomeWebPage" ).isEmpty() )
289 adr.insertCustom( "opie", "HomeWebPage", el.attribute( "HomeWebPage" ) ); 289 adr.insertCustom( "opie", "HomeWebPage", el.attribute( "HomeWebPage" ) );
290 if ( !el.attribute( "Spouse" ).isEmpty() ) 290 if ( !el.attribute( "Spouse" ).isEmpty() )
291 adr.insertCustom( "KADDRESSBOOK", "X-SpousesName", el.attribute( "Spouse" ) ); 291 adr.insertCustom( "KADDRESSBOOK", "X-SpousesName", el.attribute( "Spouse" ) );
292 if ( !el.attribute( "Gender" ).isEmpty() ) { 292 if ( !el.attribute( "Gender" ).isEmpty() ) {
293 if ( el.attribute( "Gender" ) == "1" ) 293 if ( el.attribute( "Gender" ) == "1" )
294 adr.insertCustom( "KADDRESSBOOK", "X-Gender", "male" ); 294 adr.insertCustom( "KADDRESSBOOK", "X-Gender", "male" );
295 else if ( el.attribute( "Gender" ) == "2" ) 295 else if ( el.attribute( "Gender" ) == "2" )
296 adr.insertCustom( "KADDRESSBOOK", "X-Gender", "female" ); 296 adr.insertCustom( "KADDRESSBOOK", "X-Gender", "female" );
297 } 297 }
298 QDate ann = dateFromString( el.attribute( "Anniversary" ) ); 298 QDate ann = dateFromString( el.attribute( "Anniversary" ) );
299 if ( ann.isValid() ) { 299 if ( ann.isValid() ) {
300 QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate); 300 QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate);
301 adr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt ); 301 adr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt );
302 } 302 }
303 303
304 if ( !el.attribute( "Children" ).isEmpty() ) 304 if ( !el.attribute( "Children" ).isEmpty() )
305 adr.insertCustom("KADDRESSBOOK", "X-Children", el.attribute("Children") ); 305 adr.insertCustom("KADDRESSBOOK", "X-Children", el.attribute("Children") );
306 if ( !el.attribute( "Office" ).isEmpty() ) 306 if ( !el.attribute( "Office" ).isEmpty() )
307 adr.insertCustom("KADDRESSBOOK", "X-Office", el.attribute("Office") ); 307 adr.insertCustom("KADDRESSBOOK", "X-Office", el.attribute("Office") );
308 if ( !el.attribute( "Profession" ).isEmpty() ) 308 if ( !el.attribute( "Profession" ).isEmpty() )
309 adr.insertCustom("KADDRESSBOOK", "X-Profession", el.attribute("Profession") ); 309 adr.insertCustom("KADDRESSBOOK", "X-Profession", el.attribute("Profession") );
310 if ( !el.attribute( "Assistant" ).isEmpty() ) 310 if ( !el.attribute( "Assistant" ).isEmpty() )
311 adr.insertCustom("KADDRESSBOOK", "X-AssistantsName", el.attribute("Assistant") ); 311 adr.insertCustom("KADDRESSBOOK", "X-AssistantsName", el.attribute("Assistant") );
312 if ( !el.attribute( "Manager" ).isEmpty() ) 312 if ( !el.attribute( "Manager" ).isEmpty() )
313 adr.insertCustom("KADDRESSBOOK", "X-ManagersName", el.attribute("Manager") ); 313 adr.insertCustom("KADDRESSBOOK", "X-ManagersName", el.attribute("Manager") );
314 314
315 315
316 } 316 }
317 return true; 317 return true;
318} 318}
319 319
320bool QtopiaConverter::addresseeToQtopia( const Addressee &ab, QTextStream *stream ) 320bool QtopiaConverter::addresseeToQtopia( const Addressee &ab, QTextStream *stream )
321{ 321{
322 *stream << "<Contact "; 322 *stream << "<Contact ";
323 *stream << "FirstName=\"" << escape(ab.givenName()) << "\" "; 323 *stream << "FirstName=\"" << escape(ab.givenName()) << "\" ";
324 *stream << "MiddleName=\"" << escape(ab.additionalName()) << "\" "; 324 *stream << "MiddleName=\"" << escape(ab.additionalName()) << "\" ";
325 *stream << "LastName=\"" << escape(ab.familyName()) << "\" "; 325 *stream << "LastName=\"" << escape(ab.familyName()) << "\" ";
326 *stream << "Suffix=\"" << escape(ab.suffix()) << "\" "; 326 *stream << "Suffix=\"" << escape(ab.suffix()) << "\" ";
327 327
328 QString sortStr; 328 QString sortStr;
329 sortStr = ab.formattedName(); 329 sortStr = ab.formattedName();
330 /* is formattedName is empty we use the assembled name as fallback */ 330 /* is formattedName is empty we use the assembled name as fallback */
331 if (sortStr.isEmpty() ) 331 if (sortStr.isEmpty() )
332 sortStr = ab.assembledName(); 332 sortStr = ab.assembledName();
333 *stream << "FileAs=\"" << escape(sortStr) << "\" "; 333 *stream << "FileAs=\"" << escape(sortStr) << "\" ";
334 334
335 *stream << "JobTitle=\"" << escape(ab.role()) << "\" "; 335 *stream << "JobTitle=\"" << escape(ab.role()) << "\" ";
336 *stream << "Department=\"" << escape(ab.custom( "KADDRESSBOOK", "X-Department" )) << "\" "; 336 *stream << "Department=\"" << escape(ab.custom( "KADDRESSBOOK", "X-Department" )) << "\" ";
337 *stream << "Company=\"" << escape(ab.organization()) << "\" "; 337 *stream << "Company=\"" << escape(ab.organization()) << "\" ";
338 338
339 KABC::PhoneNumber businessPhoneNum = ab.phoneNumber(KABC::PhoneNumber::Work ); 339 KABC::PhoneNumber businessPhoneNum = ab.phoneNumber(KABC::PhoneNumber::Work );
340 *stream << "BusinessPhone=\"" << escape( businessPhoneNum.number() ) << "\" "; 340 *stream << "BusinessPhone=\"" << escape( businessPhoneNum.number() ) << "\" ";
341 341
342 KABC::PhoneNumber businessFaxNum = ab.phoneNumber(KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax ); 342 KABC::PhoneNumber businessFaxNum = ab.phoneNumber(KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax );
343 *stream << "BusinessFax=\"" << escape( businessFaxNum.number() )<< "\" "; 343 *stream << "BusinessFax=\"" << escape( businessFaxNum.number() )<< "\" ";
344 344
345 KABC::PhoneNumber businessMobile = ab.phoneNumber(KABC::PhoneNumber::Work | KABC::PhoneNumber::Cell ); 345 KABC::PhoneNumber businessMobile = ab.phoneNumber(KABC::PhoneNumber::Work | KABC::PhoneNumber::Cell );
346 *stream << "BusinessMobile=\"" << escape( businessMobile.number() ) << "\" "; 346 *stream << "BusinessMobile=\"" << escape( businessMobile.number() ) << "\" ";
347 347
348 *stream << "DefaultEmail=\"" << escape( ab.preferredEmail() ) << "\" "; 348 *stream << "DefaultEmail=\"" << escape( ab.preferredEmail() ) << "\" ";
349 QStringList list = ab.emails(); 349 QStringList list = ab.emails();
350 if ( list.count() > 0 ) { 350 if ( list.count() > 0 ) {
351 QStringList::Iterator it = list.begin(); 351 QStringList::Iterator it = list.begin();
352 *stream << "Emails=\"" << escape( *it ); 352 *stream << "Emails=\"" << escape( *it );
353 while (++it != list.end()) 353 while (++it != list.end())
354 *stream << ' ' << escape( *it ); 354 *stream << ' ' << escape( *it );
355 *stream << "\" "; 355 *stream << "\" ";
356 } 356 }
357 357
358 KABC::PhoneNumber homePhoneNum = ab.phoneNumber(KABC::PhoneNumber::Home ); 358 KABC::PhoneNumber homePhoneNum = ab.phoneNumber(KABC::PhoneNumber::Home );
359 *stream << "HomePhone=\"" << escape( homePhoneNum.number() ) << "\" "; 359 *stream << "HomePhone=\"" << escape( homePhoneNum.number() ) << "\" ";
360 360
361 KABC::PhoneNumber homeFax = ab.phoneNumber( KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax ); 361 KABC::PhoneNumber homeFax = ab.phoneNumber( KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax );
diff --git a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp
index 4adcae4..3d429fa 100644
--- a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp
+++ b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp
@@ -7,329 +7,329 @@
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
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/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (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 "sharpdtmconverter.h"
33 33
34#include <sl/slcategories.h> 34#include <sl/slcategories.h>
35#include <libkdepim/ksyncprofile.h> 35#include <libkdepim/ksyncprofile.h>
36//US #include <qpe/categoryselect.h> 36//US #include <qpe/categoryselect.h>
37 37
38 38
39using namespace KABC; 39using namespace KABC;
40using namespace SlCategory; 40using namespace SlCategory;
41 41
42SharpDTMConverter::SharpDTMConverter() : catDB(0) 42SharpDTMConverter::SharpDTMConverter() : catDB(0)
43{ 43{
44} 44}
45 45
46SharpDTMConverter::~SharpDTMConverter() 46SharpDTMConverter::~SharpDTMConverter()
47{ 47{
48 deinit(); 48 deinit();
49} 49}
50 50
51bool SharpDTMConverter::init() 51bool SharpDTMConverter::init()
52{ 52{
53 catDB = new SlCategory::SlCategories(); 53 catDB = new SlCategory::SlCategories();
54 54
55 if (!catDB) 55 if (!catDB)
56 return false; 56 return false;
57 57
58// catDB->load( categoryFileName() ); 58// catDB->load( categoryFileName() );
59 return true; 59 return true;
60} 60}
61 61
62void SharpDTMConverter::deinit() 62void SharpDTMConverter::deinit()
63{ 63{
64 if (catDB) 64 if (catDB)
65 { 65 {
66 delete catDB; 66 delete catDB;
67 catDB = 0; 67 catDB = 0;
68 } 68 }
69} 69}
70 70
71bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr ) 71bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr )
72{ 72{
73 SlZDataBase* db = (SlZDataBase*)database; 73 SlZDataBase* db = (SlZDataBase*)database;
74 74
75 // for syncing: we need setting of the two fields 75 // for syncing: we need setting of the two fields
76 addr.setExternalUID( QString::number( contact ) ); 76 addr.setExternalUID( QString::number( contact ) );
77 addr.setOriginalExternalUID( QString::number( contact ) ); 77 addr.setOriginalExternalUID( QString::number( contact ) );
78 addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 78 addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
79 79
80 80
81 // name 81 // name
82 //qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!"); 82 //qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!");
83 addr.setFormattedName(db->readField(ZdbAdrs::FileAs)); 83 addr.setFormattedName(db->readField(ZdbAdrs::FileAs));
84 //addr.setName(db->readField(ZdbAdrs::FullName)); 84 //addr.setName(db->readField(ZdbAdrs::FullName));
85 85
86 addr.setFamilyName( db->readField(ZdbAdrs::LastName) ); 86 addr.setFamilyName( db->readField(ZdbAdrs::LastName) );
87 addr.setGivenName( db->readField(ZdbAdrs::FirstName) ); 87 addr.setGivenName( db->readField(ZdbAdrs::FirstName) );
88 addr.setAdditionalName( db->readField(ZdbAdrs::MiddleName) ); 88 addr.setAdditionalName( db->readField(ZdbAdrs::MiddleName) );
89 addr.setPrefix( db->readField(ZdbAdrs::Title) ); 89 addr.setPrefix( db->readField(ZdbAdrs::Title) );
90 addr.setSuffix( db->readField(ZdbAdrs::Suffix) ); 90 addr.setSuffix( db->readField(ZdbAdrs::Suffix) );
91 91
92 92
93 QString emailstr = db->readField(ZdbAdrs::Emails); 93 QString emailstr = db->readField(ZdbAdrs::Emails);
94 emailstr.replace( QRegExp(","), " " ); 94 emailstr.replace( QRegExp(","), " " );
95 emailstr.replace( QRegExp(";"), " " ); 95 emailstr.replace( QRegExp(";"), " " );
96 emailstr.replace( QRegExp(":"), " " ); 96 emailstr.replace( QRegExp(":"), " " );
97 //qDebug("SharpDTMConverter::sharpToAddressee whats the character to seperate the emailadresses? %s ", emailstr.latin1()); 97 //qDebug("SharpDTMConverter::sharpToAddressee whats the character to seperate the emailadresses? %s ", emailstr.latin1());
98 QStringList emails = QStringList::split(" ", emailstr.simplifyWhiteSpace()); 98 QStringList emails = QStringList::split(" ", emailstr.simplifyWhiteSpace());
99 bool defE = false; 99 bool defE = false;
100 bool found = false; 100 bool found = false;
101 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 101 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
102 if (found ) 102 if (found )
103 defE = false; 103 defE = false;
104 else 104 else
105 found = defE = ((*it).lower() == db->readField(ZdbAdrs::DefaultEmail).lower()); 105 found = defE = ((*it).lower() == db->readField(ZdbAdrs::DefaultEmail).lower());
106 addr.insertEmail( *it, defE ); 106 addr.insertEmail( *it, defE );
107 } 107 }
108 if ( ! found ) 108 if ( ! found )
109 if (!db->readField(ZdbAdrs::DefaultEmail).isEmpty()) 109 if (!db->readField(ZdbAdrs::DefaultEmail).isEmpty())
110 addr.insertEmail(db->readField(ZdbAdrs::DefaultEmail), true); 110 addr.insertEmail(db->readField(ZdbAdrs::DefaultEmail), true);
111 111
112 // home 112 // home
113 if ((!db->readField(ZdbAdrs::HomeStreet).isEmpty()) || 113 if ((!db->readField(ZdbAdrs::HomeStreet).isEmpty()) ||
114 (!db->readField(ZdbAdrs::HomeCity).isEmpty()) || 114 (!db->readField(ZdbAdrs::HomeCity).isEmpty()) ||
115 (!db->readField(ZdbAdrs::HomeState).isEmpty()) || 115 (!db->readField(ZdbAdrs::HomeState).isEmpty()) ||
116 (!db->readField(ZdbAdrs::HomeZip).isEmpty()) || 116 (!db->readField(ZdbAdrs::HomeZip).isEmpty()) ||
117 (!db->readField(ZdbAdrs::HomeCountry).isEmpty())) 117 (!db->readField(ZdbAdrs::HomeCountry).isEmpty()))
118 { 118 {
119 Address homeaddress; 119 Address homeaddress;
120 homeaddress.setType(Address::Home); 120 homeaddress.setType(Address::Home);
121//US homeaddress.setPostOfficeBox( "" ); 121//US homeaddress.setPostOfficeBox( "" );
122//US homeaddress.setExtended( "" ); 122//US homeaddress.setExtended( "" );
123 homeaddress.setStreet( db->readField(ZdbAdrs::HomeStreet).replace( QRegExp("\\r"), "")); 123 homeaddress.setStreet( db->readField(ZdbAdrs::HomeStreet).replace( QRegExp("\\r"), ""));
124 homeaddress.setLocality( db->readField(ZdbAdrs::HomeCity) ); 124 homeaddress.setLocality( db->readField(ZdbAdrs::HomeCity) );
125 homeaddress.setRegion( db->readField(ZdbAdrs::HomeState) ); 125 homeaddress.setRegion( db->readField(ZdbAdrs::HomeState) );
126 homeaddress.setPostalCode( db->readField(ZdbAdrs::HomeZip) ); 126 homeaddress.setPostalCode( db->readField(ZdbAdrs::HomeZip) );
127 homeaddress.setCountry( db->readField(ZdbAdrs::HomeCountry) ); 127 homeaddress.setCountry( db->readField(ZdbAdrs::HomeCountry) );
128 128
129 addr.insertAddress( homeaddress ); 129 addr.insertAddress( homeaddress );
130 } 130 }
131 131
132 if (!db->readField(ZdbAdrs::HomePhone).isEmpty()) 132 if (!db->readField(ZdbAdrs::HomePhone).isEmpty())
133 { 133 {
134 PhoneNumber homephone; 134 PhoneNumber homephone;
135 homephone.setType( PhoneNumber::Home ); 135 homephone.setType( PhoneNumber::Home | PhoneNumber::Pref );
136 homephone.setNumber( db->readField(ZdbAdrs::HomePhone) ); 136 homephone.setNumber( db->readField(ZdbAdrs::HomePhone) );
137 addr.insertPhoneNumber( homephone ); 137 addr.insertPhoneNumber( homephone );
138 } 138 }
139 139
140 if (!db->readField(ZdbAdrs::HomeFax).isEmpty()) 140 if (!db->readField(ZdbAdrs::HomeFax).isEmpty())
141 { 141 {
142 PhoneNumber homefax; 142 PhoneNumber homefax;
143 homefax.setType( PhoneNumber::Home | PhoneNumber::Fax ); 143 homefax.setType( PhoneNumber::Home | PhoneNumber::Fax );
144 homefax.setNumber( db->readField(ZdbAdrs::HomeFax) ); 144 homefax.setNumber( db->readField(ZdbAdrs::HomeFax) );
145 addr.insertPhoneNumber( homefax ); 145 addr.insertPhoneNumber( homefax );
146 } 146 }
147 147
148 if (!db->readField(ZdbAdrs::HomeMobile).isEmpty()) 148 if (!db->readField(ZdbAdrs::HomeMobile).isEmpty())
149 { 149 {
150 PhoneNumber homemobile; 150 PhoneNumber homemobile;
151 homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell ); 151 homemobile.setType( PhoneNumber::Cell );
152 homemobile.setNumber( db->readField(ZdbAdrs::HomeMobile) ); 152 homemobile.setNumber( db->readField(ZdbAdrs::HomeMobile) );
153 addr.insertPhoneNumber( homemobile ); 153 addr.insertPhoneNumber( homemobile );
154 } 154 }
155 155
156 addr.setUrl( db->readField(ZdbAdrs::HomeWebPage) ); 156 addr.setUrl( db->readField(ZdbAdrs::HomeWebPage) );
157 157
158 158
159 // business 159 // business
160 if ((!db->readField(ZdbAdrs::BusinessStreet).isEmpty()) || 160 if ((!db->readField(ZdbAdrs::BusinessStreet).isEmpty()) ||
161 (!db->readField(ZdbAdrs::BusinessCity).isEmpty()) || 161 (!db->readField(ZdbAdrs::BusinessCity).isEmpty()) ||
162 (!db->readField(ZdbAdrs::BusinessState).isEmpty()) || 162 (!db->readField(ZdbAdrs::BusinessState).isEmpty()) ||
163 (!db->readField(ZdbAdrs::BusinessZip).isEmpty()) || 163 (!db->readField(ZdbAdrs::BusinessZip).isEmpty()) ||
164 (!db->readField(ZdbAdrs::BusinessCountry).isEmpty())) 164 (!db->readField(ZdbAdrs::BusinessCountry).isEmpty()))
165 { 165 {
166 Address businessaddress; 166 Address businessaddress;
167 businessaddress.setType(Address::Work); 167 businessaddress.setType(Address::Work);
168//US businessaddress.setPostOfficeBox( "" ); 168//US businessaddress.setPostOfficeBox( "" );
169//US businessaddress.setExtended( "" ); 169//US businessaddress.setExtended( "" );
170 businessaddress.setStreet( db->readField(ZdbAdrs::BusinessStreet).replace( QRegExp("\\r"), "") ); 170 businessaddress.setStreet( db->readField(ZdbAdrs::BusinessStreet).replace( QRegExp("\\r"), "") );
171 businessaddress.setLocality( db->readField(ZdbAdrs::BusinessCity) ); 171 businessaddress.setLocality( db->readField(ZdbAdrs::BusinessCity) );
172 businessaddress.setRegion( db->readField(ZdbAdrs::BusinessState) ); 172 businessaddress.setRegion( db->readField(ZdbAdrs::BusinessState) );
173 businessaddress.setPostalCode( db->readField(ZdbAdrs::BusinessZip) ); 173 businessaddress.setPostalCode( db->readField(ZdbAdrs::BusinessZip) );
174 businessaddress.setCountry( db->readField(ZdbAdrs::BusinessCountry) ); 174 businessaddress.setCountry( db->readField(ZdbAdrs::BusinessCountry) );
175 175
176 addr.insertAddress( businessaddress ); 176 addr.insertAddress( businessaddress );
177 } 177 }
178 178
179 179
180 if (!db->readField(ZdbAdrs::BusinessPhone).isEmpty()) 180 if (!db->readField(ZdbAdrs::BusinessPhone).isEmpty())
181 { 181 {
182 PhoneNumber businessphone; 182 PhoneNumber businessphone;
183 businessphone.setType( PhoneNumber::Work ); 183 businessphone.setType( PhoneNumber::Work | PhoneNumber::Pref );
184 businessphone.setNumber( db->readField(ZdbAdrs::BusinessPhone) ); 184 businessphone.setNumber( db->readField(ZdbAdrs::BusinessPhone) );
185 addr.insertPhoneNumber( businessphone ); 185 addr.insertPhoneNumber( businessphone );
186 } 186 }
187 187
188 if (!db->readField(ZdbAdrs::BusinessFax).isEmpty()) 188 if (!db->readField(ZdbAdrs::BusinessFax).isEmpty())
189 { 189 {
190 PhoneNumber businessfax; 190 PhoneNumber businessfax;
191 businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); 191 businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax );
192 businessfax.setNumber( db->readField(ZdbAdrs::BusinessFax) ); 192 businessfax.setNumber( db->readField(ZdbAdrs::BusinessFax) );
193 addr.insertPhoneNumber( businessfax ); 193 addr.insertPhoneNumber( businessfax );
194 } 194 }
195 195
196 if (!db->readField(ZdbAdrs::BusinessMobile).isEmpty()) 196 if (!db->readField(ZdbAdrs::BusinessMobile).isEmpty())
197 { 197 {
198 PhoneNumber businessmobile; 198 PhoneNumber businessmobile;
199 businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); 199 businessmobile.setType( PhoneNumber::Car );
200 businessmobile.setNumber( db->readField(ZdbAdrs::BusinessMobile) ); 200 businessmobile.setNumber( db->readField(ZdbAdrs::BusinessMobile) );
201 addr.insertPhoneNumber( businessmobile ); 201 addr.insertPhoneNumber( businessmobile );
202 } 202 }
203 203
204 if (!db->readField(ZdbAdrs::BusinessPager).isEmpty()) 204 if (!db->readField(ZdbAdrs::BusinessPager).isEmpty())
205 { 205 {
206 PhoneNumber businesspager; 206 PhoneNumber businesspager;
207 businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); 207 businesspager.setType( PhoneNumber::Pager );
208 businesspager.setNumber( db->readField(ZdbAdrs::BusinessPager) ); 208 businesspager.setNumber( db->readField(ZdbAdrs::BusinessPager) );
209 addr.insertPhoneNumber( businesspager ); 209 addr.insertPhoneNumber( businesspager );
210 } 210 }
211 211
212 addr.setRole( db->readField(ZdbAdrs::JobTitle) ); 212 addr.setRole( db->readField(ZdbAdrs::JobTitle) );
213 addr.setOrganization( db->readField(ZdbAdrs::Company) ); 213 addr.setOrganization( db->readField(ZdbAdrs::Company) );
214 addr.insertCustom( "KADDRESSBOOK", "X-Profession", db->readField(ZdbAdrs::Profession) ); 214 addr.insertCustom( "KADDRESSBOOK", "X-Profession", db->readField(ZdbAdrs::Profession) );
215 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", db->readField(ZdbAdrs::Assistant) ); 215 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", db->readField(ZdbAdrs::Assistant) );
216 addr.insertCustom( "KADDRESSBOOK", "X-Department", db->readField(ZdbAdrs::Department) ); 216 addr.insertCustom( "KADDRESSBOOK", "X-Department", db->readField(ZdbAdrs::Department) );
217 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", db->readField(ZdbAdrs::Manager) ); 217 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", db->readField(ZdbAdrs::Manager) );
218 addr.insertCustom( "KADDRESSBOOK", "X-Office", db->readField(ZdbAdrs::Office) ); 218 addr.insertCustom( "KADDRESSBOOK", "X-Office", db->readField(ZdbAdrs::Office) );
219 219
220 //personal 220 //personal
221 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", db->readField(ZdbAdrs::Spouse) ); 221 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", db->readField(ZdbAdrs::Spouse) );
222 222
223 QString gen = db->readField(ZdbAdrs::Gender); 223 QString gen = db->readField(ZdbAdrs::Gender);
224 //qDebug("SharpDTMConverter::sharpToAddressee pleas check that gender works!! : Gender: %s", gen.latin1()); 224 //qDebug("SharpDTMConverter::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"); 225 //qDebug("SharpDTMConverter::sharpToAddressee: may be int db->readUshortField(\"ZdbAdrs::Gender\") is here better suited");
226 if (gen == "1") 226 if (gen == "1")
227 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); 227 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male");
228 else if (gen == "2") 228 else if (gen == "2")
229 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); 229 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female");
230 else 230 else
231 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "undef"); 231 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "undef");
232 232
233 233
234 QDate ann = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Anniversary) ); 234 QDate ann = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Anniversary) );
235 if (ann.isValid()) { 235 if (ann.isValid()) {
236 QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate); 236 QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate);
237 //qDebug("qtopiaToAddressee annyversary found:%s", dt.latin1()); 237 //qDebug("qtopiaToAddressee annyversary found:%s", dt.latin1());
238 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 238 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
239 } else 239 } else
240 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", " "); 240 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", " ");
241 241
242 242
243 243
244 addr.insertCustom( "KADDRESSBOOK", "X-Children", db->readField(ZdbAdrs::Children) ); 244 addr.insertCustom( "KADDRESSBOOK", "X-Children", db->readField(ZdbAdrs::Children) );
245 245
246 246
247 QDate birthd = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Birthday) ); 247 QDate birthd = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Birthday) );
248 //qDebug("birtd %s ", birthd.toString().latin1()); 248 //qDebug("birtd %s ", birthd.toString().latin1());
249 if (birthd.isValid()) 249 if (birthd.isValid())
250 addr.setBirthday( birthd ); 250 addr.setBirthday( birthd );
251 251
252 addr.setNickName( db->readField(ZdbAdrs::Nickname) ); 252 addr.setNickName( db->readField(ZdbAdrs::Nickname) );
253 253
254 // others 254 // others
255 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. 255 //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); 256 //QString notes = db->readField(ZdbAdrs::Notes);
257 //notes += "\nBusinessWebPage: " + db->readField(ZdbAdrs::BusinessWebPage) + "\n"; 257 //notes += "\nBusinessWebPage: " + db->readField(ZdbAdrs::BusinessWebPage) + "\n";
258 if ( addr.url().isEmpty() ) 258 if ( addr.url().isEmpty() )
259 addr.setUrl( db->readField(ZdbAdrs::BusinessWebPage) ); 259 addr.setUrl( db->readField(ZdbAdrs::BusinessWebPage) );
260 addr.setNote( db->readField(ZdbAdrs::Notes).replace( QRegExp("\\r"), "")); 260 addr.setNote( db->readField(ZdbAdrs::Notes).replace( QRegExp("\\r"), ""));
261 261
262 262
263 263
264//US QString groups() const { return find( Qtopia::Groups ); } 264//US QString groups() const { return find( Qtopia::Groups ); }
265//US QStringList groupList() const; 265//US QStringList groupList() const;
266 266
267 //qDebug("SharpDTMConverter::sharpToAddressee please check that the categories will be converted" ); 267 //qDebug("SharpDTMConverter::sharpToAddressee please check that the categories will be converted" );
268 QArray<int> catArray = db->readCategories(); 268 QArray<int> catArray = db->readCategories();
269 QString cat; 269 QString cat;
270 270
271 for ( unsigned int i=0; i < catArray.size(); i++ ) { 271 for ( unsigned int i=0; i < catArray.size(); i++ ) {
272 cat = catDB->label(catArray[i]); 272 cat = catDB->label(catArray[i]);
273 if ( cat.isEmpty() ) 273 if ( cat.isEmpty() )
274 addr.insertCategory(QString::number(catArray[i])); 274 addr.insertCategory(QString::number(catArray[i]));
275 else 275 else
276 addr.insertCategory( cat ); 276 addr.insertCategory( cat );
277 } 277 }
278 278
279 return true; 279 return true;
280} 280}
281 281
282bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ) 282bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact )
283{ 283{
284 bool cellHome = false, cellWork = false; 284 bool cellHome = false, cellWork = false;
285 // name 285 // name
286 database->writeField(ZdbAdrs::LastName, addr.familyName()); 286 database->writeField(ZdbAdrs::LastName, addr.familyName());
287 database->writeField(ZdbAdrs::FirstName, addr.givenName()); 287 database->writeField(ZdbAdrs::FirstName, addr.givenName());
288 database->writeField(ZdbAdrs::MiddleName, addr.additionalName()); 288 database->writeField(ZdbAdrs::MiddleName, addr.additionalName());
289 database->writeField(ZdbAdrs::Title, addr.prefix()); 289 database->writeField(ZdbAdrs::Title, addr.prefix());
290 database->writeField(ZdbAdrs::Suffix, addr.suffix()); 290 database->writeField(ZdbAdrs::Suffix, addr.suffix());
291 291
292 //qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() ); 292 //qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() );
293 QString formattedName = addr.formattedName(); 293 QString formattedName = addr.formattedName();
294 if ( formattedName.isEmpty() ) { 294 if ( formattedName.isEmpty() ) {
295 if ( !addr.familyName().isEmpty() ) { 295 if ( !addr.familyName().isEmpty() ) {
296 formattedName = addr.familyName(); 296 formattedName = addr.familyName();
297 if ( !addr.givenName().isEmpty() ) { 297 if ( !addr.givenName().isEmpty() ) {
298 formattedName += ", "; 298 formattedName += ", ";
299 formattedName += addr.givenName(); 299 formattedName += addr.givenName();
300 } 300 }
301 } else 301 } else
302 formattedName = addr.givenName(); 302 formattedName = addr.givenName();
303 } 303 }
304 database->writeField(ZdbAdrs::FileAs, formattedName); 304 database->writeField(ZdbAdrs::FileAs, formattedName);
305 database->writeField(ZdbAdrs::FullName, formattedName); 305 database->writeField(ZdbAdrs::FullName, formattedName);
306 306
307 // email 307 // email
308 //qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!"); 308 //qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!");
309 //qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee"); 309 //qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee");
310 QString emails = addr.emails().join(" "); 310 QString emails = addr.emails().join(" ");
311 database->writeField(ZdbAdrs::Emails, emails ); 311 database->writeField(ZdbAdrs::Emails, emails );
312 312
313 database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() ); 313 database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() );
314 // home 314 // home
315 const Address homeaddress = addr.address(Address::Home); 315 const Address homeaddress = addr.address(Address::Home);
316 database->writeField(ZdbAdrs::HomeStreet, homeaddress.street()); 316 database->writeField(ZdbAdrs::HomeStreet, homeaddress.street());
317 database->writeField(ZdbAdrs::HomeCity, homeaddress.locality()); 317 database->writeField(ZdbAdrs::HomeCity, homeaddress.locality());
318 database->writeField(ZdbAdrs::HomeState, homeaddress.region()); 318 database->writeField(ZdbAdrs::HomeState, homeaddress.region());
319 database->writeField(ZdbAdrs::HomeZip, homeaddress.postalCode()); 319 database->writeField(ZdbAdrs::HomeZip, homeaddress.postalCode());
320 database->writeField(ZdbAdrs::HomeCountry, homeaddress.country()); 320 database->writeField(ZdbAdrs::HomeCountry, homeaddress.country());
321 321
322 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); 322 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home );
323 database->writeField(ZdbAdrs::HomePhone, homephone.number()); 323 database->writeField(ZdbAdrs::HomePhone, homephone.number());
324 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); 324 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax );
325 database->writeField(ZdbAdrs::HomeFax, homefax.number()); 325 database->writeField(ZdbAdrs::HomeFax, homefax.number());
326 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); 326 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell );
327 database->writeField(ZdbAdrs::HomeMobile, homemobile.number()); 327 database->writeField(ZdbAdrs::HomeMobile, homemobile.number());
328 if (!homemobile.number().isEmpty()) { 328 if (!homemobile.number().isEmpty()) {
329 cellHome = true; 329 cellHome = true;
330 } 330 }
331 database->writeField(ZdbAdrs::HomeWebPage, addr.url().url()); 331 database->writeField(ZdbAdrs::HomeWebPage, addr.url().url());
332 // business 332 // business
333 const Address businessaddress = addr.address(Address::Work); 333 const Address businessaddress = addr.address(Address::Work);
334 //qDebug("write business address "); 334 //qDebug("write business address ");
335 database->writeField(ZdbAdrs::BusinessStreet, businessaddress.street()); 335 database->writeField(ZdbAdrs::BusinessStreet, businessaddress.street());