summaryrefslogtreecommitdiffabout
path: root/kabc
authorzautrix <zautrix>2004-10-23 06:49:54 (UTC)
committer zautrix <zautrix>2004-10-23 06:49:54 (UTC)
commit65989e4ab454f228fb6cd2fa532145ed54366701 (patch) (unidiff)
treea93a8cd6ef806dd5b6c38e8792a6e007b9e5e413 /kabc
parent0f0dc54f0edc8c4ec5b320118c82fa5150591fed (diff)
downloadkdepimpi-65989e4ab454f228fb6cd2fa532145ed54366701.zip
kdepimpi-65989e4ab454f228fb6cd2fa532145ed54366701.tar.gz
kdepimpi-65989e4ab454f228fb6cd2fa532145ed54366701.tar.bz2
statusmessage added topwm.fixed initialization problem.changed sring in translation
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/qtopia/qtopiaconverter.cpp2
-rw-r--r--kabc/plugins/qtopia/qtopiaconverter.h2
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp2
-rw-r--r--kabc/plugins/qtopia/resourceqtopiaconfig.cpp3
4 files changed, 0 insertions, 9 deletions
diff --git a/kabc/plugins/qtopia/qtopiaconverter.cpp b/kabc/plugins/qtopia/qtopiaconverter.cpp
index 106596f..39d366b 100644
--- a/kabc/plugins/qtopia/qtopiaconverter.cpp
+++ b/kabc/plugins/qtopia/qtopiaconverter.cpp
@@ -1,554 +1,552 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
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//US 28//US
29#include "kglobal.h" 29#include "kglobal.h"
30#include "klocale.h" 30#include "klocale.h"
31 31
32 32
33#include "qtopiaconverter.h" 33#include "qtopiaconverter.h"
34 34
35#include <qfile.h> 35#include <qfile.h>
36#include <qdir.h> 36#include <qdir.h>
37#include <qtextstream.h> 37#include <qtextstream.h>
38//#include <.h> 38//#include <.h>
39 39
40//#include <qpe/categories.h>
41#include <libkdepim/ksyncprofile.h> 40#include <libkdepim/ksyncprofile.h>
42//US #include <qpe/categoryselect.h>
43 41
44 42
45using namespace KABC; 43using namespace KABC;
46 44
47QtopiaConverter::QtopiaConverter() 45QtopiaConverter::QtopiaConverter()
48{ 46{
49 m_edit = 0; 47 m_edit = 0;
50} 48}
51 49
52QtopiaConverter::~QtopiaConverter() 50QtopiaConverter::~QtopiaConverter()
53{ 51{
54 deinit(); 52 deinit();
55} 53}
56 54
57bool QtopiaConverter::init() 55bool QtopiaConverter::init()
58{ 56{
59 QString fn = QDir::homeDirPath() +"/Settings/Categories.xml"; 57 QString fn = QDir::homeDirPath() +"/Settings/Categories.xml";
60 m_edit = new CategoryEdit( fn); 58 m_edit = new CategoryEdit( fn);
61 return true; 59 return true;
62} 60}
63 61
64void QtopiaConverter::deinit() 62void QtopiaConverter::deinit()
65{ 63{
66 if (m_edit) 64 if (m_edit)
67 { 65 {
68 delete m_edit; 66 delete m_edit;
69 m_edit = 0; 67 m_edit = 0;
70 } 68 }
71} 69}
72QString QtopiaConverter::categoriesToNumber( const QStringList &list, const QString &app ) 70QString QtopiaConverter::categoriesToNumber( const QStringList &list, const QString &app )
73{ 71{
74 startover: 72 startover:
75 QStringList dummy; 73 QStringList dummy;
76 QValueList<OpieCategories>::ConstIterator catIt; 74 QValueList<OpieCategories>::ConstIterator catIt;
77 QValueList<OpieCategories> categories = m_edit->categories(); 75 QValueList<OpieCategories> categories = m_edit->categories();
78 bool found = false; 76 bool found = false;
79 for ( QStringList::ConstIterator listIt = list.begin(); listIt != list.end(); ++listIt ) { 77 for ( QStringList::ConstIterator listIt = list.begin(); listIt != list.end(); ++listIt ) {
80 /* skip empty category name */ 78 /* skip empty category name */
81 if ( (*listIt).isEmpty() ) continue; 79 if ( (*listIt).isEmpty() ) continue;
82 80
83 found = false; 81 found = false;
84 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 82 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
85 /* 83 /*
86 * We currently do not take app into account 84 * We currently do not take app into account
87 * 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
88 */ 86 */
89 if ( (*catIt).name() == (*listIt) && !dummy.contains(( *catIt).id() ) ) { // the same name 87 if ( (*catIt).name() == (*listIt) && !dummy.contains(( *catIt).id() ) ) { // the same name
90 found= true; 88 found= true;
91 dummy << (*catIt).id(); 89 dummy << (*catIt).id();
92 } 90 }
93 } 91 }
94 /* if not found and the category is not empty 92 /* if not found and the category is not empty
95 * 93 *
96 * generate a new category and start over again 94 * generate a new category and start over again
97 * ugly goto to reiterate 95 * ugly goto to reiterate
98 */ 96 */
99 97
100 if ( !found && !(*listIt).isEmpty() ){ 98 if ( !found && !(*listIt).isEmpty() ){
101 m_edit->addCategory( app, (*listIt) ); // generate a new category 99 m_edit->addCategory( app, (*listIt) ); // generate a new category
102 goto startover; 100 goto startover;
103 } 101 }
104 } 102 }
105 103
106 return dummy.join(";"); 104 return dummy.join(";");
107} 105}
108 106
109 107
110// FROM TT timeconversion.cpp GPLed 108// FROM TT timeconversion.cpp GPLed
111QDate QtopiaConverter::fromString( const QString &datestr ) 109QDate QtopiaConverter::fromString( const QString &datestr )
112{ 110{
113 if (datestr.isEmpty() ) 111 if (datestr.isEmpty() )
114 return QDate(); 112 return QDate();
115 113
116 int monthPos = datestr.find('.'); 114 int monthPos = datestr.find('.');
117 int yearPos = datestr.find('.', monthPos+1 ); 115 int yearPos = datestr.find('.', monthPos+1 );
118 if ( monthPos == -1 || yearPos == -1 ) { 116 if ( monthPos == -1 || yearPos == -1 ) {
119 return QDate(); 117 return QDate();
120 } 118 }
121 int d = datestr.left( monthPos ).toInt(); 119 int d = datestr.left( monthPos ).toInt();
122 int m = datestr.mid( monthPos+1, yearPos - monthPos - 1 ).toInt(); 120 int m = datestr.mid( monthPos+1, yearPos - monthPos - 1 ).toInt();
123 int y = datestr.mid( yearPos+1 ).toInt(); 121 int y = datestr.mid( yearPos+1 ).toInt();
124 QDate date ( y,m,d ); 122 QDate date ( y,m,d );
125 123
126 124
127 return date; 125 return date;
128} 126}
129 127
130QDate QtopiaConverter::dateFromString( const QString& s ) 128QDate QtopiaConverter::dateFromString( const QString& s )
131{ 129{
132 QDate date; 130 QDate date;
133 131
134 if ( s.isEmpty() ) 132 if ( s.isEmpty() )
135 return date; 133 return date;
136 134
137 // Be backward compatible to old Opie format: 135 // Be backward compatible to old Opie format:
138 // 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!
139 date = fromString ( s ); 137 date = fromString ( s );
140 if ( date.isValid() ) 138 if ( date.isValid() )
141 return date; 139 return date;
142 140
143 // Read ISO-Format (YYYYMMDD) 141 // Read ISO-Format (YYYYMMDD)
144 int year = s.mid(0, 4).toInt(); 142 int year = s.mid(0, 4).toInt();
145 int month = s.mid(4,2).toInt(); 143 int month = s.mid(4,2).toInt();
146 int day = s.mid(6,2).toInt(); 144 int day = s.mid(6,2).toInt();
147 145
148 // do some quick sanity checking 146 // do some quick sanity checking
149 if ( year < 1900 || year > 3000 ) 147 if ( year < 1900 || year > 3000 )
150 return date; 148 return date;
151 149
152 if ( month < 0 || month > 12 ) 150 if ( month < 0 || month > 12 )
153 return date; 151 return date;
154 152
155 if ( day < 0 || day > 31 ) 153 if ( day < 0 || day > 31 )
156 return date; 154 return date;
157 155
158 156
159 date.setYMD( year, month, day ); 157 date.setYMD( year, month, day );
160 158
161 if ( !date.isValid() ) 159 if ( !date.isValid() )
162 return QDate(); 160 return QDate();
163 161
164 162
165 return date; 163 return date;
166} 164}
167QString QtopiaConverter::dateToString( const QDate &d ) 165QString QtopiaConverter::dateToString( const QDate &d )
168{ 166{
169 if ( d.isNull() || !d.isValid() ) 167 if ( d.isNull() || !d.isValid() )
170 return QString::null; 168 return QString::null;
171 169
172 // ISO format in year, month, day (YYYYMMDD); e.g. 20021231 170 // ISO format in year, month, day (YYYYMMDD); e.g. 20021231
173 QString year = QString::number( d.year() ); 171 QString year = QString::number( d.year() );
174 QString month = QString::number( d.month() ); 172 QString month = QString::number( d.month() );
175 month = month.rightJustify( 2, '0' ); 173 month = month.rightJustify( 2, '0' );
176 QString day = QString::number( d.day() ); 174 QString day = QString::number( d.day() );
177 day = day.rightJustify( 2, '0' ); 175 day = day.rightJustify( 2, '0' );
178 176
179 QString str = year + month + day; 177 QString str = year + month + day;
180 178
181 return str; 179 return str;
182} 180}
183 181
184bool QtopiaConverter::qtopiaToAddressee( const QDomElement& el, Addressee &adr ) 182bool QtopiaConverter::qtopiaToAddressee( const QDomElement& el, Addressee &adr )
185{ 183{
186 { //LR 184 { //LR
187 185
188 adr.setUid( el.attribute("Uid" ) ); 186 adr.setUid( el.attribute("Uid" ) );
189 adr.setFamilyName( el.attribute( "LastName" ) ); 187 adr.setFamilyName( el.attribute( "LastName" ) );
190 adr.setGivenName( el.attribute( "FirstName" ) ); 188 adr.setGivenName( el.attribute( "FirstName" ) );
191 adr.setAdditionalName( el.attribute( "MiddleName" ) ); 189 adr.setAdditionalName( el.attribute( "MiddleName" ) );
192 adr.setSuffix( el.attribute( "Suffix" ) ); 190 adr.setSuffix( el.attribute( "Suffix" ) );
193 adr.setNickName( el.attribute( "Nickname" ) ); 191 adr.setNickName( el.attribute( "Nickname" ) );
194 192
195 QDate date = dateFromString( el.attribute( "Birthday" ) ); 193 QDate date = dateFromString( el.attribute( "Birthday" ) );
196 if ( date.isValid() ) 194 if ( date.isValid() )
197 adr.setBirthday( date ); 195 adr.setBirthday( date );
198 196
199 adr.setRole( el.attribute( "JobTitle" ) ); 197 adr.setRole( el.attribute( "JobTitle" ) );
200 if ( !el.attribute( "FileAs" ).isEmpty() ) 198 if ( !el.attribute( "FileAs" ).isEmpty() )
201 adr.setFormattedName( el.attribute( "FileAs" ) ); 199 adr.setFormattedName( el.attribute( "FileAs" ) );
202 200
203 adr.setOrganization( el.attribute( "Company" ) ); 201 adr.setOrganization( el.attribute( "Company" ) );
204 202
205 KABC::PhoneNumber businessPhoneNum( el.attribute( "BusinessPhone" ), 203 KABC::PhoneNumber businessPhoneNum( el.attribute( "BusinessPhone" ),
206 KABC::PhoneNumber::Work ); 204 KABC::PhoneNumber::Work );
207 KABC::PhoneNumber businessFaxNum( el.attribute( "BusinessFax" ), 205 KABC::PhoneNumber businessFaxNum( el.attribute( "BusinessFax" ),
208 KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax ); 206 KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax );
209 KABC::PhoneNumber businessMobile( el.attribute( "BusinessMobile" ), 207 KABC::PhoneNumber businessMobile( el.attribute( "BusinessMobile" ),
210 KABC::PhoneNumber::Work | KABC::PhoneNumber::Cell ); 208 KABC::PhoneNumber::Work | KABC::PhoneNumber::Cell );
211 KABC::PhoneNumber businessPager( el.attribute( "BusinessPager" ), 209 KABC::PhoneNumber businessPager( el.attribute( "BusinessPager" ),
212 KABC::PhoneNumber::Work | KABC::PhoneNumber::Pager ); 210 KABC::PhoneNumber::Work | KABC::PhoneNumber::Pager );
213 if ( !businessPhoneNum.number().isEmpty() ) 211 if ( !businessPhoneNum.number().isEmpty() )
214 adr.insertPhoneNumber( businessPhoneNum ); 212 adr.insertPhoneNumber( businessPhoneNum );
215 if ( !businessFaxNum.number().isEmpty() ) 213 if ( !businessFaxNum.number().isEmpty() )
216 adr.insertPhoneNumber( businessFaxNum ); 214 adr.insertPhoneNumber( businessFaxNum );
217 if ( !businessMobile.number().isEmpty() ) 215 if ( !businessMobile.number().isEmpty() )
218 adr.insertPhoneNumber( businessMobile ); 216 adr.insertPhoneNumber( businessMobile );
219 if ( !businessPager.number().isEmpty() ) 217 if ( !businessPager.number().isEmpty() )
220 adr.insertPhoneNumber( businessPager ); 218 adr.insertPhoneNumber( businessPager );
221 219
222 // Handle multiple mail addresses 220 // Handle multiple mail addresses
223 QString DefaultEmail = el.attribute( "DefaultEmail" ); 221 QString DefaultEmail = el.attribute( "DefaultEmail" );
224 if ( !DefaultEmail.isEmpty() ) 222 if ( !DefaultEmail.isEmpty() )
225 adr.insertEmail( DefaultEmail, true ); // preferred 223 adr.insertEmail( DefaultEmail, true ); // preferred
226 224
227 QStringList Emails = QStringList::split(" ",el.attribute("Emails")); 225 QStringList Emails = QStringList::split(" ",el.attribute("Emails"));
228 int i; 226 int i;
229 for (i = 0;i < Emails.count();++i) { 227 for (i = 0;i < Emails.count();++i) {
230 if ( Emails[i] != DefaultEmail ) 228 if ( Emails[i] != DefaultEmail )
231 adr.insertEmail( Emails[i], false ); 229 adr.insertEmail( Emails[i], false );
232 } 230 }
233 231
234 KABC::PhoneNumber homePhoneNum( el.attribute( "HomePhone" ), 232 KABC::PhoneNumber homePhoneNum( el.attribute( "HomePhone" ),
235 KABC::PhoneNumber::Home ); 233 KABC::PhoneNumber::Home );
236 KABC::PhoneNumber homeFax( el.attribute( "HomeFax" ), 234 KABC::PhoneNumber homeFax( el.attribute( "HomeFax" ),
237 KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax ); 235 KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax );
238 236
239 KABC::PhoneNumber homeMobile( el.attribute( "HomeMobile" ), 237 KABC::PhoneNumber homeMobile( el.attribute( "HomeMobile" ),
240 KABC::PhoneNumber::Cell ); 238 KABC::PhoneNumber::Cell );
241 239
242 if ( !homePhoneNum.number().isEmpty() ) 240 if ( !homePhoneNum.number().isEmpty() )
243 adr.insertPhoneNumber( homePhoneNum ); 241 adr.insertPhoneNumber( homePhoneNum );
244 if ( !homeFax.number().isEmpty() ) 242 if ( !homeFax.number().isEmpty() )
245 adr.insertPhoneNumber( homeFax ); 243 adr.insertPhoneNumber( homeFax );
246 if ( !homeMobile.number().isEmpty() ) 244 if ( !homeMobile.number().isEmpty() )
247 adr.insertPhoneNumber( homeMobile ); 245 adr.insertPhoneNumber( homeMobile );
248 246
249 KABC::Address business( KABC::Address::Work ); 247 KABC::Address business( KABC::Address::Work );
250 business.setStreet( el.attribute( "BusinessStreet" ) ); 248 business.setStreet( el.attribute( "BusinessStreet" ) );
251 business.setLocality( el.attribute( "BusinessCity" ) ); 249 business.setLocality( el.attribute( "BusinessCity" ) );
252 business.setRegion( el.attribute( "BusinessState" ) ); 250 business.setRegion( el.attribute( "BusinessState" ) );
253 business.setPostalCode( el.attribute( "BusinessZip" ) ); 251 business.setPostalCode( el.attribute( "BusinessZip" ) );
254 business.setCountry( el.attribute( "BusinessCountry" ) ); 252 business.setCountry( el.attribute( "BusinessCountry" ) );
255 253
256 if ( !business.isEmpty() ) 254 if ( !business.isEmpty() )
257 adr.insertAddress( business ); 255 adr.insertAddress( business );
258 256
259 KABC::Address home( KABC::Address::Home ); 257 KABC::Address home( KABC::Address::Home );
260 home.setStreet( el.attribute( "HomeStreet" ) ); 258 home.setStreet( el.attribute( "HomeStreet" ) );
261 home.setLocality( el.attribute( "HomeCity" ) ); 259 home.setLocality( el.attribute( "HomeCity" ) );
262 home.setRegion( el.attribute( "HomeState" ) ); 260 home.setRegion( el.attribute( "HomeState" ) );
263 home.setPostalCode( el.attribute( "HomeZip" ) ); 261 home.setPostalCode( el.attribute( "HomeZip" ) );
264 home.setCountry( el.attribute( "HomeCountry" ) ); 262 home.setCountry( el.attribute( "HomeCountry" ) );
265 263
266 if ( !home.isEmpty() ) 264 if ( !home.isEmpty() )
267 adr.insertAddress( home ); 265 adr.insertAddress( home );
268 266
269 adr.setNickName( el.attribute( "Nickname" ) ); 267 adr.setNickName( el.attribute( "Nickname" ) );
270 adr.setNote( el.attribute( "Notes" ) ); 268 adr.setNote( el.attribute( "Notes" ) );
271 269
272 { 270 {
273 QStringList categories = QStringList::split(";", el.attribute("Categories" ) ); 271 QStringList categories = QStringList::split(";", el.attribute("Categories" ) );
274 QString cat; 272 QString cat;
275 QStringList added; 273 QStringList added;
276 for ( uint i = 0; i < categories.count(); i++ ) { 274 for ( uint i = 0; i < categories.count(); i++ ) {
277 cat = m_edit->categoryById( categories[ i ], "Contacts" ); 275 cat = m_edit->categoryById( categories[ i ], "Contacts" );
278 276
279 // if name is not empty and we did not add the 277 // if name is not empty and we did not add the
280 // cat try to repair broken files 278 // cat try to repair broken files
281 if ( !cat.isEmpty() && !added.contains( cat ) ) { 279 if ( !cat.isEmpty() && !added.contains( cat ) ) {
282 adr.insertCategory( cat ); 280 adr.insertCategory( cat );
283 added << cat; 281 added << cat;
284 } 282 }
285 } 283 }
286 } 284 }
287 285
288 if ( !el.attribute( "Department" ).isEmpty() ) 286 if ( !el.attribute( "Department" ).isEmpty() )
289 adr.insertCustom( "KADDRESSBOOK", "X-Department", el.attribute( "Department" ) ); 287 adr.insertCustom( "KADDRESSBOOK", "X-Department", el.attribute( "Department" ) );
290 if ( !el.attribute( "HomeWebPage" ).isEmpty() ) 288 if ( !el.attribute( "HomeWebPage" ).isEmpty() )
291 adr.insertCustom( "opie", "HomeWebPage", el.attribute( "HomeWebPage" ) ); 289 adr.insertCustom( "opie", "HomeWebPage", el.attribute( "HomeWebPage" ) );
292 if ( !el.attribute( "Spouse" ).isEmpty() ) 290 if ( !el.attribute( "Spouse" ).isEmpty() )
293 adr.insertCustom( "KADDRESSBOOK", "X-SpousesName", el.attribute( "Spouse" ) ); 291 adr.insertCustom( "KADDRESSBOOK", "X-SpousesName", el.attribute( "Spouse" ) );
294 if ( !el.attribute( "Gender" ).isEmpty() ) { 292 if ( !el.attribute( "Gender" ).isEmpty() ) {
295 if ( el.attribute( "Gender" ) == "1" ) 293 if ( el.attribute( "Gender" ) == "1" )
296 adr.insertCustom( "KADDRESSBOOK", "X-Gender", "male" ); 294 adr.insertCustom( "KADDRESSBOOK", "X-Gender", "male" );
297 else if ( el.attribute( "Gender" ) == "2" ) 295 else if ( el.attribute( "Gender" ) == "2" )
298 adr.insertCustom( "KADDRESSBOOK", "X-Gender", "female" ); 296 adr.insertCustom( "KADDRESSBOOK", "X-Gender", "female" );
299 } 297 }
300 QDate ann = dateFromString( el.attribute( "Anniversary" ) ); 298 QDate ann = dateFromString( el.attribute( "Anniversary" ) );
301 if ( ann.isValid() ) { 299 if ( ann.isValid() ) {
302 QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate); 300 QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate);
303 adr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt ); 301 adr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt );
304 } 302 }
305 303
306 if ( !el.attribute( "Children" ).isEmpty() ) 304 if ( !el.attribute( "Children" ).isEmpty() )
307 adr.insertCustom("KADDRESSBOOK", "X-Children", el.attribute("Children") ); 305 adr.insertCustom("KADDRESSBOOK", "X-Children", el.attribute("Children") );
308 if ( !el.attribute( "Office" ).isEmpty() ) 306 if ( !el.attribute( "Office" ).isEmpty() )
309 adr.insertCustom("KADDRESSBOOK", "X-Office", el.attribute("Office") ); 307 adr.insertCustom("KADDRESSBOOK", "X-Office", el.attribute("Office") );
310 if ( !el.attribute( "Profession" ).isEmpty() ) 308 if ( !el.attribute( "Profession" ).isEmpty() )
311 adr.insertCustom("KADDRESSBOOK", "X-Profession", el.attribute("Profession") ); 309 adr.insertCustom("KADDRESSBOOK", "X-Profession", el.attribute("Profession") );
312 if ( !el.attribute( "Assistant" ).isEmpty() ) 310 if ( !el.attribute( "Assistant" ).isEmpty() )
313 adr.insertCustom("KADDRESSBOOK", "X-AssistantsName", el.attribute("Assistant") ); 311 adr.insertCustom("KADDRESSBOOK", "X-AssistantsName", el.attribute("Assistant") );
314 if ( !el.attribute( "Manager" ).isEmpty() ) 312 if ( !el.attribute( "Manager" ).isEmpty() )
315 adr.insertCustom("KADDRESSBOOK", "X-ManagersName", el.attribute("Manager") ); 313 adr.insertCustom("KADDRESSBOOK", "X-ManagersName", el.attribute("Manager") );
316 314
317 315
318 } 316 }
319 return true; 317 return true;
320} 318}
321 319
322bool QtopiaConverter::addresseeToQtopia( const Addressee &ab, QTextStream *stream ) 320bool QtopiaConverter::addresseeToQtopia( const Addressee &ab, QTextStream *stream )
323{ 321{
324 *stream << "<Contact "; 322 *stream << "<Contact ";
325 *stream << "FirstName=\"" << escape(ab.givenName()) << "\" "; 323 *stream << "FirstName=\"" << escape(ab.givenName()) << "\" ";
326 *stream << "MiddleName=\"" << escape(ab.additionalName()) << "\" "; 324 *stream << "MiddleName=\"" << escape(ab.additionalName()) << "\" ";
327 *stream << "LastName=\"" << escape(ab.familyName()) << "\" "; 325 *stream << "LastName=\"" << escape(ab.familyName()) << "\" ";
328 *stream << "Suffix=\"" << escape(ab.suffix()) << "\" "; 326 *stream << "Suffix=\"" << escape(ab.suffix()) << "\" ";
329 327
330 QString sortStr; 328 QString sortStr;
331 sortStr = ab.formattedName(); 329 sortStr = ab.formattedName();
332 /* is formattedName is empty we use the assembled name as fallback */ 330 /* is formattedName is empty we use the assembled name as fallback */
333 if (sortStr.isEmpty() ) 331 if (sortStr.isEmpty() )
334 sortStr = ab.assembledName(); 332 sortStr = ab.assembledName();
335 *stream << "FileAs=\"" << escape(sortStr) << "\" "; 333 *stream << "FileAs=\"" << escape(sortStr) << "\" ";
336 334
337 *stream << "JobTitle=\"" << escape(ab.role()) << "\" "; 335 *stream << "JobTitle=\"" << escape(ab.role()) << "\" ";
338 *stream << "Department=\"" << escape(ab.custom( "KADDRESSBOOK", "X-Department" )) << "\" "; 336 *stream << "Department=\"" << escape(ab.custom( "KADDRESSBOOK", "X-Department" )) << "\" ";
339 *stream << "Company=\"" << escape(ab.organization()) << "\" "; 337 *stream << "Company=\"" << escape(ab.organization()) << "\" ";
340 338
341 KABC::PhoneNumber businessPhoneNum = ab.phoneNumber(KABC::PhoneNumber::Work ); 339 KABC::PhoneNumber businessPhoneNum = ab.phoneNumber(KABC::PhoneNumber::Work );
342 *stream << "BusinessPhone=\"" << escape( businessPhoneNum.number() ) << "\" "; 340 *stream << "BusinessPhone=\"" << escape( businessPhoneNum.number() ) << "\" ";
343 341
344 KABC::PhoneNumber businessFaxNum = ab.phoneNumber(KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax ); 342 KABC::PhoneNumber businessFaxNum = ab.phoneNumber(KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax );
345 *stream << "BusinessFax=\"" << escape( businessFaxNum.number() )<< "\" "; 343 *stream << "BusinessFax=\"" << escape( businessFaxNum.number() )<< "\" ";
346 344
347 KABC::PhoneNumber businessMobile = ab.phoneNumber(KABC::PhoneNumber::Work | KABC::PhoneNumber::Cell ); 345 KABC::PhoneNumber businessMobile = ab.phoneNumber(KABC::PhoneNumber::Work | KABC::PhoneNumber::Cell );
348 *stream << "BusinessMobile=\"" << escape( businessMobile.number() ) << "\" "; 346 *stream << "BusinessMobile=\"" << escape( businessMobile.number() ) << "\" ";
349 347
350 *stream << "DefaultEmail=\"" << escape( ab.preferredEmail() ) << "\" "; 348 *stream << "DefaultEmail=\"" << escape( ab.preferredEmail() ) << "\" ";
351 QStringList list = ab.emails(); 349 QStringList list = ab.emails();
352 if ( list.count() > 0 ) { 350 if ( list.count() > 0 ) {
353 QStringList::Iterator it = list.begin(); 351 QStringList::Iterator it = list.begin();
354 *stream << "Emails=\"" << escape( *it ); 352 *stream << "Emails=\"" << escape( *it );
355 while (++it != list.end()) 353 while (++it != list.end())
356 *stream << ' ' << escape( *it ); 354 *stream << ' ' << escape( *it );
357 *stream << "\" "; 355 *stream << "\" ";
358 } 356 }
359 357
360 KABC::PhoneNumber homePhoneNum = ab.phoneNumber(KABC::PhoneNumber::Home ); 358 KABC::PhoneNumber homePhoneNum = ab.phoneNumber(KABC::PhoneNumber::Home );
361 *stream << "HomePhone=\"" << escape( homePhoneNum.number() ) << "\" "; 359 *stream << "HomePhone=\"" << escape( homePhoneNum.number() ) << "\" ";
362 360
363 KABC::PhoneNumber homeFax = ab.phoneNumber( KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax ); 361 KABC::PhoneNumber homeFax = ab.phoneNumber( KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax );
364 *stream << "HomeFax=\"" << escape( homeFax.number() ) << "\" "; 362 *stream << "HomeFax=\"" << escape( homeFax.number() ) << "\" ";
365 363
366 KABC::PhoneNumber homeMobile = ab.phoneNumber( KABC::PhoneNumber::Cell ); 364 KABC::PhoneNumber homeMobile = ab.phoneNumber( KABC::PhoneNumber::Cell );
367 *stream << "HomeMobile=\"" << escape( homeMobile.number() ) << "\" "; 365 *stream << "HomeMobile=\"" << escape( homeMobile.number() ) << "\" ";
368 366
369 KABC::Address business = ab.address(KABC::Address::Work ); 367 KABC::Address business = ab.address(KABC::Address::Work );
370 *stream << "BusinessStreet=\"" << escape( business.street() ) << "\" "; 368 *stream << "BusinessStreet=\"" << escape( business.street() ) << "\" ";
371 *stream << "BusinessCity=\"" << escape( business.locality() ) << "\" "; 369 *stream << "BusinessCity=\"" << escape( business.locality() ) << "\" ";
372 *stream << "BusinessZip=\"" << escape( business.postalCode() ) << "\" "; 370 *stream << "BusinessZip=\"" << escape( business.postalCode() ) << "\" ";
373 *stream << "BusinessCountry=\"" << escape( business.country() ) << "\" "; 371 *stream << "BusinessCountry=\"" << escape( business.country() ) << "\" ";
374 *stream << "BusinessState=\"" << escape( business.region() ) << "\" "; 372 *stream << "BusinessState=\"" << escape( business.region() ) << "\" ";
375 //stream << "BusinessPager=\"" << << "\" "; 373 //stream << "BusinessPager=\"" << << "\" ";
376 *stream << "Office=\"" << escape( ab.custom( "KADDRESSBOOK", "X-Office" ) ) << "\" "; 374 *stream << "Office=\"" << escape( ab.custom( "KADDRESSBOOK", "X-Office" ) ) << "\" ";
377 *stream << "Profession=\"" << escape( ab.custom( "KADDRESSBOOK", "X-Profession" ) ) << "\" "; 375 *stream << "Profession=\"" << escape( ab.custom( "KADDRESSBOOK", "X-Profession" ) ) << "\" ";
378 *stream << "Assistant=\"" << escape( ab.custom( "KADDRESSBOOK", "X-AssistantsName") ) << "\" "; 376 *stream << "Assistant=\"" << escape( ab.custom( "KADDRESSBOOK", "X-AssistantsName") ) << "\" ";
379 *stream << "Manager=\"" << escape( ab.custom( "KADDRESSBOOK", "X-ManagersName" ) ) << "\" "; 377 *stream << "Manager=\"" << escape( ab.custom( "KADDRESSBOOK", "X-ManagersName" ) ) << "\" ";
380 378
381 KABC::Address home = ab.address( KABC::Address::Home ); 379 KABC::Address home = ab.address( KABC::Address::Home );
382 *stream << "HomeStreet=\"" << escape( home.street() ) << "\" "; 380 *stream << "HomeStreet=\"" << escape( home.street() ) << "\" ";
383 *stream << "HomeCity=\"" << escape( home.locality() ) << "\" "; 381 *stream << "HomeCity=\"" << escape( home.locality() ) << "\" ";
384 *stream << "HomeState=\"" << escape( home.region() ) << "\" "; 382 *stream << "HomeState=\"" << escape( home.region() ) << "\" ";
385 *stream << "HomeZip=\"" << escape( home.postalCode() ) << "\" "; 383 *stream << "HomeZip=\"" << escape( home.postalCode() ) << "\" ";
386 *stream << "HomeCountry=\"" << escape( home.country() ) << "\" "; 384 *stream << "HomeCountry=\"" << escape( home.country() ) << "\" ";
387 385
388 *stream << "HomeWebPage=\"" << escape( ab.custom( "opie", "HomeWebPage" ) ) << "\" "; 386 *stream << "HomeWebPage=\"" << escape( ab.custom( "opie", "HomeWebPage" ) ) << "\" ";
389 *stream << "Spouse=\"" << escape( ab.custom( "KADDRESSBOOK", "X-SpousesName") ) << "\" "; 387 *stream << "Spouse=\"" << escape( ab.custom( "KADDRESSBOOK", "X-SpousesName") ) << "\" ";
390 QString gen = "0"; 388 QString gen = "0";
391 if ( ab.custom( "KADDRESSBOOK", "X-Gender") == "male" ) 389 if ( ab.custom( "KADDRESSBOOK", "X-Gender") == "male" )
392 gen = "1"; 390 gen = "1";
393 else if ( ab.custom( "KADDRESSBOOK", "X-Gender") == "female" ) 391 else if ( ab.custom( "KADDRESSBOOK", "X-Gender") == "female" )
394 gen = "2"; 392 gen = "2";
395 *stream << "Gender=\"" << escape( gen ) << "\" "; 393 *stream << "Gender=\"" << escape( gen ) << "\" ";
396 394
397 if ( ab.birthday().date().isValid() ) 395 if ( ab.birthday().date().isValid() )
398 *stream << "Birthday=\"" << escape( dateToString(ab.birthday().date() ) ) << "\" "; 396 *stream << "Birthday=\"" << escape( dateToString(ab.birthday().date() ) ) << "\" ";
399 397
400 { 398 {
401 QDate ann = KGlobal::locale()->readDate( ab.custom("KADDRESSBOOK", "X-Anniversary" ), 399 QDate ann = KGlobal::locale()->readDate( ab.custom("KADDRESSBOOK", "X-Anniversary" ),
402 "%Y-%m-%d"); 400 "%Y-%m-%d");
403 if (ann.isValid() ) { 401 if (ann.isValid() ) {
404 *stream << "Anniversary=\"" << escape( dateToString( ann ) ) << "\" "; 402 *stream << "Anniversary=\"" << escape( dateToString( ann ) ) << "\" ";
405 } 403 }
406 } 404 }
407 *stream << "Nickname=\"" << escape( ab.nickName() ) << "\" "; 405 *stream << "Nickname=\"" << escape( ab.nickName() ) << "\" ";
408 *stream << "Children=\"" << escape( ab.custom("KADDRESSBOOK", "X-Children" ) ) << "\" "; 406 *stream << "Children=\"" << escape( ab.custom("KADDRESSBOOK", "X-Children" ) ) << "\" ";
409 *stream << "Notes=\"" << escape( ab.note() ) << "\" "; 407 *stream << "Notes=\"" << escape( ab.note() ) << "\" ";
410 *stream << "Categories=\"" << categoriesToNumber( ab.categories(), "Contacts") << "\" "; 408 *stream << "Categories=\"" << categoriesToNumber( ab.categories(), "Contacts") << "\" ";
411 409
412 QString uid = ab.uid(); 410 QString uid = ab.uid();
413 *stream << "Uid=\"" << uid << "\" "; 411 *stream << "Uid=\"" << uid << "\" ";
414 //*stream << map.toString( "addressbook", uid ); 412 //*stream << map.toString( "addressbook", uid );
415 *stream << " />" << "\n"; 413 *stream << " />" << "\n";
416 414
417 return true; 415 return true;
418} 416}
419 417
420 418
421#if 0 419#if 0
422 420
423KTempFile* AddressBook::fromKDE( KSync::AddressBookSyncee *syncee, ExtraMap& map ) 421KTempFile* AddressBook::fromKDE( KSync::AddressBookSyncee *syncee, ExtraMap& map )
424{ 422{
425 423
426} 424}
427 425
428QStringList AddressBook::attributes()const { 426QStringList AddressBook::attributes()const {
429 QStringList lst; 427 QStringList lst;
430 lst << "FirstName"; 428 lst << "FirstName";
431 lst << "MiddleName"; 429 lst << "MiddleName";
432 lst << "LastName"; 430 lst << "LastName";
433 lst << "Suffix"; 431 lst << "Suffix";
434 lst << "FileAs"; 432 lst << "FileAs";
435 lst << "JobTitle"; 433 lst << "JobTitle";
436 lst << "Department"; 434 lst << "Department";
437 lst << "Company"; 435 lst << "Company";
438 lst << "BusinessPhone"; 436 lst << "BusinessPhone";
439 lst << "BusinessFax"; 437 lst << "BusinessFax";
440 lst << "BusinessMobile"; 438 lst << "BusinessMobile";
441 lst << "DefaultEmail"; 439 lst << "DefaultEmail";
442 lst << "Emails"; 440 lst << "Emails";
443 lst << "HomePhone"; 441 lst << "HomePhone";
444 lst << "HomeFax"; 442 lst << "HomeFax";
445 lst << "HomeMobile"; 443 lst << "HomeMobile";
446 lst << "BusinessStreet"; 444 lst << "BusinessStreet";
447 lst << "BusinessCity"; 445 lst << "BusinessCity";
448 lst << "BusinessZip"; 446 lst << "BusinessZip";
449 lst << "BusinessCountry"; 447 lst << "BusinessCountry";
450 lst << "BusinessState"; 448 lst << "BusinessState";
451 lst << "Office"; 449 lst << "Office";
452 lst << "Profession"; 450 lst << "Profession";
453 lst << "Assistant"; 451 lst << "Assistant";
454 lst << "Manager"; 452 lst << "Manager";
455 lst << "HomeStreet"; 453 lst << "HomeStreet";
456 lst << "HomeCity"; 454 lst << "HomeCity";
457 lst << "HomeState"; 455 lst << "HomeState";
458 lst << "HomeZip"; 456 lst << "HomeZip";
459 lst << "HomeCountry"; 457 lst << "HomeCountry";
460 lst << "HomeWebPage"; 458 lst << "HomeWebPage";
461 lst << "Spouse"; 459 lst << "Spouse";
462 lst << "Gender"; 460 lst << "Gender";
463 lst << "Anniversary"; 461 lst << "Anniversary";
464 lst << "Nickname"; 462 lst << "Nickname";
465 lst << "Children"; 463 lst << "Children";
466 lst << "Notes"; 464 lst << "Notes";
467 lst << "Categories"; 465 lst << "Categories";
468 lst << "Uid"; 466 lst << "Uid";
469 lst << "Birthday"; 467 lst << "Birthday";
470 468
471 return lst; 469 return lst;
472} 470}
473 471
474 472
475 473
476#endif 474#endif
477 475
478 476
479CategoryEdit::CategoryEdit(){ 477CategoryEdit::CategoryEdit(){
480} 478}
481CategoryEdit::CategoryEdit(const QString &fileName){ 479CategoryEdit::CategoryEdit(const QString &fileName){
482 parse( fileName ); 480 parse( fileName );
483} 481}
484CategoryEdit::~CategoryEdit(){ 482CategoryEdit::~CategoryEdit(){
485} 483}
486void CategoryEdit::save(const QString& fileName)const{ 484void CategoryEdit::save(const QString& fileName)const{
487 QFile file( fileName ); 485 QFile file( fileName );
488 QString endl = "\n"; 486 QString endl = "\n";
489 if ( file.open( IO_WriteOnly ) ) { 487 if ( file.open( IO_WriteOnly ) ) {
490 QTextStream stream( &file ); 488 QTextStream stream( &file );
491 stream.setEncoding( QTextStream::UnicodeUTF8 ); 489 stream.setEncoding( QTextStream::UnicodeUTF8 );
492 stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl; 490 stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
493 stream << "<!DOCTYPE CategoryList>" << endl; 491 stream << "<!DOCTYPE CategoryList>" << endl;
494 stream << "<Categories>" << endl; 492 stream << "<Categories>" << endl;
495 for ( QValueList<OpieCategories>::ConstIterator it = m_categories.begin(); 493 for ( QValueList<OpieCategories>::ConstIterator it = m_categories.begin();
496 it != m_categories.end(); ++it ) 494 it != m_categories.end(); ++it )
497 { 495 {
498 stream << "<Category id=\""<< ( (*it).id() ) << "\" "; 496 stream << "<Category id=\""<< ( (*it).id() ) << "\" ";
499 497
500 if ( !(*it).app().isEmpty() ) 498 if ( !(*it).app().isEmpty() )
501 stream << " app=\""<< ( (*it).app() ) << "\" "; 499 stream << " app=\""<< ( (*it).app() ) << "\" ";
502 500
503 stream << "name=\"" << ( (*it).name() ) << "\" "; 501 stream << "name=\"" << ( (*it).name() ) << "\" ";
504 stream << " />" << endl; 502 stream << " />" << endl;
505 } 503 }
506 stream << "</Categories>" << endl; 504 stream << "</Categories>" << endl;
507 file.close(); 505 file.close();
508 } 506 }
509} 507}
510int CategoryEdit::addCategory( const QString &name, int id ){ 508int CategoryEdit::addCategory( const QString &name, int id ){
511 return addCategory( QString::null, name, id ); 509 return addCategory( QString::null, name, id );
512} 510}
513int CategoryEdit::addCategory( const QString &appName, const QString &name, int id ){ 511int CategoryEdit::addCategory( const QString &appName, const QString &name, int id ){
514 if ( id == 0 ) { 512 if ( id == 0 ) {
515 // code from tt 513 // code from tt
516 //generate uid 514 //generate uid
517 QDateTime dt = QDateTime::currentDateTime(); 515 QDateTime dt = QDateTime::currentDateTime();
518 id = -1 * (int) dt.secsTo( QDateTime(QDate( 2000,1,1)) ); 516 id = -1 * (int) dt.secsTo( QDateTime(QDate( 2000,1,1)) );
519 while ( ids.contains( id ) ){ 517 while ( ids.contains( id ) ){
520 id += -1; 518 id += -1;
521 if ( id > 0 ) 519 if ( id > 0 )
522 id = -1; 520 id = -1;
523 } 521 }
524 } 522 }
525 ids.insert( id, TRUE ); 523 ids.insert( id, TRUE );
526 OpieCategories categories(QString::number(id), name, appName); 524 OpieCategories categories(QString::number(id), name, appName);
527 //pending FIXME LR m_categories.remove( categories); 525 //pending FIXME LR m_categories.remove( categories);
528 m_categories.append( categories); 526 m_categories.append( categories);
529 return id; 527 return id;
530} 528}
531/* 529/*
532 * we parse the simple Category File here 530 * we parse the simple Category File here
533 * We also keep track of global Cats 531 * We also keep track of global Cats
534 * and Of Organizer and Contact cats and then 532 * and Of Organizer and Contact cats and then
535 * we will add them to the kde side... 533 * we will add them to the kde side...
536 */ 534 */
537void CategoryEdit::parse( const QString &tempFile ){ 535void CategoryEdit::parse( const QString &tempFile ){
538 clear(); 536 clear();
539 537
540 QDomDocument doc( "mydocument" ); 538 QDomDocument doc( "mydocument" );
541 QFile f( tempFile ); 539 QFile f( tempFile );
542 if ( !f.open( IO_ReadOnly ) ) 540 if ( !f.open( IO_ReadOnly ) )
543 return; 541 return;
544 542
545 if ( !doc.setContent( &f ) ) { 543 if ( !doc.setContent( &f ) ) {
546 f.close(); 544 f.close();
547 return; 545 return;
548 } 546 }
549 f.close(); 547 f.close();
550 548
551 QStringList global, contact, organizer; 549 QStringList global, contact, organizer;
552 550
553 // print out the element names of all elements that are a direct child 551 // print out the element names of all elements that are a direct child
554 // of the outermost element. 552 // of the outermost element.
diff --git a/kabc/plugins/qtopia/qtopiaconverter.h b/kabc/plugins/qtopia/qtopiaconverter.h
index d318ded..cb5b433 100644
--- a/kabc/plugins/qtopia/qtopiaconverter.h
+++ b/kabc/plugins/qtopia/qtopiaconverter.h
@@ -1,132 +1,130 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
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$Id$ 24$Id$
25*/ 25*/
26 26
27#ifndef KABC_QTOPIACONVERTER_H 27#ifndef KABC_QTOPIACONVERTER_H
28#define KABC_QTOPIACONVERTER_H 28#define KABC_QTOPIACONVERTER_H
29 29
30#include <qstring.h> 30#include <qstring.h>
31 31
32#include "addressee.h" 32#include "addressee.h"
33//#include <qpe/pim/contact.h>
34//#include <qpe/quuid.h>
35 33
36#include <xml/qdom.h> 34#include <xml/qdom.h>
37class Categories; 35class Categories;
38 36
39namespace KABC { 37namespace KABC {
40 38
41 39
42 40
43class OpieCategories { 41class OpieCategories {
44 public: 42 public:
45 //friend class KSync::OpieSocket; 43 //friend class KSync::OpieSocket;
46 friend bool operator== ( const OpieCategories &a, const OpieCategories &b ); 44 friend bool operator== ( const OpieCategories &a, const OpieCategories &b );
47 OpieCategories(); 45 OpieCategories();
48 OpieCategories(const QString &id, const QString &name, const QString &app ); 46 OpieCategories(const QString &id, const QString &name, const QString &app );
49 OpieCategories(const OpieCategories & ); 47 OpieCategories(const OpieCategories & );
50 ~OpieCategories() {}; 48 ~OpieCategories() {};
51 OpieCategories &operator=(const OpieCategories & ); 49 OpieCategories &operator=(const OpieCategories & );
52 QString id()const; 50 QString id()const;
53 QString name()const; 51 QString name()const;
54 QString app()const; 52 QString app()const;
55 53
56 private: 54 private:
57 QString m_name; 55 QString m_name;
58 QString m_app; 56 QString m_app;
59 QString m_id; 57 QString m_id;
60}; 58};
61 59
62 60
63 class CategoryEdit { 61 class CategoryEdit {
64 public: 62 public:
65 CategoryEdit(); 63 CategoryEdit();
66 CategoryEdit(const QString &fileName); 64 CategoryEdit(const QString &fileName);
67 ~CategoryEdit(); 65 ~CategoryEdit();
68 66
69 void save(const QString&) const; 67 void save(const QString&) const;
70 int addCategory( const QString &name, int id = 0 ); 68 int addCategory( const QString &name, int id = 0 );
71 int addCategory(const QString &appName, const QString &name, int id = 0); 69 int addCategory(const QString &appName, const QString &name, int id = 0);
72 void parse( const QString &fileName ); 70 void parse( const QString &fileName );
73 71
74 QString categoryById(const QString &id, const QString &app )const; 72 QString categoryById(const QString &id, const QString &app )const;
75 QStringList categoriesByIds( const QStringList& ids, const QString& app ); 73 QStringList categoriesByIds( const QStringList& ids, const QString& app );
76 74
77 void clear(); 75 void clear();
78 QValueList<OpieCategories> categories()const { return m_categories; }; 76 QValueList<OpieCategories> categories()const { return m_categories; };
79 private: 77 private:
80 /** 78 /**
81 * this function will be used internally to update the kde categories... 79 * this function will be used internally to update the kde categories...
82 */ 80 */
83 void updateKDE( const QString& app, const QStringList& categories ); 81 void updateKDE( const QString& app, const QStringList& categories );
84 QMap<int, bool> ids; // from tt Qtopia::UidGen 82 QMap<int, bool> ids; // from tt Qtopia::UidGen
85 QValueList<OpieCategories> m_categories; 83 QValueList<OpieCategories> m_categories;
86 }; 84 };
87 85
88 86
89class QtopiaConverter 87class QtopiaConverter
90{ 88{
91public: 89public:
92 90
93 /** 91 /**
94 * Constructor. 92 * Constructor.
95 */ 93 */
96 QtopiaConverter(); 94 QtopiaConverter();
97 95
98 /** 96 /**
99 * Destructor. 97 * Destructor.
100 */ 98 */
101 virtual ~QtopiaConverter(); 99 virtual ~QtopiaConverter();
102 100
103 bool init(); 101 bool init();
104 void deinit(); 102 void deinit();
105 103
106 /** 104 /**
107 * Converts a vcard string to an addressee. 105 * Converts a vcard string to an addressee.
108 * 106 *
109 * @param contact The qtopia contact. 107 * @param contact The qtopia contact.
110 * @param addr The addressee. 108 * @param addr The addressee.
111 */ 109 */
112 bool qtopiaToAddressee( const QDomElement& el, Addressee &adr ); 110 bool qtopiaToAddressee( const QDomElement& el, Addressee &adr );
113 /** 111 /**
114 * Converts an addressee to a vcard string. 112 * Converts an addressee to a vcard string.
115 * 113 *
116 * @param addr The addressee. 114 * @param addr The addressee.
117 * @param contact The qtopia contact. 115 * @param contact The qtopia contact.
118 */ 116 */
119 bool addresseeToQtopia( const Addressee &ab, QTextStream *stream ); 117 bool addresseeToQtopia( const Addressee &ab, QTextStream *stream );
120 118
121 private: 119 private:
122 QString categoriesToNumber( const QStringList &list, const QString &app ); 120 QString categoriesToNumber( const QStringList &list, const QString &app );
123 QString escape( const QString& s){ return s;}; 121 QString escape( const QString& s){ return s;};
124 CategoryEdit *m_edit; 122 CategoryEdit *m_edit;
125 QDate fromString( const QString& ); 123 QDate fromString( const QString& );
126 QDate dateFromString( const QString& ); 124 QDate dateFromString( const QString& );
127 QString dateToString( const QDate& ); 125 QString dateToString( const QDate& );
128 126
129 127
130}; 128};
131} 129}
132#endif 130#endif
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp
index 4ee3c3c..95fa541 100644
--- a/kabc/plugins/qtopia/resourceqtopia.cpp
+++ b/kabc/plugins/qtopia/resourceqtopia.cpp
@@ -1,330 +1,328 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
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#include <sys/types.h> 27#include <sys/types.h>
28#include <sys/stat.h> 28#include <sys/stat.h>
29#include <unistd.h> 29#include <unistd.h>
30 30
31#include <qdir.h> 31#include <qdir.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qfileinfo.h> 34#include <qfileinfo.h>
35#include <qregexp.h> 35#include <qregexp.h>
36//US #include <qtimer.h> 36//US #include <qtimer.h>
37 37
38#include <kapplication.h> 38#include <kapplication.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <kdebug.h> 40#include <kdebug.h>
41#include <klocale.h> 41#include <klocale.h>
42//US #include <ksavefile.h> 42//US #include <ksavefile.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kmessagebox.h> 44#include <kmessagebox.h>
45 45
46#include <qpe/pim/addressbookaccess.h>
47
48 46
49#include "resourceqtopiaconfig.h" 47#include "resourceqtopiaconfig.h"
50#include "stdaddressbook.h" 48#include "stdaddressbook.h"
51 49
52#include "qtopiaconverter.h" 50#include "qtopiaconverter.h"
53 51
54#include "resourceqtopia.h" 52#include "resourceqtopia.h"
55 53
56using namespace KABC; 54using namespace KABC;
57extern "C" 55extern "C"
58{ 56{
59 void *init_microkabc_qtopia() 57 void *init_microkabc_qtopia()
60 { 58 {
61 return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig>(); 59 return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig>();
62 } 60 }
63} 61}
64 62
65ResourceQtopia::ResourceQtopia( const KConfig *config ) 63ResourceQtopia::ResourceQtopia( const KConfig *config )
66 : Resource( config ), mConverter (0) 64 : Resource( config ), mConverter (0)
67{ 65{
68 // we can not choose the filename. Therefore use the default to display 66 // we can not choose the filename. Therefore use the default to display
69 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; 67 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
70 init( fileName ); 68 init( fileName );
71} 69}
72 70
73ResourceQtopia::ResourceQtopia( const QString &fileName ) 71ResourceQtopia::ResourceQtopia( const QString &fileName )
74 : Resource( 0 ) 72 : Resource( 0 )
75{ 73{
76 init( fileName ); 74 init( fileName );
77} 75}
78 76
79void ResourceQtopia::init( const QString &fileName ) 77void ResourceQtopia::init( const QString &fileName )
80{ 78{
81#ifdef _USE_DIRWATCH_ 79#ifdef _USE_DIRWATCH_
82 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 80 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
83 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); 81 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
84 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 82 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
85#endif 83#endif
86 setFileName( fileName ); 84 setFileName( fileName );
87} 85}
88 86
89ResourceQtopia::~ResourceQtopia() 87ResourceQtopia::~ResourceQtopia()
90{ 88{
91 if (mConverter != 0) 89 if (mConverter != 0)
92 delete mConverter; 90 delete mConverter;
93 91
94} 92}
95 93
96void ResourceQtopia::writeConfig( KConfig *config ) 94void ResourceQtopia::writeConfig( KConfig *config )
97{ 95{
98 Resource::writeConfig( config ); 96 Resource::writeConfig( config );
99} 97}
100 98
101Ticket *ResourceQtopia::requestSaveTicket() 99Ticket *ResourceQtopia::requestSaveTicket()
102{ 100{
103 kdDebug(5700) << "ResourceQtopia::requestSaveTicket()" << endl; 101 kdDebug(5700) << "ResourceQtopia::requestSaveTicket()" << endl;
104 102
105 qDebug("ResourceQtopia::requestSaveTicket: %s", fileName().latin1()); 103 qDebug("ResourceQtopia::requestSaveTicket: %s", fileName().latin1());
106 104
107 if ( !addressBook() ) return 0; 105 if ( !addressBook() ) return 0;
108 106
109 if ( !lock( fileName() ) ) { 107 if ( !lock( fileName() ) ) {
110 kdDebug(5700) << "ResourceQtopia::requestSaveTicket(): Unable to lock file '" 108 kdDebug(5700) << "ResourceQtopia::requestSaveTicket(): Unable to lock file '"
111 << fileName() << "'" << endl; 109 << fileName() << "'" << endl;
112 return 0; 110 return 0;
113 } 111 }
114 return createTicket( this ); 112 return createTicket( this );
115} 113}
116 114
117 115
118bool ResourceQtopia::doOpen() 116bool ResourceQtopia::doOpen()
119{ 117{
120 qDebug("ResourceQtopia::doOpen(): %s", fileName().latin1()); 118 qDebug("ResourceQtopia::doOpen(): %s", fileName().latin1());
121 119
122 120
123 if (mConverter == 0) 121 if (mConverter == 0)
124 { 122 {
125 mConverter = new QtopiaConverter(); 123 mConverter = new QtopiaConverter();
126 bool res = mConverter->init(); 124 bool res = mConverter->init();
127 if ( !res ) 125 if ( !res )
128 { 126 {
129 QString msg("Unable to initialize qtopia converter. Most likely a problem with the category file"); 127 QString msg("Unable to initialize qtopia converter. Most likely a problem with the category file");
130 qDebug(msg); 128 qDebug(msg);
131 return false; 129 return false;
132 } 130 }
133 } 131 }
134 132
135 return true; 133 return true;
136} 134}
137 135
138void ResourceQtopia::doClose() 136void ResourceQtopia::doClose()
139{ 137{
140 qDebug("ResourceQtopia::doClose: %s", fileName().latin1()); 138 qDebug("ResourceQtopia::doClose: %s", fileName().latin1());
141 139
142 140
143 // it seems so, that deletion of access deletes backend as well 141 // it seems so, that deletion of access deletes backend as well
144 //delete backend; 142 //delete backend;
145 143
146 return; 144 return;
147} 145}
148 146
149bool ResourceQtopia::load() 147bool ResourceQtopia::load()
150{ 148{
151 149
152 QFile file( fileName() ); 150 QFile file( fileName() );
153 if ( !file.open(IO_ReadOnly ) ) { 151 if ( !file.open(IO_ReadOnly ) ) {
154 return false; 152 return false;
155 } 153 }
156 154
157 QDomDocument doc("mydocument" ); 155 QDomDocument doc("mydocument" );
158 if ( !doc.setContent( &file ) ) { 156 if ( !doc.setContent( &file ) ) {
159 file.close(); 157 file.close();
160 return false; 158 return false;
161 } 159 }
162 bool res; 160 bool res;
163 QDomElement docElem = doc.documentElement( ); 161 QDomElement docElem = doc.documentElement( );
164 QDomNode n = docElem.firstChild(); 162 QDomNode n = docElem.firstChild();
165 while ( !n.isNull() ) { 163 while ( !n.isNull() ) {
166 QDomElement e = n.toElement(); 164 QDomElement e = n.toElement();
167 if ( !e.isNull() ) { 165 if ( !e.isNull() ) {
168 if ( e.tagName() == QString::fromLatin1( "Contacts" ) ) { 166 if ( e.tagName() == QString::fromLatin1( "Contacts" ) ) {
169 QDomNode no = e.firstChild(); 167 QDomNode no = e.firstChild();
170 while ( !no.isNull() ) { 168 while ( !no.isNull() ) {
171 QDomElement el = no.toElement(); 169 QDomElement el = no.toElement();
172 if ( !el.isNull() ) { 170 if ( !el.isNull() ) {
173 KABC::Addressee addressee; 171 KABC::Addressee addressee;
174 res = mConverter->qtopiaToAddressee( el, addressee ); 172 res = mConverter->qtopiaToAddressee( el, addressee );
175 if ( !addressee.isEmpty() && res ) 173 if ( !addressee.isEmpty() && res )
176 { 174 {
177 addressee.setResource( this ); 175 addressee.setResource( this );
178 addressBook()->insertAddressee( addressee ); 176 addressBook()->insertAddressee( addressee );
179 } 177 }
180 } 178 }
181 179
182 no = no.nextSibling(); 180 no = no.nextSibling();
183 } 181 }
184 } 182 }
185 } 183 }
186 184
187 n = n.nextSibling(); 185 n = n.nextSibling();
188 } 186 }
189 return true; 187 return true;
190} 188}
191 189
192bool ResourceQtopia::save( Ticket *ticket ) 190bool ResourceQtopia::save( Ticket *ticket )
193{ 191{
194#ifdef _USE_DIRWATCH_ 192#ifdef _USE_DIRWATCH_
195 mDirWatch.stopScan(); 193 mDirWatch.stopScan();
196#endif 194#endif
197 KABC::AddressBook::Iterator it; 195 KABC::AddressBook::Iterator it;
198 bool res; 196 bool res;
199 QFile file( fileName() ); 197 QFile file( fileName() );
200 if (!file.open( IO_WriteOnly ) ) { 198 if (!file.open( IO_WriteOnly ) ) {
201 return false; 199 return false;
202 } 200 }
203 QTextStream ts( &file ); 201 QTextStream ts( &file );
204 QTextStream *stream = &ts; 202 QTextStream *stream = &ts;
205 stream->setEncoding( QTextStream::UnicodeUTF8 ); 203 stream->setEncoding( QTextStream::UnicodeUTF8 );
206 *stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>" << endl; 204 *stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>" << endl;
207 *stream << " <Groups>" << endl; 205 *stream << " <Groups>" << endl;
208 *stream << " </Groups>" << endl; 206 *stream << " </Groups>" << endl;
209 *stream << " <Contacts> " << endl; 207 *stream << " <Contacts> " << endl;
210 // for all entries 208 // for all entries
211 KABC::Addressee ab; 209 KABC::Addressee ab;
212 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { 210 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
213 KABC::Addressee addressee = (*it); 211 KABC::Addressee addressee = (*it);
214 res = mConverter->addresseeToQtopia( addressee, stream ); 212 res = mConverter->addresseeToQtopia( addressee, stream );
215 if (!res == true) 213 if (!res == true)
216 { 214 {
217 qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1()); 215 qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1());
218 } 216 }
219 } 217 }
220 *stream << "</Contacts>" << endl; 218 *stream << "</Contacts>" << endl;
221 *stream << "</AddressBook>" << endl; 219 *stream << "</AddressBook>" << endl;
222 file.close(); 220 file.close();
223#ifdef _USE_DIRWATCH_ 221#ifdef _USE_DIRWATCH_
224 mDirWatch.startScan(); 222 mDirWatch.startScan();
225#endif 223#endif
226 delete ticket; 224 delete ticket;
227 unlock( fileName() ); 225 unlock( fileName() );
228 return true; 226 return true;
229} 227}
230 228
231bool ResourceQtopia::lock( const QString &lockfileName ) 229bool ResourceQtopia::lock( const QString &lockfileName )
232{ 230{
233 //disabled 231 //disabled
234 return true; 232 return true;
235 qDebug("ResourceQtopia::lock: %s", fileName().latin1()); 233 qDebug("ResourceQtopia::lock: %s", fileName().latin1());
236 QString fn = lockfileName; 234 QString fn = lockfileName;
237 235
238 KURL url(fn); 236 KURL url(fn);
239 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 237 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
240 238
241 if (QFile::exists( lockName )) 239 if (QFile::exists( lockName ))
242 { 240 {
243 qDebug("ResourceOpie::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName().latin1()); 241 qDebug("ResourceOpie::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName().latin1());
244 return false; 242 return false;
245 } 243 }
246 244
247 QString lockUniqueName; 245 QString lockUniqueName;
248 lockUniqueName = fn + KApplication::randomString( 8 ); 246 lockUniqueName = fn + KApplication::randomString( 8 );
249 247
250 url = lockUniqueName; 248 url = lockUniqueName;
251//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); 249//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
252 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); 250 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
253 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; 251 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
254 252
255 // Create unique file 253 // Create unique file
256 QFile file( mLockUniqueName ); 254 QFile file( mLockUniqueName );
257 file.open( IO_WriteOnly ); 255 file.open( IO_WriteOnly );
258 file.close(); 256 file.close();
259 257
260 // Create lock file 258 // Create lock file
261 int result = 0; 259 int result = 0;
262#ifndef _WIN32_ 260#ifndef _WIN32_
263 result = ::link( QFile::encodeName( mLockUniqueName ), 261 result = ::link( QFile::encodeName( mLockUniqueName ),
264 QFile::encodeName( lockName ) ); 262 QFile::encodeName( lockName ) );
265#endif 263#endif
266 if ( result == 0 ) { 264 if ( result == 0 ) {
267 addressBook()->emitAddressBookLocked(); 265 addressBook()->emitAddressBookLocked();
268 return true; 266 return true;
269 } 267 }
270 268
271 // TODO: check stat 269 // TODO: check stat
272 270
273 return false; 271 return false;
274} 272}
275 273
276void ResourceQtopia::unlock( const QString &fileName ) 274void ResourceQtopia::unlock( const QString &fileName )
277{ 275{
278 //disabled 276 //disabled
279 return; 277 return;
280 qDebug("ResourceQtopia::unlock() %s", fileName.latin1()); 278 qDebug("ResourceQtopia::unlock() %s", fileName.latin1());
281 279
282 QString fn = fileName; 280 QString fn = fileName;
283 KURL url(fn); 281 KURL url(fn);
284 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 282 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
285 283
286 QFile::remove( lockName ); 284 QFile::remove( lockName );
287 QFile::remove( mLockUniqueName ); 285 QFile::remove( mLockUniqueName );
288 addressBook()->emitAddressBookUnlocked(); 286 addressBook()->emitAddressBookUnlocked();
289} 287}
290 288
291void ResourceQtopia::setFileName( const QString &newFileName ) 289void ResourceQtopia::setFileName( const QString &newFileName )
292{ 290{
293#ifdef _USE_DIRWATCH_ 291#ifdef _USE_DIRWATCH_
294 mDirWatch.stopScan(); 292 mDirWatch.stopScan();
295#endif 293#endif
296 mDirWatch.removeFile( fileName() ); 294 mDirWatch.removeFile( fileName() );
297 295
298 Resource::setFileName( newFileName ); 296 Resource::setFileName( newFileName );
299 297
300 mDirWatch.addFile( fileName() ); 298 mDirWatch.addFile( fileName() );
301#ifdef _USE_DIRWATCH_ 299#ifdef _USE_DIRWATCH_
302 mDirWatch.startScan(); 300 mDirWatch.startScan();
303#endif 301#endif
304} 302}
305 303
306 304
307void ResourceQtopia::fileChanged() 305void ResourceQtopia::fileChanged()
308{ 306{
309 // There is a small theoretical chance that KDirWatch calls us before 307 // There is a small theoretical chance that KDirWatch calls us before
310 // we are fully constructed 308 // we are fully constructed
311 if (!addressBook()) 309 if (!addressBook())
312 return; 310 return;
313 311
314 QString text( i18n( "Qtopia resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) ); 312 QString text( i18n( "Qtopia resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) );
315 if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) { 313 if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) {
316 load(); 314 load();
317 addressBook()->emitAddressBookChanged(); 315 addressBook()->emitAddressBookChanged();
318 } 316 }
319} 317}
320 318
321void ResourceQtopia::removeAddressee( const Addressee &addr ) 319void ResourceQtopia::removeAddressee( const Addressee &addr )
322{ 320{
323} 321}
324 322
325void ResourceQtopia::cleanUp() 323void ResourceQtopia::cleanUp()
326{ 324{
327 unlock( fileName() ); 325 unlock( fileName() );
328} 326}
329 327
330//US #include "resourceqtopia.moc" 328//US #include "resourceqtopia.moc"
diff --git a/kabc/plugins/qtopia/resourceqtopiaconfig.cpp b/kabc/plugins/qtopia/resourceqtopiaconfig.cpp
index b2310c4..0505d0b 100644
--- a/kabc/plugins/qtopia/resourceqtopiaconfig.cpp
+++ b/kabc/plugins/qtopia/resourceqtopiaconfig.cpp
@@ -1,110 +1,107 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
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 <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> 36#include <unistd.h>
37 37
38#include <qdir.h> 38#include <qdir.h>
39#include <qfile.h> 39#include <qfile.h>
40#include "resourceqtopia.h" 40#include "resourceqtopia.h"
41//US #include <qpe/qpeapplication.h>
42
43//US #include "stdaddressbook.h"
44 41
45#include "resourceqtopiaconfig.h" 42#include "resourceqtopiaconfig.h"
46 43
47using namespace KABC; 44using namespace KABC;
48 45
49ResourceQtopiaConfig::ResourceQtopiaConfig( QWidget* parent, const char* name ) 46ResourceQtopiaConfig::ResourceQtopiaConfig( QWidget* parent, const char* name )
50 : ConfigWidget( parent, name ) 47 : ConfigWidget( parent, name )
51{ 48{
52 QGridLayout *mainLayout = new QGridLayout( this, 1, 2, 0, 49 QGridLayout *mainLayout = new QGridLayout( this, 1, 2, 0,
53 KDialog::spacingHint() ); 50 KDialog::spacingHint() );
54 51
55 QLabel *label = new QLabel( i18n( "Location:" ), this ); 52 QLabel *label = new QLabel( i18n( "Location:" ), this );
56 mFileNameEdit = new KURLRequester( this ); 53 mFileNameEdit = new KURLRequester( this );
57 54
58 connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ), 55 connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ),
59 SLOT( checkFilePermissions( const QString & ) ) ); 56 SLOT( checkFilePermissions( const QString & ) ) );
60 57
61 mainLayout->addWidget( label, 0, 0 ); 58 mainLayout->addWidget( label, 0, 0 );
62 mainLayout->addWidget( mFileNameEdit, 0, 1 ); 59 mainLayout->addWidget( mFileNameEdit, 0, 1 );
63 60
64} 61}
65 62
66void ResourceQtopiaConfig::loadSettings( KRES::Resource *res ) 63void ResourceQtopiaConfig::loadSettings( KRES::Resource *res )
67{ 64{
68//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); 65//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res );
69 ResourceQtopia *resource = (ResourceQtopia*)( res ); 66 ResourceQtopia *resource = (ResourceQtopia*)( res );
70 67
71 if ( !resource ) { 68 if ( !resource ) {
72 kdDebug(5700) << "ResourceQtopiaConfig::loadSettings(): cast failed" << endl; 69 kdDebug(5700) << "ResourceQtopiaConfig::loadSettings(): cast failed" << endl;
73 return; 70 return;
74 } 71 }
75 72
76 mFileNameEdit->setURL( resource->fileName() ); 73 mFileNameEdit->setURL( resource->fileName() );
77 if ( mFileNameEdit->url().isEmpty() ) 74 if ( mFileNameEdit->url().isEmpty() )
78 mFileNameEdit->setURL( QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml" ); 75 mFileNameEdit->setURL( QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml" );
79 76
80 //US Qtopia resources are ReadOnly by definition 77 //US Qtopia resources are ReadOnly by definition
81 emit setPersistentReadOnly( true ); 78 emit setPersistentReadOnly( true );
82 79
83 //US we can not choose the filename for the qtopia backend => make it readonly. 80 //US we can not choose the filename for the qtopia backend => make it readonly.
84 mFileNameEdit->setEnabled( false ); 81 mFileNameEdit->setEnabled( false );
85 82
86} 83}
87 84
88void ResourceQtopiaConfig::saveSettings( KRES::Resource *res ) 85void ResourceQtopiaConfig::saveSettings( KRES::Resource *res )
89{ 86{
90//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); 87//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res );
91 ResourceQtopia *resource = (ResourceQtopia*)( res ); 88 ResourceQtopia *resource = (ResourceQtopia*)( res );
92 89
93 if ( !resource ) { 90 if ( !resource ) {
94 kdDebug(5700) << "ResourceQtopiaConfig::saveSettings(): cast failed" << endl; 91 kdDebug(5700) << "ResourceQtopiaConfig::saveSettings(): cast failed" << endl;
95 return; 92 return;
96 } 93 }
97 94
98 resource->setFileName( mFileNameEdit->url() ); 95 resource->setFileName( mFileNameEdit->url() );
99} 96}
100 97
101void ResourceQtopiaConfig::checkFilePermissions( const QString& fileName ) 98void ResourceQtopiaConfig::checkFilePermissions( const QString& fileName )
102{ 99{
103 // If file exist but is not writeable... 100 // If file exist but is not writeable...
104/*US 101/*US
105 if ( access( QFile::encodeName( fileName ), F_OK ) == 0 ) 102 if ( access( QFile::encodeName( fileName ), F_OK ) == 0 )
106 emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 ); 103 emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 );
107*/ 104*/
108} 105}
109 106
110//US #include "resourceopieconfig.moc" 107//US #include "resourceopieconfig.moc"