summaryrefslogtreecommitdiffabout
path: root/kabc/plugins
Unidiff
Diffstat (limited to 'kabc/plugins') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/dir/dir.pro29
-rw-r--r--kabc/plugins/dir/resourcedir.cpp6
-rw-r--r--kabc/plugins/file/file.pro30
-rw-r--r--kabc/plugins/file/resourcefile.cpp6
4 files changed, 67 insertions, 4 deletions
diff --git a/kabc/plugins/dir/dir.pro b/kabc/plugins/dir/dir.pro
new file mode 100644
index 0000000..3db201f
--- a/dev/null
+++ b/kabc/plugins/dir/dir.pro
@@ -0,0 +1,29 @@
1 TEMPLATE= lib
2CONFIG += qt warn_on release
3#release debug
4
5TARGET = microkabc_dir
6INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat
7DESTDIR = ../../../bin
8#LIBS += -lmicrokde -lmicrokabc
9#LIBS += -L$(QPEDIR)/lib
10
11INTERFACES = \
12
13HEADERS = \
14 resourcedir.h \
15 resourcedirconfig.h
16
17SOURCES = \
18 resourcedir.cpp \
19 resourcedirconfig.cpp
20
21unix : {
22OBJECTS_DIR = obj/unix
23MOC_DIR = moc/unix
24}
25win32: {
26DEFINES += _WIN32_
27OBJECTS_DIR = obj/win
28MOC_DIR = moc/win
29} \ No newline at end of file
diff --git a/kabc/plugins/dir/resourcedir.cpp b/kabc/plugins/dir/resourcedir.cpp
index be19821..6ea2f4b 100644
--- a/kabc/plugins/dir/resourcedir.cpp
+++ b/kabc/plugins/dir/resourcedir.cpp
@@ -239,51 +239,53 @@ bool ResourceDir::lock( const QString &path )
239//US QString lockName = locateLocal( "data", "kabc/lock/" + p + ".lock" ); 239//US QString lockName = locateLocal( "data", "kabc/lock/" + p + ".lock" );
240 KURL url(p); 240 KURL url(p);
241 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 241 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
242 242
243 243
244 kdDebug(5700) << "-- lock name: " << lockName << endl; 244 kdDebug(5700) << "-- lock name: " << lockName << endl;
245 245
246 if ( QFile::exists( lockName ) ) return false; 246 if ( QFile::exists( lockName ) ) return false;
247 247
248 QString lockUniqueName; 248 QString lockUniqueName;
249 lockUniqueName = p + KApplication::randomString( 8 ); 249 lockUniqueName = p + KApplication::randomString( 8 );
250 250
251 url = lockUniqueName; 251 url = lockUniqueName;
252//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); 252//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
253 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); 253 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
254 254
255 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; 255 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
256 256
257 // Create unique file 257 // Create unique file
258 QFile file( mLockUniqueName ); 258 QFile file( mLockUniqueName );
259 file.open( IO_WriteOnly ); 259 file.open( IO_WriteOnly );
260 file.close(); 260 file.close();
261 261
262 // Create lock file 262 // Create lock file
263 int result = ::link( QFile::encodeName( mLockUniqueName ), 263 int result = 0;
264#ifndef _WIN32_
265 result = ::link( QFile::encodeName( mLockUniqueName ),
264 QFile::encodeName( lockName ) ); 266 QFile::encodeName( lockName ) );
265 267#endif
266 if ( result == 0 ) { 268 if ( result == 0 ) {
267 addressBook()->emitAddressBookLocked(); 269 addressBook()->emitAddressBookLocked();
268 return true; 270 return true;
269 } 271 }
270 272
271 // TODO: check stat 273 // TODO: check stat
272 274
273 return false; 275 return false;
274} 276}
275 277
276void ResourceDir::unlock( const QString &path ) 278void ResourceDir::unlock( const QString &path )
277{ 279{
278 QString p = path; 280 QString p = path;
279//US change the implementation how the lockfilename is getting created 281//US change the implementation how the lockfilename is getting created
280//US p.replace( QRegExp( "/" ), "_" ); 282//US p.replace( QRegExp( "/" ), "_" );
281//US QString lockName = locate( "data", "kabc/lock/" + p + ".lock" ); 283//US QString lockName = locate( "data", "kabc/lock/" + p + ".lock" );
282 KURL url(p); 284 KURL url(p);
283 QString lockName = locate( "data", "kabc/lock/" + url.fileName() + ".lock" ); 285 QString lockName = locate( "data", "kabc/lock/" + url.fileName() + ".lock" );
284 286
285 ::unlink( QFile::encodeName( lockName ) ); 287 ::unlink( QFile::encodeName( lockName ) );
286 QFile::remove( mLockUniqueName ); 288 QFile::remove( mLockUniqueName );
287 addressBook()->emitAddressBookUnlocked(); 289 addressBook()->emitAddressBookUnlocked();
288} 290}
289 291
diff --git a/kabc/plugins/file/file.pro b/kabc/plugins/file/file.pro
new file mode 100644
index 0000000..a5ade93
--- a/dev/null
+++ b/kabc/plugins/file/file.pro
@@ -0,0 +1,30 @@
1 TEMPLATE= lib
2CONFIG += qt warn_on release
3#release debug
4
5TARGET = microkabc_file
6INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat
7
8DESTDIR = ../../../bin
9#LIBS += -lmicrokde -lmicrokabc
10#LIBS += -L$(QPEDIR)/lib
11
12INTERFACES = \
13
14HEADERS = \
15 resourcefile.h \
16 resourcefileconfig.h
17
18SOURCES = \
19 resourcefile.cpp \
20 resourcefileconfig.cpp
21
22unix : {
23OBJECTS_DIR = obj/unix
24MOC_DIR = moc/unix
25}
26win32: {
27DEFINES += _WIN32_
28OBJECTS_DIR = obj/win
29MOC_DIR = moc/win
30} \ No newline at end of file
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp
index 3920f69..4b4c935 100644
--- a/kabc/plugins/file/resourcefile.cpp
+++ b/kabc/plugins/file/resourcefile.cpp
@@ -265,51 +265,53 @@ bool ResourceFile::lock( const QString &fileName )
265//US fn.replace( QRegExp("/"), "_" ); 265//US fn.replace( QRegExp("/"), "_" );
266//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); 266//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
267 267
268 KURL url(fn); 268 KURL url(fn);
269 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 269 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
270 270
271 271
272 272
273 if (QFile::exists( lockName )) return false; 273 if (QFile::exists( lockName )) return false;
274 274
275 QString lockUniqueName; 275 QString lockUniqueName;
276 lockUniqueName = fn + KApplication::randomString( 8 ); 276 lockUniqueName = fn + KApplication::randomString( 8 );
277 277
278 url = lockUniqueName; 278 url = lockUniqueName;
279//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); 279//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
280 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); 280 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
281 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; 281 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
282 282
283 // Create unique file 283 // Create unique file
284 QFile file( mLockUniqueName ); 284 QFile file( mLockUniqueName );
285 file.open( IO_WriteOnly ); 285 file.open( IO_WriteOnly );
286 file.close(); 286 file.close();
287 287
288 // Create lock file 288 // Create lock file
289 int result = ::link( QFile::encodeName( mLockUniqueName ), 289 int result = 0;
290#ifndef _WIN32_
291 result = ::link( QFile::encodeName( mLockUniqueName ),
290 QFile::encodeName( lockName ) ); 292 QFile::encodeName( lockName ) );
291 293#endif
292 if ( result == 0 ) { 294 if ( result == 0 ) {
293 addressBook()->emitAddressBookLocked(); 295 addressBook()->emitAddressBookLocked();
294 return true; 296 return true;
295 } 297 }
296 298
297 // TODO: check stat 299 // TODO: check stat
298 300
299 return false; 301 return false;
300} 302}
301 303
302void ResourceFile::unlock( const QString &fileName ) 304void ResourceFile::unlock( const QString &fileName )
303{ 305{
304 QString fn = fileName; 306 QString fn = fileName;
305//US change the implementation how the lockfilename is getting created 307//US change the implementation how the lockfilename is getting created
306//US fn.replace( QRegExp( "/" ), "_" ); 308//US fn.replace( QRegExp( "/" ), "_" );
307//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); 309//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
308//US QString lockName = fn + ".lock"; 310//US QString lockName = fn + ".lock";
309 KURL url(fn); 311 KURL url(fn);
310 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 312 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
311 313
312 QFile::remove( lockName ); 314 QFile::remove( lockName );
313 QFile::remove( mLockUniqueName ); 315 QFile::remove( mLockUniqueName );
314 addressBook()->emitAddressBookUnlocked(); 316 addressBook()->emitAddressBookUnlocked();
315} 317}