summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kabc/plugins/opie/kabc_opieE.pro24
-rw-r--r--kabc/plugins/opie/resourceopie.cpp115
-rw-r--r--kabc/plugins/opie/resourceopie.h9
-rw-r--r--kabc/plugins/opie/resourceopieconfig.cpp9
4 files changed, 112 insertions, 45 deletions
diff --git a/kabc/plugins/opie/kabc_opieE.pro b/kabc/plugins/opie/kabc_opieE.pro
index 7341ca8..f3e2ac4 100644
--- a/kabc/plugins/opie/kabc_opieE.pro
+++ b/kabc/plugins/opie/kabc_opieE.pro
@@ -1,13 +1,22 @@
TEMPLATE = lib
-CONFIG += qt warn_on release
+CONFIG += qt warn_on
#release debug
-
TARGET = microkabc_opie
-INCLUDEPATH += ../.. ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat
+
+INCLUDEPATH += ../.. ../../converter/opie ../../../microkde ../../../microkde/kdecore ../../../microkde/kio/kfile ../../../qtcompat $(QPEDIR)/include
+
+
OBJECTS_DIR = obj/$(PLATFORM)
-MOC_DIR = moc
+MOC_DIR = moc/$(PLATFORM)
DESTDIR = $(QPEDIR)/lib
-LIBS += -lmicrokde -lmicrokabc
+LIBS += -lmicrokde
+LIBS += -lmicrokabc
LIBS += -L$(QPEDIR)/lib
+LIBS += -lopie
+LIBS += -lqpe
+LIBS += -lqte
+LIBS += -lmicrokabc_opieconverter
+#LIBS += -L../../lib/$(PLATFORM)
+
INTERFACES = \
@@ -15,7 +24,8 @@ INTERFACES = \
HEADERS = \
resourceopie.h \
- resourceopieconfig.h
+ resourceopieconfig.h \
SOURCES = \
resourceopie.cpp \
- resourceopieconfig.cpp
+ resourceopieconfig.cpp \
+
diff --git a/kabc/plugins/opie/resourceopie.cpp b/kabc/plugins/opie/resourceopie.cpp
index 47e22b4..f992301 100644
--- a/kabc/plugins/opie/resourceopie.cpp
+++ b/kabc/plugins/opie/resourceopie.cpp
@@ -30,4 +30,5 @@ $Id$
#include <unistd.h>
+#include <qdir.h>
#include <qfile.h>
#include <qfileinfo.h>
@@ -43,4 +44,7 @@ $Id$
//US #include "formatfactory.h"
+//US #include <qpe/qpeapplication.h>
+
+#include <opie/ocontactaccess.h>
#include "resource.h"
@@ -48,4 +52,6 @@ $Id$
#include "stdaddressbook.h"
+#include "opieconverter.h"
+
#include "resourceopie.h"
@@ -53,5 +59,4 @@ using namespace KABC;
extern "C"
{
-//US void *init_kabc_file()
void *init_microkabc_opie()
{
@@ -61,17 +66,16 @@ extern "C"
ResourceOpie::ResourceOpie( const KConfig *config )
- : Resource( config )
+ : Resource( config ), mConverter (0)
{
- QString fileName;
+ QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
KConfig *cfg = (KConfig *)config;
if ( cfg ) {
- fileName = cfg->readEntry( "FileName", StdAddressBook::fileName() );
-// qDebug("ResourceFile::ResourceFile : 1 %s, %s", fileName.latin1(), formatName.latin1() );
- } else {
- fileName = StdAddressBook::fileName();
-// qDebug("ResourceFile::ResourceFile : 2 %s, %s", fileName.latin1(), formatName.latin1() );
+ fileName = cfg->readEntry( "FileName", fileName );
+
}
+// qDebug("ResourceOpie::ResourceOpie : %s", fileName.latin1() );
+
init( fileName );
}
@@ -80,5 +84,5 @@ ResourceOpie::ResourceOpie( const QString &fileName )
: Resource( 0 )
{
-// qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1());
+// qDebug("ResourceOpie::ResourceOpie : 3 %s", fileName.latin1());
init( fileName );
}
@@ -92,14 +96,22 @@ void ResourceOpie::init( const QString &fileName )
connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
*/
+ //US opie addressbook is always readonly
+ setReadOnly( true );
setFileName( fileName );
+
}
ResourceOpie::~ResourceOpie()
{
+ if (mConverter != 0)
+ delete mConverter;
}
void ResourceOpie::writeConfig( KConfig *config )
{
+ //US opie addressbook is always readonly
+ setReadOnly( true );
+
Resource::writeConfig( config );
@@ -127,4 +139,6 @@ Ticket *ResourceOpie::requestSaveTicket()
bool ResourceOpie::doOpen()
{
+// qDebug("ResourceOpie::doOpen() %s", mFileName.latin1());
+/*US
QFile file( mFileName );
@@ -152,23 +166,55 @@ bool ResourceOpie::doOpen()
return ok;
}
+*/
+ qDebug("ResourceOpie::doOpen() has to be fixed - %s", mFileName.latin1());
+ return true;
}
void ResourceOpie::doClose()
{
+// qDebug("ResourceOpie::doClose() %s", mFileName.latin1());
}
bool ResourceOpie::load()
{
+// qDebug("ResourceOpie::load() %s", mFileName.latin1());
kdDebug(5700) << "ResourceOpie::load(): '" << mFileName << "'" << endl;
- QFile file( mFileName );
- if ( !file.open( IO_ReadOnly ) ) {
- addressBook()->error( i18n( "Unable to open file '%1'." ).arg( mFileName ) );
+ OContactAccess* access = new OContactAccess("KDEPim/Pi", mFileName, 0l, false);
+
+ if ( !access ) {
+ qDebug("Unable to load file() %s", mFileName.latin1());
+ addressBook()->error( i18n( "Unable to load file '%1'." ).arg( mFileName ) );
return false;
}
-// qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1());
+ access -> setReadAhead( 32 ); // Use ReadAhead-Cache if available
+
+ if (mConverter == 0)
+ mConverter = new OpieConverter();
+
+
+ OContactAccess::List::Iterator it;
+ OContactAccess::List allList = access->allRecords();
+ bool res = false;
+ for ( it = allList.begin(); it != allList.end(); ++it )
+ {
+ 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;
- //US return mFormat->loadAll( addressBook(), this, &file );
return true;
}
@@ -176,10 +222,13 @@ bool ResourceOpie::load()
bool ResourceOpie::save( Ticket *ticket )
{
-// qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1());
+ 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
@@ -195,5 +244,5 @@ bool ResourceOpie::save( Ticket *ticket )
}
*/
-
+/*US
//US ToDo: write backupfile
QFile info;
@@ -219,9 +268,15 @@ bool ResourceOpie::save( Ticket *ticket )
qDebug("ResourceOpie::save has to be changed");
+*/
return true;
+
}
bool ResourceOpie::lock( const QString &fileName )
{
+ qDebug("ResourceOpie::lock() has to be fixed - %s", mFileName.latin1());
+
+/*US
+// qDebug("ResourceOpie::lock() %s", fileName.latin1());
kdDebug(5700) << "ResourceOpie::lock()" << endl;
@@ -264,8 +319,15 @@ bool ResourceOpie::lock( const QString &fileName )
return false;
+*/
+
+ return true;
}
void ResourceOpie::unlock( const QString &fileName )
{
+ qDebug("ResourceOpie::unlock() has to be fixed - %s", mFileName.latin1());
+/*US
+// qDebug("ResourceOpie::unlock() %s", fileName.latin1());
+
QString fn = fileName;
//US change the implementation how the lockfilename is getting created
@@ -279,4 +341,5 @@ void ResourceOpie::unlock( const QString &fileName )
QFile::remove( mLockUniqueName );
addressBook()->emitAddressBookUnlocked();
+*/
}
@@ -303,20 +366,4 @@ QString ResourceOpie::fileName() const
}
-/*US
-void ResourceOpie::setFormat( const QString &format )
-{
- mFormatName = format;
- delete mFormat;
-
- FormatFactory *factory = FormatFactory::self();
- mFormat = factory->format( mFormatName );
-}
-
-QString ResourceOpie::format() const
-{
- return mFormatName;
-}
-*/
-
void ResourceOpie::fileChanged()
{
@@ -340,4 +387,6 @@ void ResourceOpie::removeAddressee( const Addressee &addr )
void ResourceOpie::cleanUp()
{
+// qDebug("ResourceOpie::cleanup() %s", mFileName.latin1());
+
unlock( mFileName );
}
diff --git a/kabc/plugins/opie/resourceopie.h b/kabc/plugins/opie/resourceopie.h
index d21272a..9db9485 100644
--- a/kabc/plugins/opie/resourceopie.h
+++ b/kabc/plugins/opie/resourceopie.h
@@ -37,6 +37,7 @@ $Id$
#include "resource.h"
-class QTimer;
-class FormatPlugin;
+
+//class QTimer;
+//class FormatPlugin;
namespace KABC {
@@ -44,5 +45,5 @@ namespace KABC {
//US class FormatPlugin;
class ResourceConfigWidget;
-
+class OpieConverter;
/**
@internal
@@ -138,4 +139,6 @@ protected:
private:
+ OpieConverter* mConverter;
+
QString mFileName;
diff --git a/kabc/plugins/opie/resourceopieconfig.cpp b/kabc/plugins/opie/resourceopieconfig.cpp
index b92cfa1..f4cc4f9 100644
--- a/kabc/plugins/opie/resourceopieconfig.cpp
+++ b/kabc/plugins/opie/resourceopieconfig.cpp
@@ -36,7 +36,10 @@ $Id$
#include <unistd.h>
+#include <qdir.h>
#include <qfile.h>
#include "resourceopie.h"
-#include "stdaddressbook.h"
+//US #include <qpe/qpeapplication.h>
+
+//US #include "stdaddressbook.h"
#include "resourceopieconfig.h"
@@ -82,5 +85,5 @@ void ResourceOpieConfig::loadSettings( KRES::Resource *res )
mFileNameEdit->setURL( resource->fileName() );
if ( mFileNameEdit->url().isEmpty() )
- mFileNameEdit->setURL( KABC::StdAddressBook::fileName() );
+ mFileNameEdit->setURL( QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml" );
}
@@ -101,6 +104,8 @@ void ResourceOpieConfig::checkFilePermissions( const QString& fileName )
{
// If file exist but is not writeable...
+/*US
if ( access( QFile::encodeName( fileName ), F_OK ) == 0 )
emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 );
+*/
}