author | ulf69 <ulf69> | 2004-08-02 18:32:08 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-02 18:32:08 (UTC) |
commit | 863c4c3678e59ef125c08c00e9532ded5b540f67 (patch) (unidiff) | |
tree | 449428c45689ffe10ff1ce4caa18f959c4dfe402 /kabc/plugins/dir | |
parent | 983127ce46c9ff6663d08dedd450da3fe7dd549b (diff) | |
download | kdepimpi-863c4c3678e59ef125c08c00e9532ded5b540f67.zip kdepimpi-863c4c3678e59ef125c08c00e9532ded5b540f67.tar.gz kdepimpi-863c4c3678e59ef125c08c00e9532ded5b540f67.tar.bz2 |
added support for syncprofiles for resources and export/import capabilities
-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 | |||
@@ -3,7 +3,7 @@ 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 |
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 | |||
@@ -3,7 +3,7 @@ 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 |
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 | |||
@@ -57,12 +57,13 @@ $Id$ | |||
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 |
@@ -70,14 +71,14 @@ __declspec(dllexport) | |||
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 | ||
@@ -101,7 +102,7 @@ ResourceDir::ResourceDir( const KConfig *config ) | |||
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(); |
@@ -110,7 +111,7 @@ ResourceDir::ResourceDir( const KConfig *config ) | |||
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() ) ); |
@@ -125,8 +126,8 @@ ResourceDir::~ResourceDir() | |||
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 ); |
@@ -241,10 +242,10 @@ bool ResourceDir::lock( const QString &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; |
@@ -252,10 +253,10 @@ bool ResourceDir::lock( const QString &path ) | |||
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 |
@@ -285,7 +286,7 @@ void ResourceDir::unlock( const QString &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 ) ); |
@@ -297,13 +298,13 @@ 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 | } |
@@ -322,7 +323,7 @@ void ResourceDir::setFormat( const QString &format ) | |||
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(); |
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 | |||
@@ -49,14 +49,14 @@ class ResourceDir : public Resource | |||
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(); |
@@ -81,7 +81,7 @@ public: | |||
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. |