summaryrefslogtreecommitdiffabout
path: root/kabc/plugins/opie/resourceopie.cpp
Side-by-side diff
Diffstat (limited to 'kabc/plugins/opie/resourceopie.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kabc/plugins/opie/resourceopie.cpp20
1 files changed, 2 insertions, 18 deletions
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp
index 1222242..5559827 100644
--- a/kabc/plugins/opie/resourceopie.cpp
+++ b/kabc/plugins/opie/resourceopie.cpp
@@ -41,82 +41,76 @@ $Id$
//US #include <ksavefile.h>
#include <kstandarddirs.h>
#include <kmessagebox.h>
//US #include "formatfactory.h"
//US #include <qpe/qpeapplication.h>
#include <opie/ocontactaccess.h>
#include <opie/ocontactaccessbackend_xml.h>
#include "resourceopieconfig.h"
#include "stdaddressbook.h"
-#include "syncwidget.h"
+#include "syncprefwidget.h"
#include "opieconverter.h"
#include "resourceopie.h"
using namespace KABC;
extern "C"
{
void *init_microkabc_opie()
{
- return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig, KRES::SyncWidget>();
+ return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig, SyncPrefWidget>();
}
}
ResourceOpie::ResourceOpie( const KConfig *config, bool syncable )
: Resource( config, syncable ), mAccess(0), mConverter (0)
{
QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
KConfig *cfg = (KConfig *)config;
if ( cfg ) {
fileName = cfg->readEntry( "FileName", fileName );
}
-// qDebug("ResourceOpie::ResourceOpie : %s", fileName.latin1() );
-
init( fileName );
}
ResourceOpie::ResourceOpie( const QString &fileName, bool syncable )
: Resource( 0, syncable )
{
-// qDebug("ResourceOpie::ResourceOpie : 3 %s", fileName.latin1());
init( fileName );
}
void ResourceOpie::init( const QString &fileName )
{
connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
-
setFileName( fileName );
-
}
ResourceOpie::~ResourceOpie()
{
if (mConverter != 0)
delete mConverter;
if(mAccess != 0)
delete mAccess;
-
}
void ResourceOpie::writeConfig( KConfig *config )
{
Resource::writeConfig( config );
config->writeEntry( "FileName", fileName() );
}
Ticket *ResourceOpie::requestSaveTicket()
{
kdDebug(5700) << "ResourceOpie::requestSaveTicket()" << endl;
@@ -242,34 +236,28 @@ bool ResourceOpie::save( Ticket *ticket )
delete ticket;
unlock( fileName() );
return true;
}
bool ResourceOpie::lock( const QString &lockfileName )
{
qDebug("ResourceOpie::lock: %s", fileName().latin1());
-
-// qDebug("ResourceOpie::lock() %s", fileName.latin1());
kdDebug(5700) << "ResourceOpie::lock()" << endl;
QString fn = lockfileName;
-//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" );
kdDebug(5700) << "-- lock name: " << lockName << endl;
if (QFile::exists( lockName )) return false;
QString lockUniqueName;
lockUniqueName = fn + KApplication::randomString( 8 );
url = lockUniqueName;
//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
@@ -293,28 +281,24 @@ bool ResourceOpie::lock( const QString &lockfileName )
}
// TODO: check stat
return false;
}
void ResourceOpie::unlock( const QString &fileName )
{
qDebug("ResourceOpie::unlock() %s", fileName.latin1());
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 ResourceOpie::setFileName( const QString &newFileName )
{
mDirWatch.stopScan();
mDirWatch.removeFile( fileName() );