summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/dir/dir.pro2
-rw-r--r--kabc/plugins/dir/dirE.pro2
-rw-r--r--kabc/plugins/dir/resourcedir.cpp35
-rw-r--r--kabc/plugins/dir/resourcedir.h6
-rw-r--r--kabc/plugins/file/file.pro2
-rw-r--r--kabc/plugins/file/fileE.pro2
-rw-r--r--kabc/plugins/file/resourcefile.cpp74
-rw-r--r--kabc/plugins/file/resourcefile.h8
-rw-r--r--kabc/plugins/ldap/ldapE.pro2
-rw-r--r--kabc/plugins/ldap/resourceldap.cpp7
-rw-r--r--kabc/plugins/ldap/resourceldap.h2
-rw-r--r--kabc/plugins/opie/opieE.pro2
-rw-r--r--kabc/plugins/opie/resourceopie.cpp302
-rw-r--r--kabc/plugins/opie/resourceopie.h40
-rw-r--r--kabc/plugins/qtopia/qtopiaE.pro2
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp182
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.h35
-rw-r--r--kabc/plugins/sharpdtm/resourcesharpdtm.cpp35
-rw-r--r--kabc/plugins/sharpdtm/resourcesharpdtm.h32
-rw-r--r--kabc/plugins/sharpdtm/sharpdtmE.pro2
20 files changed, 419 insertions, 355 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
@@ -5,3 +5,3 @@ CONFIG += qt warn_on release
TARGET = microkabc_dir
-INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat
+INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat
DESTDIR = ../../../bin
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
@@ -5,3 +5,3 @@ CONFIG += qt warn_on release
TARGET = microkabc_dir
-INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat
+INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat
OBJECTS_DIR = obj/$(PLATFORM)
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
@@ -59,2 +59,3 @@ $Id$
#include "resourcedir.h"
+#include "syncwidget.h"
@@ -64,3 +65,3 @@ extern "C"
#ifdef _WIN32_
-__declspec(dllexport)
+__declspec(dllexport)
#else
@@ -72,3 +73,3 @@ __declspec(dllexport)
{
- return new KRES::PluginFactory<ResourceDir,ResourceDirConfig>();
+ return new KRES::PluginFactory<ResourceDir,ResourceDirConfig, KRES::SyncWidget>();
}
@@ -78,4 +79,4 @@ __declspec(dllexport)
-ResourceDir::ResourceDir( const KConfig *config )
- : Resource( config )
+ResourceDir::ResourceDir( const KConfig *config, bool syncable )
+ : Resource( config, syncable )
{
@@ -103,3 +104,3 @@ ResourceDir::ResourceDir( const KConfig *config )
-/*US
+/*US
//US qDebug("ResourceDir::ResourceDir initialized with format %s ", mFormatName.latin1());
@@ -112,3 +113,3 @@ ResourceDir::ResourceDir( const KConfig *config )
*/
-
+
connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( pathChanged() ) );
@@ -127,4 +128,4 @@ ResourceDir::~ResourceDir()
void ResourceDir::writeConfig( KConfig *config )
-{
- config->setGroup( "Resource_" + identifier() );
+{
+ config->setGroup( "Resource_" + identifier() );
Resource::writeConfig( config );
@@ -243,6 +244,6 @@ bool ResourceDir::lock( const QString &path )
//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;
@@ -254,6 +255,6 @@ bool ResourceDir::lock( const QString &path )
- 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;
@@ -287,3 +288,3 @@ void ResourceDir::unlock( const QString &path )
//US QString lockName = locate( "data", "kabc/lock/" + p + ".lock" );
- KURL url(p);
+ KURL url(p);
QString lockName = locate( "data", "kabc/lock/" + url.fileName() + ".lock" );
@@ -299,3 +300,3 @@ void ResourceDir::setPath( const QString &path )
mDirWatch.removeDir( mPath );
-
+
mPath = path;
@@ -305,3 +306,3 @@ void ResourceDir::setPath( const QString &path )
-//US simulate KDirWatch event
+//US simulate KDirWatch event
//US pathChanged();
@@ -324,3 +325,3 @@ void ResourceDir::setFormat( const QString &format )
mFormat = factory->format( mFormatName );
-/*US
+/*US
qDebug("ResourceDir::setFormat initialized with format %s ", format.latin1());
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
@@ -51,3 +51,3 @@ class ResourceDir : public Resource
public:
- ResourceDir( const KConfig* );
+ ResourceDir( const KConfig*, bool syncable );
~ResourceDir();
@@ -58,3 +58,3 @@ public:
virtual void doClose();
-
+
virtual Ticket *requestSaveTicket();
@@ -83,3 +83,3 @@ public:
QString format() const;
-
+
/**
diff --git a/kabc/plugins/file/file.pro b/kabc/plugins/file/file.pro
index 32555a2..154ef2a 100644
--- a/kabc/plugins/file/file.pro
+++ b/kabc/plugins/file/file.pro
@@ -5,3 +5,3 @@ CONFIG += qt warn_on release
TARGET = microkabc_file
-INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat
+INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat
diff --git a/kabc/plugins/file/fileE.pro b/kabc/plugins/file/fileE.pro
index d19a26d..3015806 100644
--- a/kabc/plugins/file/fileE.pro
+++ b/kabc/plugins/file/fileE.pro
@@ -5,3 +5,3 @@ CONFIG += qt warn_on release
TARGET = microkabc_file
-INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat
+INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat
OBJECTS_DIR = obj/$(PLATFORM)
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp
index 1d3acec..361b36b 100644
--- a/kabc/plugins/file/resourcefile.cpp
+++ b/kabc/plugins/file/resourcefile.cpp
@@ -53,2 +53,4 @@ $Id$
#include "resourcefile.h"
+#include "syncwidget.h"
+
@@ -58,3 +60,3 @@ extern "C"
#ifdef _WIN32_
-__declspec(dllexport)
+__declspec(dllexport)
#else
@@ -66,3 +68,3 @@ __declspec(dllexport)
{
- return new KRES::PluginFactory<ResourceFile,ResourceFileConfig>();
+ return new KRES::PluginFactory<ResourceFile,ResourceFileConfig, KRES::SyncWidget>();
}
@@ -72,4 +74,4 @@ __declspec(dllexport)
-ResourceFile::ResourceFile( const KConfig *config )
- : Resource( config ) , mFormat( 0 )
+ResourceFile::ResourceFile( const KConfig *config, bool syncable )
+ : Resource( config, syncable ) , mFormat( 0 )
{
@@ -91,5 +93,5 @@ ResourceFile::ResourceFile( const KConfig *config )
-ResourceFile::ResourceFile( const QString &fileName,
+ResourceFile::ResourceFile( const QString &fileName, bool syncable ,
const QString &formatName )
- : Resource( 0 )
+ : Resource( 0, syncable )
{
@@ -141,3 +143,3 @@ void ResourceFile::writeConfig( KConfig *config )
- config->setGroup( "Resource_" + identifier() );
+ config->setGroup( "Resource_" + identifier() );
Resource::writeConfig( config );
@@ -146,5 +148,5 @@ void ResourceFile::writeConfig( KConfig *config )
config->writeEntry( "FileFormat", mFormatName );
-
+
// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1());
-
+
}
@@ -199,3 +201,3 @@ bool ResourceFile::load()
{
-
+
@@ -208,3 +210,3 @@ bool ResourceFile::load()
// qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1());
-
+
return mFormat->loadAll( addressBook(), this, &file );
@@ -215,3 +217,3 @@ bool ResourceFile::save( Ticket *ticket )
// qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1());
-
+
@@ -219,5 +221,5 @@ bool ResourceFile::save( Ticket *ticket )
QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() );
-
+
/*US we use a simpler method to create a backupfile
-
+
(void) KSaveFile::backupFile( mFileName, QString::null
@@ -234,3 +236,3 @@ bool ResourceFile::save( Ticket *ticket )
-//US ToDo: write backupfile
+//US ToDo: write backupfile
QFile info;
@@ -240,3 +242,3 @@ bool ResourceFile::save( Ticket *ticket )
mFormat->saveAll( addressBook(), this, &info );
-
+
info.close();
@@ -245,11 +247,11 @@ bool ResourceFile::save( Ticket *ticket )
else {
-
+
}
-
+
if ( !ok )
addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) );
-
+
delete ticket;
unlock( mFileName );
-
+
return ok;
@@ -262,3 +264,3 @@ bool ResourceFile::lock( const QString &fileName )
{
-
+
@@ -269,7 +271,7 @@ bool ResourceFile::lock( const QString &fileName )
//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
-
- KURL url(fn);
+
+ KURL url(fn);
QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
-
-
+
+
@@ -279,4 +281,4 @@ bool ResourceFile::lock( const QString &fileName )
lockUniqueName = fn + KApplication::randomString( 8 );
-
- url = lockUniqueName;
+
+ url = lockUniqueName;
//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
@@ -313,5 +315,5 @@ void ResourceFile::unlock( const QString &fileName )
//US QString lockName = fn + ".lock";
- KURL url(fn);
+ KURL url(fn);
QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
-
+
QFile::remove( lockName );
@@ -325,6 +327,6 @@ void ResourceFile::setFileName( const QString &fileName )
mDirWatch.removeFile( mFileName );
-
+
mFileName = fileName;
-
+
mDirWatch.addFile( mFileName );
@@ -332,3 +334,3 @@ void ResourceFile::setFileName( const QString &fileName )
-//US simulate KDirWatch event
+//US simulate KDirWatch event
//US fileChanged();
@@ -348,3 +350,3 @@ void ResourceFile::setFormat( const QString &format )
mFormat = factory->format( mFormatName );
-/*US
+/*US
//qDebug("ResourceFile::setFormat initialized with format %s ", format.latin1());
@@ -361,3 +363,3 @@ void ResourceFile::setFormat( const QString &format )
*/
-
+
}
@@ -375,4 +377,4 @@ void ResourceFile::fileChanged()
return;
-
-
+
+
QString text( i18n( "File resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( mFileName ) );
diff --git a/kabc/plugins/file/resourcefile.h b/kabc/plugins/file/resourcefile.h
index 4522d78..0a3027c 100644
--- a/kabc/plugins/file/resourcefile.h
+++ b/kabc/plugins/file/resourcefile.h
@@ -60,3 +60,3 @@ public:
*/
- ResourceFile( const KConfig *cfg );
+ ResourceFile( const KConfig *cfg, bool syncable );
@@ -65,3 +65,3 @@ public:
*/
- ResourceFile( const QString &fileName, const QString &formatName = "vcard" );
+ ResourceFile( const QString &fileName, bool syncable , const QString &formatName = "vcard" );
@@ -87,3 +87,3 @@ public:
virtual void doClose();
-
+
/**
@@ -155,3 +155,3 @@ private:
QString mLockUniqueName;
-
+
KDirWatch mDirWatch;
diff --git a/kabc/plugins/ldap/ldapE.pro b/kabc/plugins/ldap/ldapE.pro
index f6ca586..2e79fc0 100644
--- a/kabc/plugins/ldap/ldapE.pro
+++ b/kabc/plugins/ldap/ldapE.pro
@@ -5,3 +5,3 @@ CONFIG += qt warn_on release
TARGET = microkabc_ldap
-INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat $(QPEDIR)/include
+INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kresources ../../../qtcompat $(QPEDIR)/include
OBJECTS_DIR = obj/$(PLATFORM)
diff --git a/kabc/plugins/ldap/resourceldap.cpp b/kabc/plugins/ldap/resourceldap.cpp
index 55c43af..4b9dede 100644
--- a/kabc/plugins/ldap/resourceldap.cpp
+++ b/kabc/plugins/ldap/resourceldap.cpp
@@ -38,2 +38,3 @@ $Id$
#include "resourceldapconfig.h"
+#include "syncwidget.h"
@@ -46,3 +47,3 @@ extern "C"
{
- return new KRES::PluginFactory<ResourceLDAP,ResourceLDAPConfig>();
+ return new KRES::PluginFactory<ResourceLDAP,ResourceLDAPConfig, KRES::SyncWidget>();
}
@@ -53,4 +54,4 @@ void addModOp( LDAPMod ***pmods, const QString &attr, const QString &value );
-ResourceLDAP::ResourceLDAP( const KConfig *config )
- : Resource( config ), mPort( 389 ), mLdap( 0 )
+ResourceLDAP::ResourceLDAP( const KConfig *config, bool syncable )
+ : Resource( config, syncable ), mPort( 389 ), mLdap( 0 )
{
diff --git a/kabc/plugins/ldap/resourceldap.h b/kabc/plugins/ldap/resourceldap.h
index 0625f30..0aad3c1 100644
--- a/kabc/plugins/ldap/resourceldap.h
+++ b/kabc/plugins/ldap/resourceldap.h
@@ -45,3 +45,3 @@ public:
- ResourceLDAP( const KConfig* );
+ ResourceLDAP( const KConfig*, bool syncable );
diff --git a/kabc/plugins/opie/opieE.pro b/kabc/plugins/opie/opieE.pro
index 8d45c3d..912e596 100644
--- a/kabc/plugins/opie/opieE.pro
+++ b/kabc/plugins/opie/opieE.pro
@@ -5,3 +5,3 @@ TARGET = microkabc_opie
-INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat $(QPEDIR)/include $(OPIEDIR)/include
+INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat $(QPEDIR)/include $(OPIEDIR)/include
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp
index aaee801..1222242 100644
--- a/kabc/plugins/opie/resourceopie.cpp
+++ b/kabc/plugins/opie/resourceopie.cpp
@@ -52,2 +52,3 @@ $Id$
#include "stdaddressbook.h"
+#include "syncwidget.h"
@@ -62,3 +63,3 @@ extern "C"
{
- return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig>();
+ return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig, KRES::SyncWidget>();
}
@@ -66,4 +67,4 @@ extern "C"
-ResourceOpie::ResourceOpie( const KConfig *config )
- : Resource( config ), mConverter (0)
+ResourceOpie::ResourceOpie( const KConfig *config, bool syncable )
+ : Resource( config, syncable ), mAccess(0), mConverter (0)
{
@@ -74,3 +75,3 @@ ResourceOpie::ResourceOpie( const KConfig *config )
fileName = cfg->readEntry( "FileName", fileName );
-
+
}
@@ -78,3 +79,3 @@ ResourceOpie::ResourceOpie( const KConfig *config )
// qDebug("ResourceOpie::ResourceOpie : %s", fileName.latin1() );
-
+
init( fileName );
@@ -82,4 +83,4 @@ ResourceOpie::ResourceOpie( const KConfig *config )
-ResourceOpie::ResourceOpie( const QString &fileName )
- : Resource( 0 )
+ResourceOpie::ResourceOpie( const QString &fileName, bool syncable )
+ : Resource( 0, syncable )
{
@@ -95,6 +96,6 @@ void ResourceOpie::init( const QString &fileName )
connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
-
+
setFileName( fileName );
-
+
}
@@ -105,2 +106,6 @@ ResourceOpie::~ResourceOpie()
delete mConverter;
+
+ if(mAccess != 0)
+ delete mAccess;
+
}
@@ -111,6 +116,3 @@ void ResourceOpie::writeConfig( KConfig *config )
- config->writeEntry( "FileName", mFileName );
-
-// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1());
-
+ config->writeEntry( "FileName", fileName() );
}
@@ -121,7 +123,9 @@ Ticket *ResourceOpie::requestSaveTicket()
+ qDebug("ResourceOpie::requestSaveTicket: %s", fileName().latin1());
+
if ( !addressBook() ) return 0;
- if ( !lock( mFileName ) ) {
+ if ( !lock( fileName() ) ) {
kdDebug(5700) << "ResourceOpie::requestSaveTicket(): Unable to lock file '"
- << mFileName << "'" << endl;
+ << fileName() << "'" << endl;
return 0;
@@ -134,58 +138,15 @@ bool ResourceOpie::doOpen()
{
-// qDebug("ResourceOpie::doOpen() %s", mFileName.latin1());
-/*US
- QFile file( mFileName );
-
- if ( !file.exists() ) {
- // try to create the file
- bool ok = file.open( IO_WriteOnly );
- if ( ok )
- file.close();
-
- return ok;
- } else {
- if ( !file.open( IO_ReadWrite ) )
- return false;
-
- if ( file.size() == 0 ) {
- file.close();
- return true;
- }
+ qDebug("ResourceOpie::doOpen: %s", fileName().latin1());
-//US bool ok = mFormat->checkFormat( &file );
- bool ok = true;
-
- file.close();
+ OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", fileName() );
+ mAccess = new OContactAccess("KDEPim/Pi", 0l, backend, false);
- return ok;
+ if ( !mAccess ) {
+ qDebug("Unable to load file() %s", fileName().latin1());
+ return false;
}
-*/
- qDebug("ResourceOpie::doOpen() has to be fixed - %s", mFileName.latin1());
- return true;
-}
-void ResourceOpie::doClose()
-{
-// qDebug("ResourceOpie::doClose() %s", mFileName.latin1());
-}
+ mAccess->setReadAhead( 32 ); // Use ReadAhead-Cache if available
-bool ResourceOpie::load()
-{
-// qDebug("ResourceOpie::load() %s", mFileName.latin1());
- kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl;
-
- qDebug("ResourceOpie::load: Try to load file() %s", mFileName.latin1());
-
- OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", mFileName );
- OContactAccess* access = new OContactAccess("KDEPim/Pi", 0l, backend, false);
-
- if ( !access ) {
- qDebug("Unable to load file() %s", mFileName.latin1());
- addressBook()->error( i18n( "Unable to load file '%1'." ).arg( mFileName ) );
- return false;
- }
-
- access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available
- bool res = false;
if (mConverter == 0)
@@ -193,3 +154,3 @@ bool ResourceOpie::load()
mConverter = new OpieConverter();
- res = mConverter->init();
+ bool res = mConverter->init();
if ( !res )
@@ -197,4 +158,4 @@ bool ResourceOpie::load()
qDebug("Unable to initialize opie converter. Most likely a problem with the category file");
- addressBook()->error( i18n( "Unable to initialize opie converter. Most likely a problem with the category file" ) );
- delete access;
+ delete mAccess;
+ mAccess = 0;
return false;
@@ -204,4 +165,31 @@ bool ResourceOpie::load()
- OContactAccess::List::Iterator it;
- OContactAccess::List allList = access->allRecords();
+
+ return true;
+}
+
+void ResourceOpie::doClose()
+{
+ qDebug("ResourceOpie::doClose: %s", fileName().latin1());
+
+ if(mAccess)
+ {
+ delete mAccess;
+ mAccess = 0;
+ }
+ // it seems so, that deletion of access deletes backend as well
+ //delete backend;
+
+ return;
+
+}
+
+
+bool ResourceOpie::load()
+{
+ qDebug("ResourceOpie::load: %s", fileName().latin1());
+
+ bool res = false;
+
+ OContactAccess::List::Iterator it;
+ OContactAccess::List allList = mAccess->allRecords();
for ( it = allList.begin(); it != allList.end(); ++it )
@@ -209,7 +197,7 @@ bool ResourceOpie::load()
const OContact c = (*it);
-
+
KABC::Addressee addressee;
-
- res = mConverter->opieToAddressee( c, addressee );
-
+
+ res = mConverter->opieToAddressee( c, addressee );
+
if ( !addressee.isEmpty() && res )
@@ -219,10 +207,6 @@ bool ResourceOpie::load()
}
-
-// qDebug("found %s", c.fullName().latin1());
+
}
-
- delete access;
- // it seems so, that deletion of access deletes backend as well
- //delete backend;
-
+
+
return true;
@@ -232,55 +216,40 @@ bool ResourceOpie::save( Ticket *ticket )
{
- qDebug("ResourceOpie::save() has to be fixed - %s", mFileName.latin1());
-/*US
-
- qDebug("ResourceOpie::save %s", mFileName.latin1());
- kdDebug(5700) << "ResourceOpie::save()" << endl;
-
- // create backup file
- QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() );
-*/
-/*US we use a simpler method to create a backupfile
-
- (void) KSaveFile::backupFile( mFileName, QString::null
- ,extension );
-
- KSaveFile saveFile( mFileName );
- bool ok = false;
- if ( saveFile.status() == 0 && saveFile.file() )
- {
- mFormat->saveAll( addressBook(), this, saveFile.file() );
- ok = saveFile.close();
- }
-*/
-/*US
-//US ToDo: write backupfile
- QFile info;
- info.setName( mFileName );
- bool ok = info.open( IO_WriteOnly );
- if ( ok ) {
-//US mFormat->saveAll( addressBook(), this, &info );
-
- info.close();
- ok = true;
- }
- else {
-
+ qDebug("ResourceOpie::save: %s", fileName().latin1());
+
+
+
+ KABC::AddressBook::Iterator it;
+ bool res;
+
+ for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
+ OContact c;
+ KABC::Addressee addressee = (*it);
+
+ res = mConverter->addresseeToOpie( *it, c );
+ if (res == true)
+ {
+ res = mAccess->add(c);
+ if (res == false)
+ qDebug("Unable to append Contact %s", c.fullName().latin1());
+ }
+ else
+ {
+ qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1());
+ }
}
-
- if ( !ok )
- addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) );
-
+
+ mAccess->save();
+
delete ticket;
- unlock( mFileName );
-
- return ok;
+ unlock( fileName() );
- qDebug("ResourceOpie::save has to be changed");
-*/
return true;
-
+
}
-bool ResourceOpie::lock( const QString &fileName )
+bool ResourceOpie::lock( const QString &lockfileName )
{
+ qDebug("ResourceOpie::lock: %s", fileName().latin1());
+
+
// qDebug("ResourceOpie::lock() %s", fileName.latin1());
@@ -288,3 +257,3 @@ bool ResourceOpie::lock( const QString &fileName )
- QString fn = fileName;
+ QString fn = lockfileName;
@@ -293,6 +262,6 @@ bool ResourceOpie::lock( const QString &fileName )
//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
-
- KURL url(fn);
+
+ KURL url(fn);
QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
-
+
kdDebug(5700) << "-- lock name: " << lockName << endl;
@@ -303,4 +272,4 @@ bool ResourceOpie::lock( const QString &fileName )
lockUniqueName = fn + KApplication::randomString( 8 );
-
- url = lockUniqueName;
+
+ url = lockUniqueName;
//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
@@ -332,4 +301,4 @@ void ResourceOpie::unlock( const QString &fileName )
{
-// qDebug("ResourceOpie::unlock() %s", fileName.latin1());
-
+ qDebug("ResourceOpie::unlock() %s", fileName.latin1());
+
QString fn = fileName;
@@ -339,5 +308,5 @@ void ResourceOpie::unlock( const QString &fileName )
//US QString lockName = fn + ".lock";
- KURL url(fn);
+ KURL url(fn);
QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
-
+
QFile::remove( lockName );
@@ -347,20 +316,14 @@ void ResourceOpie::unlock( const QString &fileName )
-void ResourceOpie::setFileName( const QString &fileName )
+void ResourceOpie::setFileName( const QString &newFileName )
{
mDirWatch.stopScan();
- mDirWatch.removeFile( mFileName );
-
- mFileName = fileName;
-
- mDirWatch.addFile( mFileName );
+ mDirWatch.removeFile( fileName() );
+
+ Resource::setFileName( newFileName );
+
+ mDirWatch.addFile( fileName() );
mDirWatch.startScan();
-//US simulate KDirWatch event
-//US fileChanged();
}
-QString ResourceOpie::fileName() const
-{
- return mFileName;
-}
@@ -372,4 +335,4 @@ void ResourceOpie::fileChanged()
return;
-
- QString text( i18n( "Opie resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( mFileName ) );
+
+ QString text( i18n( "Opie resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) );
if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) {
@@ -378,3 +341,3 @@ void ResourceOpie::fileChanged()
}
-
+
load();
@@ -391,5 +354,38 @@ void ResourceOpie::cleanUp()
- unlock( mFileName );
+ unlock( fileName() );
+}
+
+
+/**
+ * This method returns the number of elements that are currently in the resource.
+ */
+int ResourceOpie::count() const
+{
+ qDebug("ResourceOpie::count: %x", mAccess);
+
+ if (mAccess != 0)
+ {
+ OContactAccess::List contactList = mAccess->allRecords();
+ return contactList.count();
+ }
+ else
+ return 0;
+}
+
+
+/**
+ * This method removes all elements from the resource!! (Not from the addressbook)
+ */
+bool ResourceOpie::clear()
+{
+ if (mAccess != 0) {
+ mAccess->clear();
+ return true;
+ }
+ else
+ return false;
}
+
+
//US #include "resourceopie.moc"
diff --git a/kabc/plugins/opie/resourceopie.h b/kabc/plugins/opie/resourceopie.h
index 9db9485..ca30fee 100644
--- a/kabc/plugins/opie/resourceopie.h
+++ b/kabc/plugins/opie/resourceopie.h
@@ -39,4 +39,3 @@ $Id$
-//class QTimer;
-//class FormatPlugin;
+class OContactAccess;
@@ -44,3 +43,2 @@ namespace KABC {
-//US class FormatPlugin;
class ResourceConfigWidget;
@@ -61,3 +59,3 @@ public:
*/
- ResourceOpie( const KConfig *cfg );
+ ResourceOpie( const KConfig *cfg, bool syncable );
@@ -66,3 +64,3 @@ public:
*/
- ResourceOpie( const QString &fileName );
+ ResourceOpie( const QString &fileName, bool syncable );
@@ -88,3 +86,3 @@ public:
virtual void doClose();
-
+
/**
@@ -108,11 +106,2 @@ public:
- /**
- * Set name of file to be used for saving.
- */
- void setFileName( const QString & );
-
- /**
- * Return name of file used for loading and saving the address book.
- */
- QString fileName() const;
@@ -125,2 +114,7 @@ public:
/**
+ * Set name of file to be used for saving.
+ */
+ virtual void setFileName( const QString & );
+
+ /**
* This method is called by an error handler if the application
@@ -130,2 +124,13 @@ public:
+ /**
+ * This method returns the number of elements that are currently in the resource.
+ */
+ virtual int count() const;
+
+ /**
+ * This method removes all elements from the resource!! (Not from the addressbook)
+ */
+ virtual bool clear();
+
+
protected slots:
@@ -140,8 +145,7 @@ protected:
private:
+ OContactAccess* mAccess;
OpieConverter* mConverter;
-
- QString mFileName;
QString mLockUniqueName;
-
+
KDirWatch mDirWatch;
diff --git a/kabc/plugins/qtopia/qtopiaE.pro b/kabc/plugins/qtopia/qtopiaE.pro
index 56eae87..d956519 100644
--- a/kabc/plugins/qtopia/qtopiaE.pro
+++ b/kabc/plugins/qtopia/qtopiaE.pro
@@ -5,3 +5,3 @@ TARGET = microkabc_qtopia
-INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat $(QPEDIR)/include
+INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat $(QPEDIR)/include
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp
index 7e10e46..dc88272 100644
--- a/kabc/plugins/qtopia/resourceqtopia.cpp
+++ b/kabc/plugins/qtopia/resourceqtopia.cpp
@@ -51,2 +51,3 @@ $Id$
#include "qtopiaconverter.h"
+#include "syncwidget.h"
@@ -59,3 +60,3 @@ extern "C"
{
- return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig>();
+ return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig, KRES::SyncWidget>();
}
@@ -63,4 +64,4 @@ extern "C"
-ResourceQtopia::ResourceQtopia( const KConfig *config )
- : Resource( config ), mConverter (0)
+ResourceQtopia::ResourceQtopia( const KConfig *config, bool syncable )
+ : Resource( config, syncable ), mConverter (0)
{
@@ -72,4 +73,4 @@ ResourceQtopia::ResourceQtopia( const KConfig *config )
-ResourceQtopia::ResourceQtopia( const QString &fileName )
- : Resource( 0 )
+ResourceQtopia::ResourceQtopia( const QString &fileName, bool syncable )
+ : Resource( 0, syncable )
{
@@ -94,2 +95,4 @@ ResourceQtopia::~ResourceQtopia()
+ if(mAccess != 0)
+ delete mAccess;
}
@@ -107,5 +110,5 @@ Ticket *ResourceQtopia::requestSaveTicket()
- if ( !lock( mFileName ) ) {
+ if ( !lock( fileName() ) ) {
kdDebug(5700) << "ResourceQtopia::requestSaveTicket(): Unable to lock file '"
- << mFileName << "'" << endl;
+ << fileName() << "'" << endl;
return 0;
@@ -118,47 +121,8 @@ bool ResourceQtopia::doOpen()
{
-/*US
- QFile file( mFileName );
-
- if ( !file.exists() ) {
- // try to create the file
- bool ok = file.open( IO_WriteOnly );
- if ( ok )
- file.close();
-
- return ok;
- } else {
- if ( !file.open( IO_ReadWrite ) )
- return false;
-
- if ( file.size() == 0 ) {
- file.close();
- return true;
- }
-
-//US bool ok = mFormat->checkFormat( &file );
- bool ok = true;
-
- file.close();
-
- return ok;
- }
-*/
- return true;
-}
-
-void ResourceQtopia::doClose()
-{
-}
+ qDebug("ResourceQtopia::doOpen(): %s", fileName().latin1());
-bool ResourceQtopia::load()
-{
- kdDebug(5700) << "ResourceQtopia::load(): '" << mFileName << "'" << endl;
-
-// qDebug("ResourceQtopia::load: Try to load file() %s", mFileName.latin1());
+ mAccess = new AddressBookAccess();
- AddressBookAccess* access = new AddressBookAccess();
-
- if ( !access ) {
- qDebug("Unable to load file() %s", mFileName.latin1());
- addressBook()->error( i18n( "Unable to load file '%1'." ).arg( mFileName ) );
+ if ( !mAccess ) {
+ qDebug("Unable to load file() %s", fileName().latin1());
return false;
@@ -175,4 +139,4 @@ bool ResourceQtopia::load()
qDebug(msg);
- addressBook()->error( i18n( msg ) );
- delete access;
+ delete mAccess;
+ mAccess = 0;
return false;
@@ -181,18 +145,40 @@ bool ResourceQtopia::load()
- { //create a new scope
- AddressBookIterator it(*access);
- const PimContact* contact;
+ return true;
+}
- for (contact=it.toFirst(); it.current(); ++it) {
- contact = it.current();
+void ResourceQtopia::doClose()
+{
+ qDebug("ResourceQtopia::doClose: %s", fileName().latin1());
- KABC::Addressee addressee;
+ if(mAccess)
+ {
+ delete mAccess;
+ mAccess = 0;
+ }
+ // it seems so, that deletion of access deletes backend as well
+ //delete backend;
+
+ return;
+}
+
+bool ResourceQtopia::load()
+{
+ qDebug("ResourceQtopia::load: %s", fileName().latin1());
- res = mConverter->qtopiaToAddressee( (*contact), addressee );
+ AddressBookIterator it(*mAccess);
+ const PimContact* contact;
+ bool res;
+
+ for (contact=it.toFirst(); it.current(); ++it)
+ {
+ contact = it.current();
- if ( !addressee.isEmpty() && res )
- {
- addressee.setResource( this );
- addressBook()->insertAddressee( addressee );
- }
+ KABC::Addressee addressee;
+
+ res = mConverter->qtopiaToAddressee( (*contact), addressee );
+
+ if ( !addressee.isEmpty() && res )
+ {
+ addressee.setResource( this );
+ addressBook()->insertAddressee( addressee );
}
@@ -200,3 +186,2 @@ bool ResourceQtopia::load()
- delete access;
return true;
@@ -251,3 +236,8 @@ bool ResourceQtopia::save( Ticket *ticket )
qDebug("ResourceQtopia::save has to be changed");
+
+
+ access->save();
+
*/
+
return true;
@@ -314,20 +304,13 @@ void ResourceQtopia::unlock( const QString &fileName )
-void ResourceQtopia::setFileName( const QString &fileName )
+void ResourceQtopia::setFileName( const QString &newFileName )
{
mDirWatch.stopScan();
- mDirWatch.removeFile( mFileName );
+ mDirWatch.removeFile( fileName() );
- mFileName = fileName;
+ Resource::setFileName( newFileName );
- mDirWatch.addFile( mFileName );
+ mDirWatch.addFile( fileName() );
mDirWatch.startScan();
-
-//US simulate KDirWatch event
-//US fileChanged();
}
-QString ResourceQtopia::fileName() const
-{
- return mFileName;
-}
@@ -340,3 +323,3 @@ void ResourceQtopia::fileChanged()
- QString text( i18n( "Qtopia resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( mFileName ) );
+ QString text( i18n( "Qtopia resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) );
if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) {
@@ -353,5 +336,48 @@ void ResourceQtopia::cleanUp()
{
- unlock( mFileName );
+ unlock( fileName() );
}
+
+
+/**
+ * This method returns the number of elements that are currently in the resource.
+ */
+int ResourceQtopia::count() const
+{
+ if (mAccess != 0)
+ {
+ int counter = 0;
+ AddressBookIterator it2(*mAccess);
+ for (it2.toFirst(); it2.current(); ++it2) {
+ counter++;
+ }
+
+ return counter;
+ }
+ else
+ return 0;
+}
+
+
+/**
+ * This method removes all elements from the resource!! (Not from the addressbook)
+ */
+bool ResourceQtopia::clear()
+{
+ if (mAccess != 0)
+ {
+ AddressBookIterator it2(*mAccess);
+ for (it2.toFirst(); it2.current(); ++it2) {
+ mAccess->removeContact(*it2.current());
+ }
+ return true;
+ }
+ else
+ return false;
+}
+
+
+
+
+
//US #include "resourceqtopia.moc"
diff --git a/kabc/plugins/qtopia/resourceqtopia.h b/kabc/plugins/qtopia/resourceqtopia.h
index bf9dd45..90ab1f4 100644
--- a/kabc/plugins/qtopia/resourceqtopia.h
+++ b/kabc/plugins/qtopia/resourceqtopia.h
@@ -38,2 +38,3 @@ $Id$
+class AddressBookAccess;
@@ -59,3 +60,3 @@ public:
*/
- ResourceQtopia( const KConfig *cfg );
+ ResourceQtopia( const KConfig *cfg, bool syncable );
@@ -64,3 +65,3 @@ public:
*/
- ResourceQtopia( const QString &fileName );
+ ResourceQtopia( const QString &fileName, bool syncable );
@@ -86,3 +87,3 @@ public:
virtual void doClose();
-
+
/**
@@ -107,22 +108,27 @@ public:
/**
+ * Remove a addressee from its source.
+ * This method is mainly called by KABC::AddressBook.
+ */
+ virtual void removeAddressee( const Addressee& addr );
+
+ /**
* Set name of file to be used for saving.
*/
- void setFileName( const QString & );
+ virtual void setFileName( const QString & );
/**
- * Return name of file used for loading and saving the address book.
+ * This method is called by an error handler if the application
+ * crashed
*/
- QString fileName() const;
+ virtual void cleanUp();
/**
- * Remove a addressee from its source.
- * This method is mainly called by KABC::AddressBook.
+ * This method returns the number of elements that are currently in the resource.
*/
- virtual void removeAddressee( const Addressee& addr );
+ virtual int count() const;
/**
- * This method is called by an error handler if the application
- * crashed
+ * This method removes all elements from the resource!! (Not from the addressbook)
*/
- virtual void cleanUp();
+ virtual bool clear();
@@ -138,8 +144,7 @@ protected:
private:
+ AddressBookAccess* mAccess;
QtopiaConverter* mConverter;
-
- QString mFileName;
QString mLockUniqueName;
-
+
KDirWatch mDirWatch;
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
index 31b99ca..7b909de 100644
--- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
+++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
@@ -2,3 +2,3 @@
This file is part of libkabc.
- Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+ Copyright (c) 2004 Ulf Schenk
@@ -64,4 +64,4 @@ extern "C"
-ResourceSharpDTM::ResourceSharpDTM( const KConfig *config )
- : Resource( config ), mConverter (0)
+ResourceSharpDTM::ResourceSharpDTM( const KConfig *config, bool syncable )
+ : Resource( config, syncable ), mConverter (0)
{
@@ -73,4 +73,4 @@ ResourceSharpDTM::ResourceSharpDTM( const KConfig *config )
-ResourceSharpDTM::ResourceSharpDTM( const QString &fileName )
- : Resource( 0 )
+ResourceSharpDTM::ResourceSharpDTM( const QString &fileName, bool syncable )
+ : Resource( 0, syncable )
{
@@ -357 +357,26 @@ void ResourceSharpDTM::cleanUp()
+/**
+ * This method returns the number of elements that are currently in the resource.
+ */
+int ResourceSharpDTM::count() const
+{
+ if (mAccess != 0)
+ return mAccess->count();
+ else
+ return 0;
+}
+
+
+/**
+ * This method removes all elements from the resource!! (Not from the addressbook)
+ */
+bool ResourceSharpDTM::clear()
+{
+ if (mAccess != 0)
+ return mAccess->deleteCard(0, SlZDataBase::AllCard );
+ else
+ return false;
+}
+
+
+
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.h b/kabc/plugins/sharpdtm/resourcesharpdtm.h
index d2e2a52..f495e9d 100644
--- a/kabc/plugins/sharpdtm/resourcesharpdtm.h
+++ b/kabc/plugins/sharpdtm/resourcesharpdtm.h
@@ -2,3 +2,3 @@
This file is part of libkabc.
- Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+ Copyright (c) 2004 Ulf Schenk
@@ -58,3 +58,3 @@ public:
*/
- ResourceSharpDTM( const KConfig *cfg );
+ ResourceSharpDTM( const KConfig *cfg, bool syncable );
@@ -63,3 +63,3 @@ public:
*/
- ResourceSharpDTM( const QString &fileName );
+ ResourceSharpDTM( const QString &fileName, bool syncable );
@@ -106,22 +106,28 @@ public:
/**
+ * Remove a addressee from its source.
+ * This method is mainly called by KABC::AddressBook.
+ */
+ virtual void removeAddressee( const Addressee& addr );
+
+ /**
* Set name of file to be used for saving.
*/
- void setFileName( const QString & );
+ virtual void setFileName( const QString & );
/**
- * Return name of file used for loading and saving the address book.
+ * This method is called by an error handler if the application
+ * crashed
*/
- QString fileName() const;
+ virtual void cleanUp();
/**
- * Remove a addressee from its source.
- * This method is mainly called by KABC::AddressBook.
+ * This method returns the number of elements that are currently in the resource.
*/
- virtual void removeAddressee( const Addressee& addr );
+ virtual int count() const;
/**
- * This method is called by an error handler if the application
- * crashed
+ * This method removes all elements from the resource!! (Not from the addressbook)
*/
- virtual void cleanUp();
+ virtual bool clear();
+
@@ -139,4 +145,2 @@ private:
- QString mFileName;
-
QString mLockUniqueName;
diff --git a/kabc/plugins/sharpdtm/sharpdtmE.pro b/kabc/plugins/sharpdtm/sharpdtmE.pro
index 54ef083..52bc10f 100644
--- a/kabc/plugins/sharpdtm/sharpdtmE.pro
+++ b/kabc/plugins/sharpdtm/sharpdtmE.pro
@@ -4,3 +4,3 @@ TARGET = microkabc_sharpdtm
-INCLUDEPATH += ../.. $(SHARPDTMSDK)/include ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../qtcompat $(QPEDIR)/include
+INCLUDEPATH += ../.. $(SHARPDTMSDK)/include ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../microkde/kio/kio ../../../microkde/kresources ../../../qtcompat $(QPEDIR)/include