summaryrefslogtreecommitdiffabout
path: root/kabc
Side-by-side diff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp13
-rw-r--r--kabc/addressee.h2
-rw-r--r--kabc/plugins/qtopia/qtopiaE.pro2
-rw-r--r--kabc/plugins/qtopia/qtopiaconverter.cpp7
-rw-r--r--kabc/plugins/qtopia/qtopiaconverter.h1
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp78
6 files changed, 75 insertions, 28 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 3a2dc5f..fda62f1 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -22,96 +22,97 @@
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
#include <kconfig.h>
#include <ksharedptr.h>
#include <kdebug.h>
#include <kapplication.h>
#include <klocale.h>
#include <kidmanager.h>
//US
#include <kstandarddirs.h>
#include <libkcal/syncdefines.h>
//US #include "resource.h"
#include "addressee.h"
using namespace KABC;
static bool matchBinaryPattern( int value, int pattern );
struct Addressee::AddresseeData : public KShared
{
QString uid;
QString name;
QString formattedName;
QString familyName;
QString givenName;
QString additionalName;
QString prefix;
QString suffix;
QString nickName;
QDateTime birthday;
QString mailer;
TimeZone timeZone;
Geo geo;
QString title;
QString role;
QString organization;
QString note;
QString productId;
QDateTime revision;
QString sortString;
QString externalUID;
+ QString originalExternalUID;
KURL url;
Secrecy secrecy;
Picture logo;
Picture photo;
Sound sound;
Agent agent;
QString mExternalId;
PhoneNumber::List phoneNumbers;
Address::List addresses;
Key::List keys;
QStringList emails;
QStringList categories;
QStringList custom;
int mTempSyncStat;
Resource *resource;
bool empty :1;
bool changed :1;
};
Addressee::Addressee()
{
mData = new AddresseeData;
mData->empty = true;
mData->changed = false;
mData->resource = 0;
mData->mExternalId = ":";
mData->revision = QDateTime ( QDate( 2004,1,1));
mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
}
Addressee::~Addressee()
{
}
Addressee::Addressee( const Addressee &a )
{
mData = a.mData;
}
Addressee &Addressee::operator=( const Addressee &a )
{
mData = a.mData;
return (*this);
}
Addressee Addressee::copy()
{
@@ -328,96 +329,108 @@ void Addressee::setTempSyncStat( int id )
mData->mTempSyncStat = id;
}
int Addressee::tempSyncStat() const
{
return mData->mTempSyncStat;
}
QString Addressee::getID( const QString & prof)
{
return KIdManager::getId ( mData->mExternalId, prof );
}
void Addressee::setCsum( const QString & prof , const QString & id )
{
detach();
//qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
//qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
}
QString Addressee::getCsum( const QString & prof)
{
return KIdManager::getCsum ( mData->mExternalId, prof );
}
void Addressee::setIDStr( const QString & s )
{
detach();
mData->mExternalId = s;
}
QString Addressee::IDStr() const
{
return mData->mExternalId;
}
void Addressee::setExternalUID( const QString &id )
{
if ( id == mData->externalUID ) return;
detach();
mData->empty = false;
mData->externalUID = id;
}
QString Addressee::externalUID() const
{
return mData->externalUID;
}
+void Addressee::setOriginalExternalUID( const QString &id )
+{
+ if ( id == mData->originalExternalUID ) return;
+ detach();
+ mData->empty = false;
+ mData->originalExternalUID = id;
+}
+
+QString Addressee::originalExternalUID() const
+{
+ return mData->originalExternalUID;
+}
void Addressee::setUid( const QString &id )
{
if ( id == mData->uid ) return;
detach();
mData->empty = false;
mData->uid = id;
}
QString Addressee::uid() const
{
if ( mData->uid.isEmpty() )
mData->uid = KApplication::randomString( 10 );
return mData->uid;
}
QString Addressee::uidLabel()
{
return i18n("Unique Identifier");
}
void Addressee::setName( const QString &name )
{
if ( name == mData->name ) return;
detach();
mData->empty = false;
mData->name = name;
}
QString Addressee::name() const
{
return mData->name;
}
QString Addressee::nameLabel()
{
return i18n("Name");
}
void Addressee::setFormattedName( const QString &formattedName )
{
if ( formattedName == mData->formattedName ) return;
detach();
mData->empty = false;
mData->formattedName = formattedName;
}
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 3ba7777..8baa888 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -69,96 +69,98 @@ class Resource;
naming. formattedName() is the full name with the correct formatting.
It is used as an override, when the correct formatting can't be generated
from the other name fields automatically.
realName() returns a fully formatted name(). It uses formattedName, if set,
otherwise it constucts the name from the name fields. As fallback, if
nothing else is set it uses name().
name() is the NAME type of RFC2426. It can be used as internal name for the
data enty, but shouldn't be used for displaying the data to the user.
*/
class Addressee
{
friend QDataStream &operator<<( QDataStream &, const Addressee & );
friend QDataStream &operator>>( QDataStream &, Addressee & );
public:
typedef QValueList<Addressee> List;
/**
Construct an empty address book entry.
*/
Addressee();
~Addressee();
Addressee( const Addressee & );
Addressee &operator=( const Addressee & );
bool operator==( const Addressee & ) const;
bool operator!=( const Addressee & ) const;
// sync stuff
void setTempSyncStat(int id);
int tempSyncStat() const;
void setIDStr( const QString & );
QString IDStr() const;
void setID( const QString &, const QString & );
QString getID( const QString & );
void setCsum( const QString &, const QString & );
QString getCsum( const QString & );
void removeID(const QString &);
void computeCsum(const QString &dev);
ulong getCsum4List( const QStringList & attList);
/**
Return, if the address book entry is empty.
*/
bool isEmpty() const;
void setExternalUID( const QString &id );
QString externalUID() const;
+ void setOriginalExternalUID( const QString &id );
+ QString originalExternalUID() const;
void mergeContact( const Addressee& ad );
/**
Set unique identifier.
*/
void setUid( const QString &uid );
/**
Return unique identifier.
*/
QString uid() const;
/**
Return translated label for uid field.
*/
static QString uidLabel();
/**
Set name.
*/
void setName( const QString &name );
/**
Return name.
*/
QString name() const;
/**
Return translated label for name field.
*/
static QString nameLabel();
/**
Set formatted name.
*/
void setFormattedName( const QString &formattedName );
/**
Return formatted name.
*/
QString formattedName() const;
/**
Return translated label for formattedName field.
*/
static QString formattedNameLabel();
/**
Set family name.
*/
void setFamilyName( const QString &familyName );
/**
Return family name.
*/
QString familyName() const;
diff --git a/kabc/plugins/qtopia/qtopiaE.pro b/kabc/plugins/qtopia/qtopiaE.pro
index 148da2a..c0aa960 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 += $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include
+INCLUDEPATH += $(KDEPIMDIR) $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kio/kio $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/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/qtopiaconverter.cpp b/kabc/plugins/qtopia/qtopiaconverter.cpp
index 7d00a3f..de45e63 100644
--- a/kabc/plugins/qtopia/qtopiaconverter.cpp
+++ b/kabc/plugins/qtopia/qtopiaconverter.cpp
@@ -1,126 +1,130 @@
/*
This file is part of libkabc.
Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
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$
*/
//US
#include "kglobal.h"
#include "qtopiaconverter.h"
#include <qpe/categories.h>
+#include <libkdepim/ksyncprofile.h>
//US #include <qpe/categoryselect.h>
using namespace KABC;
QtopiaConverter::QtopiaConverter() : catDB(0)
{
}
QtopiaConverter::~QtopiaConverter()
{
deinit();
}
bool QtopiaConverter::init()
{
catDB = new Categories();
if (!catDB)
return false;
catDB->load( categoryFileName() );
return true;
}
void QtopiaConverter::deinit()
{
if (catDB)
{
delete catDB;
catDB = 0;
}
}
bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr )
{
// name
addr.setFormattedName(contact.fileAs());
addr.setFamilyName( contact.lastName() );
addr.setGivenName( contact.firstName() );
addr.setAdditionalName( contact.middleName() );
addr.setPrefix( contact.nameTitle() );
addr.setSuffix( contact.suffix() );
+
+ addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
QString exuid = contact.uid().toString();
+ addr.setOriginalExternalUID( exuid );
int ente = exuid.find( "-0000");
if ( exuid.left(1) == "{" )
exuid = exuid.mid(1);
if ( ente > -1 )
exuid = exuid.left( ente-1 );
addr.setExternalUID( exuid );
//qDebug("QtopiaConverter:set uid %s ",addr.externalUID().latin1() );
// email
QStringList emails = contact.emailList();
for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
addr.insertEmail( *it, ((*it) == contact.defaultEmail()) );
}
if (!contact.defaultEmail().isEmpty())
addr.insertEmail(contact.defaultEmail(), true);
// home
if ((!contact.homeStreet().isEmpty()) ||
(!contact.homeCity().isEmpty()) ||
(!contact.homeState().isEmpty()) ||
(!contact.homeZip().isEmpty()) ||
(!contact.homeCountry().isEmpty()))
{
Address homeaddress;
homeaddress.setType(Address::Home);
//US homeaddress.setPostOfficeBox( "" );
//US homeaddress.setExtended( "" );
homeaddress.setStreet( contact.homeStreet() );
homeaddress.setLocality( contact.homeCity() );
homeaddress.setRegion( contact.homeState() );
homeaddress.setPostalCode( contact.homeZip() );
homeaddress.setCountry( contact.homeCountry() );
addr.insertAddress( homeaddress );
}
if (!contact.homePhone().isEmpty())
{
PhoneNumber homephone;
homephone.setType( PhoneNumber::Home );
homephone.setNumber( contact.homePhone() );
addr.insertPhoneNumber( homephone );
}
if (!contact.homeFax().isEmpty())
{
PhoneNumber homefax;
@@ -206,96 +210,99 @@ bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &a
// qtopia uses this categorization:
// enum GenderType { UnspecifiedGender=0, Male, Female };
if (contact.gender() == PimContact::Male)
addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male");
else if (contact.gender() == PimContact::Female)
addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female");
if (contact.anniversary().isValid()) {
QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate);
//US
// qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1());
addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
}
addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() );
if (contact.birthday().isValid())
addr.setBirthday( contact.birthday() );
addr.setNickName( contact.nickname() );
// others
//US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available.
QString notes = contact.notes();
notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n";
addr.setNote( contact.notes() );
//US QString groups() const { return find( Qtopia::Groups ); }
//US QStringList groupList() const;
QArray<int> catArray = contact.categories();
QString cat;
for ( unsigned int i=0; i < catArray.size(); i++ ) {
cat = catDB->label("contact", catArray[i]);
if ( cat.isEmpty() )
addr.insertCategory(QString::number(catArray[i]));
else
addr.insertCategory( cat );
}
return true;
}
bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &contact )
{
+
+
+
// name
contact.setLastName(addr.familyName());
contact.setFirstName(addr.givenName());
contact.setMiddleName(addr.additionalName());
contact.setNameTitle(addr.prefix());
contact.setSuffix(addr.suffix());
contact.setFileAs();
// email
QStringList emails = addr.emails();
for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
contact.insertEmail(*it);
}
contact.setDefaultEmail( addr.preferredEmail() );
// home
const Address homeaddress = addr.address(Address::Home);
if (!homeaddress.isEmpty()) {
contact.setHomeStreet(homeaddress.street());
contact.setHomeCity(homeaddress.locality());
contact.setHomeState(homeaddress.region());
contact.setHomeZip(homeaddress.postalCode());
contact.setHomeCountry(homeaddress.country());
}
PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home );
if (!homephone.number().isEmpty())
contact.setHomePhone(homephone.number());
PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax );
if (!homefax.number().isEmpty())
contact.setHomeFax(homefax.number());
PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell );
if (!homemobile.number().isEmpty())
contact.setHomeMobile(homemobile.number());
contact.setHomeWebpage(addr.url().url());
// business
const Address businessaddress = addr.address(Address::Work);
if (!businessaddress.isEmpty()) {
contact.setBusinessStreet(businessaddress.street());
contact.setBusinessCity(businessaddress.locality());
contact.setBusinessState(businessaddress.region());
diff --git a/kabc/plugins/qtopia/qtopiaconverter.h b/kabc/plugins/qtopia/qtopiaconverter.h
index 8f4c698..012a6e2 100644
--- a/kabc/plugins/qtopia/qtopiaconverter.h
+++ b/kabc/plugins/qtopia/qtopiaconverter.h
@@ -1,79 +1,80 @@
/*
This file is part of libkabc.
Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
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$
*/
#ifndef KABC_QTOPIACONVERTER_H
#define KABC_QTOPIACONVERTER_H
#include <qstring.h>
#include "addressee.h"
#include <qpe/pim/contact.h>
+#include <qpe/quuid.h>
class Categories;
namespace KABC {
class QtopiaConverter
{
public:
/**
* Constructor.
*/
QtopiaConverter();
/**
* Destructor.
*/
virtual ~QtopiaConverter();
bool init();
void deinit();
/**
* Converts a vcard string to an addressee.
*
* @param contact The qtopia contact.
* @param addr The addressee.
*/
bool qtopiaToAddressee( const PimContact &contact, Addressee &addr );
/**
* Converts an addressee to a vcard string.
*
* @param addr The addressee.
* @param contact The qtopia contact.
*/
bool addresseeToQtopia( const Addressee &addr, PimContact &contact );
private:
Categories* catDB;
};
}
#endif
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp
index 48a9f22..935a1cf 100644
--- a/kabc/plugins/qtopia/resourceqtopia.cpp
+++ b/kabc/plugins/qtopia/resourceqtopia.cpp
@@ -7,96 +7,98 @@
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$
*/
#include <sys/types.h>
#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 "syncprefwidget.h"
#include "resourceqtopia.h"
+#include <libkdepim/ksyncprofile.h>
+#include <qpe/quuid.h>
using namespace KABC;
extern "C"
{
void *init_microkabc_qtopia()
{
return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig, SyncPrefWidgetContainer>();
}
}
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, bool syncable )
: Resource( 0, syncable )
{
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 );
}
@@ -144,128 +146,150 @@ bool ResourceQtopia::doOpen()
}
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)
{
contact = it.current();
KABC::Addressee addressee;
res = mConverter->qtopiaToAddressee( (*contact), addressee );
if ( !addressee.isEmpty() && res )
{
addressee.setResource( this );
addressBook()->insertAddressee( addressee );
}
}
return true;
}
bool ResourceQtopia::save( Ticket *ticket )
{
- qDebug("ResourceQtopia::save: %s", fileName().latin1());
-
- mDirWatch.stopScan();
-
- KABC::AddressBook::Iterator it;
- bool res;
-
- for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
- PimContact c;
- KABC::Addressee addressee = (*it);
-
- res = mConverter->addresseeToQtopia( *it, c );
- if (res == true)
- {
- mAccess->addContact(c);
-// if (res == false)
-// qDebug("Unable to append Contact %s", c.fullName().latin1());
+ qDebug("ResourceQtopia::save: %s", fileName().latin1());
+
+ mDirWatch.stopScan();
+
+ KABC::AddressBook::Iterator it;
+ bool res;
+
+ for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
+ //KABC::Addressee addressee = (*it);
+ if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
+ QUuid uid( (*it).originalExternalUID() );
+ bool ok;
+ PimContact c = mAccess->contactForId( uid, &ok );
+ res = mConverter->addresseeToQtopia( *it, c );
+ if (res == true) {
+ if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) {
+ mAccess->addContact(c);
+ KABC::Addressee addressee;
+ mConverter->qtopiaToAddressee( c, addressee );
+ addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
+ addressBook()->insertAddressee( addressee );
+
+ } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
+ if ( ok )
+ mAccess->removeContact(c);
+ else
+ qDebug("Error revoe contact from qtopia ");
+ } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
+ if ( ok ) {
+ mAccess->updateContact(c);
+ KABC::Addressee addressee;
+ mConverter->qtopiaToAddressee( c, addressee );
+ addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM );
+ addressBook()->insertAddressee( addressee );
+ }
+ else
+ qDebug("Error update contact from qtopia ");
+
+ }
+
+ } else {
+ qDebug("Unable to convert Addressee %s", (*it).formattedName().latin1());
+ }
+ }
}
- else
- {
- qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1());
- }
- }
-// mAccess->addressBookUpdated();
+ // mAccess->addressBookUpdated();
- mDirWatch.startScan();
+ mDirWatch.startScan();
- delete ticket;
- unlock( fileName() );
+ delete ticket;
+ unlock( fileName() );
- return true;
+ return true;
}
bool ResourceQtopia::lock( const QString &lockfileName )
{
qDebug("ResourceQtopia::lock: %s", fileName().latin1());
kdDebug(5700) << "ResourceQtopia::lock()" << endl;
QString fn = lockfileName;
KURL url(fn);
QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
kdDebug(5700) << "-- lock name: " << lockName << endl;
if (QFile::exists( lockName ))
{
qDebug("ResourceOpie::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName().latin1());
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;