summaryrefslogtreecommitdiffabout
path: root/kabc/plugins/dir/resourcedir.cpp
Unidiff
Diffstat (limited to 'kabc/plugins/dir/resourcedir.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/dir/resourcedir.cpp35
1 files changed, 18 insertions, 17 deletions
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
61using namespace KABC; 62using namespace KABC;
62 63
63extern "C" 64extern "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
79ResourceDir::ResourceDir( const KConfig *config ) 80ResourceDir::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
127void ResourceDir::writeConfig( KConfig *config ) 128void 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
326qDebug("ResourceDir::setFormat initialized with format %s ", format.latin1()); 327qDebug("ResourceDir::setFormat initialized with format %s ", format.latin1());
327 if (mFormatName == "vcard") 328 if (mFormatName == "vcard")
328 mFormat = new VCardFormatPlugin2(); 329 mFormat = new VCardFormatPlugin2();