summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/field.cpp8
-rw-r--r--kabc/plugins/opie/resourceopie.cpp16
-rw-r--r--kabc/plugins/opie/resourceopieconfig.cpp11
-rw-r--r--kabc/plugins/opie/resourceopieconfig.h3
4 files changed, 20 insertions, 18 deletions
diff --git a/kabc/field.cpp b/kabc/field.cpp
index bc2e176..e27970e 100644
--- a/kabc/field.cpp
+++ b/kabc/field.cpp
@@ -168,196 +168,196 @@ QString Field::label()
168 return Addressee::businessPhoneLabel(); 168 return Addressee::businessPhoneLabel();
169 case FieldImpl::MobilePhone: 169 case FieldImpl::MobilePhone:
170 return Addressee::mobilePhoneLabel(); 170 return Addressee::mobilePhoneLabel();
171 case FieldImpl::HomeFax: 171 case FieldImpl::HomeFax:
172 return Addressee::homeFaxLabel(); 172 return Addressee::homeFaxLabel();
173 case FieldImpl::BusinessFax: 173 case FieldImpl::BusinessFax:
174 return Addressee::businessFaxLabel(); 174 return Addressee::businessFaxLabel();
175 case FieldImpl::CarPhone: 175 case FieldImpl::CarPhone:
176 return Addressee::carPhoneLabel(); 176 return Addressee::carPhoneLabel();
177 case FieldImpl::Isdn: 177 case FieldImpl::Isdn:
178 return Addressee::isdnLabel(); 178 return Addressee::isdnLabel();
179 case FieldImpl::Pager: 179 case FieldImpl::Pager:
180 return Addressee::pagerLabel(); 180 return Addressee::pagerLabel();
181 case FieldImpl::Email: 181 case FieldImpl::Email:
182 return Addressee::emailLabel(); 182 return Addressee::emailLabel();
183 case FieldImpl::Mailer: 183 case FieldImpl::Mailer:
184 return Addressee::mailerLabel(); 184 return Addressee::mailerLabel();
185 case FieldImpl::Title: 185 case FieldImpl::Title:
186 return Addressee::titleLabel(); 186 return Addressee::titleLabel();
187 case FieldImpl::Role: 187 case FieldImpl::Role:
188 return Addressee::roleLabel(); 188 return Addressee::roleLabel();
189 case FieldImpl::Organization: 189 case FieldImpl::Organization:
190 return Addressee::organizationLabel(); 190 return Addressee::organizationLabel();
191 case FieldImpl::Note: 191 case FieldImpl::Note:
192 return Addressee::noteLabel(); 192 return Addressee::noteLabel();
193 case FieldImpl::Url: 193 case FieldImpl::Url:
194 return Addressee::urlLabel(); 194 return Addressee::urlLabel();
195 case FieldImpl::Resource: 195 case FieldImpl::Resource:
196 return Addressee::resourceLabel(); 196 return Addressee::resourceLabel();
197 case FieldImpl::CustomField: 197 case FieldImpl::CustomField:
198 return mImpl->label(); 198 return mImpl->label();
199 default: 199 default:
200 return i18n("Unknown Field"); 200 return i18n("Unknown Field");
201 } 201 }
202} 202}
203 203
204int Field::category() 204int Field::category()
205{ 205{
206 return mImpl->category(); 206 return mImpl->category();
207} 207}
208 208
209QString Field::categoryLabel( int category ) 209QString Field::categoryLabel( int category )
210{ 210{
211 switch ( category ) { 211 switch ( category ) {
212 case All: 212 case All:
213 return i18n("All"); 213 return i18n("All");
214 case Frequent: 214 case Frequent:
215 return i18n("Frequent"); 215 return i18n("Frequent");
216 case Address: 216 case Address:
217 return i18n("Address"); 217 return i18n("Address");
218 case Email: 218 case Email:
219 return i18n("Email"); 219 return i18n("Email");
220 case Personal: 220 case Personal:
221 return i18n("Personal"); 221 return i18n("Personal");
222 case Organization: 222 case Organization:
223 return i18n("Organization"); 223 return i18n("Organization");
224 case CustomCategory: 224 case CustomCategory:
225 return i18n("Custom"); 225 return i18n("Custom");
226 default: 226 default:
227 return i18n("Undefined"); 227 return i18n("Undefined");
228 } 228 }
229} 229}
230 230
231QString Field::value( const KABC::Addressee &a ) 231QString Field::value( const KABC::Addressee &a )
232{ 232{
233 switch ( mImpl->fieldId() ) { 233 switch ( mImpl->fieldId() ) {
234 case FieldImpl::FormattedName: 234 case FieldImpl::FormattedName:
235 return a.formattedName(); 235 return a.formattedName();
236 case FieldImpl::FamilyName: 236 case FieldImpl::FamilyName:
237 return a.familyName(); 237 return a.familyName();
238 case FieldImpl::GivenName: 238 case FieldImpl::GivenName:
239 return a.givenName(); 239 return a.givenName();
240 case FieldImpl::AdditionalName: 240 case FieldImpl::AdditionalName:
241 return a.additionalName(); 241 return a.additionalName();
242 case FieldImpl::Prefix: 242 case FieldImpl::Prefix:
243 return a.prefix(); 243 return a.prefix();
244 case FieldImpl::Suffix: 244 case FieldImpl::Suffix:
245 return a.suffix(); 245 return a.suffix();
246 case FieldImpl::NickName: 246 case FieldImpl::NickName:
247 return a.nickName(); 247 return a.nickName();
248 case FieldImpl::Mailer: 248 case FieldImpl::Mailer:
249 return a.mailer(); 249 return a.mailer();
250 case FieldImpl::Title: 250 case FieldImpl::Title:
251 return a.title(); 251 return a.title();
252 case FieldImpl::Role: 252 case FieldImpl::Role:
253 return a.role(); 253 return a.role();
254 case FieldImpl::Organization: 254 case FieldImpl::Organization:
255 return a.organization(); 255 return a.organization();
256 case FieldImpl::Note: 256 case FieldImpl::Note:
257 return a.note(); 257 return a.note();
258 case FieldImpl::Email: 258 case FieldImpl::Email:
259 return a.preferredEmail(); 259 return a.preferredEmail();
260 case FieldImpl::Birthday: 260 case FieldImpl::Birthday:
261 if ( a.birthday().isValid() ) { 261 if ( a.birthday().isValid() ) {
262//the generated code had the following format: return a.birthday().date().toString( Qt::ISODate ); 262//the generated code had the following format: return a.birthday().date().toString( Qt::ISODate );
263// But Qt::IsoDate was not specified. 263// But Qt::IsoDate was not specified.
264 QString _oldFormat = KGlobal::locale()->dateFormat(); 264// QString _oldFormat = KGlobal::locale()->dateFormat();
265 KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate 265// KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate
266 QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false); 266 QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate);
267 KGlobal::locale()->setDateFormat(_oldFormat); 267// KGlobal::locale()->setDateFormat(_oldFormat);
268 return dt; 268 return dt;
269 } 269 }
270 else 270 else
271 return QString::null; 271 return QString::null;
272 case FieldImpl::Url: 272 case FieldImpl::Url:
273 return a.url().prettyURL(); 273 return a.url().prettyURL();
274//US 274//US
275 case FieldImpl::Resource: 275 case FieldImpl::Resource:
276 return a.resource()->resourceName(); 276 return a.resource()->resourceName();
277 case FieldImpl::HomePhone: 277 case FieldImpl::HomePhone:
278 return a.phoneNumber( PhoneNumber::Home ).number(); 278 return a.phoneNumber( PhoneNumber::Home ).number();
279 case FieldImpl::BusinessPhone: 279 case FieldImpl::BusinessPhone:
280 return a.phoneNumber( PhoneNumber::Work ).number(); 280 return a.phoneNumber( PhoneNumber::Work ).number();
281 case FieldImpl::MobilePhone: 281 case FieldImpl::MobilePhone:
282 return a.phoneNumber( PhoneNumber::Cell ).number(); 282 return a.phoneNumber( PhoneNumber::Cell ).number();
283 case FieldImpl::HomeFax: 283 case FieldImpl::HomeFax:
284 return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); 284 return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number();
285 case FieldImpl::BusinessFax: 285 case FieldImpl::BusinessFax:
286 return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number(); 286 return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number();
287 case FieldImpl::CarPhone: 287 case FieldImpl::CarPhone:
288 return a.phoneNumber( PhoneNumber::Car ).number(); 288 return a.phoneNumber( PhoneNumber::Car ).number();
289 case FieldImpl::Isdn: 289 case FieldImpl::Isdn:
290 return a.phoneNumber( PhoneNumber::Isdn ).number(); 290 return a.phoneNumber( PhoneNumber::Isdn ).number();
291 case FieldImpl::Pager: 291 case FieldImpl::Pager:
292 return a.phoneNumber( PhoneNumber::Pager ).number(); 292 return a.phoneNumber( PhoneNumber::Pager ).number();
293 case FieldImpl::HomeAddressStreet: 293 case FieldImpl::HomeAddressStreet:
294 return a.address( Address::Home ).street(); 294 return a.address( Address::Home ).street();
295 case FieldImpl::HomeAddressLocality: 295 case FieldImpl::HomeAddressLocality:
296 return a.address( Address::Home ).locality(); 296 return a.address( Address::Home ).locality();
297 case FieldImpl::HomeAddressRegion: 297 case FieldImpl::HomeAddressRegion:
298 return a.address( Address::Home ).region(); 298 return a.address( Address::Home ).region();
299 case FieldImpl::HomeAddressPostalCode: 299 case FieldImpl::HomeAddressPostalCode:
300 return a.address( Address::Home ).postalCode(); 300 return a.address( Address::Home ).postalCode();
301 case FieldImpl::HomeAddressCountry: 301 case FieldImpl::HomeAddressCountry:
302 return a.address( Address::Home ).country(); 302 return a.address( Address::Home ).country();
303 case FieldImpl::BusinessAddressStreet: 303 case FieldImpl::BusinessAddressStreet:
304 return a.address( Address::Work ).street(); 304 return a.address( Address::Work ).street();
305 case FieldImpl::BusinessAddressLocality: 305 case FieldImpl::BusinessAddressLocality:
306 return a.address( Address::Work ).locality(); 306 return a.address( Address::Work ).locality();
307 case FieldImpl::BusinessAddressRegion: 307 case FieldImpl::BusinessAddressRegion:
308 return a.address( Address::Work ).region(); 308 return a.address( Address::Work ).region();
309 case FieldImpl::BusinessAddressPostalCode: 309 case FieldImpl::BusinessAddressPostalCode:
310 return a.address( Address::Work ).postalCode(); 310 return a.address( Address::Work ).postalCode();
311 case FieldImpl::BusinessAddressCountry: 311 case FieldImpl::BusinessAddressCountry:
312 return a.address( Address::Work ).country(); 312 return a.address( Address::Work ).country();
313 case FieldImpl::CustomField: 313 case FieldImpl::CustomField:
314 return a.custom( mImpl->app(), mImpl->key() ); 314 return a.custom( mImpl->app(), mImpl->key() );
315 default: 315 default:
316 return QString::null; 316 return QString::null;
317 } 317 }
318} 318}
319 319
320bool Field::setValue( KABC::Addressee &a, const QString &value ) 320bool Field::setValue( KABC::Addressee &a, const QString &value )
321{ 321{
322 switch ( mImpl->fieldId() ) { 322 switch ( mImpl->fieldId() ) {
323 case FieldImpl::FormattedName: 323 case FieldImpl::FormattedName:
324 a.setFormattedName( value ); 324 a.setFormattedName( value );
325 return true; 325 return true;
326 case FieldImpl::FamilyName: 326 case FieldImpl::FamilyName:
327 a.setFamilyName( value ); 327 a.setFamilyName( value );
328 return true; 328 return true;
329 case FieldImpl::GivenName: 329 case FieldImpl::GivenName:
330 a.setGivenName( value ); 330 a.setGivenName( value );
331 return true; 331 return true;
332 case FieldImpl::AdditionalName: 332 case FieldImpl::AdditionalName:
333 a.setAdditionalName( value ); 333 a.setAdditionalName( value );
334 return true; 334 return true;
335 case FieldImpl::Prefix: 335 case FieldImpl::Prefix:
336 a.setPrefix( value ); 336 a.setPrefix( value );
337 return true; 337 return true;
338 case FieldImpl::Suffix: 338 case FieldImpl::Suffix:
339 a.setSuffix( value ); 339 a.setSuffix( value );
340 return true; 340 return true;
341 case FieldImpl::NickName: 341 case FieldImpl::NickName:
342 a.setNickName( value ); 342 a.setNickName( value );
343 return true; 343 return true;
344 case FieldImpl::Mailer: 344 case FieldImpl::Mailer:
345 a.setMailer( value ); 345 a.setMailer( value );
346 return true; 346 return true;
347 case FieldImpl::Title: 347 case FieldImpl::Title:
348 a.setTitle( value ); 348 a.setTitle( value );
349 return true; 349 return true;
350 case FieldImpl::Role: 350 case FieldImpl::Role:
351 a.setRole( value ); 351 a.setRole( value );
352 return true; 352 return true;
353 case FieldImpl::Organization: 353 case FieldImpl::Organization:
354 a.setOrganization( value ); 354 a.setOrganization( value );
355 return true; 355 return true;
356 case FieldImpl::Note: 356 case FieldImpl::Note:
357 a.setNote( value ); 357 a.setNote( value );
358 return true; 358 return true;
359 case FieldImpl::Birthday: 359 case FieldImpl::Birthday:
360//US 360//US
361//the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) ); 361//the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) );
362// But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ? 362// But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ?
363 { 363 {
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp
index 3b2a6b7..a7d271f 100644
--- a/kabc/plugins/opie/resourceopie.cpp
+++ b/kabc/plugins/opie/resourceopie.cpp
@@ -4,296 +4,306 @@
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 <sys/types.h> 28#include <sys/types.h>
29#include <sys/stat.h> 29#include <sys/stat.h>
30#include <unistd.h> 30#include <unistd.h>
31 31
32#include <qdir.h> 32#include <qdir.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qfileinfo.h> 34#include <qfileinfo.h>
35#include <qregexp.h> 35#include <qregexp.h>
36#include <qtimer.h> 36#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 44
45//US #include "formatfactory.h" 45//US #include "formatfactory.h"
46//US #include <qpe/qpeapplication.h> 46//US #include <qpe/qpeapplication.h>
47 47
48#include <opie/ocontactaccess.h> 48#include <opie/ocontactaccess.h>
49#include <opie/ocontactaccessbackend_xml.h> 49#include <opie/ocontactaccessbackend_xml.h>
50 50
51#include "resource.h" 51#include "resource.h"
52#include "resourceopieconfig.h" 52#include "resourceopieconfig.h"
53#include "stdaddressbook.h" 53#include "stdaddressbook.h"
54 54
55#include "opieconverter.h" 55#include "opieconverter.h"
56 56
57#include "resourceopie.h" 57#include "resourceopie.h"
58 58
59using namespace KABC; 59using namespace KABC;
60extern "C" 60extern "C"
61{ 61{
62 void *init_microkabc_opie() 62 void *init_microkabc_opie()
63 { 63 {
64 return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig>(); 64 return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig>();
65 } 65 }
66} 66}
67 67
68ResourceOpie::ResourceOpie( const KConfig *config ) 68ResourceOpie::ResourceOpie( const KConfig *config )
69 : Resource( config ), mConverter (0) 69 : Resource( config ), mConverter (0)
70{ 70{
71 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; 71 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
72 72
73 KConfig *cfg = (KConfig *)config; 73 KConfig *cfg = (KConfig *)config;
74 if ( cfg ) { 74 if ( cfg ) {
75 fileName = cfg->readEntry( "FileName", fileName ); 75 fileName = cfg->readEntry( "FileName", fileName );
76 76
77 } 77 }
78 78
79// qDebug("ResourceOpie::ResourceOpie : %s", fileName.latin1() ); 79// qDebug("ResourceOpie::ResourceOpie : %s", fileName.latin1() );
80 80
81 init( fileName ); 81 init( fileName );
82} 82}
83 83
84ResourceOpie::ResourceOpie( const QString &fileName ) 84ResourceOpie::ResourceOpie( const QString &fileName )
85 : Resource( 0 ) 85 : Resource( 0 )
86{ 86{
87// qDebug("ResourceOpie::ResourceOpie : 3 %s", fileName.latin1()); 87// qDebug("ResourceOpie::ResourceOpie : 3 %s", fileName.latin1());
88 init( fileName ); 88 init( fileName );
89} 89}
90 90
91void ResourceOpie::init( const QString &fileName ) 91void ResourceOpie::init( const QString &fileName )
92{ 92{
93 93
94/*US we have no KDirWatch. SO simulate the signals from inside the apropriate methods 94/*US we have no KDirWatch. SO simulate the signals from inside the apropriate methods
95 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 95 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
96 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); 96 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
97 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 97 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
98*/ 98*/
99 //US opie addressbook is always readonly 99 //US opie addressbook is always readonly
100 setReadOnly( true ); 100//US setReadOnly( true );
101 101
102 setFileName( fileName ); 102 setFileName( fileName );
103 103
104} 104}
105 105
106ResourceOpie::~ResourceOpie() 106ResourceOpie::~ResourceOpie()
107{ 107{
108 if (mConverter != 0) 108 if (mConverter != 0)
109 delete mConverter; 109 delete mConverter;
110} 110}
111 111
112void ResourceOpie::writeConfig( KConfig *config ) 112void ResourceOpie::writeConfig( KConfig *config )
113{ 113{
114 //US opie addressbook is always readonly 114 //US opie addressbook is always readonly
115 setReadOnly( true ); 115//US setReadOnly( true );
116 116
117 Resource::writeConfig( config ); 117 Resource::writeConfig( config );
118 118
119 config->writeEntry( "FileName", mFileName ); 119 config->writeEntry( "FileName", mFileName );
120 120
121// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1()); 121// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1());
122 122
123} 123}
124 124
125Ticket *ResourceOpie::requestSaveTicket() 125Ticket *ResourceOpie::requestSaveTicket()
126{ 126{
127 kdDebug(5700) << "ResourceOpie::requestSaveTicket()" << endl; 127 kdDebug(5700) << "ResourceOpie::requestSaveTicket()" << endl;
128 128
129 if ( !addressBook() ) return 0; 129 if ( !addressBook() ) return 0;
130 130
131 if ( !lock( mFileName ) ) { 131 if ( !lock( mFileName ) ) {
132 kdDebug(5700) << "ResourceOpie::requestSaveTicket(): Unable to lock file '" 132 kdDebug(5700) << "ResourceOpie::requestSaveTicket(): Unable to lock file '"
133 << mFileName << "'" << endl; 133 << mFileName << "'" << endl;
134 return 0; 134 return 0;
135 } 135 }
136 return createTicket( this ); 136 return createTicket( this );
137} 137}
138 138
139 139
140bool ResourceOpie::doOpen() 140bool ResourceOpie::doOpen()
141{ 141{
142// qDebug("ResourceOpie::doOpen() %s", mFileName.latin1()); 142// qDebug("ResourceOpie::doOpen() %s", mFileName.latin1());
143/*US 143/*US
144 QFile file( mFileName ); 144 QFile file( mFileName );
145 145
146 if ( !file.exists() ) { 146 if ( !file.exists() ) {
147 // try to create the file 147 // try to create the file
148 bool ok = file.open( IO_WriteOnly ); 148 bool ok = file.open( IO_WriteOnly );
149 if ( ok ) 149 if ( ok )
150 file.close(); 150 file.close();
151 151
152 return ok; 152 return ok;
153 } else { 153 } else {
154 if ( !file.open( IO_ReadWrite ) ) 154 if ( !file.open( IO_ReadWrite ) )
155 return false; 155 return false;
156 156
157 if ( file.size() == 0 ) { 157 if ( file.size() == 0 ) {
158 file.close(); 158 file.close();
159 return true; 159 return true;
160 } 160 }
161 161
162//US bool ok = mFormat->checkFormat( &file ); 162//US bool ok = mFormat->checkFormat( &file );
163 bool ok = true; 163 bool ok = true;
164 164
165 file.close(); 165 file.close();
166 166
167 return ok; 167 return ok;
168 } 168 }
169*/ 169*/
170 qDebug("ResourceOpie::doOpen() has to be fixed - %s", mFileName.latin1()); 170 qDebug("ResourceOpie::doOpen() has to be fixed - %s", mFileName.latin1());
171 return true; 171 return true;
172} 172}
173 173
174void ResourceOpie::doClose() 174void ResourceOpie::doClose()
175{ 175{
176// qDebug("ResourceOpie::doClose() %s", mFileName.latin1()); 176// qDebug("ResourceOpie::doClose() %s", mFileName.latin1());
177} 177}
178 178
179bool ResourceOpie::load() 179bool ResourceOpie::load()
180{ 180{
181// qDebug("ResourceOpie::load() %s", mFileName.latin1()); 181// qDebug("ResourceOpie::load() %s", mFileName.latin1());
182 kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl; 182 kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl;
183 183
184 qDebug("ResourceOpie::load: Try to load file() %s", mFileName.latin1()); 184 qDebug("ResourceOpie::load: Try to load file() %s", mFileName.latin1());
185 185
186 OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", mFileName ); 186 OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", mFileName );
187 OContactAccess* access = new OContactAccess("KDEPim/Pi", 0l, backend, false); 187 OContactAccess* access = new OContactAccess("KDEPim/Pi", 0l, backend, false);
188 188
189 if ( !access ) { 189 if ( !access ) {
190 qDebug("Unable to load file() %s", mFileName.latin1()); 190 qDebug("Unable to load file() %s", mFileName.latin1());
191 addressBook()->error( i18n( "Unable to load file '%1'." ).arg( mFileName ) ); 191 addressBook()->error( i18n( "Unable to load file '%1'." ).arg( mFileName ) );
192 return false; 192 return false;
193 } 193 }
194 194
195 access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available 195 access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available
196 196
197 bool res = false;
197 if (mConverter == 0) 198 if (mConverter == 0)
199 {
198 mConverter = new OpieConverter(); 200 mConverter = new OpieConverter();
201 res = mConverter->init();
202 if ( !res )
203 {
204 qDebug("Unable to initialize opie converter. Most likely a problem with the category file");
205 addressBook()->error( i18n( "Unable to initialize opie converter. Most likely a problem with the category file" ) );
206 delete access;
207 return false;
208 }
209 }
199 210
200 211
201 OContactAccess::List::Iterator it; 212 OContactAccess::List::Iterator it;
202 OContactAccess::List allList = access->allRecords(); 213 OContactAccess::List allList = access->allRecords();
203 bool res = false;
204 for ( it = allList.begin(); it != allList.end(); ++it ) 214 for ( it = allList.begin(); it != allList.end(); ++it )
205 { 215 {
206 OContact c = (*it); 216 OContact c = (*it);
207 217
208 KABC::Addressee addressee; 218 KABC::Addressee addressee;
209 219
210 res = mConverter->opieToAddressee( c, addressee ); 220 res = mConverter->opieToAddressee( c, addressee );
211 221
212 if ( !addressee.isEmpty() && res ) 222 if ( !addressee.isEmpty() && res )
213 { 223 {
214 addressee.setResource( this ); 224 addressee.setResource( this );
215 addressBook()->insertAddressee( addressee ); 225 addressBook()->insertAddressee( addressee );
216 } 226 }
217 227
218// qDebug("found %s", c.fullName().latin1()); 228// qDebug("found %s", c.fullName().latin1());
219 } 229 }
220 230
221 delete access; 231 delete access;
222 // it seems so, that deletion of access deletes backend as well 232 // it seems so, that deletion of access deletes backend as well
223 //delete backend; 233 //delete backend;
224 234
225 return true; 235 return true;
226} 236}
227 237
228bool ResourceOpie::save( Ticket *ticket ) 238bool ResourceOpie::save( Ticket *ticket )
229{ 239{
230 qDebug("ResourceOpie::save() has to be fixed - %s", mFileName.latin1()); 240 qDebug("ResourceOpie::save() has to be fixed - %s", mFileName.latin1());
231/*US 241/*US
232 242
233 qDebug("ResourceOpie::save %s", mFileName.latin1()); 243 qDebug("ResourceOpie::save %s", mFileName.latin1());
234 kdDebug(5700) << "ResourceOpie::save()" << endl; 244 kdDebug(5700) << "ResourceOpie::save()" << endl;
235 245
236 // create backup file 246 // create backup file
237 QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); 247 QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() );
238*/ 248*/
239/*US we use a simpler method to create a backupfile 249/*US we use a simpler method to create a backupfile
240 250
241 (void) KSaveFile::backupFile( mFileName, QString::null 251 (void) KSaveFile::backupFile( mFileName, QString::null
242 ,extension ); 252 ,extension );
243 253
244 KSaveFile saveFile( mFileName ); 254 KSaveFile saveFile( mFileName );
245 bool ok = false; 255 bool ok = false;
246 if ( saveFile.status() == 0 && saveFile.file() ) 256 if ( saveFile.status() == 0 && saveFile.file() )
247 { 257 {
248 mFormat->saveAll( addressBook(), this, saveFile.file() ); 258 mFormat->saveAll( addressBook(), this, saveFile.file() );
249 ok = saveFile.close(); 259 ok = saveFile.close();
250 } 260 }
251*/ 261*/
252/*US 262/*US
253//US ToDo: write backupfile 263//US ToDo: write backupfile
254 QFile info; 264 QFile info;
255 info.setName( mFileName ); 265 info.setName( mFileName );
256 bool ok = info.open( IO_WriteOnly ); 266 bool ok = info.open( IO_WriteOnly );
257 if ( ok ) { 267 if ( ok ) {
258//US mFormat->saveAll( addressBook(), this, &info ); 268//US mFormat->saveAll( addressBook(), this, &info );
259 269
260 info.close(); 270 info.close();
261 ok = true; 271 ok = true;
262 } 272 }
263 else { 273 else {
264 274
265 } 275 }
266 276
267 if ( !ok ) 277 if ( !ok )
268 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); 278 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) );
269 279
270 delete ticket; 280 delete ticket;
271 unlock( mFileName ); 281 unlock( mFileName );
272 282
273 return ok; 283 return ok;
274 284
275 qDebug("ResourceOpie::save has to be changed"); 285 qDebug("ResourceOpie::save has to be changed");
276*/ 286*/
277 return true; 287 return true;
278 288
279} 289}
280 290
281bool ResourceOpie::lock( const QString &fileName ) 291bool ResourceOpie::lock( const QString &fileName )
282{ 292{
283 qDebug("ResourceOpie::lock() has to be fixed - %s", mFileName.latin1()); 293 qDebug("ResourceOpie::lock() has to be fixed - %s", mFileName.latin1());
284 294
285/*US 295/*US
286// qDebug("ResourceOpie::lock() %s", fileName.latin1()); 296// qDebug("ResourceOpie::lock() %s", fileName.latin1());
287 kdDebug(5700) << "ResourceOpie::lock()" << endl; 297 kdDebug(5700) << "ResourceOpie::lock()" << endl;
288 298
289 QString fn = fileName; 299 QString fn = fileName;
290 300
291//US change the implementation how the lockfilename is getting created 301//US change the implementation how the lockfilename is getting created
292//US fn.replace( QRegExp("/"), "_" ); 302//US fn.replace( QRegExp("/"), "_" );
293//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); 303//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
294 304
295 KURL url(fn); 305 KURL url(fn);
296 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 306 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
297 307
298 kdDebug(5700) << "-- lock name: " << lockName << endl; 308 kdDebug(5700) << "-- lock name: " << lockName << endl;
299 309
diff --git a/kabc/plugins/opie/resourceopieconfig.cpp b/kabc/plugins/opie/resourceopieconfig.cpp
index f4cc4f9..eef9cc9 100644
--- a/kabc/plugins/opie/resourceopieconfig.cpp
+++ b/kabc/plugins/opie/resourceopieconfig.cpp
@@ -1,112 +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 "resourceopie.h" 40#include "resourceopie.h"
41//US #include <qpe/qpeapplication.h> 41//US #include <qpe/qpeapplication.h>
42 42
43//US #include "stdaddressbook.h" 43//US #include "stdaddressbook.h"
44 44
45#include "resourceopieconfig.h" 45#include "resourceopieconfig.h"
46 46
47using namespace KABC; 47using namespace KABC;
48 48
49ResourceOpieConfig::ResourceOpieConfig( QWidget* parent, const char* name ) 49ResourceOpieConfig::ResourceOpieConfig( QWidget* parent, const char* name )
50 : ConfigWidget( parent, name ) 50 : ConfigWidget( parent, name )
51{ 51{
52//qDebug("ResourceFileConfig::ResourceFileConfig"); 52//qDebug("ResourceFileConfig::ResourceFileConfig");
53 53
54 QGridLayout *mainLayout = new QGridLayout( this, 1, 2, 0, 54 QGridLayout *mainLayout = new QGridLayout( this, 1, 2, 0,
55 KDialog::spacingHint() ); 55 KDialog::spacingHint() );
56 56
57 QLabel *label = new QLabel( i18n( "Location:" ), this ); 57 QLabel *label = new QLabel( i18n( "Location:" ), this );
58 mFileNameEdit = new KURLRequester( this ); 58 mFileNameEdit = new KURLRequester( this );
59 59
60 connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ), 60 connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ),
61 SLOT( checkFilePermissions( const QString & ) ) ); 61 SLOT( checkFilePermissions( const QString & ) ) );
62 62
63 mainLayout->addWidget( label, 0, 0 ); 63 mainLayout->addWidget( label, 0, 0 );
64 mainLayout->addWidget( mFileNameEdit, 0, 1 ); 64 mainLayout->addWidget( mFileNameEdit, 0, 1 );
65
66//US mInEditMode = false;
67}
68/*US
69void ResourceOpieConfig::setEditMode( bool value )
70{
71 mInEditMode = value;
72} 65}
73*/
74 66
75void ResourceOpieConfig::loadSettings( KRES::Resource *res ) 67void ResourceOpieConfig::loadSettings( KRES::Resource *res )
76{ 68{
77//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); 69//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res );
78 ResourceOpie *resource = (ResourceOpie*)( res ); 70 ResourceOpie *resource = (ResourceOpie*)( res );
79 71
80 if ( !resource ) { 72 if ( !resource ) {
81 kdDebug(5700) << "ResourceOpieConfig::loadSettings(): cast failed" << endl; 73 kdDebug(5700) << "ResourceOpieConfig::loadSettings(): cast failed" << endl;
82 return; 74 return;
83 } 75 }
84 76
85 mFileNameEdit->setURL( resource->fileName() ); 77 mFileNameEdit->setURL( resource->fileName() );
86 if ( mFileNameEdit->url().isEmpty() ) 78 if ( mFileNameEdit->url().isEmpty() )
87 mFileNameEdit->setURL( QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml" ); 79 mFileNameEdit->setURL( QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml" );
80
81 //US Opie resources are ReadOnly by definition
82 emit setPersistentReadOnly( true );
88} 83}
89 84
90void ResourceOpieConfig::saveSettings( KRES::Resource *res ) 85void ResourceOpieConfig::saveSettings( KRES::Resource *res )
91{ 86{
92//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); 87//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res );
93 ResourceOpie *resource = (ResourceOpie*)( res ); 88 ResourceOpie *resource = (ResourceOpie*)( res );
94 89
95 if ( !resource ) { 90 if ( !resource ) {
96 kdDebug(5700) << "ResourceOpieConfig::saveSettings(): cast failed" << endl; 91 kdDebug(5700) << "ResourceOpieConfig::saveSettings(): cast failed" << endl;
97 return; 92 return;
98 } 93 }
99 94
100 resource->setFileName( mFileNameEdit->url() ); 95 resource->setFileName( mFileNameEdit->url() );
101} 96}
102 97
103void ResourceOpieConfig::checkFilePermissions( const QString& fileName ) 98void ResourceOpieConfig::checkFilePermissions( const QString& fileName )
104{ 99{
105 // If file exist but is not writeable... 100 // If file exist but is not writeable...
106/*US 101/*US
107 if ( access( QFile::encodeName( fileName ), F_OK ) == 0 ) 102 if ( access( QFile::encodeName( fileName ), F_OK ) == 0 )
108 emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 ); 103 emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 );
109*/ 104*/
110} 105}
111 106
112//US #include "resourceopieconfig.moc" 107//US #include "resourceopieconfig.moc"
diff --git a/kabc/plugins/opie/resourceopieconfig.h b/kabc/plugins/opie/resourceopieconfig.h
index 533b7f4..8cc192c 100644
--- a/kabc/plugins/opie/resourceopieconfig.h
+++ b/kabc/plugins/opie/resourceopieconfig.h
@@ -1,61 +1,58 @@
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
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#ifndef RESOURCEOPIECONFIG_H 29#ifndef RESOURCEOPIECONFIG_H
30#define RESOURCEOPIECONFIG_H 30#define RESOURCEOPIECONFIG_H
31 31
32#include <kurlrequester.h> 32#include <kurlrequester.h>
33 33
34#include <kresources/configwidget.h> 34#include <kresources/configwidget.h>
35 35
36namespace KABC { 36namespace KABC {
37 37
38class ResourceOpieConfig : public KRES::ConfigWidget 38class ResourceOpieConfig : public KRES::ConfigWidget
39{ 39{
40 Q_OBJECT 40 Q_OBJECT
41 41
42public: 42public:
43 ResourceOpieConfig( QWidget* parent = 0, const char* name = 0 ); 43 ResourceOpieConfig( QWidget* parent = 0, const char* name = 0 );
44 44
45//US void setEditMode( bool value );
46
47public slots: 45public slots:
48 void loadSettings( KRES::Resource *resource ); 46 void loadSettings( KRES::Resource *resource );
49 void saveSettings( KRES::Resource *resource ); 47 void saveSettings( KRES::Resource *resource );
50 48
51protected slots: 49protected slots:
52 void checkFilePermissions( const QString& fileName ); 50 void checkFilePermissions( const QString& fileName );
53 51
54private: 52private:
55 KURLRequester* mFileNameEdit; 53 KURLRequester* mFileNameEdit;
56//US bool mInEditMode;
57}; 54};
58 55
59} 56}
60 57
61#endif 58#endif