-rw-r--r-- | kabc/addressbook.cpp | 70 | ||||
-rw-r--r-- | kabc/addressbook.h | 5 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 20 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 2 | ||||
-rw-r--r-- | kaddressbook/xxport/vcard_xxport.cpp | 1 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 5 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 5 |
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 | |||
@@ -17,55 +17,60 @@ | |||
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
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 | ||
51 | using namespace KABC; | 56 | using namespace KABC; |
52 | 57 | ||
53 | struct AddressBook::AddressBookData | 58 | struct 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 | ||
63 | struct AddressBook::Iterator::IteratorData | 68 | struct AddressBook::Iterator::IteratorData |
64 | { | 69 | { |
65 | Addressee::List::Iterator mIt; | 70 | Addressee::List::Iterator mIt; |
66 | }; | 71 | }; |
67 | 72 | ||
68 | struct AddressBook::ConstIterator::ConstIteratorData | 73 | struct AddressBook::ConstIterator::ConstIteratorData |
69 | { | 74 | { |
70 | Addressee::List::ConstIterator mIt; | 75 | Addressee::List::ConstIterator mIt; |
71 | }; | 76 | }; |
@@ -349,48 +354,96 @@ bool AddressBook::load() | |||
349 | Addressee::List::Iterator addrIt; | 354 | Addressee::List::Iterator addrIt; |
350 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { | 355 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { |
351 | (*addrIt).setChanged( false ); | 356 | (*addrIt).setChanged( false ); |
352 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); | 357 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); |
353 | if ( !id.isEmpty() ) { | 358 | if ( !id.isEmpty() ) { |
354 | //qDebug("setId aa %s ", id.latin1()); | 359 | //qDebug("setId aa %s ", id.latin1()); |
355 | (*addrIt).setIDStr(id ); | 360 | (*addrIt).setIDStr(id ); |
356 | } | 361 | } |
357 | } | 362 | } |
358 | blockLSEchange = true; | 363 | blockLSEchange = true; |
359 | return ok; | 364 | return ok; |
360 | } | 365 | } |
361 | 366 | ||
362 | bool AddressBook::save( Ticket *ticket ) | 367 | bool 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 | } |
378 | void 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 | } | ||
404 | void 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 | |||
373 | bool AddressBook::saveAB() | 426 | bool 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 ); |
389 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 442 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
390 | if ( !ticket ) { | 443 | if ( !ticket ) { |
391 | error( i18n( "Unable to save to resource '%1'. It is locked." ) | 444 | error( i18n( "Unable to save to resource '%1'. It is locked." ) |
392 | .arg( (*it)->resourceName() ) ); | 445 | .arg( (*it)->resourceName() ) ); |
393 | return false; | 446 | return false; |
394 | } | 447 | } |
395 | 448 | ||
396 | //if ( !save( ticket ) ) | 449 | //if ( !save( ticket ) ) |
@@ -440,69 +493,74 @@ void AddressBook::clear() | |||
440 | 493 | ||
441 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 494 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) |
442 | { | 495 | { |
443 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; | 496 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; |
444 | 497 | ||
445 | if ( !resource ) | 498 | if ( !resource ) |
446 | { | 499 | { |
447 | qDebug("AddressBook::requestSaveTicket no resource" ); | 500 | qDebug("AddressBook::requestSaveTicket no 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 | ||
464 | void AddressBook::insertAddressee( const Addressee &a, bool setRev ) | 517 | void 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 ); |
501 | Addressee b = a; | 559 | Addressee b = a; |
502 | QString id = b.getID( name ); | 560 | QString id = b.getID( name ); |
503 | if ( ! id.isEmpty() ) { | 561 | if ( ! id.isEmpty() ) { |
504 | QString des = (*it).note(); | 562 | QString des = (*it).note(); |
505 | int startN; | 563 | int startN; |
506 | if( (startN = des.find( id ) ) >= 0 ) { | 564 | if( (startN = des.find( id ) ) >= 0 ) { |
507 | int endN = des.find( ",", startN+1 ); | 565 | int endN = des.find( ",", startN+1 ); |
508 | des = des.left( startN ) + des.mid( endN+1 ); | 566 | des = des.left( startN ) + des.mid( endN+1 ); |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 8f62f0d..3603ec1 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -121,80 +121,81 @@ class AddressBook : public QObject | |||
121 | 121 | ||
122 | /** | 122 | /** |
123 | Requests a ticket for saving the addressbook. Calling this function locks | 123 | Requests a ticket for saving the addressbook. Calling this function locks |
124 | the addressbook for all other processes. If the address book is already | 124 | the addressbook for all other processes. If the address book is already |
125 | locked the function returns 0. You need the returned @ref Ticket object | 125 | locked the function returns 0. You need the returned @ref Ticket object |
126 | for calling the @ref save() function. | 126 | for calling the @ref save() function. |
127 | 127 | ||
128 | @see save() | 128 | @see save() |
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 | */ |
193 | Iterator find( const Addressee & ); | 194 | Iterator find( const Addressee & ); |
194 | 195 | ||
195 | /** | 196 | /** |
196 | Find the entry specified by an unique id. Returns an empty Addressee | 197 | Find the entry specified by an unique id. Returns an empty Addressee |
197 | object, if the address book does not contain an entry with this id. | 198 | object, if the address book does not contain an entry with this id. |
198 | */ | 199 | */ |
199 | Addressee findByUid( const QString & ); | 200 | Addressee findByUid( const QString & ); |
200 | 201 | ||
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 83fede4..6404410 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1662,51 +1662,51 @@ void KABCore::initGUI() | |||
1662 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1662 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1663 | #else //KAB_NOSPLITTER | 1663 | #else //KAB_NOSPLITTER |
1664 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1664 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1665 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1665 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1666 | topLayout->setSpacing( 10 ); | 1666 | topLayout->setSpacing( 10 ); |
1667 | 1667 | ||
1668 | // mDetailsSplitter = new QSplitter( this ); | 1668 | // mDetailsSplitter = new QSplitter( this ); |
1669 | 1669 | ||
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(); |
1705 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1705 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1706 | SLOT( incrementalSearch( const QString& ) ) ); | 1706 | SLOT( incrementalSearch( const QString& ) ) ); |
1707 | 1707 | ||
1708 | 1708 | ||
1709 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1709 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1710 | 1710 | ||
1711 | topLayout->addWidget( mJumpButtonBar ); | 1711 | topLayout->addWidget( mJumpButtonBar ); |
1712 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1712 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
@@ -2841,31 +2841,41 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource) | |||
2841 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2841 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2842 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2842 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2843 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2843 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2844 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2844 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2845 | if ( syncOK ) { | 2845 | if ( syncOK ) { |
2846 | if ( syncManager->mWriteBackFile ) { | 2846 | if ( syncManager->mWriteBackFile ) { |
2847 | abLocal.saveAB(); | 2847 | abLocal.saveAB(); |
2848 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2848 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
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 | ||
2859 | void KABCore::getFile( bool success ) | 2859 | void 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 | } |
2868 | void KABCore::syncFileRequest() | ||
2869 | { | ||
2870 | mAddressBook->export2File( sentSyncFile() ); | ||
2871 | } | ||
2872 | QString 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 | |||
@@ -322,48 +322,49 @@ class KABCore : public QWidget, public KSyncInterface | |||
322 | */ | 322 | */ |
323 | void openLDAPDialog(); | 323 | void openLDAPDialog(); |
324 | 324 | ||
325 | /** | 325 | /** |
326 | Creates a KAddressBookPrinter, which will display the print | 326 | Creates a KAddressBookPrinter, which will display the print |
327 | dialog and do the printing. | 327 | dialog and do the printing. |
328 | */ | 328 | */ |
329 | void print(); | 329 | void print(); |
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 | ||
362 | void slotEditorDestroyed( const QString &uid ); | 363 | void slotEditorDestroyed( const QString &uid ); |
363 | void configurationChanged(); | 364 | void configurationChanged(); |
364 | void addressBookChanged(); | 365 | void addressBookChanged(); |
365 | 366 | ||
366 | private: | 367 | private: |
367 | void initGUI(); | 368 | void initGUI(); |
368 | void initActions(); | 369 | void initActions(); |
369 | 370 | ||
@@ -444,36 +445,37 @@ class KABCore : public QWidget, public KSyncInterface | |||
444 | QPopupMenu *ExportMenu; | 445 | QPopupMenu *ExportMenu; |
445 | //LR additional methods | 446 | //LR additional methods |
446 | KAction *mActionRemoveVoice; | 447 | KAction *mActionRemoveVoice; |
447 | KAction * mActionImportOL; | 448 | KAction * mActionImportOL; |
448 | 449 | ||
449 | #ifndef KAB_EMBEDDED | 450 | #ifndef KAB_EMBEDDED |
450 | KAddressBookService *mAddressBookService; | 451 | KAddressBookService *mAddressBookService; |
451 | #endif //KAB_EMBEDDED | 452 | #endif //KAB_EMBEDDED |
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 | |||
@@ -100,48 +100,49 @@ bool VCardXXPort::exportContacts( const KABC::AddresseeList &list, const QString | |||
100 | if ( fileName.isEmpty() ) | 100 | if ( fileName.isEmpty() ) |
101 | return false; | 101 | return false; |
102 | 102 | ||
103 | QFile outFile( fileName ); | 103 | QFile outFile( fileName ); |
104 | if ( !outFile.open( IO_WriteOnly ) ) { | 104 | if ( !outFile.open( IO_WriteOnly ) ) { |
105 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); | 105 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); |
106 | KMessageBox::error( parentWidget(), text.arg( fileName ) ); | 106 | KMessageBox::error( parentWidget(), text.arg( fileName ) ); |
107 | return false; | 107 | return false; |
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 | ||
133 | KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const | 134 | KABC::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 |
140 | if ( !XXPortManager::importData.isEmpty() ) | 141 | if ( !XXPortManager::importData.isEmpty() ) |
141 | addrList = parseVCard( XXPortManager::importData ); | 142 | addrList = parseVCard( XXPortManager::importData ); |
142 | else { | 143 | else { |
143 | if ( XXPortManager::importURL.isEmpty() ) | 144 | if ( XXPortManager::importURL.isEmpty() ) |
144 | { | 145 | { |
145 | url = KFileDialog::getLoadFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); | 146 | url = KFileDialog::getLoadFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); |
146 | } | 147 | } |
147 | else | 148 | else |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 5d48884..ea543dd 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -254,49 +254,50 @@ void KSyncManager::enableQuick() | |||
254 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 254 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
255 | dia.show(); | 255 | dia.show(); |
256 | if ( ! dia.exec() ) | 256 | if ( ! dia.exec() ) |
257 | return; | 257 | return; |
258 | dia.hide(); | 258 | dia.hide(); |
259 | qApp->processEvents(); | 259 | qApp->processEvents(); |
260 | mPrefs->mPassiveSyncPw = lepw.text(); | 260 | mPrefs->mPassiveSyncPw = lepw.text(); |
261 | mPrefs->mPassiveSyncPort = lab.text(); | 261 | mPrefs->mPassiveSyncPort = lab.text(); |
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 | ||
282 | void KSyncManager::syncLocalFile() | 283 | void 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)"; |
295 | break; | 296 | break; |
296 | case (PWMPI): | 297 | case (PWMPI): |
297 | ext = "(*.pwm)"; | 298 | ext = "(*.pwm)"; |
298 | break; | 299 | break; |
299 | default: | 300 | default: |
300 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); | 301 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); |
301 | break; | 302 | break; |
302 | 303 | ||
@@ -907,49 +908,49 @@ void KServerSocket::readClient() | |||
907 | end_connect(); | 908 | end_connect(); |
908 | } | 909 | } |
909 | } | 910 | } |
910 | } | 911 | } |
911 | void KServerSocket::end_connect() | 912 | void KServerSocket::end_connect() |
912 | { | 913 | { |
913 | delete mSyncActionDialog; | 914 | delete mSyncActionDialog; |
914 | mSyncActionDialog = 0; | 915 | mSyncActionDialog = 0; |
915 | } | 916 | } |
916 | void KServerSocket::send_file() | 917 | void 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") ); |
948 | QTextStream os( mSocket ); | 949 | QTextStream os( mSocket ); |
949 | os.setCodec( QTextCodec::codecForName("utf8") ); | 950 | os.setCodec( QTextCodec::codecForName("utf8") ); |
950 | //os.setEncoding( QTextStream::UnicodeUTF8 ); | 951 | //os.setEncoding( QTextStream::UnicodeUTF8 ); |
951 | while ( ! ts.atEnd() ) { | 952 | while ( ! ts.atEnd() ) { |
952 | os << ts.readLine() << "\n"; | 953 | os << ts.readLine() << "\n"; |
953 | } | 954 | } |
954 | //os << ts.read(); | 955 | //os << ts.read(); |
955 | file.close(); | 956 | file.close(); |
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 52e2772..0eb3323 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h | |||
@@ -29,52 +29,50 @@ $Id$ | |||
29 | #include <qserversocket.h> | 29 | #include <qserversocket.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | 32 | ||
33 | class QPopupMenu; | 33 | class QPopupMenu; |
34 | class KSyncProfile; | 34 | class KSyncProfile; |
35 | class KPimPrefs; | 35 | class KPimPrefs; |
36 | class QWidget; | 36 | class QWidget; |
37 | class KSyncManager; | 37 | class KSyncManager; |
38 | class KSyncInterface; | 38 | class KSyncInterface; |
39 | class QProgressBar; | 39 | class QProgressBar; |
40 | 40 | ||
41 | 41 | ||
42 | class KServerSocket : public QServerSocket | 42 | class KServerSocket : public QServerSocket |
43 | { | 43 | { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | 45 | ||
46 | public: | 46 | public: |
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 | ||
52 | signals: | 52 | signals: |
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(); |
59 | private slots: | 57 | private 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; |
73 | QString piFileString; | 71 | QString piFileString; |
74 | }; | 72 | }; |
75 | 73 | ||
76 | class KCommandSocket : public QObject | 74 | class KCommandSocket : public QObject |
77 | { | 75 | { |
78 | Q_OBJECT | 76 | Q_OBJECT |
79 | public: | 77 | public: |
80 | enum state { successR, errorR, successW, errorW, quiet }; | 78 | enum state { successR, errorR, successW, errorW, quiet }; |
@@ -135,48 +133,49 @@ class KSyncManager : public QObject | |||
135 | 133 | ||
136 | // sync stuff | 134 | // sync stuff |
137 | QString mLocalMachineName; | 135 | QString mLocalMachineName; |
138 | QStringList mExternSyncProfiles; | 136 | QStringList mExternSyncProfiles; |
139 | QStringList mSyncProfileNames; | 137 | QStringList mSyncProfileNames; |
140 | bool mAskForPreferences; | 138 | bool mAskForPreferences; |
141 | bool mShowSyncSummary; | 139 | bool mShowSyncSummary; |
142 | bool mShowSyncEvents; | 140 | bool mShowSyncEvents; |
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; |
175 | QString mCurrentSyncName; | 174 | QString mCurrentSyncName; |
176 | void quickSyncLocalFile(); | 175 | void quickSyncLocalFile(); |
177 | bool syncWithFile( QString fn , bool quick ); | 176 | bool syncWithFile( QString fn , bool quick ); |
178 | void syncLocalFile(); | 177 | void syncLocalFile(); |
179 | void syncPhone(); | 178 | void syncPhone(); |
180 | void syncSharp(); | 179 | void syncSharp(); |
181 | bool syncExternalApplication(QString); | 180 | bool syncExternalApplication(QString); |
182 | void multiSync( bool askforPrefs ); | 181 | void multiSync( bool askforPrefs ); |