summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-07 09:56:31 (UTC)
committer zautrix <zautrix>2004-10-07 09:56:31 (UTC)
commitedd36b813763c304b104f276437c2c60ee9bd1f1 (patch) (unidiff)
treeda3a9f6fbd905fe876131af5025690806ce60704
parent9345818e9c291130691288e4b065190259eb4e01 (diff)
downloadkdepimpi-edd36b813763c304b104f276437c2c60ee9bd1f1.zip
kdepimpi-edd36b813763c304b104f276437c2c60ee9bd1f1.tar.gz
kdepimpi-edd36b813763c304b104f276437c2c60ee9bd1f1.tar.bz2
sync fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp70
-rw-r--r--kabc/addressbook.h5
-rw-r--r--kaddressbook/kabcore.cpp20
-rw-r--r--kaddressbook/kabcore.h2
-rw-r--r--kaddressbook/xxport/vcard_xxport.cpp1
-rw-r--r--libkdepim/ksyncmanager.cpp5
-rw-r--r--libkdepim/ksyncmanager.h5
7 files changed, 90 insertions, 18 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 5fb49eb..295cf03 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -25,39 +25,44 @@ Copyright (c) 2004 Ulf Schenk
25$Id$ 25$Id$
26*/ 26*/
27 27
28/*US 28/*US
29 29
30#include <qfile.h> 30#include <qfile.h>
31#include <qregexp.h> 31#include <qregexp.h>
32#include <qtimer.h> 32#include <qtimer.h>
33 33
34#include <kapplication.h> 34#include <kapplication.h>
35#include <kinstance.h> 35#include <kinstance.h>
36#include <kstandarddirs.h> 36#include <kstandarddirs.h>
37 37
38#include "errorhandler.h" 38#include "errorhandler.h"
39*/ 39*/
40#include <qptrlist.h> 40#include <qptrlist.h>
41#include <qtextstream.h>
42#include <qfile.h>
41 43
42#include <kglobal.h> 44#include <kglobal.h>
43#include <klocale.h> 45#include <klocale.h>>
46#include <kmessagebox.h>
44#include <kdebug.h> 47#include <kdebug.h>
45#include <libkcal/syncdefines.h> 48#include <libkcal/syncdefines.h>
46#include "addressbook.h" 49#include "addressbook.h"
47#include "resource.h" 50#include "resource.h"
51#include "vcardconverter.h"
52#include "vcardparser/vcardtool.h"
48 53
49//US #include "addressbook.moc" 54//US #include "addressbook.moc"
50 55
51using namespace KABC; 56using namespace KABC;
52 57
53struct AddressBook::AddressBookData 58struct AddressBook::AddressBookData
54{ 59{
55 Addressee::List mAddressees; 60 Addressee::List mAddressees;
56 Addressee::List mRemovedAddressees; 61 Addressee::List mRemovedAddressees;
57 Field::List mAllFields; 62 Field::List mAllFields;
58 KConfig *mConfig; 63 KConfig *mConfig;
59 KRES::Manager<Resource> *mManager; 64 KRES::Manager<Resource> *mManager;
60//US ErrorHandler *mErrorHandler; 65//US ErrorHandler *mErrorHandler;
61}; 66};
62 67
63struct AddressBook::Iterator::IteratorData 68struct AddressBook::Iterator::IteratorData
@@ -357,32 +362,80 @@ bool AddressBook::load()
357 } 362 }
358 blockLSEchange = true; 363 blockLSEchange = true;
359 return ok; 364 return ok;
360} 365}
361 366
362bool AddressBook::save( Ticket *ticket ) 367bool AddressBook::save( Ticket *ticket )
363{ 368{
364 kdDebug(5700) << "AddressBook::save()"<< endl; 369 kdDebug(5700) << "AddressBook::save()"<< endl;
365 370
366 if ( ticket->resource() ) { 371 if ( ticket->resource() ) {
367 deleteRemovedAddressees(); 372 deleteRemovedAddressees();
368 return ticket->resource()->save( ticket ); 373 return ticket->resource()->save( ticket );
369 } 374 }
370 375
371 return false; 376 return false;
372} 377}
378void AddressBook::export2File( QString fileName )
379{
380
381 QFile outFile( fileName );
382 if ( !outFile.open( IO_WriteOnly ) ) {
383 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
384 KMessageBox::error( 0, text.arg( fileName ) );
385 return ;
386 }
387 QTextStream t( &outFile );
388 t.setEncoding( QTextStream::UnicodeUTF8 );
389 Iterator it;
390 KABC::VCardConverter::Version version;
391 version = KABC::VCardConverter::v3_0;
392 for ( it = begin(); it != end(); ++it ) {
393 if ( !(*it).IDStr().isEmpty() ) {
394 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() );
395 }
396 KABC::VCardConverter converter;
397 QString vcard;
398 //Resource *resource() const;
399 converter.addresseeToVCard( *it, vcard, version );
400 t << vcard << "\r\n";
401 }
402 outFile.close();
403}
404void AddressBook::importFromFile( QString fileName )
405{
406
407 KABC::Addressee::List list;
408 QFile file( fileName );
409
410 file.open( IO_ReadOnly );
411 QByteArray rawData = file.readAll();
412 file.close();
413
414 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
415 KABC::VCardTool tool;
416 list = tool.parseVCards( data );
417
418 KABC::Addressee::List::Iterator it;
419 for ( it = list.begin(); it != list.end(); ++it ) {
420 (*it).setResource( 0 );
421 insertAddressee( (*it), false, true );
422 }
423
424}
425
373bool AddressBook::saveAB() 426bool AddressBook::saveAB()
374{ 427{
375 bool ok = true; 428 bool ok = true;
376 429
377 deleteRemovedAddressees(); 430 deleteRemovedAddressees();
378 Iterator ait; 431 Iterator ait;
379 for ( ait = begin(); ait != end(); ++ait ) { 432 for ( ait = begin(); ait != end(); ++ait ) {
380 if ( !(*ait).IDStr().isEmpty() ) { 433 if ( !(*ait).IDStr().isEmpty() ) {
381 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 434 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
382 } 435 }
383 } 436 }
384 KRES::Manager<Resource>::ActiveIterator it; 437 KRES::Manager<Resource>::ActiveIterator it;
385 KRES::Manager<Resource> *manager = d->mManager; 438 KRES::Manager<Resource> *manager = d->mManager;
386 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 439 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
387 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 440 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
388 Ticket *ticket = requestSaveTicket( *it ); 441 Ticket *ticket = requestSaveTicket( *it );
@@ -448,53 +501,58 @@ Ticket *AddressBook::requestSaveTicket( Resource *resource )
448 resource = standardResource(); 501 resource = standardResource();
449 } 502 }
450 503
451 KRES::Manager<Resource>::ActiveIterator it; 504 KRES::Manager<Resource>::ActiveIterator it;
452 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 505 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
453 if ( (*it) == resource ) { 506 if ( (*it) == resource ) {
454 if ( (*it)->readOnly() || !(*it)->isOpen() ) 507 if ( (*it)->readOnly() || !(*it)->isOpen() )
455 return 0; 508 return 0;
456 else 509 else
457 return (*it)->requestSaveTicket(); 510 return (*it)->requestSaveTicket();
458 } 511 }
459 } 512 }
460 513
461 return 0; 514 return 0;
462} 515}
463 516
464void AddressBook::insertAddressee( const Addressee &a, bool setRev ) 517void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource )
465{ 518{
466 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { 519 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) {
467 //qDebug("block insert "); 520 //qDebug("block insert ");
468 return; 521 return;
469 } 522 }
470 //qDebug("inserting.... %s ",a.uid().latin1() ); 523 //qDebug("inserting.... %s ",a.uid().latin1() );
471 bool found = false; 524 bool found = false;
472 Addressee::List::Iterator it; 525 Addressee::List::Iterator it;
473 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 526 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
474 if ( a.uid() == (*it).uid() ) { 527 if ( a.uid() == (*it).uid() ) {
475 528
476 bool changed = false; 529 bool changed = false;
477 Addressee addr = a; 530 Addressee addr = a;
478 if ( addr != (*it) ) 531 if ( addr != (*it) )
479 changed = true; 532 changed = true;
480 533
481 (*it) = a; 534 if ( takeResource ) {
482 if ( (*it).resource() == 0 ) 535 Resource * res = (*it).resource();
483 (*it).setResource( standardResource() ); 536 (*it) = a;
484 537 (*it).setResource( res );
538 } else {
539 (*it) = a;
540 if ( (*it).resource() == 0 )
541 (*it).setResource( standardResource() );
542 }
485 if ( changed ) { 543 if ( changed ) {
486 if ( setRev ) { 544 if ( setRev ) {
487 545
488 // get rid of micro seconds 546 // get rid of micro seconds
489 QDateTime dt = QDateTime::currentDateTime(); 547 QDateTime dt = QDateTime::currentDateTime();
490 QTime t = dt.time(); 548 QTime t = dt.time();
491 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 549 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
492 (*it).setRevision( dt ); 550 (*it).setRevision( dt );
493 } 551 }
494 (*it).setChanged( true ); 552 (*it).setChanged( true );
495 } 553 }
496 554
497 found = true; 555 found = true;
498 } else { 556 } else {
499 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 557 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
500 QString name = (*it).uid().mid( 19 ); 558 QString name = (*it).uid().mid( 19 );
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 8f62f0d..3603ec1 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -129,64 +129,65 @@ class AddressBook : public QObject
129 */ 129 */
130 Ticket *requestSaveTicket( Resource *resource=0 ); 130 Ticket *requestSaveTicket( Resource *resource=0 );
131 131
132 /** 132 /**
133 Load address book from file. 133 Load address book from file.
134 */ 134 */
135 bool load(); 135 bool load();
136 136
137 /** 137 /**
138 Save address book. The address book is saved to the file, the Ticket 138 Save address book. The address book is saved to the file, the Ticket
139 object has been requested for by @ref requestSaveTicket(). 139 object has been requested for by @ref requestSaveTicket().
140 140
141 @param ticket a ticket object returned by @ref requestSaveTicket() 141 @param ticket a ticket object returned by @ref requestSaveTicket()
142 */ 142 */
143 bool save( Ticket *ticket ); 143 bool save( Ticket *ticket );
144 bool saveAB( ); 144 bool saveAB( );
145 145 void export2File( QString fileName );
146 void importFromFile( QString fileName );
146 /** 147 /**
147 Returns a iterator for first entry of address book. 148 Returns a iterator for first entry of address book.
148 */ 149 */
149 Iterator begin(); 150 Iterator begin();
150 151
151 /** 152 /**
152 Returns a const iterator for first entry of address book. 153 Returns a const iterator for first entry of address book.
153 */ 154 */
154 ConstIterator begin() const; 155 ConstIterator begin() const;
155 156
156 /** 157 /**
157 Returns a iterator for first entry of address book. 158 Returns a iterator for first entry of address book.
158 */ 159 */
159 Iterator end(); 160 Iterator end();
160 161
161 /** 162 /**
162 Returns a const iterator for first entry of address book. 163 Returns a const iterator for first entry of address book.
163 */ 164 */
164 ConstIterator end() const; 165 ConstIterator end() const;
165 166
166 /** 167 /**
167 Removes all entries from address book. 168 Removes all entries from address book.
168 */ 169 */
169 void clear(); 170 void clear();
170 171
171 /** 172 /**
172 Insert an Addressee object into address book. If an object with the same 173 Insert an Addressee object into address book. If an object with the same
173 unique id already exists in the address book it it replaced by the new 174 unique id already exists in the address book it it replaced by the new
174 one. If not the new object is appended to the address book. 175 one. If not the new object is appended to the address book.
175 */ 176 */
176 void insertAddressee( const Addressee &, bool setRev = true ); 177 void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false);
177 178
178 /** 179 /**
179 Removes entry from the address book. 180 Removes entry from the address book.
180 */ 181 */
181 void removeAddressee( const Addressee & ); 182 void removeAddressee( const Addressee & );
182 183
183 /** 184 /**
184 This is like @ref removeAddressee() just above, with the difference that 185 This is like @ref removeAddressee() just above, with the difference that
185 the first element is a iterator, returned by @ref begin(). 186 the first element is a iterator, returned by @ref begin().
186 */ 187 */
187 void removeAddressee( const Iterator & ); 188 void removeAddressee( const Iterator & );
188 189
189 /** 190 /**
190 Find the specified entry in address book. Returns end(), if the entry 191 Find the specified entry in address book. Returns end(), if the entry
191 couldn't be found. 192 couldn't be found.
192 */ 193 */
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 83fede4..6404410 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1670,35 +1670,35 @@ void KABCore::initGUI()
1670 QVBox *viewSpace = new QVBox( this ); 1670 QVBox *viewSpace = new QVBox( this );
1671 1671
1672 mViewManager = new ViewManager( this, viewSpace ); 1672 mViewManager = new ViewManager( this, viewSpace );
1673 viewSpace->setStretchFactor( mViewManager, 1 ); 1673 viewSpace->setStretchFactor( mViewManager, 1 );
1674 1674
1675 mDetails = new ViewContainer( this ); 1675 mDetails = new ViewContainer( this );
1676 1676
1677 topLayout->addWidget( viewSpace ); 1677 topLayout->addWidget( viewSpace );
1678// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1678// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1679 topLayout->addWidget( mDetails ); 1679 topLayout->addWidget( mDetails );
1680#endif //KAB_NOSPLITTER 1680#endif //KAB_NOSPLITTER
1681*/ 1681*/
1682 1682
1683 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1683 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1684 syncManager->setBlockSave(false); 1684 syncManager->setBlockSave(false);
1685 1685
1686 connect(syncManager , SIGNAL( save() ), this, SLOT( save() ) ); 1686 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1687 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1687 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1688 syncManager->setDefaultFileName(locateLocal( "apps","kabc/std.vcf") ); 1688 syncManager->setDefaultFileName( sentSyncFile());
1689 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1689 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1690 1690
1691#endif //KAB_EMBEDDED 1691#endif //KAB_EMBEDDED
1692 initActions(); 1692 initActions();
1693 1693
1694#ifdef KAB_EMBEDDED 1694#ifdef KAB_EMBEDDED
1695 addActionsManually(); 1695 addActionsManually();
1696 //US make sure the export and import menues are initialized before creating the xxPortManager. 1696 //US make sure the export and import menues are initialized before creating the xxPortManager.
1697 mXXPortManager = new XXPortManager( this, this ); 1697 mXXPortManager = new XXPortManager( this, this );
1698 1698
1699 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1699 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1700 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1700 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1701 // mActionQuit->plug ( mMainWindow->toolBar()); 1701 // mActionQuit->plug ( mMainWindow->toolBar());
1702 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1702 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1703 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1703 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1704 // mIncSearchWidget->hide(); 1704 // mIncSearchWidget->hide();
@@ -2849,23 +2849,33 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2849 } 2849 }
2850 } 2850 }
2851 setModified(); 2851 setModified();
2852 } 2852 }
2853 if ( syncOK ) 2853 if ( syncOK )
2854 mViewManager->refreshView(); 2854 mViewManager->refreshView();
2855 return syncOK; 2855 return syncOK;
2856 2856
2857} 2857}
2858 2858
2859void KABCore::getFile( bool success ) 2859void KABCore::getFile( bool success )
2860{ 2860{
2861 if ( ! success ) { 2861 if ( ! success ) {
2862 setCaption( i18n("Error receiving file. Nothing changed!") ); 2862 setCaption( i18n("Error receiving file. Nothing changed!") );
2863 return; 2863 return;
2864 } 2864 }
2865 //mView->watchSavedFile(); 2865 mAddressBook->importFromFile( sentSyncFile() );
2866 //mView->openCalendar( defaultFileName() );
2867 // pending: reload received file!
2868 setCaption( i18n("Pi-Sync successful!") ); 2866 setCaption( i18n("Pi-Sync successful!") );
2869} 2867}
2868void KABCore::syncFileRequest()
2869{
2870 mAddressBook->export2File( sentSyncFile() );
2871}
2872QString KABCore::sentSyncFile()
2873{
2874#ifdef _WIN32_
2875 return locateLocal( "tmp", "syncab.ics" );
2876#else
2877 return QString( "/tmp/kapitempfile.vcf" );
2878#endif
2879}
2870 2880
2871 2881
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 355e828..987369d 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -330,32 +330,33 @@ class KABCore : public QWidget, public KSyncInterface
330 330
331 /** 331 /**
332 Registers a new GUI client, so plugins can register its actions. 332 Registers a new GUI client, so plugins can register its actions.
333 */ 333 */
334 void addGUIClient( KXMLGUIClient *client ); 334 void addGUIClient( KXMLGUIClient *client );
335 335
336 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); 336 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
337 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 337 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
338 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); 338 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid);
339 339
340 340
341 signals: 341 signals:
342 void contactSelected( const QString &name ); 342 void contactSelected( const QString &name );
343 void contactSelected( const QPixmap &pixmap ); 343 void contactSelected( const QPixmap &pixmap );
344 public slots: 344 public slots:
345 void getFile( bool success ); 345 void getFile( bool success );
346 void syncFileRequest();
346 void setDetailsVisible( bool visible ); 347 void setDetailsVisible( bool visible );
347 void setDetailsToState(); 348 void setDetailsToState();
348 // void slotSyncMenu( int ); 349 // void slotSyncMenu( int );
349 private slots: 350 private slots:
350 void setJumpButtonBarVisible( bool visible ); 351 void setJumpButtonBarVisible( bool visible );
351 void importFromOL(); 352 void importFromOL();
352 void extensionModified( const KABC::Addressee::List &list ); 353 void extensionModified( const KABC::Addressee::List &list );
353 void extensionChanged( int id ); 354 void extensionChanged( int id );
354 void clipboardDataChanged(); 355 void clipboardDataChanged();
355 void updateActionMenu(); 356 void updateActionMenu();
356 void configureKeyBindings(); 357 void configureKeyBindings();
357 void removeVoice(); 358 void removeVoice();
358#ifdef KAB_EMBEDDED 359#ifdef KAB_EMBEDDED
359 void configureResources(); 360 void configureResources();
360#endif //KAB_EMBEDDED 361#endif //KAB_EMBEDDED
361 362
@@ -452,28 +453,29 @@ class KABCore : public QWidget, public KSyncInterface
452 453
453 class KABCorePrivate; 454 class KABCorePrivate;
454 KABCorePrivate *d; 455 KABCorePrivate *d;
455 //US bool mBlockSaveFlag; 456 //US bool mBlockSaveFlag;
456 457
457#ifdef KAB_EMBEDDED 458#ifdef KAB_EMBEDDED
458 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 459 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
459#endif //KAB_EMBEDDED 460#endif //KAB_EMBEDDED
460 461
461 //this are the overwritten callbackmethods from the syncinterface 462 //this are the overwritten callbackmethods from the syncinterface
462 virtual bool sync(KSyncManager* manager, QString filename, int mode); 463 virtual bool sync(KSyncManager* manager, QString filename, int mode);
463 virtual bool syncExternal(KSyncManager* manager, QString resource); 464 virtual bool syncExternal(KSyncManager* manager, QString resource);
464 465
465 466
466 // LR ******************************* 467 // LR *******************************
467 // sync stuff! 468 // sync stuff!
469 QString sentSyncFile();
468 QPopupMenu *syncMenu; 470 QPopupMenu *syncMenu;
469 KSyncManager* syncManager; 471 KSyncManager* syncManager;
470 int mGlobalSyncMode; 472 int mGlobalSyncMode;
471 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 473 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
472 KABC::Addressee getLastSyncAddressee(); 474 KABC::Addressee getLastSyncAddressee();
473 QDateTime mLastAddressbookSync; 475 QDateTime mLastAddressbookSync;
474 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); 476 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
475 // ********************* 477 // *********************
476 478
477}; 479};
478 480
479#endif 481#endif
diff --git a/kaddressbook/xxport/vcard_xxport.cpp b/kaddressbook/xxport/vcard_xxport.cpp
index acf6419..3079d42 100644
--- a/kaddressbook/xxport/vcard_xxport.cpp
+++ b/kaddressbook/xxport/vcard_xxport.cpp
@@ -108,32 +108,33 @@ bool VCardXXPort::exportContacts( const KABC::AddresseeList &list, const QString
108 } 108 }
109 109
110 QTextStream t( &outFile ); 110 QTextStream t( &outFile );
111 t.setEncoding( QTextStream::UnicodeUTF8 ); 111 t.setEncoding( QTextStream::UnicodeUTF8 );
112 112
113 KABC::Addressee::List::ConstIterator it; 113 KABC::Addressee::List::ConstIterator it;
114 for ( it = list.begin(); it != list.end(); ++it ) { 114 for ( it = list.begin(); it != list.end(); ++it ) {
115 KABC::VCardConverter converter; 115 KABC::VCardConverter converter;
116 QString vcard; 116 QString vcard;
117 117
118 KABC::VCardConverter::Version version; 118 KABC::VCardConverter::Version version;
119 if ( data == "v21" ) 119 if ( data == "v21" )
120 version = KABC::VCardConverter::v2_1; 120 version = KABC::VCardConverter::v2_1;
121 else 121 else
122 version = KABC::VCardConverter::v3_0; 122 version = KABC::VCardConverter::v3_0;
123 123
124 version = KABC::VCardConverter::v2_1;
124 converter.addresseeToVCard( *it, vcard, version ); 125 converter.addresseeToVCard( *it, vcard, version );
125 t << vcard << "\r\n\r\n"; 126 t << vcard << "\r\n\r\n";
126 } 127 }
127 128
128 outFile.close(); 129 outFile.close();
129 130
130 return true; 131 return true;
131} 132}
132 133
133KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const 134KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const
134{ 135{
135 QString fileName; 136 QString fileName;
136 KABC::AddresseeList addrList; 137 KABC::AddresseeList addrList;
137 KURL url; 138 KURL url;
138 139
139#ifndef KAB_EMBEDDED 140#ifndef KAB_EMBEDDED
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 5d48884..ea543dd 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -262,33 +262,34 @@ void KSyncManager::enableQuick()
262 bool ok; 262 bool ok;
263 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 263 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
264 if ( ! ok ) { 264 if ( ! ok ) {
265 KMessageBox::information( 0, i18n("No valid port")); 265 KMessageBox::information( 0, i18n("No valid port"));
266 return; 266 return;
267 } 267 }
268 //qDebug("port %d ", port); 268 //qDebug("port %d ", port);
269 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 269 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
270 mServerSocket->setFileName( defaultFileName() ); 270 mServerSocket->setFileName( defaultFileName() );
271 //qDebug("connected "); 271 //qDebug("connected ");
272 if ( !mServerSocket->ok() ) { 272 if ( !mServerSocket->ok() ) {
273 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 273 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
274 delete mServerSocket; 274 delete mServerSocket;
275 mServerSocket = 0; 275 mServerSocket = 0;
276 return; 276 return;
277 } 277 }
278 connect( mServerSocket, SIGNAL ( saveFile() ),this, SIGNAL ( save() ) ); 278 //connect( mServerSocket, SIGNAL ( saveFile() ),this, SIGNAL ( save() ) );
279 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
279 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 280 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
280} 281}
281 282
282void KSyncManager::syncLocalFile() 283void KSyncManager::syncLocalFile()
283{ 284{
284 285
285 QString fn =mLastSyncedLocalFile; 286 QString fn =mLastSyncedLocalFile;
286 QString ext; 287 QString ext;
287 288
288 switch(mTargetApp) 289 switch(mTargetApp)
289 { 290 {
290 case (KAPI): 291 case (KAPI):
291 ext = "(*.vcf)"; 292 ext = "(*.vcf)";
292 break; 293 break;
293 case (KOPI): 294 case (KOPI):
294 ext = "(*.ics/*.vcs)"; 295 ext = "(*.ics/*.vcs)";
@@ -915,33 +916,33 @@ void KServerSocket::end_connect()
915} 916}
916void KServerSocket::send_file() 917void KServerSocket::send_file()
917{ 918{
918 //qDebug("MainWindow::sendFile(QSocket* s) "); 919 //qDebug("MainWindow::sendFile(QSocket* s) ");
919 if ( mSyncActionDialog ) 920 if ( mSyncActionDialog )
920 delete mSyncActionDialog; 921 delete mSyncActionDialog;
921 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 922 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
922 mSyncActionDialog->setCaption(i18n("Received sync request")); 923 mSyncActionDialog->setCaption(i18n("Received sync request"));
923 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 924 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
924 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 925 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
925 lay->addWidget( label); 926 lay->addWidget( label);
926 lay->setMargin(7); 927 lay->setMargin(7);
927 lay->setSpacing(7); 928 lay->setSpacing(7);
928 mSyncActionDialog->setFixedSize( 230, 120); 929 mSyncActionDialog->setFixedSize( 230, 120);
929 mSyncActionDialog->show(); 930 mSyncActionDialog->show();
930 qDebug("KSS::saving ... "); 931 qDebug("KSS::saving ... ");
931 emit saveFile(); 932 emit request_file();
932 qApp->processEvents(); 933 qApp->processEvents();
933 QString fileName = mFileName; 934 QString fileName = mFileName;
934 QFile file( fileName ); 935 QFile file( fileName );
935 if (!file.open( IO_ReadOnly ) ) { 936 if (!file.open( IO_ReadOnly ) ) {
936 delete mSyncActionDialog; 937 delete mSyncActionDialog;
937 mSyncActionDialog = 0; 938 mSyncActionDialog = 0;
938 qDebug("KSS::error open file "); 939 qDebug("KSS::error open file ");
939 mSocket->close(); 940 mSocket->close();
940 if ( mSocket->state() == QSocket::Idle ) 941 if ( mSocket->state() == QSocket::Idle )
941 QTimer::singleShot( 10, this , SLOT ( discardClient())); 942 QTimer::singleShot( 10, this , SLOT ( discardClient()));
942 return ; 943 return ;
943 944
944 } 945 }
945 mSyncActionDialog->setCaption( i18n("Sending file...") ); 946 mSyncActionDialog->setCaption( i18n("Sending file...") );
946 QTextStream ts( &file ); 947 QTextStream ts( &file );
947 ts.setCodec( QTextCodec::codecForName("utf8") ); 948 ts.setCodec( QTextCodec::codecForName("utf8") );
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 52e2772..0eb3323 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -37,36 +37,34 @@ class QWidget;
37class KSyncManager; 37class KSyncManager;
38class KSyncInterface; 38class KSyncInterface;
39class QProgressBar; 39class QProgressBar;
40 40
41 41
42class KServerSocket : public QServerSocket 42class KServerSocket : public QServerSocket
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45 45
46public: 46public:
47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); 47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
48 48
49 void newConnection ( int socket ) ; 49 void newConnection ( int socket ) ;
50 void setFileName( QString fn ) {mFileName = fn;}; 50 void setFileName( QString fn ) {mFileName = fn;};
51 51
52signals: 52signals:
53 //void sendFile(QSocket*);
54 //void getFile(QSocket*);
55 void file_received( bool ); 53 void file_received( bool );
56 //void file_sent(); 54 void request_file();
57 void saveFile(); 55 void saveFile();
58 void endConnect(); 56 void endConnect();
59private slots: 57private slots:
60 void discardClient(); 58 void discardClient();
61 void readClient(); 59 void readClient();
62 void readBackFileFromSocket(); 60 void readBackFileFromSocket();
63 private : 61 private :
64 bool blockRC; 62 bool blockRC;
65 void send_file(); 63 void send_file();
66 void get_file(); 64 void get_file();
67 void end_connect(); 65 void end_connect();
68 QDialog* mSyncActionDialog; 66 QDialog* mSyncActionDialog;
69 QSocket* mSocket; 67 QSocket* mSocket;
70 QString mPassWord; 68 QString mPassWord;
71 QString mFileName; 69 QString mFileName;
72 QTime piTime; 70 QTime piTime;
@@ -143,32 +141,33 @@ class KSyncManager : public QObject
143 bool mShowTodoInAgenda; 141 bool mShowTodoInAgenda;
144 bool mWriteBackExistingOnly; 142 bool mWriteBackExistingOnly;
145 int mSyncAlgoPrefs; 143 int mSyncAlgoPrefs;
146 int mRingSyncAlgoPrefs; 144 int mRingSyncAlgoPrefs;
147 bool mWriteBackFile; 145 bool mWriteBackFile;
148 int mWriteBackInFuture; 146 int mWriteBackInFuture;
149 QString mPhoneDevice; 147 QString mPhoneDevice;
150 QString mPhoneConnection; 148 QString mPhoneConnection;
151 QString mPhoneModel; 149 QString mPhoneModel;
152 QString mLastSyncedLocalFile; // save! 150 QString mLastSyncedLocalFile; // save!
153 QString mPassWordPiSync; 151 QString mPassWordPiSync;
154 QString mActiveSyncPort; 152 QString mActiveSyncPort;
155 QString mActiveSyncIP ; 153 QString mActiveSyncIP ;
156 154
157 signals: 155 signals:
158 void save(); 156 void save();
157 void request_file();
159 void getFile( bool ); 158 void getFile( bool );
160 159
161 public slots: 160 public slots:
162 void slotSyncMenu( int ); 161 void slotSyncMenu( int );
163 162
164 private: 163 private:
165 // LR ******************************* 164 // LR *******************************
166 // sync stuff! 165 // sync stuff!
167 void syncPi(); 166 void syncPi();
168 void deleteCommandSocket(KCommandSocket*s, int state); 167 void deleteCommandSocket(KCommandSocket*s, int state);
169 void readFileFromSocket(); 168 void readFileFromSocket();
170 KServerSocket * mServerSocket; 169 KServerSocket * mServerSocket;
171 void enableQuick(); 170 void enableQuick();
172 KPimPrefs* mPrefs; 171 KPimPrefs* mPrefs;
173 QString mDefFileName; 172 QString mDefFileName;
174 QString mCurrentSyncDevice; 173 QString mCurrentSyncDevice;