summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-06-30 22:02:19 (UTC)
committer ulf69 <ulf69>2004-06-30 22:02:19 (UTC)
commit570dc8214a4b43ca89e71901f48deea2b53492bb (patch) (unidiff)
treed3eb25840e1e0e29541c0005ed7950b84557c34c
parent2de4aeb0272fa7d96a55332196a11e52b2f27539 (diff)
downloadkdepimpi-570dc8214a4b43ca89e71901f48deea2b53492bb.zip
kdepimpi-570dc8214a4b43ca89e71901f48deea2b53492bb.tar.gz
kdepimpi-570dc8214a4b43ca89e71901f48deea2b53492bb.tar.bz2
implemented loading of opie resources
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/opie/kabc_opieE.pro24
-rw-r--r--kabc/plugins/opie/resourceopie.cpp117
-rw-r--r--kabc/plugins/opie/resourceopie.h9
-rw-r--r--kabc/plugins/opie/resourceopieconfig.cpp9
4 files changed, 113 insertions, 46 deletions
diff --git a/kabc/plugins/opie/kabc_opieE.pro b/kabc/plugins/opie/kabc_opieE.pro
index 7341ca8..f3e2ac4 100644
--- a/kabc/plugins/opie/kabc_opieE.pro
+++ b/kabc/plugins/opie/kabc_opieE.pro
@@ -1,21 +1,31 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on release 2CONFIG += qt warn_on
3#release debug 3#release debug
4
5TARGET = microkabc_opie 4TARGET = microkabc_opie
6INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat 5
6INCLUDEPATH += ../.. ../../converter/opie ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat $(QPEDIR)/include
7
8
7OBJECTS_DIR = obj/$(PLATFORM) 9OBJECTS_DIR = obj/$(PLATFORM)
8MOC_DIR = moc 10MOC_DIR = moc/$(PLATFORM)
9DESTDIR = $(QPEDIR)/lib 11DESTDIR = $(QPEDIR)/lib
10LIBS += -lmicrokde -lmicrokabc 12LIBS += -lmicrokde
13LIBS += -lmicrokabc
11LIBS += -L$(QPEDIR)/lib 14LIBS += -L$(QPEDIR)/lib
15LIBS += -lopie
16LIBS += -lqpe
17LIBS += -lqte
18LIBS += -lmicrokabc_opieconverter
19#LIBS += -L../../lib/$(PLATFORM)
20
12 21
13INTERFACES = \ 22INTERFACES = \
14 23
15HEADERS = \ 24HEADERS = \
16 resourceopie.h \ 25 resourceopie.h \
17 resourceopieconfig.h 26 resourceopieconfig.h \
18 27
19SOURCES = \ 28SOURCES = \
20 resourceopie.cpp \ 29 resourceopie.cpp \
21 resourceopieconfig.cpp 30 resourceopieconfig.cpp \
31
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp
index 47e22b4..f992301 100644
--- a/kabc/plugins/opie/resourceopie.cpp
+++ b/kabc/plugins/opie/resourceopie.cpp
@@ -8,338 +8,387 @@
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 <qfile.h> 33#include <qfile.h>
33#include <qfileinfo.h> 34#include <qfileinfo.h>
34#include <qregexp.h> 35#include <qregexp.h>
35#include <qtimer.h> 36#include <qtimer.h>
36 37
37#include <kapplication.h> 38#include <kapplication.h>
38#include <kconfig.h> 39#include <kconfig.h>
39#include <kdebug.h> 40#include <kdebug.h>
40#include <klocale.h> 41#include <klocale.h>
41//US #include <ksavefile.h> 42//US #include <ksavefile.h>
42#include <kstandarddirs.h> 43#include <kstandarddirs.h>
43 44
44//US #include "formatfactory.h" 45//US #include "formatfactory.h"
46//US #include <qpe/qpeapplication.h>
47
48#include <opie/ocontactaccess.h>
45 49
46#include "resource.h" 50#include "resource.h"
47#include "resourceopieconfig.h" 51#include "resourceopieconfig.h"
48#include "stdaddressbook.h" 52#include "stdaddressbook.h"
49 53
54#include "opieconverter.h"
55
50#include "resourceopie.h" 56#include "resourceopie.h"
51 57
52using namespace KABC; 58using namespace KABC;
53extern "C" 59extern "C"
54{ 60{
55//US void *init_kabc_file()
56 void *init_microkabc_opie() 61 void *init_microkabc_opie()
57 { 62 {
58 return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig>(); 63 return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig>();
59 } 64 }
60} 65}
61 66
62ResourceOpie::ResourceOpie( const KConfig *config ) 67ResourceOpie::ResourceOpie( const KConfig *config )
63 : Resource( config ) 68 : Resource( config ), mConverter (0)
64{ 69{
65 QString fileName; 70 QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
66 71
67 KConfig *cfg = (KConfig *)config; 72 KConfig *cfg = (KConfig *)config;
68 if ( cfg ) { 73 if ( cfg ) {
69 fileName = cfg->readEntry( "FileName", StdAddressBook::fileName() ); 74 fileName = cfg->readEntry( "FileName", fileName );
70// qDebug("ResourceFile::ResourceFile : 1 %s, %s", fileName.latin1(), formatName.latin1() ); 75
71 } else {
72 fileName = StdAddressBook::fileName();
73// qDebug("ResourceFile::ResourceFile : 2 %s, %s", fileName.latin1(), formatName.latin1() );
74 } 76 }
75 77
78// qDebug("ResourceOpie::ResourceOpie : %s", fileName.latin1() );
79
76 init( fileName ); 80 init( fileName );
77} 81}
78 82
79ResourceOpie::ResourceOpie( const QString &fileName ) 83ResourceOpie::ResourceOpie( const QString &fileName )
80 : Resource( 0 ) 84 : Resource( 0 )
81{ 85{
82// qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); 86// qDebug("ResourceOpie::ResourceOpie : 3 %s", fileName.latin1());
83 init( fileName ); 87 init( fileName );
84} 88}
85 89
86void ResourceOpie::init( const QString &fileName ) 90void ResourceOpie::init( const QString &fileName )
87{ 91{
88 92
89/*US we have no KDirWatch. SO simulate the signals from inside the apropriate methods 93/*US we have no KDirWatch. SO simulate the signals from inside the apropriate methods
90 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 94 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
91 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); 95 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
92 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 96 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
93*/ 97*/
98 //US opie addressbook is always readonly
99 setReadOnly( true );
94 100
95 setFileName( fileName ); 101 setFileName( fileName );
102
96} 103}
97 104
98ResourceOpie::~ResourceOpie() 105ResourceOpie::~ResourceOpie()
99{ 106{
107 if (mConverter != 0)
108 delete mConverter;
100} 109}
101 110
102void ResourceOpie::writeConfig( KConfig *config ) 111void ResourceOpie::writeConfig( KConfig *config )
103{ 112{
113 //US opie addressbook is always readonly
114 setReadOnly( true );
115
104 Resource::writeConfig( config ); 116 Resource::writeConfig( config );
105 117
106 config->writeEntry( "FileName", mFileName ); 118 config->writeEntry( "FileName", mFileName );
107 119
108// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1()); 120// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1());
109 121
110} 122}
111 123
112Ticket *ResourceOpie::requestSaveTicket() 124Ticket *ResourceOpie::requestSaveTicket()
113{ 125{
114 kdDebug(5700) << "ResourceOpie::requestSaveTicket()" << endl; 126 kdDebug(5700) << "ResourceOpie::requestSaveTicket()" << endl;
115 127
116 if ( !addressBook() ) return 0; 128 if ( !addressBook() ) return 0;
117 129
118 if ( !lock( mFileName ) ) { 130 if ( !lock( mFileName ) ) {
119 kdDebug(5700) << "ResourceOpie::requestSaveTicket(): Unable to lock file '" 131 kdDebug(5700) << "ResourceOpie::requestSaveTicket(): Unable to lock file '"
120 << mFileName << "'" << endl; 132 << mFileName << "'" << endl;
121 return 0; 133 return 0;
122 } 134 }
123 return createTicket( this ); 135 return createTicket( this );
124} 136}
125 137
126 138
127bool ResourceOpie::doOpen() 139bool ResourceOpie::doOpen()
128{ 140{
141// qDebug("ResourceOpie::doOpen() %s", mFileName.latin1());
142/*US
129 QFile file( mFileName ); 143 QFile file( mFileName );
130 144
131 if ( !file.exists() ) { 145 if ( !file.exists() ) {
132 // try to create the file 146 // try to create the file
133 bool ok = file.open( IO_WriteOnly ); 147 bool ok = file.open( IO_WriteOnly );
134 if ( ok ) 148 if ( ok )
135 file.close(); 149 file.close();
136 150
137 return ok; 151 return ok;
138 } else { 152 } else {
139 if ( !file.open( IO_ReadWrite ) ) 153 if ( !file.open( IO_ReadWrite ) )
140 return false; 154 return false;
141 155
142 if ( file.size() == 0 ) { 156 if ( file.size() == 0 ) {
143 file.close(); 157 file.close();
144 return true; 158 return true;
145 } 159 }
146 160
147//US bool ok = mFormat->checkFormat( &file ); 161//US bool ok = mFormat->checkFormat( &file );
148 bool ok = true; 162 bool ok = true;
149 163
150 file.close(); 164 file.close();
151 165
152 return ok; 166 return ok;
153 } 167 }
168*/
169 qDebug("ResourceOpie::doOpen() has to be fixed - %s", mFileName.latin1());
170 return true;
154} 171}
155 172
156void ResourceOpie::doClose() 173void ResourceOpie::doClose()
157{ 174{
175// qDebug("ResourceOpie::doClose() %s", mFileName.latin1());
158} 176}
159 177
160bool ResourceOpie::load() 178bool ResourceOpie::load()
161{ 179{
180// qDebug("ResourceOpie::load() %s", mFileName.latin1());
162 kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl; 181 kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl;
163 182
164 QFile file( mFileName ); 183 OContactAccess* access = new OContactAccess("KDEPim/Pi", mFileName, 0l, false);
165 if ( !file.open( IO_ReadOnly ) ) { 184
166 addressBook()->error( i18n( "Unable to open file '%1'." ).arg( mFileName ) ); 185 if ( !access ) {
186 qDebug("Unable to load file() %s", mFileName.latin1());
187 addressBook()->error( i18n( "Unable to load file '%1'." ).arg( mFileName ) );
167 return false; 188 return false;
168 } 189 }
190
191 access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available
192
193 if (mConverter == 0)
194 mConverter = new OpieConverter();
169 195
170// qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1()); 196
197 OContactAccess::List::Iterator it;
198 OContactAccess::List allList = access->allRecords();
199 bool res = false;
200 for ( it = allList.begin(); it != allList.end(); ++it )
201 {
202 OContact c = (*it);
203
204 KABC::Addressee addressee;
205
206 res = mConverter->opieToAddressee( c, addressee );
207
208 if ( !addressee.isEmpty() && res )
209 {
210 addressee.setResource( this );
211 addressBook()->insertAddressee( addressee );
212 }
213
214// qDebug("found %s", c.fullName().latin1());
215 }
216
217 delete access;
171 218
172 //US return mFormat->loadAll( addressBook(), this, &file );
173 return true; 219 return true;
174} 220}
175 221
176bool ResourceOpie::save( Ticket *ticket ) 222bool ResourceOpie::save( Ticket *ticket )
177{ 223{
178// qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1()); 224 qDebug("ResourceOpie::save() has to be fixed - %s", mFileName.latin1());
225/*US
226
227 qDebug("ResourceOpie::save %s", mFileName.latin1());
179 kdDebug(5700) << "ResourceOpie::save()" << endl; 228 kdDebug(5700) << "ResourceOpie::save()" << endl;
180 229
181 // create backup file 230 // create backup file
182 QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); 231 QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() );
183 232*/
184/*US we use a simpler method to create a backupfile 233/*US we use a simpler method to create a backupfile
185 234
186 (void) KSaveFile::backupFile( mFileName, QString::null 235 (void) KSaveFile::backupFile( mFileName, QString::null
187 ,extension ); 236 ,extension );
188 237
189 KSaveFile saveFile( mFileName ); 238 KSaveFile saveFile( mFileName );
190 bool ok = false; 239 bool ok = false;
191 if ( saveFile.status() == 0 && saveFile.file() ) 240 if ( saveFile.status() == 0 && saveFile.file() )
192 { 241 {
193 mFormat->saveAll( addressBook(), this, saveFile.file() ); 242 mFormat->saveAll( addressBook(), this, saveFile.file() );
194 ok = saveFile.close(); 243 ok = saveFile.close();
195 } 244 }
196*/ 245*/
197 246/*US
198//US ToDo: write backupfile 247//US ToDo: write backupfile
199 QFile info; 248 QFile info;
200 info.setName( mFileName ); 249 info.setName( mFileName );
201 bool ok = info.open( IO_WriteOnly ); 250 bool ok = info.open( IO_WriteOnly );
202 if ( ok ) { 251 if ( ok ) {
203//US mFormat->saveAll( addressBook(), this, &info ); 252//US mFormat->saveAll( addressBook(), this, &info );
204 253
205 info.close(); 254 info.close();
206 ok = true; 255 ok = true;
207 } 256 }
208 else { 257 else {
209 258
210 } 259 }
211 260
212 if ( !ok ) 261 if ( !ok )
213 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); 262 addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) );
214 263
215 delete ticket; 264 delete ticket;
216 unlock( mFileName ); 265 unlock( mFileName );
217 266
218 return ok; 267 return ok;
219 268
220 qDebug("ResourceOpie::save has to be changed"); 269 qDebug("ResourceOpie::save has to be changed");
270*/
221 return true; 271 return true;
272
222} 273}
223 274
224bool ResourceOpie::lock( const QString &fileName ) 275bool ResourceOpie::lock( const QString &fileName )
225{ 276{
277 qDebug("ResourceOpie::lock() has to be fixed - %s", mFileName.latin1());
278
279/*US
280// qDebug("ResourceOpie::lock() %s", fileName.latin1());
226 kdDebug(5700) << "ResourceOpie::lock()" << endl; 281 kdDebug(5700) << "ResourceOpie::lock()" << endl;
227 282
228 QString fn = fileName; 283 QString fn = fileName;
229 284
230//US change the implementation how the lockfilename is getting created 285//US change the implementation how the lockfilename is getting created
231//US fn.replace( QRegExp("/"), "_" ); 286//US fn.replace( QRegExp("/"), "_" );
232//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); 287//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
233 288
234 KURL url(fn); 289 KURL url(fn);
235 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 290 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
236 291
237 kdDebug(5700) << "-- lock name: " << lockName << endl; 292 kdDebug(5700) << "-- lock name: " << lockName << endl;
238 293
239 if (QFile::exists( lockName )) return false; 294 if (QFile::exists( lockName )) return false;
240 295
241 QString lockUniqueName; 296 QString lockUniqueName;
242 lockUniqueName = fn + KApplication::randomString( 8 ); 297 lockUniqueName = fn + KApplication::randomString( 8 );
243 298
244 url = lockUniqueName; 299 url = lockUniqueName;
245//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); 300//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
246 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); 301 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
247 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; 302 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
248 303
249 // Create unique file 304 // Create unique file
250 QFile file( mLockUniqueName ); 305 QFile file( mLockUniqueName );
251 file.open( IO_WriteOnly ); 306 file.open( IO_WriteOnly );
252 file.close(); 307 file.close();
253 308
254 // Create lock file 309 // Create lock file
255 int result = ::link( QFile::encodeName( mLockUniqueName ), 310 int result = ::link( QFile::encodeName( mLockUniqueName ),
256 QFile::encodeName( lockName ) ); 311 QFile::encodeName( lockName ) );
257 312
258 if ( result == 0 ) { 313 if ( result == 0 ) {
259 addressBook()->emitAddressBookLocked(); 314 addressBook()->emitAddressBookLocked();
260 return true; 315 return true;
261 } 316 }
262 317
263 // TODO: check stat 318 // TODO: check stat
264 319
265 return false; 320 return false;
321*/
322
323 return true;
266} 324}
267 325
268void ResourceOpie::unlock( const QString &fileName ) 326void ResourceOpie::unlock( const QString &fileName )
269{ 327{
328 qDebug("ResourceOpie::unlock() has to be fixed - %s", mFileName.latin1());
329/*US
330// qDebug("ResourceOpie::unlock() %s", fileName.latin1());
331
270 QString fn = fileName; 332 QString fn = fileName;
271//US change the implementation how the lockfilename is getting created 333//US change the implementation how the lockfilename is getting created
272//US fn.replace( QRegExp( "/" ), "_" ); 334//US fn.replace( QRegExp( "/" ), "_" );
273//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); 335//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
274//US QString lockName = fn + ".lock"; 336//US QString lockName = fn + ".lock";
275 KURL url(fn); 337 KURL url(fn);
276 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 338 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
277 339
278 QFile::remove( lockName ); 340 QFile::remove( lockName );
279 QFile::remove( mLockUniqueName ); 341 QFile::remove( mLockUniqueName );
280 addressBook()->emitAddressBookUnlocked(); 342 addressBook()->emitAddressBookUnlocked();
343*/
281} 344}
282 345
283void ResourceOpie::setFileName( const QString &fileName ) 346void ResourceOpie::setFileName( const QString &fileName )
284{ 347{
285/*US ToDo: no synchronization so far. Has to be changed in the future 348/*US ToDo: no synchronization so far. Has to be changed in the future
286 mDirWatch.stopScan(); 349 mDirWatch.stopScan();
287 mDirWatch.removeFile( mFileName ); 350 mDirWatch.removeFile( mFileName );
288*/ 351*/
289 mFileName = fileName; 352 mFileName = fileName;
290 353
291 354
292/*US ToDo: no synchronization so far. Has to be changed in the future 355/*US ToDo: no synchronization so far. Has to be changed in the future
293 mDirWatch.addFile( mFileName ); 356 mDirWatch.addFile( mFileName );
294 mDirWatch.startScan(); 357 mDirWatch.startScan();
295*/ 358*/
296//US simulate KDirWatch event 359//US simulate KDirWatch event
297 fileChanged(); 360 fileChanged();
298} 361}
299 362
300QString ResourceOpie::fileName() const 363QString ResourceOpie::fileName() const
301{ 364{
302 return mFileName; 365 return mFileName;
303} 366}
304 367
305/*US
306void ResourceOpie::setFormat( const QString &format )
307{
308 mFormatName = format;
309 delete mFormat;
310
311 FormatFactory *factory = FormatFactory::self();
312 mFormat = factory->format( mFormatName );
313}
314
315QString ResourceOpie::format() const
316{
317 return mFormatName;
318}
319*/
320
321void ResourceOpie::fileChanged() 368void ResourceOpie::fileChanged()
322{ 369{
323 // There is a small theoretical chance that KDirWatch calls us before 370 // There is a small theoretical chance that KDirWatch calls us before
324 // we are fully constructed 371 // we are fully constructed
325 if (!addressBook()) 372 if (!addressBook())
326 return; 373 return;
327 load(); 374 load();
328 addressBook()->emitAddressBookChanged(); 375 addressBook()->emitAddressBookChanged();
329} 376}
330 377
331void ResourceOpie::removeAddressee( const Addressee &addr ) 378void ResourceOpie::removeAddressee( const Addressee &addr )
332{ 379{
333/*US 380/*US
334 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/photos/" ) + addr.uid() ) ); 381 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/photos/" ) + addr.uid() ) );
335 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/logos/" ) + addr.uid() ) ); 382 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/logos/" ) + addr.uid() ) );
336 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/sounds/" ) + addr.uid() ) ); 383 QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/sounds/" ) + addr.uid() ) );
337*/ 384*/
338} 385}
339 386
340void ResourceOpie::cleanUp() 387void ResourceOpie::cleanUp()
341{ 388{
389// qDebug("ResourceOpie::cleanup() %s", mFileName.latin1());
390
342 unlock( mFileName ); 391 unlock( mFileName );
343} 392}
344 393
345//US #include "resourceopie.moc" 394//US #include "resourceopie.moc"
diff --git a/kabc/plugins/opie/resourceopie.h b/kabc/plugins/opie/resourceopie.h
index d21272a..9db9485 100644
--- a/kabc/plugins/opie/resourceopie.h
+++ b/kabc/plugins/opie/resourceopie.h
@@ -15,56 +15,57 @@
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 28
29#ifndef KABC_RESOURCEOPIE_H 29#ifndef KABC_RESOURCEOPIE_H
30#define KABC_RESOURCEOPIE_H 30#define KABC_RESOURCEOPIE_H
31 31
32#include <kconfig.h> 32#include <kconfig.h>
33#include <kdirwatch.h> 33#include <kdirwatch.h>
34 34
35#include <sys/types.h> 35#include <sys/types.h>
36 36
37#include "resource.h" 37#include "resource.h"
38 38
39class QTimer; 39
40class FormatPlugin; 40//class QTimer;
41//class FormatPlugin;
41 42
42namespace KABC { 43namespace KABC {
43 44
44//US class FormatPlugin; 45//US class FormatPlugin;
45class ResourceConfigWidget; 46class ResourceConfigWidget;
46 47class OpieConverter;
47/** 48/**
48 @internal 49 @internal
49*/ 50*/
50class ResourceOpie : public Resource 51class ResourceOpie : public Resource
51{ 52{
52 Q_OBJECT 53 Q_OBJECT
53 54
54public: 55public:
55 56
56 /** 57 /**
57 Constructor. 58 Constructor.
58 59
59 @param cfg The config object where custom resource settings are stored. 60 @param cfg The config object where custom resource settings are stored.
60 */ 61 */
61 ResourceOpie( const KConfig *cfg ); 62 ResourceOpie( const KConfig *cfg );
62 63
63 /** 64 /**
64 Construct file resource on file @arg fileName using format @arg formatName. 65 Construct file resource on file @arg fileName using format @arg formatName.
65 */ 66 */
66 ResourceOpie( const QString &fileName ); 67 ResourceOpie( const QString &fileName );
67 68
68 /** 69 /**
69 * Destructor. 70 * Destructor.
70 */ 71 */
@@ -116,34 +117,36 @@ public:
116 QString fileName() const; 117 QString fileName() const;
117 118
118 /** 119 /**
119 * Remove a addressee from its source. 120 * Remove a addressee from its source.
120 * This method is mainly called by KABC::AddressBook. 121 * This method is mainly called by KABC::AddressBook.
121 */ 122 */
122 virtual void removeAddressee( const Addressee& addr ); 123 virtual void removeAddressee( const Addressee& addr );
123 124
124 /** 125 /**
125 * This method is called by an error handler if the application 126 * This method is called by an error handler if the application
126 * crashed 127 * crashed
127 */ 128 */
128 virtual void cleanUp(); 129 virtual void cleanUp();
129 130
130protected slots: 131protected slots:
131 void fileChanged(); 132 void fileChanged();
132 133
133protected: 134protected:
134 void init( const QString &fileName ); 135 void init( const QString &fileName );
135 136
136 bool lock( const QString &fileName ); 137 bool lock( const QString &fileName );
137 void unlock( const QString &fileName ); 138 void unlock( const QString &fileName );
138 139
139private: 140private:
141 OpieConverter* mConverter;
142
140 QString mFileName; 143 QString mFileName;
141 144
142 QString mLockUniqueName; 145 QString mLockUniqueName;
143 146
144 KDirWatch mDirWatch; 147 KDirWatch mDirWatch;
145}; 148};
146 149
147} 150}
148 151
149#endif 152#endif
diff --git a/kabc/plugins/opie/resourceopieconfig.cpp b/kabc/plugins/opie/resourceopieconfig.cpp
index b92cfa1..f4cc4f9 100644
--- a/kabc/plugins/opie/resourceopieconfig.cpp
+++ b/kabc/plugins/opie/resourceopieconfig.cpp
@@ -14,94 +14,99 @@
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 <qfile.h> 39#include <qfile.h>
39#include "resourceopie.h" 40#include "resourceopie.h"
40#include "stdaddressbook.h" 41//US #include <qpe/qpeapplication.h>
42
43//US #include "stdaddressbook.h"
41 44
42#include "resourceopieconfig.h" 45#include "resourceopieconfig.h"
43 46
44using namespace KABC; 47using namespace KABC;
45 48
46ResourceOpieConfig::ResourceOpieConfig( QWidget* parent, const char* name ) 49ResourceOpieConfig::ResourceOpieConfig( QWidget* parent, const char* name )
47 : ConfigWidget( parent, name ) 50 : ConfigWidget( parent, name )
48{ 51{
49//qDebug("ResourceFileConfig::ResourceFileConfig"); 52//qDebug("ResourceFileConfig::ResourceFileConfig");
50 53
51 QGridLayout *mainLayout = new QGridLayout( this, 1, 2, 0, 54 QGridLayout *mainLayout = new QGridLayout( this, 1, 2, 0,
52 KDialog::spacingHint() ); 55 KDialog::spacingHint() );
53 56
54 QLabel *label = new QLabel( i18n( "Location:" ), this ); 57 QLabel *label = new QLabel( i18n( "Location:" ), this );
55 mFileNameEdit = new KURLRequester( this ); 58 mFileNameEdit = new KURLRequester( this );
56 59
57 connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ), 60 connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ),
58 SLOT( checkFilePermissions( const QString & ) ) ); 61 SLOT( checkFilePermissions( const QString & ) ) );
59 62
60 mainLayout->addWidget( label, 0, 0 ); 63 mainLayout->addWidget( label, 0, 0 );
61 mainLayout->addWidget( mFileNameEdit, 0, 1 ); 64 mainLayout->addWidget( mFileNameEdit, 0, 1 );
62 65
63//US mInEditMode = false; 66//US mInEditMode = false;
64} 67}
65/*US 68/*US
66void ResourceOpieConfig::setEditMode( bool value ) 69void ResourceOpieConfig::setEditMode( bool value )
67{ 70{
68 mInEditMode = value; 71 mInEditMode = value;
69} 72}
70*/ 73*/
71 74
72void ResourceOpieConfig::loadSettings( KRES::Resource *res ) 75void ResourceOpieConfig::loadSettings( KRES::Resource *res )
73{ 76{
74//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); 77//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res );
75 ResourceOpie *resource = (ResourceOpie*)( res ); 78 ResourceOpie *resource = (ResourceOpie*)( res );
76 79
77 if ( !resource ) { 80 if ( !resource ) {
78 kdDebug(5700) << "ResourceOpieConfig::loadSettings(): cast failed" << endl; 81 kdDebug(5700) << "ResourceOpieConfig::loadSettings(): cast failed" << endl;
79 return; 82 return;
80 } 83 }
81 84
82 mFileNameEdit->setURL( resource->fileName() ); 85 mFileNameEdit->setURL( resource->fileName() );
83 if ( mFileNameEdit->url().isEmpty() ) 86 if ( mFileNameEdit->url().isEmpty() )
84 mFileNameEdit->setURL( KABC::StdAddressBook::fileName() ); 87 mFileNameEdit->setURL( QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml" );
85} 88}
86 89
87void ResourceOpieConfig::saveSettings( KRES::Resource *res ) 90void ResourceOpieConfig::saveSettings( KRES::Resource *res )
88{ 91{
89//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); 92//US ResourceFile *resource = dynamic_cast<ResourceFile*>( res );
90 ResourceOpie *resource = (ResourceOpie*)( res ); 93 ResourceOpie *resource = (ResourceOpie*)( res );
91 94
92 if ( !resource ) { 95 if ( !resource ) {
93 kdDebug(5700) << "ResourceOpieConfig::saveSettings(): cast failed" << endl; 96 kdDebug(5700) << "ResourceOpieConfig::saveSettings(): cast failed" << endl;
94 return; 97 return;
95 } 98 }
96 99
97 resource->setFileName( mFileNameEdit->url() ); 100 resource->setFileName( mFileNameEdit->url() );
98} 101}
99 102
100void ResourceOpieConfig::checkFilePermissions( const QString& fileName ) 103void ResourceOpieConfig::checkFilePermissions( const QString& fileName )
101{ 104{
102 // If file exist but is not writeable... 105 // If file exist but is not writeable...
106/*US
103 if ( access( QFile::encodeName( fileName ), F_OK ) == 0 ) 107 if ( access( QFile::encodeName( fileName ), F_OK ) == 0 )
104 emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 ); 108 emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 );
109*/
105} 110}
106 111
107//US #include "resourceopieconfig.moc" 112//US #include "resourceopieconfig.moc"