summaryrefslogtreecommitdiffabout
path: root/kabc
authorzautrix <zautrix>2004-10-20 21:49:51 (UTC)
committer zautrix <zautrix>2004-10-20 21:49:51 (UTC)
commitbb235c5a639b914574e1e247d2de6e479517585f (patch) (unidiff)
tree0f074ec87d93b6f5fb81b6893f0174cabc52c1df /kabc
parent8e00329a4a5f0b66d26d20f067ab6aefca17f17a (diff)
downloadkdepimpi-bb235c5a639b914574e1e247d2de6e479517585f.zip
kdepimpi-bb235c5a639b914574e1e247d2de6e479517585f.tar.gz
kdepimpi-bb235c5a639b914574e1e247d2de6e479517585f.tar.bz2
qtopia resource fixes
Diffstat (limited to 'kabc') (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 )
293 adr.insertCustom( "KADDRESSBOOK", "X-SpousesName", el.attribute( "Spouse" ) ); 293 adr.insertCustom( "KADDRESSBOOK", "X-SpousesName", el.attribute( "Spouse" ) );
294 if ( !el.attribute( "Gender" ).isEmpty() ) 294 if ( !el.attribute( "Gender" ).isEmpty() ) {
295 adr.insertCustom( "opie", "Gender", el.attribute( "Gender" ) ); 295 if ( el.attribute( "Gender" ) == "1" )
296 296 adr.insertCustom( "KADDRESSBOOK", "X-Gender", "male" );
297 else if ( el.attribute( "Gender" ) == "2" )
298 adr.insertCustom( "KADDRESSBOOK", "X-Gender", "female" );
299 }
297 QDate ann = dateFromString( el.attribute( "Anniversary" ) ); 300 QDate ann = dateFromString( el.attribute( "Anniversary" ) );
@@ -303,3 +306,3 @@ bool QtopiaConverter::qtopiaToAddressee( const QDomElement& el, Addressee &adr )
303 if ( !el.attribute( "Children" ).isEmpty() ) 306 if ( !el.attribute( "Children" ).isEmpty() )
304 adr.insertCustom("opie", "Children", el.attribute("Children") ); 307 adr.insertCustom("KADDRESSBOOK", "X-Children", el.attribute("Children") );
305 if ( !el.attribute( "Office" ).isEmpty() ) 308 if ( !el.attribute( "Office" ).isEmpty() )
@@ -386,3 +389,8 @@ bool QtopiaConverter::addresseeToQtopia( const Addressee &ab, QTextStream *strea
386 *stream << "Spouse=\"" << escape( ab.custom( "KADDRESSBOOK", "X-SpousesName") ) << "\" "; 389 *stream << "Spouse=\"" << escape( ab.custom( "KADDRESSBOOK", "X-SpousesName") ) << "\" ";
387 *stream << "Gender=\"" << escape( ab.custom( "opie", "Gender") ) << "\" "; 390 QString gen = "0";
391 if ( ab.custom( "KADDRESSBOOK", "X-Gender") == "male" )
392 gen = "1";
393 else if ( ab.custom( "KADDRESSBOOK", "X-Gender") == "female" )
394 gen = "2";
395 *stream << "Gender=\"" << escape( gen ) << "\" ";
388 396
@@ -391,6 +399,2 @@ bool QtopiaConverter::addresseeToQtopia( const Addressee &ab, QTextStream *strea
391 399
392 /*
393 * Anniversary block again
394 * Go from ISO -> QDate -> toString and then escape
395 */
396 { 400 {
@@ -403,3 +407,3 @@ bool QtopiaConverter::addresseeToQtopia( const Addressee &ab, QTextStream *strea
403 *stream << "Nickname=\"" << escape( ab.nickName() ) << "\" "; 407 *stream << "Nickname=\"" << escape( ab.nickName() ) << "\" ";
404 *stream << "Children=\"" << escape( ab.custom("opie", "Children" ) ) << "\" "; 408 *stream << "Children=\"" << escape( ab.custom("KADDRESSBOOK", "X-Children" ) ) << "\" ";
405 *stream << "Notes=\"" << escape( ab.note() ) << "\" "; 409 *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 )
80{ 80{
81 81#ifdef _USE_DIRWATCH_
82 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 82 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
@@ -84,3 +84,3 @@ void ResourceQtopia::init( const QString &fileName )
84 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 84 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
85 85#endif
86 setFileName( fileName ); 86 setFileName( fileName );
@@ -167,3 +167,3 @@ bool ResourceQtopia::load()
167 if ( !e.isNull() ) { 167 if ( !e.isNull() ) {
168 if ( e.tagName() == QString::fromLatin1( "Contacts" ) ) { // we're looking for them 168 if ( e.tagName() == QString::fromLatin1( "Contacts" ) ) {
169 QDomNode no = e.firstChild(); 169 QDomNode no = e.firstChild();
@@ -188,26 +188,2 @@ bool ResourceQtopia::load()
188 } 188 }
189
190#if 0
191/ old code
192 qDebug("ResourceQtopia::load: %s", fileName().latin1());
193
194 AddressBookIterator it(*mAccess);
195 const PimContact* contact;
196 bool res;
197
198 for (contact=it.toFirst(); it.current(); ++it)
199 {
200 contact = it.current();
201
202 KABC::Addressee addressee;
203
204 //LRres = mConverter->qtopiaToAddressee( (*contact), addressee );
205
206 if ( !addressee.isEmpty() && res )
207 {
208 addressee.setResource( this );
209 addressBook()->insertAddressee( addressee );
210 }
211 }
212#endif
213 return true; 189 return true;
@@ -217,8 +193,13 @@ bool ResourceQtopia::save( Ticket *ticket )
217{ 193{
218 194#ifdef _USE_DIRWATCH_
219 mDirWatch.stopScan(); 195 mDirWatch.stopScan();
196#endif
220 KABC::AddressBook::Iterator it; 197 KABC::AddressBook::Iterator it;
221 bool res; 198 bool res;
222 //pending open file for stream 199 QFile file( fileName() );
223 QTextStream *stream;// = tempFile->textStream(); 200 if (!file.open( IO_WriteOnly ) ) {
201 return false;
202 }
203 QTextStream ts( &file );
204 QTextStream *stream = &ts;
224 stream->setEncoding( QTextStream::UnicodeUTF8 ); 205 stream->setEncoding( QTextStream::UnicodeUTF8 );
@@ -238,46 +219,10 @@ bool ResourceQtopia::save( Ticket *ticket )
238 } 219 }
239
240
241 *stream << "</Contacts>" << endl; 220 *stream << "</Contacts>" << endl;
242 *stream << "</AddressBook>" << endl; 221 *stream << "</AddressBook>" << endl;
243 //pending close file 222 file.close();
223#ifdef _USE_DIRWATCH_
244 mDirWatch.startScan(); 224 mDirWatch.startScan();
245 225#endif
246 delete ticket; 226 delete ticket;
247 unlock( fileName() ); 227 unlock( fileName() );
248
249
250#if 0
251 //old code
252 qDebug("ResourceQtopia::save: %s", fileName().latin1());
253
254 mDirWatch.stopScan();
255
256 KABC::AddressBook::Iterator it;
257 bool res;
258
259 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
260 PimContact c;
261 KABC::Addressee addressee = (*it);
262
263 //res = mConverter->addresseeToQtopia( *it, c );
264 if (res == true)
265 {
266 mAccess->addContact(c);
267// if (res == false)
268// qDebug("Unable to append Contact %s", c.fullName().latin1());
269 }
270 else
271 {
272 qDebug("Unable to convert Addressee %s", addressee.formattedName().latin1());
273 }
274 }
275
276// mAccess->addressBookUpdated();
277
278 mDirWatch.startScan();
279
280 delete ticket;
281 unlock( fileName() );
282#endif
283 return true; 228 return true;
@@ -287,6 +232,5 @@ bool ResourceQtopia::lock( const QString &lockfileName )
287{ 232{
233 //disabled
234 return true;
288 qDebug("ResourceQtopia::lock: %s", fileName().latin1()); 235 qDebug("ResourceQtopia::lock: %s", fileName().latin1());
289
290 kdDebug(5700) << "ResourceQtopia::lock()" << endl;
291
292 QString fn = lockfileName; 236 QString fn = lockfileName;
@@ -296,4 +240,2 @@ bool ResourceQtopia::lock( const QString &lockfileName )
296 240
297 kdDebug(5700) << "-- lock name: " << lockName << endl;
298
299 if (QFile::exists( lockName )) 241 if (QFile::exists( lockName ))
@@ -335,2 +277,4 @@ void ResourceQtopia::unlock( const QString &fileName )
335{ 277{
278 //disabled
279 return;
336 qDebug("ResourceQtopia::unlock() %s", fileName.latin1()); 280 qDebug("ResourceQtopia::unlock() %s", fileName.latin1());
@@ -348,3 +292,5 @@ void ResourceQtopia::setFileName( const QString &newFileName )
348{ 292{
293#ifdef _USE_DIRWATCH_
349 mDirWatch.stopScan(); 294 mDirWatch.stopScan();
295#endif
350 mDirWatch.removeFile( fileName() ); 296 mDirWatch.removeFile( fileName() );
@@ -354,3 +300,5 @@ void ResourceQtopia::setFileName( const QString &newFileName )
354 mDirWatch.addFile( fileName() ); 300 mDirWatch.addFile( fileName() );
301#ifdef _USE_DIRWATCH_
355 mDirWatch.startScan(); 302 mDirWatch.startScan();
303#endif
356} 304}