-rw-r--r-- | kabc/plugins/dir/dir.pro | 2 | ||||
-rw-r--r-- | kabc/plugins/dir/dirE.pro | 2 | ||||
-rw-r--r-- | kabc/plugins/dir/resourcedir.cpp | 35 | ||||
-rw-r--r-- | kabc/plugins/dir/resourcedir.h | 6 |
4 files changed, 23 insertions, 22 deletions
diff --git a/kabc/plugins/dir/dir.pro b/kabc/plugins/dir/dir.pro index 0555484..a7c1503 100644 --- a/kabc/plugins/dir/dir.pro +++ b/kabc/plugins/dir/dir.pro | |||
@@ -1,12 +1,12 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | #release debug | 3 | #release debug |
4 | 4 | ||
5 | TARGET = microkabc_dir | 5 | TARGET = microkabc_dir |
6 | INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat | 6 | INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat |
7 | DESTDIR = ../../../bin | 7 | DESTDIR = ../../../bin |
8 | #LIBS += -lmicrokde -lmicrokabc | 8 | #LIBS += -lmicrokde -lmicrokabc |
9 | #LIBS += -L$(QPEDIR)/lib | 9 | #LIBS += -L$(QPEDIR)/lib |
10 | 10 | ||
11 | INTERFACES = \ | 11 | INTERFACES = \ |
12 | 12 | ||
diff --git a/kabc/plugins/dir/dirE.pro b/kabc/plugins/dir/dirE.pro index 729f4ce..9066556 100644 --- a/kabc/plugins/dir/dirE.pro +++ b/kabc/plugins/dir/dirE.pro | |||
@@ -1,12 +1,12 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | #release debug | 3 | #release debug |
4 | 4 | ||
5 | TARGET = microkabc_dir | 5 | TARGET = microkabc_dir |
6 | INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat | 6 | INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat |
7 | OBJECTS_DIR = obj/$(PLATFORM) | 7 | OBJECTS_DIR = obj/$(PLATFORM) |
8 | MOC_DIR = moc/$(PLATFORM) | 8 | MOC_DIR = moc/$(PLATFORM) |
9 | DESTDIR = $(QPEDIR)/lib | 9 | DESTDIR = $(QPEDIR)/lib |
10 | LIBS += -lmicrokde -lmicrokabc | 10 | LIBS += -lmicrokde -lmicrokabc |
11 | LIBS += -L$(QPEDIR)/lib | 11 | LIBS += -L$(QPEDIR)/lib |
12 | 12 | ||
diff --git a/kabc/plugins/dir/resourcedir.cpp b/kabc/plugins/dir/resourcedir.cpp index 52863d5..d978e61 100644 --- a/kabc/plugins/dir/resourcedir.cpp +++ b/kabc/plugins/dir/resourcedir.cpp | |||
@@ -54,33 +54,34 @@ $Id$ | |||
54 | #include "stdaddressbook.h" | 54 | #include "stdaddressbook.h" |
55 | 55 | ||
56 | //US | 56 | //US |
57 | #include <qdir.h> | 57 | #include <qdir.h> |
58 | 58 | ||
59 | #include "resourcedir.h" | 59 | #include "resourcedir.h" |
60 | #include "syncwidget.h" | ||
60 | 61 | ||
61 | using namespace KABC; | 62 | using namespace KABC; |
62 | 63 | ||
63 | extern "C" | 64 | extern "C" |
64 | #ifdef _WIN32_ | 65 | #ifdef _WIN32_ |
65 | __declspec(dllexport) | 66 | __declspec(dllexport) |
66 | #else | 67 | #else |
67 | { | 68 | { |
68 | #endif | 69 | #endif |
69 | 70 | ||
70 | //US void *init_kabc_dir() | 71 | //US void *init_kabc_dir() |
71 | void *init_microkabc_dir() | 72 | void *init_microkabc_dir() |
72 | { | 73 | { |
73 | return new KRES::PluginFactory<ResourceDir,ResourceDirConfig>(); | 74 | return new KRES::PluginFactory<ResourceDir,ResourceDirConfig, KRES::SyncWidget>(); |
74 | } | 75 | } |
75 | #ifndef _WIN32_ | 76 | #ifndef _WIN32_ |
76 | } | 77 | } |
77 | #endif | 78 | #endif |
78 | 79 | ||
79 | ResourceDir::ResourceDir( const KConfig *config ) | 80 | ResourceDir::ResourceDir( const KConfig *config, bool syncable ) |
80 | : Resource( config ) | 81 | : Resource( config, syncable ) |
81 | { | 82 | { |
82 | QString path; | 83 | QString path; |
83 | 84 | ||
84 | KConfig *cfg = (KConfig *)config; | 85 | KConfig *cfg = (KConfig *)config; |
85 | if ( cfg ) { | 86 | if ( cfg ) { |
86 | //US path = config->readEntry( "FilePath" ); | 87 | //US path = config->readEntry( "FilePath" ); |
@@ -98,22 +99,22 @@ ResourceDir::ResourceDir( const KConfig *config ) | |||
98 | 99 | ||
99 | if ( !mFormat ) { | 100 | if ( !mFormat ) { |
100 | mFormatName = "vcard"; | 101 | mFormatName = "vcard"; |
101 | mFormat = factory->format( mFormatName ); | 102 | mFormat = factory->format( mFormatName ); |
102 | } | 103 | } |
103 | 104 | ||
104 | /*US | 105 | /*US |
105 | //US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1()); | 106 | //US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1()); |
106 | if (mFormatName == "vcard") | 107 | if (mFormatName == "vcard") |
107 | mFormat = new VCardFormatPlugin2(); | 108 | mFormat = new VCardFormatPlugin2(); |
108 | else if (mFormatName == "binary") | 109 | else if (mFormatName == "binary") |
109 | mFormat = new BinaryFormat(); | 110 | mFormat = new BinaryFormat(); |
110 | else | 111 | else |
111 | qDebug("ResourceFile::init format unknown !!! %s ", mFormatName.latin1()); | 112 | qDebug("ResourceFile::init format unknown !!! %s ", mFormatName.latin1()); |
112 | */ | 113 | */ |
113 | 114 | ||
114 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( pathChanged() ) ); | 115 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( pathChanged() ) ); |
115 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( pathChanged() ) ); | 116 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( pathChanged() ) ); |
116 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( pathChanged() ) ); | 117 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( pathChanged() ) ); |
117 | 118 | ||
118 | setPath( path ); | 119 | setPath( path ); |
119 | } | 120 | } |
@@ -122,14 +123,14 @@ ResourceDir::~ResourceDir() | |||
122 | { | 123 | { |
123 | delete mFormat; | 124 | delete mFormat; |
124 | mFormat = 0; | 125 | mFormat = 0; |
125 | } | 126 | } |
126 | 127 | ||
127 | void ResourceDir::writeConfig( KConfig *config ) | 128 | void ResourceDir::writeConfig( KConfig *config ) |
128 | { | 129 | { |
129 | config->setGroup( "Resource_" + identifier() ); | 130 | config->setGroup( "Resource_" + identifier() ); |
130 | Resource::writeConfig( config ); | 131 | Resource::writeConfig( config ); |
131 | 132 | ||
132 | config->writeEntry( "FilePath", mPath ); | 133 | config->writeEntry( "FilePath", mPath ); |
133 | config->writeEntry( "FileFormat", mFormatName ); | 134 | config->writeEntry( "FileFormat", mFormatName ); |
134 | } | 135 | } |
135 | 136 | ||
@@ -238,27 +239,27 @@ bool ResourceDir::lock( const QString &path ) | |||
238 | kdDebug(5700) << "ResourceDir::lock()" << endl; | 239 | kdDebug(5700) << "ResourceDir::lock()" << endl; |
239 | 240 | ||
240 | QString p = path; | 241 | QString p = path; |
241 | //US change the implementation how the lockfilename is getting created | 242 | //US change the implementation how the lockfilename is getting created |
242 | //US p.replace( QRegExp("/"), "_" ); | 243 | //US p.replace( QRegExp("/"), "_" ); |
243 | //US QString lockName = locateLocal( "data", "kabc/lock/" + p + ".lock" ); | 244 | //US QString lockName = locateLocal( "data", "kabc/lock/" + p + ".lock" ); |
244 | KURL url(p); | 245 | KURL url(p); |
245 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); | 246 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); |
246 | 247 | ||
247 | 248 | ||
248 | kdDebug(5700) << "-- lock name: " << lockName << endl; | 249 | kdDebug(5700) << "-- lock name: " << lockName << endl; |
249 | 250 | ||
250 | if ( QFile::exists( lockName ) ) return false; | 251 | if ( QFile::exists( lockName ) ) return false; |
251 | 252 | ||
252 | QString lockUniqueName; | 253 | QString lockUniqueName; |
253 | lockUniqueName = p + KApplication::randomString( 8 ); | 254 | lockUniqueName = p + KApplication::randomString( 8 ); |
254 | 255 | ||
255 | url = lockUniqueName; | 256 | url = lockUniqueName; |
256 | //US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); | 257 | //US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); |
257 | mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); | 258 | mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); |
258 | 259 | ||
259 | kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; | 260 | kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; |
260 | 261 | ||
261 | // Create unique file | 262 | // Create unique file |
262 | QFile file( mLockUniqueName ); | 263 | QFile file( mLockUniqueName ); |
263 | file.open( IO_WriteOnly ); | 264 | file.open( IO_WriteOnly ); |
264 | file.close(); | 265 | file.close(); |
@@ -282,31 +283,31 @@ bool ResourceDir::lock( const QString &path ) | |||
282 | void ResourceDir::unlock( const QString &path ) | 283 | void ResourceDir::unlock( const QString &path ) |
283 | { | 284 | { |
284 | QString p = path; | 285 | QString p = path; |
285 | //US change the implementation how the lockfilename is getting created | 286 | //US change the implementation how the lockfilename is getting created |
286 | //US p.replace( QRegExp( "/" ), "_" ); | 287 | //US p.replace( QRegExp( "/" ), "_" ); |
287 | //US QString lockName = locate( "data", "kabc/lock/" + p + ".lock" ); | 288 | //US QString lockName = locate( "data", "kabc/lock/" + p + ".lock" ); |
288 | KURL url(p); | 289 | KURL url(p); |
289 | QString lockName = locate( "data", "kabc/lock/" + url.fileName() + ".lock" ); | 290 | QString lockName = locate( "data", "kabc/lock/" + url.fileName() + ".lock" ); |
290 | 291 | ||
291 | ::unlink( QFile::encodeName( lockName ) ); | 292 | ::unlink( QFile::encodeName( lockName ) ); |
292 | QFile::remove( mLockUniqueName ); | 293 | QFile::remove( mLockUniqueName ); |
293 | addressBook()->emitAddressBookUnlocked(); | 294 | addressBook()->emitAddressBookUnlocked(); |
294 | } | 295 | } |
295 | 296 | ||
296 | void ResourceDir::setPath( const QString &path ) | 297 | void ResourceDir::setPath( const QString &path ) |
297 | { | 298 | { |
298 | mDirWatch.stopScan(); | 299 | mDirWatch.stopScan(); |
299 | mDirWatch.removeDir( mPath ); | 300 | mDirWatch.removeDir( mPath ); |
300 | 301 | ||
301 | mPath = path; | 302 | mPath = path; |
302 | 303 | ||
303 | mDirWatch.addDir( mPath, true ); | 304 | mDirWatch.addDir( mPath, true ); |
304 | mDirWatch.startScan(); | 305 | mDirWatch.startScan(); |
305 | 306 | ||
306 | //US simulate KDirWatch event | 307 | //US simulate KDirWatch event |
307 | //US pathChanged(); | 308 | //US pathChanged(); |
308 | 309 | ||
309 | } | 310 | } |
310 | 311 | ||
311 | QString ResourceDir::path() const | 312 | QString ResourceDir::path() const |
312 | { | 313 | { |
@@ -319,13 +320,13 @@ void ResourceDir::setFormat( const QString &format ) | |||
319 | 320 | ||
320 | if ( mFormat ) | 321 | if ( mFormat ) |
321 | delete mFormat; | 322 | delete mFormat; |
322 | 323 | ||
323 | FormatFactory *factory = FormatFactory::self(); | 324 | FormatFactory *factory = FormatFactory::self(); |
324 | mFormat = factory->format( mFormatName ); | 325 | mFormat = factory->format( mFormatName ); |
325 | /*US | 326 | /*US |
326 | qDebug("ResourceDir::setFormat initialized with format %s ", format.latin1()); | 327 | qDebug("ResourceDir::setFormat initialized with format %s ", format.latin1()); |
327 | if (mFormatName == "vcard") | 328 | if (mFormatName == "vcard") |
328 | mFormat = new VCardFormatPlugin2(); | 329 | mFormat = new VCardFormatPlugin2(); |
329 | else if (mFormatName == "binary") | 330 | else if (mFormatName == "binary") |
330 | mFormat = new BinaryFormat(); | 331 | mFormat = new BinaryFormat(); |
331 | else | 332 | else |
diff --git a/kabc/plugins/dir/resourcedir.h b/kabc/plugins/dir/resourcedir.h index 6e35695..c2aedad 100644 --- a/kabc/plugins/dir/resourcedir.h +++ b/kabc/plugins/dir/resourcedir.h | |||
@@ -46,20 +46,20 @@ class FormatPlugin; | |||
46 | */ | 46 | */ |
47 | class ResourceDir : public Resource | 47 | class ResourceDir : public Resource |
48 | { | 48 | { |
49 | Q_OBJECT | 49 | Q_OBJECT |
50 | 50 | ||
51 | public: | 51 | public: |
52 | ResourceDir( const KConfig* ); | 52 | ResourceDir( const KConfig*, bool syncable ); |
53 | ~ResourceDir(); | 53 | ~ResourceDir(); |
54 | 54 | ||
55 | virtual void writeConfig( KConfig* ); | 55 | virtual void writeConfig( KConfig* ); |
56 | 56 | ||
57 | virtual bool doOpen(); | 57 | virtual bool doOpen(); |
58 | virtual void doClose(); | 58 | virtual void doClose(); |
59 | 59 | ||
60 | virtual Ticket *requestSaveTicket(); | 60 | virtual Ticket *requestSaveTicket(); |
61 | 61 | ||
62 | virtual bool load(); | 62 | virtual bool load(); |
63 | virtual bool save( Ticket * ); | 63 | virtual bool save( Ticket * ); |
64 | 64 | ||
65 | /** | 65 | /** |
@@ -78,13 +78,13 @@ public: | |||
78 | void setFormat( const QString &format ); | 78 | void setFormat( const QString &format ); |
79 | 79 | ||
80 | /** | 80 | /** |
81 | * Returns the format name. | 81 | * Returns the format name. |
82 | */ | 82 | */ |
83 | QString format() const; | 83 | QString format() const; |
84 | 84 | ||
85 | /** | 85 | /** |
86 | * Remove a addressee from its source. | 86 | * Remove a addressee from its source. |
87 | * This method is mainly called by KABC::AddressBook. | 87 | * This method is mainly called by KABC::AddressBook. |
88 | */ | 88 | */ |
89 | virtual void removeAddressee( const Addressee& addr ); | 89 | virtual void removeAddressee( const Addressee& addr ); |
90 | 90 | ||