summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/qtopia/qtopiaconverter.cpp24
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp98
-rw-r--r--microkde/kresources/managerimpl.cpp9
3 files changed, 45 insertions, 86 deletions
diff --git a/kabc/plugins/qtopia/qtopiaconverter.cpp b/kabc/plugins/qtopia/qtopiaconverter.cpp
index 040226c..106596f 100644
--- a/kabc/plugins/qtopia/qtopiaconverter.cpp
+++ b/kabc/plugins/qtopia/qtopiaconverter.cpp
@@ -288,23 +288,26 @@ bool QtopiaConverter::qtopiaToAddressee( const QDomElement& el, Addressee &adr )
if ( !el.attribute( "Department" ).isEmpty() )
adr.insertCustom( "KADDRESSBOOK", "X-Department", el.attribute( "Department" ) );
if ( !el.attribute( "HomeWebPage" ).isEmpty() )
adr.insertCustom( "opie", "HomeWebPage", el.attribute( "HomeWebPage" ) );
if ( !el.attribute( "Spouse" ).isEmpty() )
adr.insertCustom( "KADDRESSBOOK", "X-SpousesName", el.attribute( "Spouse" ) );
- if ( !el.attribute( "Gender" ).isEmpty() )
- adr.insertCustom( "opie", "Gender", el.attribute( "Gender" ) );
-
+ if ( !el.attribute( "Gender" ).isEmpty() ) {
+ if ( el.attribute( "Gender" ) == "1" )
+ adr.insertCustom( "KADDRESSBOOK", "X-Gender", "male" );
+ else if ( el.attribute( "Gender" ) == "2" )
+ adr.insertCustom( "KADDRESSBOOK", "X-Gender", "female" );
+ }
QDate ann = dateFromString( el.attribute( "Anniversary" ) );
if ( ann.isValid() ) {
QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate);
adr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt );
}
if ( !el.attribute( "Children" ).isEmpty() )
- adr.insertCustom("opie", "Children", el.attribute("Children") );
+ adr.insertCustom("KADDRESSBOOK", "X-Children", el.attribute("Children") );
if ( !el.attribute( "Office" ).isEmpty() )
adr.insertCustom("KADDRESSBOOK", "X-Office", el.attribute("Office") );
if ( !el.attribute( "Profession" ).isEmpty() )
adr.insertCustom("KADDRESSBOOK", "X-Profession", el.attribute("Profession") );
if ( !el.attribute( "Assistant" ).isEmpty() )
adr.insertCustom("KADDRESSBOOK", "X-AssistantsName", el.attribute("Assistant") );
@@ -381,30 +384,31 @@ bool QtopiaConverter::addresseeToQtopia( const Addressee &ab, QTextStream *strea
*stream << "HomeState=\"" << escape( home.region() ) << "\" ";
*stream << "HomeZip=\"" << escape( home.postalCode() ) << "\" ";
*stream << "HomeCountry=\"" << escape( home.country() ) << "\" ";
*stream << "HomeWebPage=\"" << escape( ab.custom( "opie", "HomeWebPage" ) ) << "\" ";
*stream << "Spouse=\"" << escape( ab.custom( "KADDRESSBOOK", "X-SpousesName") ) << "\" ";
- *stream << "Gender=\"" << escape( ab.custom( "opie", "Gender") ) << "\" ";
+ QString gen = "0";
+ if ( ab.custom( "KADDRESSBOOK", "X-Gender") == "male" )
+ gen = "1";
+ else if ( ab.custom( "KADDRESSBOOK", "X-Gender") == "female" )
+ gen = "2";
+ *stream << "Gender=\"" << escape( gen ) << "\" ";
if ( ab.birthday().date().isValid() )
*stream << "Birthday=\"" << escape( dateToString(ab.birthday().date() ) ) << "\" ";
- /*
- * Anniversary block again
- * Go from ISO -> QDate -> toString and then escape
- */
{
QDate ann = KGlobal::locale()->readDate( ab.custom("KADDRESSBOOK", "X-Anniversary" ),
"%Y-%m-%d");
if (ann.isValid() ) {
*stream << "Anniversary=\"" << escape( dateToString( ann ) ) << "\" ";
}
}
*stream << "Nickname=\"" << escape( ab.nickName() ) << "\" ";
- *stream << "Children=\"" << escape( ab.custom("opie", "Children" ) ) << "\" ";
+ *stream << "Children=\"" << escape( ab.custom("KADDRESSBOOK", "X-Children" ) ) << "\" ";
*stream << "Notes=\"" << escape( ab.note() ) << "\" ";
*stream << "Categories=\"" << categoriesToNumber( ab.categories(), "Contacts") << "\" ";
QString uid = ab.uid();
*stream << "Uid=\"" << uid << "\" ";
//*stream << map.toString( "addressbook", uid );
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp
index b7263bb..4ee3c3c 100644
--- a/kabc/plugins/qtopia/resourceqtopia.cpp
+++ b/kabc/plugins/qtopia/resourceqtopia.cpp
@@ -75,17 +75,17 @@ ResourceQtopia::ResourceQtopia( const QString &fileName )
{
init( fileName );
}
void ResourceQtopia::init( const QString &fileName )
{
-
+#ifdef _USE_DIRWATCH_
connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
-
+#endif
setFileName( fileName );
}
ResourceQtopia::~ResourceQtopia()
{
if (mConverter != 0)
@@ -162,13 +162,13 @@ bool ResourceQtopia::load()
bool res;
QDomElement docElem = doc.documentElement( );
QDomNode n = docElem.firstChild();
while ( !n.isNull() ) {
QDomElement e = n.toElement();
if ( !e.isNull() ) {
- if ( e.tagName() == QString::fromLatin1( "Contacts" ) ) { // we're looking for them
+ if ( e.tagName() == QString::fromLatin1( "Contacts" ) ) {
QDomNode no = e.firstChild();
while ( !no.isNull() ) {
QDomElement el = no.toElement();
if ( !el.isNull() ) {
KABC::Addressee addressee;
res = mConverter->qtopiaToAddressee( el, addressee );
@@ -183,47 +183,28 @@ bool ResourceQtopia::load()
}
}
}
n = n.nextSibling();
}
-
-#if 0
-/ old code
- 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;
-
- //LRres = mConverter->qtopiaToAddressee( (*contact), addressee );
-
- if ( !addressee.isEmpty() && res )
- {
- addressee.setResource( this );
- addressBook()->insertAddressee( addressee );
- }
- }
-#endif
return true;
}
bool ResourceQtopia::save( Ticket *ticket )
{
-
+#ifdef _USE_DIRWATCH_
mDirWatch.stopScan();
+#endif
KABC::AddressBook::Iterator it;
- bool res;
- //pending open file for stream
- QTextStream *stream;// = tempFile->textStream();
+ bool res;
+ QFile file( fileName() );
+ if (!file.open( IO_WriteOnly ) ) {
+ return false;
+ }
+ QTextStream ts( &file );
+ QTextStream *stream = &ts;
stream->setEncoding( QTextStream::UnicodeUTF8 );
*stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>" << endl;
*stream << " <Groups>" << endl;
*stream << " </Groups>" << endl;
*stream << " <Contacts> " << endl;
// for all entries
@@ -233,72 +214,33 @@ bool ResourceQtopia::save( Ticket *ticket )
res = mConverter->addresseeToQtopia( addressee, stream );
if (!res == true)
{
qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1());
}
}
-
-
*stream << "</Contacts>" << endl;
*stream << "</AddressBook>" << endl;
- //pending close file
+ file.close();
+#ifdef _USE_DIRWATCH_
mDirWatch.startScan();
-
+#endif
delete ticket;
unlock( fileName() );
-
-
-#if 0
- //old code
- 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());
- }
- else
- {
- qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1());
- }
- }
-
-// mAccess->addressBookUpdated();
-
- mDirWatch.startScan();
-
- delete ticket;
- unlock( fileName() );
-#endif
return true;
}
bool ResourceQtopia::lock( const QString &lockfileName )
{
+ //disabled
+ return true;
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;
}
@@ -330,12 +272,14 @@ bool ResourceQtopia::lock( const QString &lockfileName )
return false;
}
void ResourceQtopia::unlock( const QString &fileName )
{
+ //disabled
+ return;
qDebug("ResourceQtopia::unlock() %s", fileName.latin1());
QString fn = fileName;
KURL url(fn);
QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
@@ -343,19 +287,23 @@ void ResourceQtopia::unlock( const QString &fileName )
QFile::remove( mLockUniqueName );
addressBook()->emitAddressBookUnlocked();
}
void ResourceQtopia::setFileName( const QString &newFileName )
{
+#ifdef _USE_DIRWATCH_
mDirWatch.stopScan();
+#endif
mDirWatch.removeFile( fileName() );
Resource::setFileName( newFileName );
mDirWatch.addFile( fileName() );
+#ifdef _USE_DIRWATCH_
mDirWatch.startScan();
+#endif
}
void ResourceQtopia::fileChanged()
{
// There is a small theoretical chance that KDirWatch calls us before
diff --git a/microkde/kresources/managerimpl.cpp b/microkde/kresources/managerimpl.cpp
index 81bbbec..5bd9eb7 100644
--- a/microkde/kresources/managerimpl.cpp
+++ b/microkde/kresources/managerimpl.cpp
@@ -31,12 +31,13 @@ $Id$
#include <kglobal.h>
#include <kapplication.h>
#include <kdebug.h>
#include <kconfig.h>
#include <kstandarddirs.h>
+#include <qfile.h>
#include "resource.h"
#include "factory.h"
#include "managerimpl.h"
using namespace KRES;
@@ -64,13 +65,19 @@ ManagerImpl::~ManagerImpl()
}
void ManagerImpl::createStandardConfig()
{
if ( !mStdConfig ) {
QString file = locateLocal( "data", KGlobal::getAppName()
- + "/kresources/" + mFamily + "rc" );
+ + "/kresources/" + mFamily + "rc" );
+ if ( mFamily == "tmpcontact" ) {
+ if (QFile::exists ( file ) ){
+ QFile::remove ( file );
+ qDebug("removed tmp rc file: %s ", file.latin1());
+ }
+ }
mStdConfig = new KConfig( file );
}
mConfig = mStdConfig;
}