author | zautrix <zautrix> | 2004-07-07 11:56:39 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-07 11:56:39 (UTC) |
commit | 56721aac86c9ae5253abac8962474c8d1a7e648a (patch) (side-by-side diff) | |
tree | c12f41eba0d5724ee800cdb92727ffd6d3c1cf6c /kabc/plugins | |
parent | 13d88c91f2916090bd45e23b504d0b665c68126f (diff) | |
download | kdepimpi-56721aac86c9ae5253abac8962474c8d1a7e648a.zip kdepimpi-56721aac86c9ae5253abac8962474c8d1a7e648a.tar.gz kdepimpi-56721aac86c9ae5253abac8962474c8d1a7e648a.tar.bz2 |
Changes for compiling on desktop
-rw-r--r-- | kabc/plugins/dir/dir.pro | 29 | ||||
-rw-r--r-- | kabc/plugins/dir/resourcedir.cpp | 6 | ||||
-rw-r--r-- | kabc/plugins/file/file.pro | 30 | ||||
-rw-r--r-- | kabc/plugins/file/resourcefile.cpp | 6 |
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 @@ +TEMPLATE = lib +CONFIG += qt warn_on release +#release debug + +TARGET = microkabc_dir +INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat +DESTDIR = ../../../bin +#LIBS += -lmicrokde -lmicrokabc +#LIBS += -L$(QPEDIR)/lib + +INTERFACES = \ + +HEADERS = \ + resourcedir.h \ + resourcedirconfig.h + +SOURCES = \ + resourcedir.cpp \ + resourcedirconfig.cpp + +unix : { +OBJECTS_DIR = obj/unix +MOC_DIR = moc/unix +} +win32: { +DEFINES += _WIN32_ +OBJECTS_DIR = obj/win +MOC_DIR = moc/win +}
\ 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 @@ -215,99 +215,101 @@ bool ResourceDir::save( Ticket *ticket ) continue; } mFormat->save( *it, &file ); // mark as unchanged (*it).setChanged( false ); file.close(); } delete ticket; unlock( mPath ); return ok; } bool ResourceDir::lock( const QString &path ) { kdDebug(5700) << "ResourceDir::lock()" << endl; QString p = path; //US change the implementation how the lockfilename is getting created //US p.replace( QRegExp("/"), "_" ); //US QString lockName = locateLocal( "data", "kabc/lock/" + p + ".lock" ); KURL url(p); QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); kdDebug(5700) << "-- lock name: " << lockName << endl; if ( QFile::exists( lockName ) ) return false; QString lockUniqueName; lockUniqueName = p + KApplication::randomString( 8 ); url = lockUniqueName; //US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; // Create unique file QFile file( mLockUniqueName ); file.open( IO_WriteOnly ); file.close(); // Create lock file - int result = ::link( QFile::encodeName( mLockUniqueName ), + int result = 0; +#ifndef _WIN32_ + result = ::link( QFile::encodeName( mLockUniqueName ), QFile::encodeName( lockName ) ); - +#endif if ( result == 0 ) { addressBook()->emitAddressBookLocked(); return true; } // TODO: check stat return false; } void ResourceDir::unlock( const QString &path ) { QString p = path; //US change the implementation how the lockfilename is getting created //US p.replace( QRegExp( "/" ), "_" ); //US QString lockName = locate( "data", "kabc/lock/" + p + ".lock" ); KURL url(p); QString lockName = locate( "data", "kabc/lock/" + url.fileName() + ".lock" ); ::unlink( QFile::encodeName( lockName ) ); QFile::remove( mLockUniqueName ); addressBook()->emitAddressBookUnlocked(); } void ResourceDir::setPath( const QString &path ) { /*US ToDo: no synchronization so far. Has to be changed in the future mDirWatch.stopScan(); mDirWatch.removeDir( mPath ); */ mPath = path; /*US ToDo: no synchronization so far. Has to be changed in the future mDirWatch.addDir( mPath, true ); mDirWatch.startScan(); */ //US simulate KDirWatch event pathChanged(); } QString ResourceDir::path() const { return mPath; } void ResourceDir::setFormat( const QString &format ) 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 @@ +TEMPLATE = lib +CONFIG += qt warn_on release +#release debug + +TARGET = microkabc_file +INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat + +DESTDIR = ../../../bin +#LIBS += -lmicrokde -lmicrokabc +#LIBS += -L$(QPEDIR)/lib + +INTERFACES = \ + +HEADERS = \ + resourcefile.h \ + resourcefileconfig.h + +SOURCES = \ + resourcefile.cpp \ + resourcefileconfig.cpp + +unix : { +OBJECTS_DIR = obj/unix +MOC_DIR = moc/unix +} +win32: { +DEFINES += _WIN32_ +OBJECTS_DIR = obj/win +MOC_DIR = moc/win +}
\ 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 @@ -241,99 +241,101 @@ bool ResourceFile::save( Ticket *ticket ) } else { } if ( !ok ) addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); delete ticket; unlock( mFileName ); return ok; qDebug("ResourceFile::save has to be changed"); return true; } bool ResourceFile::lock( const QString &fileName ) { QString fn = fileName; //US change the implementation how the lockfilename is getting created //US fn.replace( QRegExp("/"), "_" ); //US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); KURL url(fn); QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); if (QFile::exists( lockName )) return false; QString lockUniqueName; lockUniqueName = fn + KApplication::randomString( 8 ); url = lockUniqueName; //US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; // Create unique file QFile file( mLockUniqueName ); file.open( IO_WriteOnly ); file.close(); // Create lock file - int result = ::link( QFile::encodeName( mLockUniqueName ), + int result = 0; +#ifndef _WIN32_ + result = ::link( QFile::encodeName( mLockUniqueName ), QFile::encodeName( lockName ) ); - +#endif if ( result == 0 ) { addressBook()->emitAddressBookLocked(); return true; } // TODO: check stat return false; } void ResourceFile::unlock( const QString &fileName ) { QString fn = fileName; //US change the implementation how the lockfilename is getting created //US fn.replace( QRegExp( "/" ), "_" ); //US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); //US QString lockName = fn + ".lock"; KURL url(fn); QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); QFile::remove( lockName ); QFile::remove( mLockUniqueName ); addressBook()->emitAddressBookUnlocked(); } void ResourceFile::setFileName( const QString &fileName ) { /*US ToDo: no synchronization so far. Has to be changed in the future mDirWatch.stopScan(); mDirWatch.removeFile( mFileName ); */ mFileName = fileName; /*US ToDo: no synchronization so far. Has to be changed in the future mDirWatch.addFile( mFileName ); mDirWatch.startScan(); */ //US simulate KDirWatch event fileChanged(); } QString ResourceFile::fileName() const { return mFileName; } void ResourceFile::setFormat( const QString &format ) |