summaryrefslogtreecommitdiffabout
path: root/kabc/plugins/dir/resourcedir.cpp
Side-by-side diff
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
@@ -54,33 +54,34 @@ $Id$
#include "stdaddressbook.h"
//US
#include <qdir.h>
#include "resourcedir.h"
+#include "syncwidget.h"
using namespace KABC;
extern "C"
#ifdef _WIN32_
-__declspec(dllexport)
+__declspec(dllexport)
#else
{
#endif
//US void *init_kabc_dir()
void *init_microkabc_dir()
{
- return new KRES::PluginFactory<ResourceDir,ResourceDirConfig>();
+ return new KRES::PluginFactory<ResourceDir,ResourceDirConfig, KRES::SyncWidget>();
}
#ifndef _WIN32_
}
#endif
-ResourceDir::ResourceDir( const KConfig *config )
- : Resource( config )
+ResourceDir::ResourceDir( const KConfig *config, bool syncable )
+ : Resource( config, syncable )
{
QString path;
KConfig *cfg = (KConfig *)config;
if ( cfg ) {
//US path = config->readEntry( "FilePath" );
@@ -98,22 +99,22 @@ ResourceDir::ResourceDir( const KConfig *config )
if ( !mFormat ) {
mFormatName = "vcard";
mFormat = factory->format( mFormatName );
}
-/*US
+/*US
//US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1());
if (mFormatName == "vcard")
mFormat = new VCardFormatPlugin2();
else if (mFormatName == "binary")
mFormat = new BinaryFormat();
else
qDebug("ResourceFile::init format unknown !!! %s ", mFormatName.latin1());
*/
-
+
connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( pathChanged() ) );
connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( pathChanged() ) );
connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( pathChanged() ) );
setPath( path );
}
@@ -122,14 +123,14 @@ ResourceDir::~ResourceDir()
{
delete mFormat;
mFormat = 0;
}
void ResourceDir::writeConfig( KConfig *config )
-{
- config->setGroup( "Resource_" + identifier() );
+{
+ config->setGroup( "Resource_" + identifier() );
Resource::writeConfig( config );
config->writeEntry( "FilePath", mPath );
config->writeEntry( "FileFormat", mFormatName );
}
@@ -238,27 +239,27 @@ 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);
+ 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;
+ 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();
@@ -282,31 +283,31 @@ bool ResourceDir::lock( const QString &path )
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);
+ 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 )
{
mDirWatch.stopScan();
mDirWatch.removeDir( mPath );
-
+
mPath = path;
mDirWatch.addDir( mPath, true );
mDirWatch.startScan();
-//US simulate KDirWatch event
+//US simulate KDirWatch event
//US pathChanged();
}
QString ResourceDir::path() const
{
@@ -319,13 +320,13 @@ void ResourceDir::setFormat( const QString &format )
if ( mFormat )
delete mFormat;
FormatFactory *factory = FormatFactory::self();
mFormat = factory->format( mFormatName );
-/*US
+/*US
qDebug("ResourceDir::setFormat initialized with format %s ", format.latin1());
if (mFormatName == "vcard")
mFormat = new VCardFormatPlugin2();
else if (mFormatName == "binary")
mFormat = new BinaryFormat();
else