summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/converter/opie/opieE.pro2
-rw-r--r--kabc/plugins/opie/resourceopie.cpp7
2 files changed, 2 insertions, 7 deletions
diff --git a/kabc/converter/opie/opieE.pro b/kabc/converter/opie/opieE.pro
index e026f2a..131c398 100644
--- a/kabc/converter/opie/opieE.pro
+++ b/kabc/converter/opie/opieE.pro
@@ -1,32 +1,32 @@
1TEMPLATE = lib 1TEMPLATE = lib
2INCLUDEPATH += . ../.. ../../../microkde ../../../microkde/kdecore $(OPIEDIR)/include $(OPEDIR)/include 2INCLUDEPATH += . ../.. ../../../microkde ../../../microkde/kdecore $(OPIEDIR)/include
3#CONFIG += staticlib 3#CONFIG += staticlib
4OBJECTS_DIR = obj/$(PLATFORM) 4OBJECTS_DIR = obj/$(PLATFORM)
5MOC_DIR = moc/$(PLATFORM) 5MOC_DIR = moc/$(PLATFORM)
6 6
7#for static linkage, put it here 7#for static linkage, put it here
8#DESTDIR=../../lib/$(PLATFORM) 8#DESTDIR=../../lib/$(PLATFORM)
9 9
10#for dynamic linkage, put it here 10#for dynamic linkage, put it here
11DESTDIR=$(QPEDIR)/lib 11DESTDIR=$(QPEDIR)/lib
12 12
13LIBS += -lmicrokde 13LIBS += -lmicrokde
14LIBS += -lmicrokabc 14LIBS += -lmicrokabc
15LIBS += -L$(QPEDIR)/lib 15LIBS += -L$(QPEDIR)/lib
16LIBS += -L$(OPIEDIR)/lib 16LIBS += -L$(OPIEDIR)/lib
17LIBS += -lopie 17LIBS += -lopie
18LIBS += -lqpe 18LIBS += -lqpe
19LIBS += -lqte 19LIBS += -lqte
20 20
21 21
22TARGET = microkabc_opieconverter 22TARGET = microkabc_opieconverter
23 23
24# Input 24# Input
25 25
26HEADERS += \ 26HEADERS += \
27 opieconverter.h \ 27 opieconverter.h \
28 28
29 29
30SOURCES += \ 30SOURCES += \
31 opieconverter.cpp \ 31 opieconverter.cpp \
32 32
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp
index a7d271f..3a40ea2 100644
--- a/kabc/plugins/opie/resourceopie.cpp
+++ b/kabc/plugins/opie/resourceopie.cpp
@@ -1,408 +1,403 @@
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 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>
37 36
38#include <kapplication.h> 37#include <kapplication.h>
39#include <kconfig.h> 38#include <kconfig.h>
40#include <kdebug.h> 39#include <kdebug.h>
41#include <klocale.h> 40#include <klocale.h>
42//US #include <ksavefile.h> 41//US #include <ksavefile.h>
43#include <kstandarddirs.h> 42#include <kstandarddirs.h>
44 43
45//US #include "formatfactory.h" 44//US #include "formatfactory.h"
46//US #include <qpe/qpeapplication.h> 45//US #include <qpe/qpeapplication.h>
47 46
48#include <opie/ocontactaccess.h> 47#include <opie/ocontactaccess.h>
49#include <opie/ocontactaccessbackend_xml.h> 48#include <opie/ocontactaccessbackend_xml.h>
50 49
51#include "resource.h"
52#include "resourceopieconfig.h" 50#include "resourceopieconfig.h"
53#include "stdaddressbook.h" 51#include "stdaddressbook.h"
54 52
55#include "opieconverter.h" 53#include "opieconverter.h"
56 54
57#include "resourceopie.h" 55#include "resourceopie.h"
58 56
59using namespace KABC; 57using namespace KABC;
60extern "C" 58extern "C"
61{ 59{
62 void *init_microkabc_opie() 60 void *init_microkabc_opie()
63 { 61 {
64 return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig>(); 62 return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig>();
65 } 63 }
66} 64}
67 65
68ResourceOpie::ResourceOpie( const KConfig *config ) 66ResourceOpie::ResourceOpie( const KConfig *config )
69 : Resource( config ), mConverter (0) 67 : Resource( config ), mConverter (0)
70{ 68{
71 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; 69 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
72 70
73 KConfig *cfg = (KConfig *)config; 71 KConfig *cfg = (KConfig *)config;
74 if ( cfg ) { 72 if ( cfg ) {
75 fileName = cfg->readEntry( "FileName", fileName ); 73 fileName = cfg->readEntry( "FileName", fileName );
76 74
77 } 75 }
78 76
79// qDebug("ResourceOpie::ResourceOpie : %s", fileName.latin1() ); 77// qDebug("ResourceOpie::ResourceOpie : %s", fileName.latin1() );
80 78
81 init( fileName ); 79 init( fileName );
82} 80}
83 81
84ResourceOpie::ResourceOpie( const QString &fileName ) 82ResourceOpie::ResourceOpie( const QString &fileName )
85 : Resource( 0 ) 83 : Resource( 0 )
86{ 84{
87// qDebug("ResourceOpie::ResourceOpie : 3 %s", fileName.latin1()); 85// qDebug("ResourceOpie::ResourceOpie : 3 %s", fileName.latin1());
88 init( fileName ); 86 init( fileName );
89} 87}
90 88
91void ResourceOpie::init( const QString &fileName ) 89void ResourceOpie::init( const QString &fileName )
92{ 90{
93 91
94/*US we have no KDirWatch. SO simulate the signals from inside the apropriate methods 92/*US we have no KDirWatch. SO simulate the signals from inside the apropriate methods
95 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 93 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
96 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); 94 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
97 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 95 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
98*/ 96*/
99 //US opie addressbook is always readonly 97 //US opie addressbook is always readonly
100//US setReadOnly( true ); 98//US setReadOnly( true );
101 99
102 setFileName( fileName ); 100 setFileName( fileName );
103 101
104} 102}
105 103
106ResourceOpie::~ResourceOpie() 104ResourceOpie::~ResourceOpie()
107{ 105{
108 if (mConverter != 0) 106 if (mConverter != 0)
109 delete mConverter; 107 delete mConverter;
110} 108}
111 109
112void ResourceOpie::writeConfig( KConfig *config ) 110void ResourceOpie::writeConfig( KConfig *config )
113{ 111{
114 //US opie addressbook is always readonly
115//US setReadOnly( true );
116
117 Resource::writeConfig( config ); 112 Resource::writeConfig( config );
118 113
119 config->writeEntry( "FileName", mFileName ); 114 config->writeEntry( "FileName", mFileName );
120 115
121// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1()); 116// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1());
122 117
123} 118}
124 119
125Ticket *ResourceOpie::requestSaveTicket() 120Ticket *ResourceOpie::requestSaveTicket()
126{ 121{
127 kdDebug(5700) << "ResourceOpie::requestSaveTicket()" << endl; 122 kdDebug(5700) << "ResourceOpie::requestSaveTicket()" << endl;
128 123
129 if ( !addressBook() ) return 0; 124 if ( !addressBook() ) return 0;
130 125
131 if ( !lock( mFileName ) ) { 126 if ( !lock( mFileName ) ) {
132 kdDebug(5700) << "ResourceOpie::requestSaveTicket(): Unable to lock file '" 127 kdDebug(5700) << "ResourceOpie::requestSaveTicket(): Unable to lock file '"
133 << mFileName << "'" << endl; 128 << mFileName << "'" << endl;
134 return 0; 129 return 0;
135 } 130 }
136 return createTicket( this ); 131 return createTicket( this );
137} 132}
138 133
139 134
140bool ResourceOpie::doOpen() 135bool ResourceOpie::doOpen()
141{ 136{
142// qDebug("ResourceOpie::doOpen() %s", mFileName.latin1()); 137// qDebug("ResourceOpie::doOpen() %s", mFileName.latin1());
143/*US 138/*US
144 QFile file( mFileName ); 139 QFile file( mFileName );
145 140
146 if ( !file.exists() ) { 141 if ( !file.exists() ) {
147 // try to create the file 142 // try to create the file
148 bool ok = file.open( IO_WriteOnly ); 143 bool ok = file.open( IO_WriteOnly );
149 if ( ok ) 144 if ( ok )
150 file.close(); 145 file.close();
151 146
152 return ok; 147 return ok;
153 } else { 148 } else {
154 if ( !file.open( IO_ReadWrite ) ) 149 if ( !file.open( IO_ReadWrite ) )
155 return false; 150 return false;
156 151
157 if ( file.size() == 0 ) { 152 if ( file.size() == 0 ) {
158 file.close(); 153 file.close();
159 return true; 154 return true;
160 } 155 }
161 156
162//US bool ok = mFormat->checkFormat( &file ); 157//US bool ok = mFormat->checkFormat( &file );
163 bool ok = true; 158 bool ok = true;
164 159
165 file.close(); 160 file.close();
166 161
167 return ok; 162 return ok;
168 } 163 }
169*/ 164*/
170 qDebug("ResourceOpie::doOpen() has to be fixed - %s", mFileName.latin1()); 165 qDebug("ResourceOpie::doOpen() has to be fixed - %s", mFileName.latin1());
171 return true; 166 return true;
172} 167}
173 168
174void ResourceOpie::doClose() 169void ResourceOpie::doClose()
175{ 170{
176// qDebug("ResourceOpie::doClose() %s", mFileName.latin1()); 171// qDebug("ResourceOpie::doClose() %s", mFileName.latin1());
177} 172}
178 173
179bool ResourceOpie::load() 174bool ResourceOpie::load()
180{ 175{
181// qDebug("ResourceOpie::load() %s", mFileName.latin1()); 176// qDebug("ResourceOpie::load() %s", mFileName.latin1());
182 kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl; 177 kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl;
183 178
184 qDebug("ResourceOpie::load: Try to load file() %s", mFileName.latin1()); 179 qDebug("ResourceOpie::load: Try to load file() %s", mFileName.latin1());
185 180
186 OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", mFileName ); 181 OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", mFileName );
187 OContactAccess* access = new OContactAccess("KDEPim/Pi", 0l, backend, false); 182 OContactAccess* access = new OContactAccess("KDEPim/Pi", 0l, backend, false);
188 183
189 if ( !access ) { 184 if ( !access ) {
190 qDebug("Unable to load file() %s", mFileName.latin1()); 185 qDebug("Unable to load file() %s", mFileName.latin1());
191 addressBook()->error( i18n( "Unable to load file '%1'." ).arg( mFileName ) ); 186 addressBook()->error( i18n( "Unable to load file '%1'." ).arg( mFileName ) );
192 return false; 187 return false;
193 } 188 }
194 189
195 access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available 190 access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available
196 191
197 bool res = false; 192 bool res = false;
198 if (mConverter == 0) 193 if (mConverter == 0)
199 { 194 {
200 mConverter = new OpieConverter(); 195 mConverter = new OpieConverter();
201 res = mConverter->init(); 196 res = mConverter->init();
202 if ( !res ) 197 if ( !res )
203 { 198 {
204 qDebug("Unable to initialize opie converter. Most likely a problem with the category file"); 199 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" ) ); 200 addressBook()->error( i18n( "Unable to initialize opie converter. Most likely a problem with the category file" ) );
206 delete access; 201 delete access;
207 return false; 202 return false;
208 } 203 }
209 } 204 }
210 205
211 206
212 OContactAccess::List::Iterator it; 207 OContactAccess::List::Iterator it;
213 OContactAccess::List allList = access->allRecords(); 208 OContactAccess::List allList = access->allRecords();
214 for ( it = allList.begin(); it != allList.end(); ++it ) 209 for ( it = allList.begin(); it != allList.end(); ++it )
215 { 210 {
216 OContact c = (*it); 211 const OContact c = (*it);
217 212
218 KABC::Addressee addressee; 213 KABC::Addressee addressee;
219 214
220 res = mConverter->opieToAddressee( c, addressee ); 215 res = mConverter->opieToAddressee( c, addressee );
221 216
222 if ( !addressee.isEmpty() && res ) 217 if ( !addressee.isEmpty() && res )
223 { 218 {
224 addressee.setResource( this ); 219 addressee.setResource( this );
225 addressBook()->insertAddressee( addressee ); 220 addressBook()->insertAddressee( addressee );
226 } 221 }
227 222
228// qDebug("found %s", c.fullName().latin1()); 223// qDebug("found %s", c.fullName().latin1());
229 } 224 }
230 225
231 delete access; 226 delete access;
232 // it seems so, that deletion of access deletes backend as well 227 // it seems so, that deletion of access deletes backend as well
233 //delete backend; 228 //delete backend;
234 229
235 return true; 230 return true;
236} 231}
237 232
238bool ResourceOpie::save( Ticket *ticket ) 233bool ResourceOpie::save( Ticket *ticket )
239{ 234{
240 qDebug("ResourceOpie::save() has to be fixed - %s", mFileName.latin1()); 235 qDebug("ResourceOpie::save() has to be fixed - %s", mFileName.latin1());
241/*US 236/*US
242 237
243 qDebug("ResourceOpie::save %s", mFileName.latin1()); 238 qDebug("ResourceOpie::save %s", mFileName.latin1());
244 kdDebug(5700) << "ResourceOpie::save()" << endl; 239 kdDebug(5700) << "ResourceOpie::save()" << endl;
245 240
246 // create backup file 241 // create backup file
247 QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); 242 QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() );
248*/ 243*/
249/*US we use a simpler method to create a backupfile 244/*US we use a simpler method to create a backupfile
250 245
251 (void) KSaveFile::backupFile( mFileName, QString::null 246 (void) KSaveFile::backupFile( mFileName, QString::null
252 ,extension ); 247 ,extension );
253 248
254 KSaveFile saveFile( mFileName ); 249 KSaveFile saveFile( mFileName );
255 bool ok = false; 250 bool ok = false;
256 if ( saveFile.status() == 0 && saveFile.file() ) 251 if ( saveFile.status() == 0 && saveFile.file() )
257 { 252 {
258 mFormat->saveAll( addressBook(), this, saveFile.file() ); 253 mFormat->saveAll( addressBook(), this, saveFile.file() );
259 ok = saveFile.close(); 254 ok = saveFile.close();
260 } 255 }
261*/ 256*/
262/*US 257/*US
263//US ToDo: write backupfile 258//US ToDo: write backupfile
264 QFile info; 259 QFile info;
265 info.setName( mFileName ); 260 info.setName( mFileName );
266 bool ok = info.open( IO_WriteOnly ); 261 bool ok = info.open( IO_WriteOnly );
267 if ( ok ) { 262 if ( ok ) {
268//US mFormat->saveAll( addressBook(), this, &info ); 263//US mFormat->saveAll( addressBook(), this, &info );
269 264
270 info.close(); 265 info.close();
271 ok = true; 266 ok = true;
272 } 267 }
273 else { 268 else {
274 269
275 } 270 }
276 271
277 if ( !ok ) 272 if ( !ok )
278 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); 273 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) );
279 274
280 delete ticket; 275 delete ticket;
281 unlock( mFileName ); 276 unlock( mFileName );
282 277
283 return ok; 278 return ok;
284 279
285 qDebug("ResourceOpie::save has to be changed"); 280 qDebug("ResourceOpie::save has to be changed");
286*/ 281*/
287 return true; 282 return true;
288 283
289} 284}
290 285
291bool ResourceOpie::lock( const QString &fileName ) 286bool ResourceOpie::lock( const QString &fileName )
292{ 287{
293 qDebug("ResourceOpie::lock() has to be fixed - %s", mFileName.latin1()); 288 qDebug("ResourceOpie::lock() has to be fixed - %s", mFileName.latin1());
294 289
295/*US 290/*US
296// qDebug("ResourceOpie::lock() %s", fileName.latin1()); 291// qDebug("ResourceOpie::lock() %s", fileName.latin1());
297 kdDebug(5700) << "ResourceOpie::lock()" << endl; 292 kdDebug(5700) << "ResourceOpie::lock()" << endl;
298 293
299 QString fn = fileName; 294 QString fn = fileName;
300 295
301//US change the implementation how the lockfilename is getting created 296//US change the implementation how the lockfilename is getting created
302//US fn.replace( QRegExp("/"), "_" ); 297//US fn.replace( QRegExp("/"), "_" );
303//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); 298//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
304 299
305 KURL url(fn); 300 KURL url(fn);
306 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 301 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
307 302
308 kdDebug(5700) << "-- lock name: " << lockName << endl; 303 kdDebug(5700) << "-- lock name: " << lockName << endl;
309 304
310 if (QFile::exists( lockName )) return false; 305 if (QFile::exists( lockName )) return false;
311 306
312 QString lockUniqueName; 307 QString lockUniqueName;
313 lockUniqueName = fn + KApplication::randomString( 8 ); 308 lockUniqueName = fn + KApplication::randomString( 8 );
314 309
315 url = lockUniqueName; 310 url = lockUniqueName;
316//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); 311//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
317 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); 312 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
318 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; 313 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
319 314
320 // Create unique file 315 // Create unique file
321 QFile file( mLockUniqueName ); 316 QFile file( mLockUniqueName );
322 file.open( IO_WriteOnly ); 317 file.open( IO_WriteOnly );
323 file.close(); 318 file.close();
324 319
325 // Create lock file 320 // Create lock file
326 int result = ::link( QFile::encodeName( mLockUniqueName ), 321 int result = ::link( QFile::encodeName( mLockUniqueName ),
327 QFile::encodeName( lockName ) ); 322 QFile::encodeName( lockName ) );
328 323
329 if ( result == 0 ) { 324 if ( result == 0 ) {
330 addressBook()->emitAddressBookLocked(); 325 addressBook()->emitAddressBookLocked();
331 return true; 326 return true;
332 } 327 }
333 328
334 // TODO: check stat 329 // TODO: check stat
335 330
336 return false; 331 return false;
337*/ 332*/
338 333
339 return true; 334 return true;
340} 335}
341 336
342void ResourceOpie::unlock( const QString &fileName ) 337void ResourceOpie::unlock( const QString &fileName )
343{ 338{
344 qDebug("ResourceOpie::unlock() has to be fixed - %s", mFileName.latin1()); 339 qDebug("ResourceOpie::unlock() has to be fixed - %s", mFileName.latin1());
345/*US 340/*US
346// qDebug("ResourceOpie::unlock() %s", fileName.latin1()); 341// qDebug("ResourceOpie::unlock() %s", fileName.latin1());
347 342
348 QString fn = fileName; 343 QString fn = fileName;
349//US change the implementation how the lockfilename is getting created 344//US change the implementation how the lockfilename is getting created
350//US fn.replace( QRegExp( "/" ), "_" ); 345//US fn.replace( QRegExp( "/" ), "_" );
351//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); 346//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
352//US QString lockName = fn + ".lock"; 347//US QString lockName = fn + ".lock";
353 KURL url(fn); 348 KURL url(fn);
354 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 349 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
355 350
356 QFile::remove( lockName ); 351 QFile::remove( lockName );
357 QFile::remove( mLockUniqueName ); 352 QFile::remove( mLockUniqueName );
358 addressBook()->emitAddressBookUnlocked(); 353 addressBook()->emitAddressBookUnlocked();
359*/ 354*/
360} 355}
361 356
362void ResourceOpie::setFileName( const QString &fileName ) 357void ResourceOpie::setFileName( const QString &fileName )
363{ 358{
364/*US ToDo: no synchronization so far. Has to be changed in the future 359/*US ToDo: no synchronization so far. Has to be changed in the future
365 mDirWatch.stopScan(); 360 mDirWatch.stopScan();
366 mDirWatch.removeFile( mFileName ); 361 mDirWatch.removeFile( mFileName );
367*/ 362*/
368 mFileName = fileName; 363 mFileName = fileName;
369 364
370 365
371/*US ToDo: no synchronization so far. Has to be changed in the future 366/*US ToDo: no synchronization so far. Has to be changed in the future
372 mDirWatch.addFile( mFileName ); 367 mDirWatch.addFile( mFileName );
373 mDirWatch.startScan(); 368 mDirWatch.startScan();
374*/ 369*/
375//US simulate KDirWatch event 370//US simulate KDirWatch event
376 fileChanged(); 371 fileChanged();
377} 372}
378 373
379QString ResourceOpie::fileName() const 374QString ResourceOpie::fileName() const
380{ 375{
381 return mFileName; 376 return mFileName;
382} 377}
383 378
384void ResourceOpie::fileChanged() 379void ResourceOpie::fileChanged()
385{ 380{
386 // There is a small theoretical chance that KDirWatch calls us before 381 // There is a small theoretical chance that KDirWatch calls us before
387 // we are fully constructed 382 // we are fully constructed
388 if (!addressBook()) 383 if (!addressBook())
389 return; 384 return;
390 load(); 385 load();
391 addressBook()->emitAddressBookChanged(); 386 addressBook()->emitAddressBookChanged();
392} 387}
393 388
394void ResourceOpie::removeAddressee( const Addressee &addr ) 389void ResourceOpie::removeAddressee( const Addressee &addr )
395{ 390{
396/*US 391/*US
397 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/photos/" ) + addr.uid() ) ); 392 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/photos/" ) + addr.uid() ) );
398 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/logos/" ) + addr.uid() ) ); 393 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/logos/" ) + addr.uid() ) );
399 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/sounds/" ) + addr.uid() ) ); 394 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/sounds/" ) + addr.uid() ) );
400*/ 395*/
401} 396}
402 397
403void ResourceOpie::cleanUp() 398void ResourceOpie::cleanUp()
404{ 399{
405// qDebug("ResourceOpie::cleanup() %s", mFileName.latin1()); 400// qDebug("ResourceOpie::cleanup() %s", mFileName.latin1());
406 401
407 unlock( mFileName ); 402 unlock( mFileName );
408} 403}