summaryrefslogtreecommitdiffabout
path: root/kabc/plugins
authorzautrix <zautrix>2004-10-20 21:49:51 (UTC)
committer zautrix <zautrix>2004-10-20 21:49:51 (UTC)
commitbb235c5a639b914574e1e247d2de6e479517585f (patch) (side-by-side diff)
tree0f074ec87d93b6f5fb81b6893f0174cabc52c1df /kabc/plugins
parent8e00329a4a5f0b66d26d20f067ab6aefca17f17a (diff)
downloadkdepimpi-bb235c5a639b914574e1e247d2de6e479517585f.zip
kdepimpi-bb235c5a639b914574e1e247d2de6e479517585f.tar.gz
kdepimpi-bb235c5a639b914574e1e247d2de6e479517585f.tar.bz2
qtopia resource fixes
Diffstat (limited to 'kabc/plugins') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/plugins/qtopia/qtopiaconverter.cpp24
-rw-r--r--kabc/plugins/qtopia/resourceqtopia.cpp98
2 files changed, 37 insertions, 85 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
@@ -293,5 +293,8 @@ bool QtopiaConverter::qtopiaToAddressee( const QDomElement& el, Addressee &adr )
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" ) );
@@ -303,3 +306,3 @@ bool QtopiaConverter::qtopiaToAddressee( const QDomElement& el, Addressee &adr )
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() )
@@ -386,3 +389,8 @@ bool QtopiaConverter::addresseeToQtopia( const Addressee &ab, QTextStream *strea
*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 ) << "\" ";
@@ -391,6 +399,2 @@ bool QtopiaConverter::addresseeToQtopia( const Addressee &ab, QTextStream *strea
- /*
- * Anniversary block again
- * Go from ISO -> QDate -> toString and then escape
- */
{
@@ -403,3 +407,3 @@ bool QtopiaConverter::addresseeToQtopia( const Addressee &ab, QTextStream *strea
*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() ) << "\" ";
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
@@ -80,3 +80,3 @@ void ResourceQtopia::init( const QString &fileName )
{
-
+#ifdef _USE_DIRWATCH_
connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
@@ -84,3 +84,3 @@ void ResourceQtopia::init( const QString &fileName )
connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
-
+#endif
setFileName( fileName );
@@ -167,3 +167,3 @@ bool ResourceQtopia::load()
if ( !e.isNull() ) {
- if ( e.tagName() == QString::fromLatin1( "Contacts" ) ) { // we're looking for them
+ if ( e.tagName() == QString::fromLatin1( "Contacts" ) ) {
QDomNode no = e.firstChild();
@@ -188,26 +188,2 @@ bool ResourceQtopia::load()
}
-
-#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;
@@ -217,8 +193,13 @@ 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 );
@@ -238,46 +219,10 @@ bool ResourceQtopia::save( Ticket *ticket )
}
-
-
*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;
@@ -287,6 +232,5 @@ bool ResourceQtopia::lock( const QString &lockfileName )
{
+ //disabled
+ return true;
qDebug("ResourceQtopia::lock: %s", fileName().latin1());
-
- kdDebug(5700) << "ResourceQtopia::lock()" << endl;
-
QString fn = lockfileName;
@@ -296,4 +240,2 @@ bool ResourceQtopia::lock( const QString &lockfileName )
- kdDebug(5700) << "-- lock name: " << lockName << endl;
-
if (QFile::exists( lockName ))
@@ -335,2 +277,4 @@ void ResourceQtopia::unlock( const QString &fileName )
{
+ //disabled
+ return;
qDebug("ResourceQtopia::unlock() %s", fileName.latin1());
@@ -348,3 +292,5 @@ void ResourceQtopia::setFileName( const QString &newFileName )
{
+#ifdef _USE_DIRWATCH_
mDirWatch.stopScan();
+#endif
mDirWatch.removeFile( fileName() );
@@ -354,3 +300,5 @@ void ResourceQtopia::setFileName( const QString &newFileName )
mDirWatch.addFile( fileName() );
+#ifdef _USE_DIRWATCH_
mDirWatch.startScan();
+#endif
}