summaryrefslogtreecommitdiffabout
path: root/kabc/plugins
Side-by-side diff
Diffstat (limited to 'kabc/plugins') (more/less context) (show 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.cpp7
-rw-r--r--kabc/plugins/dir/resourcedir.h2
-rw-r--r--kabc/plugins/file/file.pro2
-rw-r--r--kabc/plugins/file/fileE.pro2
-rw-r--r--kabc/plugins/file/resourcefile.cpp12
-rw-r--r--kabc/plugins/file/resourcefile.h4
-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.cpp224
-rw-r--r--kabc/plugins/opie/resourceopie.h36
-rw-r--r--kabc/plugins/qtopia/qtopiaE.pro2
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp166
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.h31
-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, 319 insertions, 255 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
@@ -1,30 +1,30 @@
TEMPLATE = lib
CONFIG += qt warn_on release
#release debug
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
#LIBS += -lmicrokde -lmicrokabc
#LIBS += -L$(QPEDIR)/lib
INTERFACES = \
HEADERS = \
resourcedir.h \
resourcedirconfig.h
SOURCES = \
resourcedir.cpp \
resourcedirconfig.cpp
unix : {
OBJECTS_DIR = obj/unix
MOC_DIR = moc/unix
}
win32: {
CONFIG += dll
DEFINES += _WIN32_
OBJECTS_DIR = obj/win
MOC_DIR = moc/win
LIBS += ../../../bin/microkdepim.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
@@ -1,21 +1,21 @@
TEMPLATE = lib
CONFIG += qt warn_on release
#release debug
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)
MOC_DIR = moc/$(PLATFORM)
DESTDIR = $(QPEDIR)/lib
LIBS += -lmicrokde -lmicrokabc
LIBS += -L$(QPEDIR)/lib
INTERFACES = \
HEADERS = \
resourcedir.h \
resourcedirconfig.h
SOURCES = \
resourcedir.cpp \
resourcedirconfig.cpp
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
@@ -36,69 +36,70 @@ $Id$
#include <qtimer.h>
#include <qwidget.h>
#include <kapplication.h>
#include <kconfig.h>
#include <kdebug.h>
//US #include <kgenericfactory.h>
#include <kglobal.h>
#include <klocale.h>
#include <kstandarddirs.h>
#include <kurlrequester.h>
#include <kmessagebox.h>
#include "addressbook.h"
#include "formatfactory.h"
#include "resourcedirconfig.h"
#include "stdaddressbook.h"
//US
#include <qdir.h>
#include "resourcedir.h"
+#include "syncwidget.h"
using namespace KABC;
extern "C"
#ifdef _WIN32_
__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" );
path = cfg->readEntry( "FilePath", StdAddressBook::directoryName() );
//US mFormatName = config->readEntry( "FileFormat" );
mFormatName = cfg->readEntry( "FileFormat", "vcard" );
} else {
path = StdAddressBook::directoryName();
mFormatName = "vcard";
}
FormatFactory *factory = FormatFactory::self();
mFormat = factory->format( mFormatName );
if ( !mFormat ) {
mFormatName = "vcard";
mFormat = factory->format( mFormatName );
}
/*US
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
@@ -28,49 +28,49 @@ $Id$
#ifndef KABC_RESOURCEDIR_H
#define KABC_RESOURCEDIR_H
#include <kconfig.h>
#include <kdirwatch.h>
#include <sys/types.h>
#include "resource.h"
class QTimer;
namespace KABC {
class FormatPlugin;
/**
@internal
*/
class ResourceDir : public Resource
{
Q_OBJECT
public:
- ResourceDir( const KConfig* );
+ ResourceDir( const KConfig*, bool syncable );
~ResourceDir();
virtual void writeConfig( KConfig* );
virtual bool doOpen();
virtual void doClose();
virtual Ticket *requestSaveTicket();
virtual bool load();
virtual bool save( Ticket * );
/**
* Set path to be used for saving.
*/
void setPath( const QString & );
/**
* Return path used for loading and saving the address book.
*/
QString path() const;
/**
* Set the format by name.
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
@@ -1,30 +1,30 @@
TEMPLATE = lib
CONFIG += qt warn_on release
#release debug
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
DESTDIR = ../../../bin
#LIBS += -lmicrokde -lmicrokabc
#LIBS += -L$(QPEDIR)/lib
INTERFACES = \
HEADERS = \
resourcefile.h \
resourcefileconfig.h
SOURCES = \
resourcefile.cpp \
resourcefileconfig.cpp
unix : {
OBJECTS_DIR = obj/unix
MOC_DIR = moc/unix
}
win32: {
CONFIG += dll
DEFINES += _WIN32_
OBJECTS_DIR = obj/win
MOC_DIR = moc/win
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
@@ -1,21 +1,21 @@
TEMPLATE = lib
CONFIG += qt warn_on release
#release debug
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)
MOC_DIR = moc/$(PLATFORM)
DESTDIR = $(QPEDIR)/lib
LIBS += -lmicrokde -lmicrokabc
LIBS += -L$(QPEDIR)/lib
INTERFACES = \
HEADERS = \
resourcefile.h \
resourcefileconfig.h
SOURCES = \
resourcefile.cpp \
resourcefileconfig.cpp
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
@@ -30,89 +30,91 @@ $Id$
#ifndef _WIN32_
#include <unistd.h>
#endif
#include <qfile.h>
#include <qfileinfo.h>
#include <qregexp.h>
#include <qtimer.h>
#include <kapplication.h>
#include <kconfig.h>
#include <kdebug.h>
#include <klocale.h>
//US #include <ksavefile.h>
#include <kstandarddirs.h>
#include <kmessagebox.h>
#include "formatfactory.h"
#include "resource.h"
#include "resourcefileconfig.h"
#include "stdaddressbook.h"
#include "resourcefile.h"
+#include "syncwidget.h"
+
using namespace KABC;
extern "C"
#ifdef _WIN32_
__declspec(dllexport)
#else
{
#endif
//US void *init_kabc_file()
void *init_microkabc_file()
{
- return new KRES::PluginFactory<ResourceFile,ResourceFileConfig>();
+ return new KRES::PluginFactory<ResourceFile,ResourceFileConfig, KRES::SyncWidget>();
}
#ifndef _WIN32_
}
#endif
-ResourceFile::ResourceFile( const KConfig *config )
- : Resource( config ) , mFormat( 0 )
+ResourceFile::ResourceFile( const KConfig *config, bool syncable )
+ : Resource( config, syncable ) , mFormat( 0 )
{
QString fileName, formatName;
KConfig *cfg = (KConfig *)config;
if ( cfg ) {
fileName = cfg->readEntry( "FileName", StdAddressBook::fileName() );
formatName = cfg->readEntry( "FileFormat", "vcard" );
// qDebug("ResourceFile::ResourceFile : 1 %s, %s", fileName.latin1(), formatName.latin1() );
} else {
fileName = StdAddressBook::fileName();
formatName = "vcard";
// qDebug("ResourceFile::ResourceFile : 2 %s, %s", fileName.latin1(), formatName.latin1() );
}
init( fileName, formatName );
}
-ResourceFile::ResourceFile( const QString &fileName,
+ResourceFile::ResourceFile( const QString &fileName, bool syncable ,
const QString &formatName )
- : Resource( 0 )
+ : Resource( 0, syncable )
{
// qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1());
init( fileName, formatName );
}
void ResourceFile::init( const QString &fileName, const QString &formatName )
{
mFormatName = formatName;
FormatFactory *factory = FormatFactory::self();
mFormat = factory->format( mFormatName );
if ( !mFormat ) {
mFormatName = "vcard";
mFormat = factory->format( mFormatName );
}
/*US
//US qDebug("ResourceFile::init initialized with format %s ", formatName.latin1());
if (mFormatName == "vcard") {
mFormat = new VCardFormatPlugin2();
// qDebug("ResourceFile::init format VCardFormatPlugin2");
}
else if (mFormatName == "binary") {
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
@@ -37,54 +37,54 @@ $Id$
#include <resource.h>
class QTimer;
class FormatPlugin;
namespace KABC {
//US class FormatPlugin;
class ResourceConfigWidget;
/**
@internal
*/
class ResourceFile : public Resource
{
Q_OBJECT
public:
/**
Constructor.
@param cfg The config object where custom resource settings are stored.
*/
- ResourceFile( const KConfig *cfg );
+ ResourceFile( const KConfig *cfg, bool syncable );
/**
Construct file resource on file @arg fileName using format @arg formatName.
*/
- ResourceFile( const QString &fileName, const QString &formatName = "vcard" );
+ ResourceFile( const QString &fileName, bool syncable , const QString &formatName = "vcard" );
/**
* Destructor.
*/
~ResourceFile();
/**
Writes the config back.
*/
virtual void writeConfig( KConfig *cfg );
/**
* Tries to open the file and checks for the proper format.
* This method should be called before @ref load().
*/
virtual bool doOpen();
/**
* Closes the file again.
*/
virtual void doClose();
/**
* Requests a save ticket, that is used by @ref save()
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
@@ -1,21 +1,21 @@
TEMPLATE = lib
CONFIG += qt warn_on release
#release debug
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)
MOC_DIR = moc/$(PLATFORM)
DESTDIR = $(QPEDIR)/lib
LIBS += -lmicrokde -lmicrokabc
LIBS += -L$(QPEDIR)/lib
INTERFACES = \
HEADERS = \
resourceldap.h \
resourceldapconfig.h
SOURCES = \
resourceldap.cpp \
resourceldapconfig.cpp
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
@@ -15,65 +15,66 @@
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
#include <kdebug.h>
#include <kglobal.h>
#include <klineedit.h>
#include <klocale.h>
#include <kconfig.h>
#include <kstringhandler.h>
#include <stdlib.h>
#include "resourceldap.h"
#include "resourceldapconfig.h"
+#include "syncwidget.h"
using namespace KABC;
extern "C"
{
//US void *init_kabc_ldap()
void *init_microkabc_ldap()
{
- return new KRES::PluginFactory<ResourceLDAP,ResourceLDAPConfig>();
+ return new KRES::PluginFactory<ResourceLDAP,ResourceLDAPConfig, KRES::SyncWidget>();
}
}
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 )
{
KConfig *cfg = (KConfig *)config;
if ( cfg ) {
mUser = cfg->readEntry( "LdapUser" );
mPassword = KStringHandler::obscure( cfg->readEntry( "LdapPassword" ) );
mDn = cfg->readEntry( "LdapDn" );
mHost = cfg->readEntry( "LdapHost" );
mPort = cfg->readNumEntry( "LdapPort", 389 );
mFilter = cfg->readEntry( "LdapFilter" );
mAnonymous = cfg->readBoolEntry( "LdapAnonymous" );
QStringList attributes = cfg->readListEntry( "LdapAttributes" );
for ( uint pos = 0; pos < attributes.count(); pos += 2 )
mAttributes.insert( attributes[ pos ], attributes[ pos + 1 ] );
}
/**
If you want to add new attributes, append them here, add a
translation string in the ctor of AttributesDialog and
handle them in the load() method below.
These are the default values from
*/
if ( mAttributes.count() == 0 ) {
mAttributes.insert( "commonName", "cn" );
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
@@ -22,49 +22,49 @@
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
#ifndef KABC_RESOURCELDAP_H
#define KABC_RESOURCELDAP_H
#include <lber.h>
#include <ldap.h>
#include "addressbook.h"
#include "resource.h"
class KConfig;
namespace KABC {
class ResourceLDAP : public Resource
{
public:
- ResourceLDAP( const KConfig* );
+ ResourceLDAP( const KConfig*, bool syncable );
virtual void writeConfig( KConfig* );
virtual bool doOpen();
virtual void doClose();
virtual Ticket *requestSaveTicket();
virtual bool load();
virtual bool save( Ticket * );
virtual void removeAddressee( const Addressee& addr );
void setUser( const QString &user );
QString user() const;
void setPassword( const QString &password );
QString password() const;
void setDn( const QString &dn );
QString dn() const;
void setHost( const QString &host );
QString host() const;
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
@@ -1,30 +1,30 @@
TEMPLATE = lib
CONFIG += qt warn_on
#release debug
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
OBJECTS_DIR = obj/$(PLATFORM)
MOC_DIR = moc/$(PLATFORM)
DESTDIR = $(QPEDIR)/lib
LIBS += -lmicrokde
LIBS += -lmicrokabc
LIBS += -L$(QPEDIR)/lib
LIBS += -L$(OPIEDIR)/lib
LIBS += -lopie
LIBS += -lqpe
LIBS += -lqte
INTERFACES = \
HEADERS = \
resourceopie.h \
resourceopieconfig.h \
opieconverter.h \
SOURCES = \
resourceopie.cpp \
resourceopieconfig.cpp \
opieconverter.cpp \
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
@@ -29,367 +29,363 @@ $Id$
#include <sys/stat.h>
#include <unistd.h>
#include <qdir.h>
#include <qfile.h>
#include <qfileinfo.h>
#include <qregexp.h>
#include <kapplication.h>
#include <kconfig.h>
#include <kdebug.h>
#include <klocale.h>
//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 "opieconverter.h"
#include "resourceopie.h"
using namespace KABC;
extern "C"
{
void *init_microkabc_opie()
{
- return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig>();
+ return new KRES::PluginFactory<ResourceOpie,ResourceOpieConfig, KRES::SyncWidget>();
}
}
-ResourceOpie::ResourceOpie( const KConfig *config )
- : Resource( config ), mConverter (0)
+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 )
- : Resource( 0 )
+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", mFileName );
-
-// qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1());
-
+ config->writeEntry( "FileName", fileName() );
}
Ticket *ResourceOpie::requestSaveTicket()
{
kdDebug(5700) << "ResourceOpie::requestSaveTicket()" << endl;
+ 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;
}
return createTicket( this );
}
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();
+ qDebug("ResourceOpie::doOpen: %s", fileName().latin1());
- return ok;
- } else {
- if ( !file.open( IO_ReadWrite ) )
- return false;
+ OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", fileName() );
+ mAccess = new OContactAccess("KDEPim/Pi", 0l, backend, false);
- if ( file.size() == 0 ) {
- file.close();
- return true;
+ if ( !mAccess ) {
+ qDebug("Unable to load file() %s", fileName().latin1());
+ return false;
}
-//US bool ok = mFormat->checkFormat( &file );
- bool ok = true;
+ mAccess->setReadAhead( 32 ); // Use ReadAhead-Cache if available
- file.close();
- return ok;
+ if (mConverter == 0)
+ {
+ mConverter = new OpieConverter();
+ bool res = mConverter->init();
+ if ( !res )
+ {
+ qDebug("Unable to initialize opie converter. Most likely a problem with the category file");
+ delete mAccess;
+ mAccess = 0;
+ return false;
}
-*/
- qDebug("ResourceOpie::doOpen() has to be fixed - %s", mFileName.latin1());
+ }
+
+
+
return true;
}
void ResourceOpie::doClose()
{
-// qDebug("ResourceOpie::doClose() %s", mFileName.latin1());
-}
+ qDebug("ResourceOpie::doClose: %s", fileName().latin1());
-bool ResourceOpie::load()
+ if(mAccess)
{
-// qDebug("ResourceOpie::load() %s", mFileName.latin1());
- kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl;
-
- qDebug("ResourceOpie::load: Try to load file() %s", mFileName.latin1());
+ delete mAccess;
+ mAccess = 0;
+ }
+ // it seems so, that deletion of access deletes backend as well
+ //delete backend;
- OContactAccessBackend_XML* backend = new OContactAccessBackend_XML( "KDEPim/Pi", mFileName );
- OContactAccess* access = new OContactAccess("KDEPim/Pi", 0l, backend, false);
+ return;
- 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)
- {
- mConverter = new OpieConverter();
- res = mConverter->init();
- if ( !res )
+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;
- return false;
- }
- }
+ qDebug("ResourceOpie::load: %s", fileName().latin1());
+ bool res = false;
OContactAccess::List::Iterator it;
- OContactAccess::List allList = access->allRecords();
+ OContactAccess::List allList = mAccess->allRecords();
for ( it = allList.begin(); it != allList.end(); ++it )
{
const OContact c = (*it);
KABC::Addressee addressee;
res = mConverter->opieToAddressee( c, addressee );
if ( !addressee.isEmpty() && res )
{
addressee.setResource( this );
addressBook()->insertAddressee( addressee );
}
-// qDebug("found %s", c.fullName().latin1());
}
- delete access;
- // it seems so, that deletion of access deletes backend as well
- //delete backend;
return true;
}
bool ResourceOpie::save( Ticket *ticket )
{
- qDebug("ResourceOpie::save() has to be fixed - %s", mFileName.latin1());
-/*US
+ qDebug("ResourceOpie::save: %s", fileName().latin1());
- 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 );
+ KABC::AddressBook::Iterator it;
+ bool res;
+
+ for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
+ OContact c;
+ KABC::Addressee addressee = (*it);
- KSaveFile saveFile( mFileName );
- bool ok = false;
- if ( saveFile.status() == 0 && saveFile.file() )
+ res = mConverter->addresseeToOpie( *it, c );
+ if (res == true)
{
- mFormat->saveAll( addressBook(), this, saveFile.file() );
- ok = saveFile.close();
+ res = mAccess->add(c);
+ if (res == false)
+ qDebug("Unable to append Contact %s", c.fullName().latin1());
}
-*/
-/*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("Unable to convert Addressee %s", addressee.formattedName().latin1());
}
- else {
-
}
- 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());
kdDebug(5700) << "ResourceOpie::lock()" << endl;
- QString fn = fileName;
+ 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 );
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();
// Create lock file
int result = 0;
#ifndef _WIN32_
result = ::link( QFile::encodeName( mLockUniqueName ),
QFile::encodeName( lockName ) );
#endif
if ( result == 0 ) {
addressBook()->emitAddressBookLocked();
return true;
}
// TODO: check stat
return false;
}
void ResourceOpie::unlock( const QString &fileName )
{
-// qDebug("ResourceOpie::unlock() %s", fileName.latin1());
+ 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 &fileName )
+void ResourceOpie::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 ResourceOpie::fileName() const
-{
- return mFileName;
-}
void ResourceOpie::fileChanged()
{
// There is a small theoretical chance that KDirWatch calls us before
// we are fully constructed
if (!addressBook())
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 ) {
load();
addressBook()->emitAddressBookChanged();
}
load();
addressBook()->emitAddressBookChanged();
}
void ResourceOpie::removeAddressee( const Addressee &addr )
{
}
void ResourceOpie::cleanUp()
{
// qDebug("ResourceOpie::cleanup() %s", mFileName.latin1());
- 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
@@ -16,137 +16,141 @@
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
#ifndef KABC_RESOURCEOPIE_H
#define KABC_RESOURCEOPIE_H
#include <kconfig.h>
#include <kdirwatch.h>
#include <sys/types.h>
#include "resource.h"
-//class QTimer;
-//class FormatPlugin;
+class OContactAccess;
namespace KABC {
-//US class FormatPlugin;
class ResourceConfigWidget;
class OpieConverter;
/**
@internal
*/
class ResourceOpie : public Resource
{
Q_OBJECT
public:
/**
Constructor.
@param cfg The config object where custom resource settings are stored.
*/
- ResourceOpie( const KConfig *cfg );
+ ResourceOpie( const KConfig *cfg, bool syncable );
/**
Construct file resource on file @arg fileName using format @arg formatName.
*/
- ResourceOpie( const QString &fileName );
+ ResourceOpie( const QString &fileName, bool syncable );
/**
* Destructor.
*/
~ResourceOpie();
/**
Writes the config back.
*/
virtual void writeConfig( KConfig *cfg );
/**
* Tries to open the file and checks for the proper format.
* This method should be called before @ref load().
*/
virtual bool doOpen();
/**
* Closes the file again.
*/
virtual void doClose();
/**
* Requests a save ticket, that is used by @ref save()
*/
virtual Ticket *requestSaveTicket();
/**
* Loads all addressees from file to the address book.
* Returns true if all addressees could be loaded otherwise false.
*/
virtual bool load();
/**
* Saves all addresses from address book to file.
* Returns true if all addressees could be saved otherwise false.
*
* @param ticket The ticket returned by @ref requestSaveTicket()
*/
virtual bool save( Ticket *ticket );
- /**
- * 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;
/**
* 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.
+ */
+ virtual void setFileName( const QString & );
+
+ /**
* This method is called by an error handler if the application
* crashed
*/
virtual void cleanUp();
+ /**
+ * 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:
void fileChanged();
protected:
void init( const QString &fileName );
bool lock( const QString &fileName );
void unlock( const QString &fileName );
private:
+ OContactAccess* mAccess;
OpieConverter* mConverter;
- QString mFileName;
-
QString mLockUniqueName;
KDirWatch mDirWatch;
};
}
#endif
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
@@ -1,27 +1,27 @@
TEMPLATE = lib
CONFIG += qt warn_on
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
OBJECTS_DIR = obj/$(PLATFORM)
MOC_DIR = moc/$(PLATFORM)
DESTDIR = $(QPEDIR)/lib
LIBS += -lmicrokde
LIBS += -lmicrokabc
LIBS += -L$(QPEDIR)/lib
LIBS += -lqpepim
LIBS += -lqpe
INTERFACES = \
HEADERS = \
resourceqtopia.h \
resourceqtopiaconfig.h \
qtopiaconverter.h
SOURCES = \
resourceqtopia.cpp \
resourceqtopiaconfig.cpp \
qtopiaconverter.cpp
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
@@ -28,198 +28,183 @@ $Id$
#include <sys/stat.h>
#include <unistd.h>
#include <qdir.h>
#include <qfile.h>
#include <qfileinfo.h>
#include <qregexp.h>
//US #include <qtimer.h>
#include <kapplication.h>
#include <kconfig.h>
#include <kdebug.h>
#include <klocale.h>
//US #include <ksavefile.h>
#include <kstandarddirs.h>
#include <kmessagebox.h>
#include <qpe/pim/addressbookaccess.h>
#include "resourceqtopiaconfig.h"
#include "stdaddressbook.h"
#include "qtopiaconverter.h"
+#include "syncwidget.h"
#include "resourceqtopia.h"
using namespace KABC;
extern "C"
{
void *init_microkabc_qtopia()
{
- return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig>();
+ return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig, KRES::SyncWidget>();
}
}
-ResourceQtopia::ResourceQtopia( const KConfig *config )
- : Resource( config ), mConverter (0)
+ResourceQtopia::ResourceQtopia( const KConfig *config, bool syncable )
+ : Resource( config, syncable ), mConverter (0)
{
// we can not choose the filename. Therefore use the default to display
QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
init( fileName );
}
-ResourceQtopia::ResourceQtopia( const QString &fileName )
- : Resource( 0 )
+ResourceQtopia::ResourceQtopia( const QString &fileName, bool syncable )
+ : Resource( 0, syncable )
{
// qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1());
init( fileName );
}
void ResourceQtopia::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 );
}
ResourceQtopia::~ResourceQtopia()
{
if (mConverter != 0)
delete mConverter;
+ if(mAccess != 0)
+ delete mAccess;
}
void ResourceQtopia::writeConfig( KConfig *config )
{
Resource::writeConfig( config );
}
Ticket *ResourceQtopia::requestSaveTicket()
{
kdDebug(5700) << "ResourceQtopia::requestSaveTicket()" << endl;
if ( !addressBook() ) return 0;
- if ( !lock( mFileName ) ) {
+ if ( !lock( fileName() ) ) {
kdDebug(5700) << "ResourceQtopia::requestSaveTicket(): Unable to lock file '"
- << mFileName << "'" << endl;
+ << fileName() << "'" << endl;
return 0;
}
return createTicket( this );
}
bool ResourceQtopia::doOpen()
{
-/*US
- QFile file( mFileName );
+ qDebug("ResourceQtopia::doOpen(): %s", fileName().latin1());
- if ( !file.exists() ) {
- // try to create the file
- bool ok = file.open( IO_WriteOnly );
- if ( ok )
- file.close();
+ mAccess = new AddressBookAccess();
- 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()
-{
-}
-
-bool ResourceQtopia::load()
-{
- kdDebug(5700) << "ResourceQtopia::load(): '" << mFileName << "'" << endl;
-
-// qDebug("ResourceQtopia::load: Try to load file() %s", mFileName.latin1());
-
- 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;
}
bool res = false;
if (mConverter == 0)
{
mConverter = new QtopiaConverter();
res = mConverter->init();
if ( !res )
{
QString msg("Unable to initialize qtopia converter. Most likely a problem with the category file");
qDebug(msg);
- addressBook()->error( i18n( msg ) );
- delete access;
+ delete mAccess;
+ mAccess = 0;
return false;
}
}
- { //create a new scope
- AddressBookIterator it(*access);
+ return true;
+}
+
+void ResourceQtopia::doClose()
+{
+ qDebug("ResourceQtopia::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 ResourceQtopia::load()
+{
+ qDebug("ResourceQtopia::load: %s", fileName().latin1());
+
+ AddressBookIterator it(*mAccess);
const PimContact* contact;
+ bool res;
- for (contact=it.toFirst(); it.current(); ++it) {
+ for (contact=it.toFirst(); it.current(); ++it)
+ {
contact = it.current();
KABC::Addressee addressee;
res = mConverter->qtopiaToAddressee( (*contact), addressee );
if ( !addressee.isEmpty() && res )
{
addressee.setResource( this );
addressBook()->insertAddressee( addressee );
}
}
- }
- delete access;
return true;
}
bool ResourceQtopia::save( Ticket *ticket )
{
/*US
// qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1());
kdDebug(5700) << "ResourceQtopia::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();
}
@@ -228,49 +213,54 @@ bool ResourceQtopia::save( Ticket *ticket )
/*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 {
}
if ( !ok )
addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) );
delete ticket;
unlock( mFileName );
return ok;
qDebug("ResourceQtopia::save has to be changed");
+
+
+ access->save();
+
*/
+
return true;
}
bool ResourceQtopia::lock( const QString &fileName )
{
kdDebug(5700) << "ResourceQtopia::lock()" << endl;
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" );
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;
@@ -291,67 +281,103 @@ bool ResourceQtopia::lock( const QString &fileName )
addressBook()->emitAddressBookLocked();
return true;
}
// TODO: check stat
return false;
}
void ResourceQtopia::unlock( const QString &fileName )
{
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 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;
-}
void ResourceQtopia::fileChanged()
{
// There is a small theoretical chance that KDirWatch calls us before
// we are fully constructed
if (!addressBook())
return;
- 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 ) {
load();
addressBook()->emitAddressBookChanged();
}
}
void ResourceQtopia::removeAddressee( const Addressee &addr )
{
}
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
@@ -15,136 +15,141 @@
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
#ifndef KABC_RESOURCEOPIE_H
#define KABC_RESOURCEOPIE_H
#include <kconfig.h>
#include <kdirwatch.h>
#include <sys/types.h>
#include "resource.h"
+class AddressBookAccess;
namespace KABC {
//US class FormatPlugin;
class ResourceConfigWidget;
class QtopiaConverter;
/**
@internal
*/
class ResourceQtopia : public Resource
{
Q_OBJECT
public:
/**
Constructor.
@param cfg The config object where custom resource settings are stored.
*/
- ResourceQtopia( const KConfig *cfg );
+ ResourceQtopia( const KConfig *cfg, bool syncable );
/**
Construct file resource on file @arg fileName using format @arg formatName.
*/
- ResourceQtopia( const QString &fileName );
+ ResourceQtopia( const QString &fileName, bool syncable );
/**
* Destructor.
*/
~ResourceQtopia();
/**
Writes the config back.
*/
virtual void writeConfig( KConfig *cfg );
/**
* Tries to open the file and checks for the proper format.
* This method should be called before @ref load().
*/
virtual bool doOpen();
/**
* Closes the file again.
*/
virtual void doClose();
/**
* Requests a save ticket, that is used by @ref save()
*/
virtual Ticket *requestSaveTicket();
/**
* Loads all addressees from file to the address book.
* Returns true if all addressees could be loaded otherwise false.
*/
virtual bool load();
/**
* Saves all addresses from address book to file.
* Returns true if all addressees could be saved otherwise false.
*
* @param ticket The ticket returned by @ref requestSaveTicket()
*/
virtual bool save( Ticket *ticket );
/**
+ * 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();
protected slots:
void fileChanged();
protected:
void init( const QString &fileName );
bool lock( const QString &fileName );
void unlock( const QString &fileName );
private:
+ AddressBookAccess* mAccess;
QtopiaConverter* mConverter;
- QString mFileName;
-
QString mLockUniqueName;
KDirWatch mDirWatch;
};
}
#endif
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
@@ -1,27 +1,27 @@
/*
This file is part of libkabc.
- Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+ Copyright (c) 2004 Ulf Schenk
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
@@ -41,59 +41,59 @@ $Id$
#include <klocale.h>
//US #include <ksavefile.h>
#include <kstandarddirs.h>
#include <kmessagebox.h>
#include <sl/slzdb.h>
#include "resourcesharpdtmconfig.h"
#include "resourcesharpdtm.h"
#include "stdaddressbook.h"
#include "sharpdtmconverter.h"
using namespace KABC;
extern "C"
{
void *init_microkabc_sharpdtm()
{
return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig>();
}
}
-ResourceSharpDTM::ResourceSharpDTM( const KConfig *config )
- : Resource( config ), mConverter (0)
+ResourceSharpDTM::ResourceSharpDTM( const KConfig *config, bool syncable )
+ : Resource( config, syncable ), mConverter (0)
{
// we can not choose the filename. Therefore use the default to display
QString fileName = SlZDataBase::addressbookFileName();
init( fileName );
}
-ResourceSharpDTM::ResourceSharpDTM( const QString &fileName )
- : Resource( 0 )
+ResourceSharpDTM::ResourceSharpDTM( const QString &fileName, bool syncable )
+ : Resource( 0, syncable )
{
// qDebug("ResourceFile::ResourceSharpDTM : 3 %s, %s", fileName.latin1(), formatName.latin1());
init( fileName );
}
void ResourceSharpDTM::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 );
}
ResourceSharpDTM::~ResourceSharpDTM()
{
// if (mConverter != 0)
// delete mConverter;
}
void ResourceSharpDTM::writeConfig( KConfig *config )
{
@@ -334,24 +334,49 @@ QString ResourceSharpDTM::fileName() const
void ResourceSharpDTM::fileChanged()
{
// There is a small theoretical chance that KDirWatch calls us before
// we are fully constructed
if (!addressBook())
return;
QString text( i18n( "Sharp DTM resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( mFileName ) );
if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) {
load();
addressBook()->emitAddressBookChanged();
}
}
void ResourceSharpDTM::removeAddressee( const Addressee &addr )
{
}
void ResourceSharpDTM::cleanUp()
{
unlock( mFileName );
}
+/**
+ * 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
@@ -1,27 +1,27 @@
/*
This file is part of libkabc.
- Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+ Copyright (c) 2004 Ulf Schenk
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
@@ -35,115 +35,119 @@ $Id$
#include <sys/types.h>
#include "resource.h"
namespace KABC {
class ResourceConfigWidget;
class SharpDTMConverter;
/**
@internal
*/
class ResourceSharpDTM : public Resource
{
Q_OBJECT
public:
/**
Constructor.
@param cfg The config object where custom resource settings are stored.
*/
- ResourceSharpDTM( const KConfig *cfg );
+ ResourceSharpDTM( const KConfig *cfg, bool syncable );
/**
Construct file resource on file @arg fileName using format @arg formatName.
*/
- ResourceSharpDTM( const QString &fileName );
+ ResourceSharpDTM( const QString &fileName, bool syncable );
/**
* Destructor.
*/
~ResourceSharpDTM();
/**
Writes the config back.
*/
virtual void writeConfig( KConfig *cfg );
/**
* Tries to open the file and checks for the proper format.
* This method should be called before @ref load().
*/
virtual bool doOpen();
/**
* Closes the file again.
*/
virtual void doClose();
/**
* Requests a save ticket, that is used by @ref save()
*/
virtual Ticket *requestSaveTicket();
/**
* Loads all addressees from file to the address book.
* Returns true if all addressees could be loaded otherwise false.
*/
virtual bool load();
/**
* Saves all addresses from address book to file.
* Returns true if all addressees could be saved otherwise false.
*
* @param ticket The ticket returned by @ref requestSaveTicket()
*/
virtual bool save( Ticket *ticket );
/**
+ * 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();
+
protected slots:
void fileChanged();
protected:
void init( const QString &fileName );
bool lock( const QString &fileName );
void unlock( const QString &fileName );
private:
SharpDTMConverter* mConverter;
- QString mFileName;
-
QString mLockUniqueName;
KDirWatch mDirWatch;
};
}
#endif
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
@@ -1,29 +1,29 @@
TEMPLATE = lib
CONFIG += qt warn_on
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
OBJECTS_DIR = obj/$(PLATFORM)
MOC_DIR = moc/$(PLATFORM)
DESTDIR = $(QPEDIR)/lib
LIBS += -lmicrokde
LIBS += -lmicrokabc
LIBS += -L$(QPEDIR)/lib
LIBS += -lqpe
LIBS += -lqte
LIBS += -lzdtm
INTERFACES = \
HEADERS = \
resourcesharpdtm.h \
resourcesharpdtmconfig.h \
sharpdtmconverter.h
SOURCES = \
resourcesharpdtm.cpp \
resourcesharpdtmconfig.cpp \