summaryrefslogtreecommitdiffabout
path: root/kabc/plugins/qtopia/resourceqtopia.cpp
Side-by-side diff
Diffstat (limited to 'kabc/plugins/qtopia/resourceqtopia.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp89
1 files changed, 32 insertions, 57 deletions
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp
index dc88272..4a35f19 100644
--- a/kabc/plugins/qtopia/resourceqtopia.cpp
+++ b/kabc/plugins/qtopia/resourceqtopia.cpp
@@ -51,3 +51,3 @@ $Id$
#include "qtopiaconverter.h"
-#include "syncwidget.h"
+#include "syncprefwidget.h"
@@ -60,3 +60,3 @@ extern "C"
{
- return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig, KRES::SyncWidget>();
+ return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig, SyncPrefWidget>();
}
@@ -69,3 +69,2 @@ ResourceQtopia::ResourceQtopia( const KConfig *config, bool syncable )
QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml";
-
init( fileName );
@@ -76,3 +75,2 @@ ResourceQtopia::ResourceQtopia( const QString &fileName, bool syncable )
{
-// qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1());
init( fileName );
@@ -108,2 +106,4 @@ Ticket *ResourceQtopia::requestSaveTicket()
+ qDebug("ResourceQtopia::requestSaveTicket: %s", fileName().latin1());
+
if ( !addressBook() ) return 0;
@@ -130,3 +130,3 @@ bool ResourceQtopia::doOpen()
- bool res = false;
+
if (mConverter == 0)
@@ -134,3 +134,3 @@ bool ResourceQtopia::doOpen()
mConverter = new QtopiaConverter();
- res = mConverter->init();
+ bool res = mConverter->init();
if ( !res )
@@ -191,52 +191,29 @@ bool ResourceQtopia::save( Ticket *ticket )
{
-/*US
-// qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1());
- kdDebug(5700) << "ResourceQtopia::save()" << endl;
+ qDebug("ResourceQtopia::save: %s", fileName().latin1());
- // create backup file
- QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() );
-/*US we use a simpler method to create a backupfile
+ KABC::AddressBook::Iterator it;
+ bool res;
- (void) KSaveFile::backupFile( mFileName, QString::null
- ,extension );
+ for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
+ PimContact c;
+ KABC::Addressee addressee = (*it);
- KSaveFile saveFile( mFileName );
- bool ok = false;
- if ( saveFile.status() == 0 && saveFile.file() )
+ res = mConverter->addresseeToQtopia( *it, c );
+ if (res == true)
{
- mFormat->saveAll( addressBook(), this, saveFile.file() );
- ok = saveFile.close();
+ mAccess->addContact(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->addressBookUpdated();
delete ticket;
- unlock( mFileName );
-
- return ok;
-
- qDebug("ResourceQtopia::save has to be changed");
-
-
- access->save();
-
-*/
+ unlock( fileName() );
@@ -245,11 +222,9 @@ bool ResourceQtopia::save( Ticket *ticket )
-bool ResourceQtopia::lock( const QString &fileName )
+bool ResourceQtopia::lock( const QString &lockfileName )
{
- kdDebug(5700) << "ResourceQtopia::lock()" << endl;
+ qDebug("ResourceQtopia::lock: %s", fileName().latin1());
- QString fn = fileName;
+ kdDebug(5700) << "ResourceQtopia::lock()" << endl;
-//US change the implementation how the lockfilename is getting created
-//US fn.replace( QRegExp("/"), "_" );
-//US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" );
+ QString fn = lockfileName;
@@ -276,5 +251,7 @@ bool ResourceQtopia::lock( const QString &fileName )
// Create lock file
- int result = ::link( QFile::encodeName( mLockUniqueName ),
+ int result = 0;
+#ifndef _WIN32_
+ result = ::link( QFile::encodeName( mLockUniqueName ),
QFile::encodeName( lockName ) );
-
+#endif
if ( result == 0 ) {
@@ -291,7 +268,5 @@ void ResourceQtopia::unlock( const QString &fileName )
{
+ qDebug("ResourceQtopia::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);