-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 | |||
@@ -1,143 +1,148 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
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 | }; |
72 | 77 | ||
73 | AddressBook::Iterator::Iterator() | 78 | AddressBook::Iterator::Iterator() |
74 | { | 79 | { |
75 | d = new IteratorData; | 80 | d = new IteratorData; |
76 | } | 81 | } |
77 | 82 | ||
78 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) | 83 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) |
79 | { | 84 | { |
80 | d = new IteratorData; | 85 | d = new IteratorData; |
81 | d->mIt = i.d->mIt; | 86 | d->mIt = i.d->mIt; |
82 | } | 87 | } |
83 | 88 | ||
84 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) | 89 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) |
85 | { | 90 | { |
86 | if( this == &i ) return *this; // guard against self assignment | 91 | if( this == &i ) return *this; // guard against self assignment |
87 | delete d; // delete the old data the Iterator was completely constructed before | 92 | delete d; // delete the old data the Iterator was completely constructed before |
88 | d = new IteratorData; | 93 | d = new IteratorData; |
89 | d->mIt = i.d->mIt; | 94 | d->mIt = i.d->mIt; |
90 | return *this; | 95 | return *this; |
91 | } | 96 | } |
92 | 97 | ||
93 | AddressBook::Iterator::~Iterator() | 98 | AddressBook::Iterator::~Iterator() |
94 | { | 99 | { |
95 | delete d; | 100 | delete d; |
96 | } | 101 | } |
97 | 102 | ||
98 | const Addressee &AddressBook::Iterator::operator*() const | 103 | const Addressee &AddressBook::Iterator::operator*() const |
99 | { | 104 | { |
100 | return *(d->mIt); | 105 | return *(d->mIt); |
101 | } | 106 | } |
102 | 107 | ||
103 | Addressee &AddressBook::Iterator::operator*() | 108 | Addressee &AddressBook::Iterator::operator*() |
104 | { | 109 | { |
105 | return *(d->mIt); | 110 | return *(d->mIt); |
106 | } | 111 | } |
107 | 112 | ||
108 | Addressee *AddressBook::Iterator::operator->() | 113 | Addressee *AddressBook::Iterator::operator->() |
109 | { | 114 | { |
110 | return &(*(d->mIt)); | 115 | return &(*(d->mIt)); |
111 | } | 116 | } |
112 | 117 | ||
113 | AddressBook::Iterator &AddressBook::Iterator::operator++() | 118 | AddressBook::Iterator &AddressBook::Iterator::operator++() |
114 | { | 119 | { |
115 | (d->mIt)++; | 120 | (d->mIt)++; |
116 | return *this; | 121 | return *this; |
117 | } | 122 | } |
118 | 123 | ||
119 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) | 124 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) |
120 | { | 125 | { |
121 | (d->mIt)++; | 126 | (d->mIt)++; |
122 | return *this; | 127 | return *this; |
123 | } | 128 | } |
124 | 129 | ||
125 | AddressBook::Iterator &AddressBook::Iterator::operator--() | 130 | AddressBook::Iterator &AddressBook::Iterator::operator--() |
126 | { | 131 | { |
127 | (d->mIt)--; | 132 | (d->mIt)--; |
128 | return *this; | 133 | return *this; |
129 | } | 134 | } |
130 | 135 | ||
131 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) | 136 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) |
132 | { | 137 | { |
133 | (d->mIt)--; | 138 | (d->mIt)--; |
134 | return *this; | 139 | return *this; |
135 | } | 140 | } |
136 | 141 | ||
137 | bool AddressBook::Iterator::operator==( const Iterator &it ) | 142 | bool AddressBook::Iterator::operator==( const Iterator &it ) |
138 | { | 143 | { |
139 | return ( d->mIt == it.d->mIt ); | 144 | return ( d->mIt == it.d->mIt ); |
140 | } | 145 | } |
141 | 146 | ||
142 | bool AddressBook::Iterator::operator!=( const Iterator &it ) | 147 | bool AddressBook::Iterator::operator!=( const Iterator &it ) |
143 | { | 148 | { |
@@ -277,304 +282,357 @@ void AddressBook::init(const QString &config, const QString &family ) | |||
277 | KRES::Manager<Resource>::ActiveIterator it; | 282 | KRES::Manager<Resource>::ActiveIterator it; |
278 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 283 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
279 | (*it)->setAddressBook( this ); | 284 | (*it)->setAddressBook( this ); |
280 | if ( !(*it)->open() ) | 285 | if ( !(*it)->open() ) |
281 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 286 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
282 | } | 287 | } |
283 | Resource *res = standardResource(); | 288 | Resource *res = standardResource(); |
284 | if ( !res ) { | 289 | if ( !res ) { |
285 | qDebug("ERROR: no standard resource"); | 290 | qDebug("ERROR: no standard resource"); |
286 | res = manager->createResource( "file" ); | 291 | res = manager->createResource( "file" ); |
287 | if ( res ) | 292 | if ( res ) |
288 | { | 293 | { |
289 | addResource( res ); | 294 | addResource( res ); |
290 | } | 295 | } |
291 | else | 296 | else |
292 | qDebug(" No resource available!!!"); | 297 | qDebug(" No resource available!!!"); |
293 | } | 298 | } |
294 | setStandardResource( res ); | 299 | setStandardResource( res ); |
295 | manager->writeConfig(); | 300 | manager->writeConfig(); |
296 | } | 301 | } |
297 | addCustomField( i18n( "Department" ), KABC::Field::Organization, | 302 | addCustomField( i18n( "Department" ), KABC::Field::Organization, |
298 | "X-Department", "KADDRESSBOOK" ); | 303 | "X-Department", "KADDRESSBOOK" ); |
299 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 304 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
300 | "X-Profession", "KADDRESSBOOK" ); | 305 | "X-Profession", "KADDRESSBOOK" ); |
301 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 306 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
302 | "X-AssistantsName", "KADDRESSBOOK" ); | 307 | "X-AssistantsName", "KADDRESSBOOK" ); |
303 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 308 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
304 | "X-ManagersName", "KADDRESSBOOK" ); | 309 | "X-ManagersName", "KADDRESSBOOK" ); |
305 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 310 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
306 | "X-SpousesName", "KADDRESSBOOK" ); | 311 | "X-SpousesName", "KADDRESSBOOK" ); |
307 | addCustomField( i18n( "Office" ), KABC::Field::Personal, | 312 | addCustomField( i18n( "Office" ), KABC::Field::Personal, |
308 | "X-Office", "KADDRESSBOOK" ); | 313 | "X-Office", "KADDRESSBOOK" ); |
309 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 314 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
310 | "X-IMAddress", "KADDRESSBOOK" ); | 315 | "X-IMAddress", "KADDRESSBOOK" ); |
311 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 316 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
312 | "X-Anniversary", "KADDRESSBOOK" ); | 317 | "X-Anniversary", "KADDRESSBOOK" ); |
313 | 318 | ||
314 | //US added this field to become compatible with Opie/qtopia addressbook | 319 | //US added this field to become compatible with Opie/qtopia addressbook |
315 | // values can be "female" or "male" or "". An empty field represents undefined. | 320 | // values can be "female" or "male" or "". An empty field represents undefined. |
316 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 321 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
317 | "X-Gender", "KADDRESSBOOK" ); | 322 | "X-Gender", "KADDRESSBOOK" ); |
318 | addCustomField( i18n( "Children" ), KABC::Field::Personal, | 323 | addCustomField( i18n( "Children" ), KABC::Field::Personal, |
319 | "X-Children", "KADDRESSBOOK" ); | 324 | "X-Children", "KADDRESSBOOK" ); |
320 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 325 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
321 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 326 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
322 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, | 327 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, |
323 | "X-ExternalID", "KADDRESSBOOK" ); | 328 | "X-ExternalID", "KADDRESSBOOK" ); |
324 | } | 329 | } |
325 | 330 | ||
326 | AddressBook::~AddressBook() | 331 | AddressBook::~AddressBook() |
327 | { | 332 | { |
328 | delete d->mConfig; d->mConfig = 0; | 333 | delete d->mConfig; d->mConfig = 0; |
329 | delete d->mManager; d->mManager = 0; | 334 | delete d->mManager; d->mManager = 0; |
330 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 335 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
331 | delete d; d = 0; | 336 | delete d; d = 0; |
332 | } | 337 | } |
333 | 338 | ||
334 | bool AddressBook::load() | 339 | bool AddressBook::load() |
335 | { | 340 | { |
336 | 341 | ||
337 | 342 | ||
338 | clear(); | 343 | clear(); |
339 | 344 | ||
340 | KRES::Manager<Resource>::ActiveIterator it; | 345 | KRES::Manager<Resource>::ActiveIterator it; |
341 | bool ok = true; | 346 | bool ok = true; |
342 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 347 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
343 | if ( !(*it)->load() ) { | 348 | if ( !(*it)->load() ) { |
344 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 349 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
345 | ok = false; | 350 | ok = false; |
346 | } | 351 | } |
347 | 352 | ||
348 | // mark all addressees as unchanged | 353 | // mark all addressees as unchanged |
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 ) ) |
397 | if ( ticket->resource() ) { | 450 | if ( ticket->resource() ) { |
398 | if ( ! ticket->resource()->save( ticket ) ) | 451 | if ( ! ticket->resource()->save( ticket ) ) |
399 | ok = false; | 452 | ok = false; |
400 | } else | 453 | } else |
401 | ok = false; | 454 | ok = false; |
402 | 455 | ||
403 | } | 456 | } |
404 | } | 457 | } |
405 | return ok; | 458 | return ok; |
406 | } | 459 | } |
407 | 460 | ||
408 | AddressBook::Iterator AddressBook::begin() | 461 | AddressBook::Iterator AddressBook::begin() |
409 | { | 462 | { |
410 | Iterator it = Iterator(); | 463 | Iterator it = Iterator(); |
411 | it.d->mIt = d->mAddressees.begin(); | 464 | it.d->mIt = d->mAddressees.begin(); |
412 | return it; | 465 | return it; |
413 | } | 466 | } |
414 | 467 | ||
415 | AddressBook::ConstIterator AddressBook::begin() const | 468 | AddressBook::ConstIterator AddressBook::begin() const |
416 | { | 469 | { |
417 | ConstIterator it = ConstIterator(); | 470 | ConstIterator it = ConstIterator(); |
418 | it.d->mIt = d->mAddressees.begin(); | 471 | it.d->mIt = d->mAddressees.begin(); |
419 | return it; | 472 | return it; |
420 | } | 473 | } |
421 | 474 | ||
422 | AddressBook::Iterator AddressBook::end() | 475 | AddressBook::Iterator AddressBook::end() |
423 | { | 476 | { |
424 | Iterator it = Iterator(); | 477 | Iterator it = Iterator(); |
425 | it.d->mIt = d->mAddressees.end(); | 478 | it.d->mIt = d->mAddressees.end(); |
426 | return it; | 479 | return it; |
427 | } | 480 | } |
428 | 481 | ||
429 | AddressBook::ConstIterator AddressBook::end() const | 482 | AddressBook::ConstIterator AddressBook::end() const |
430 | { | 483 | { |
431 | ConstIterator it = ConstIterator(); | 484 | ConstIterator it = ConstIterator(); |
432 | it.d->mIt = d->mAddressees.end(); | 485 | it.d->mIt = d->mAddressees.end(); |
433 | return it; | 486 | return it; |
434 | } | 487 | } |
435 | 488 | ||
436 | void AddressBook::clear() | 489 | void AddressBook::clear() |
437 | { | 490 | { |
438 | d->mAddressees.clear(); | 491 | d->mAddressees.clear(); |
439 | } | 492 | } |
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 ); |
509 | (*it).setNote( des ); | 567 | (*it).setNote( des ); |
510 | } | 568 | } |
511 | } | 569 | } |
512 | } | 570 | } |
513 | } | 571 | } |
514 | } | 572 | } |
515 | if ( found ) | 573 | if ( found ) |
516 | return; | 574 | return; |
517 | d->mAddressees.append( a ); | 575 | d->mAddressees.append( a ); |
518 | Addressee& addr = d->mAddressees.last(); | 576 | Addressee& addr = d->mAddressees.last(); |
519 | if ( addr.resource() == 0 ) | 577 | if ( addr.resource() == 0 ) |
520 | addr.setResource( standardResource() ); | 578 | addr.setResource( standardResource() ); |
521 | 579 | ||
522 | addr.setChanged( true ); | 580 | addr.setChanged( true ); |
523 | } | 581 | } |
524 | 582 | ||
525 | void AddressBook::removeAddressee( const Addressee &a ) | 583 | void AddressBook::removeAddressee( const Addressee &a ) |
526 | { | 584 | { |
527 | Iterator it; | 585 | Iterator it; |
528 | Iterator it2; | 586 | Iterator it2; |
529 | bool found = false; | 587 | bool found = false; |
530 | for ( it = begin(); it != end(); ++it ) { | 588 | for ( it = begin(); it != end(); ++it ) { |
531 | if ( a.uid() == (*it).uid() ) { | 589 | if ( a.uid() == (*it).uid() ) { |
532 | found = true; | 590 | found = true; |
533 | it2 = it; | 591 | it2 = it; |
534 | } else { | 592 | } else { |
535 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 593 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
536 | QString name = (*it).uid().mid( 19 ); | 594 | QString name = (*it).uid().mid( 19 ); |
537 | Addressee b = a; | 595 | Addressee b = a; |
538 | QString id = b.getID( name ); | 596 | QString id = b.getID( name ); |
539 | if ( ! id.isEmpty() ) { | 597 | if ( ! id.isEmpty() ) { |
540 | QString des = (*it).note(); | 598 | QString des = (*it).note(); |
541 | if( des.find( id ) < 0 ) { | 599 | if( des.find( id ) < 0 ) { |
542 | des += id + ","; | 600 | des += id + ","; |
543 | (*it).setNote( des ); | 601 | (*it).setNote( des ); |
544 | } | 602 | } |
545 | } | 603 | } |
546 | } | 604 | } |
547 | 605 | ||
548 | } | 606 | } |
549 | } | 607 | } |
550 | 608 | ||
551 | if ( found ) | 609 | if ( found ) |
552 | removeAddressee( it2 ); | 610 | removeAddressee( it2 ); |
553 | 611 | ||
554 | } | 612 | } |
555 | 613 | ||
556 | void AddressBook::removeSyncAddressees( bool removeDeleted ) | 614 | void AddressBook::removeSyncAddressees( bool removeDeleted ) |
557 | { | 615 | { |
558 | Iterator it = begin(); | 616 | Iterator it = begin(); |
559 | Iterator it2 ; | 617 | Iterator it2 ; |
560 | QDateTime dt ( QDate( 2004,1,1) ); | 618 | QDateTime dt ( QDate( 2004,1,1) ); |
561 | while ( it != end() ) { | 619 | while ( it != end() ) { |
562 | (*it).setRevision( dt ); | 620 | (*it).setRevision( dt ); |
563 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 621 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
564 | (*it).setIDStr(""); | 622 | (*it).setIDStr(""); |
565 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { | 623 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { |
566 | it2 = it; | 624 | it2 = it; |
567 | //qDebug("removing %s ",(*it).uid().latin1() ); | 625 | //qDebug("removing %s ",(*it).uid().latin1() ); |
568 | ++it; | 626 | ++it; |
569 | removeAddressee( it2 ); | 627 | removeAddressee( it2 ); |
570 | } else { | 628 | } else { |
571 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 629 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
572 | ++it; | 630 | ++it; |
573 | } | 631 | } |
574 | } | 632 | } |
575 | deleteRemovedAddressees(); | 633 | deleteRemovedAddressees(); |
576 | } | 634 | } |
577 | 635 | ||
578 | void AddressBook::removeAddressee( const Iterator &it ) | 636 | void AddressBook::removeAddressee( const Iterator &it ) |
579 | { | 637 | { |
580 | d->mRemovedAddressees.append( (*it) ); | 638 | d->mRemovedAddressees.append( (*it) ); |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 8f62f0d..3603ec1 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -49,224 +49,225 @@ class Ticket; | |||
49 | */ | 49 | */ |
50 | class AddressBook : public QObject | 50 | class AddressBook : public QObject |
51 | { | 51 | { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | friend QDataStream &operator<<( QDataStream &, const AddressBook & ); | 54 | friend QDataStream &operator<<( QDataStream &, const AddressBook & ); |
55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); | 55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); |
56 | friend class StdAddressBook; | 56 | friend class StdAddressBook; |
57 | 57 | ||
58 | public: | 58 | public: |
59 | /** | 59 | /** |
60 | @short Address Book Iterator | 60 | @short Address Book Iterator |
61 | 61 | ||
62 | This class provides an iterator for address book entries. | 62 | This class provides an iterator for address book entries. |
63 | */ | 63 | */ |
64 | class Iterator | 64 | class Iterator |
65 | { | 65 | { |
66 | public: | 66 | public: |
67 | Iterator(); | 67 | Iterator(); |
68 | Iterator( const Iterator & ); | 68 | Iterator( const Iterator & ); |
69 | ~Iterator(); | 69 | ~Iterator(); |
70 | 70 | ||
71 | Iterator &operator=( const Iterator & ); | 71 | Iterator &operator=( const Iterator & ); |
72 | const Addressee &operator*() const; | 72 | const Addressee &operator*() const; |
73 | Addressee &operator*(); | 73 | Addressee &operator*(); |
74 | Addressee* operator->(); | 74 | Addressee* operator->(); |
75 | Iterator &operator++(); | 75 | Iterator &operator++(); |
76 | Iterator &operator++(int); | 76 | Iterator &operator++(int); |
77 | Iterator &operator--(); | 77 | Iterator &operator--(); |
78 | Iterator &operator--(int); | 78 | Iterator &operator--(int); |
79 | bool operator==( const Iterator &it ); | 79 | bool operator==( const Iterator &it ); |
80 | bool operator!=( const Iterator &it ); | 80 | bool operator!=( const Iterator &it ); |
81 | 81 | ||
82 | struct IteratorData; | 82 | struct IteratorData; |
83 | IteratorData *d; | 83 | IteratorData *d; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | /** | 86 | /** |
87 | @short Address Book Const Iterator | 87 | @short Address Book Const Iterator |
88 | 88 | ||
89 | This class provides a const iterator for address book entries. | 89 | This class provides a const iterator for address book entries. |
90 | */ | 90 | */ |
91 | class ConstIterator | 91 | class ConstIterator |
92 | { | 92 | { |
93 | public: | 93 | public: |
94 | ConstIterator(); | 94 | ConstIterator(); |
95 | ConstIterator( const ConstIterator & ); | 95 | ConstIterator( const ConstIterator & ); |
96 | ~ConstIterator(); | 96 | ~ConstIterator(); |
97 | 97 | ||
98 | ConstIterator &operator=( const ConstIterator & ); | 98 | ConstIterator &operator=( const ConstIterator & ); |
99 | const Addressee &operator*() const; | 99 | const Addressee &operator*() const; |
100 | const Addressee* operator->() const; | 100 | const Addressee* operator->() const; |
101 | ConstIterator &operator++(); | 101 | ConstIterator &operator++(); |
102 | ConstIterator &operator++(int); | 102 | ConstIterator &operator++(int); |
103 | ConstIterator &operator--(); | 103 | ConstIterator &operator--(); |
104 | ConstIterator &operator--(int); | 104 | ConstIterator &operator--(int); |
105 | bool operator==( const ConstIterator &it ); | 105 | bool operator==( const ConstIterator &it ); |
106 | bool operator!=( const ConstIterator &it ); | 106 | bool operator!=( const ConstIterator &it ); |
107 | 107 | ||
108 | struct ConstIteratorData; | 108 | struct ConstIteratorData; |
109 | ConstIteratorData *d; | 109 | ConstIteratorData *d; |
110 | }; | 110 | }; |
111 | 111 | ||
112 | /** | 112 | /** |
113 | Constructs a address book object. | 113 | Constructs a address book object. |
114 | 114 | ||
115 | @param format File format class. | 115 | @param format File format class. |
116 | */ | 116 | */ |
117 | AddressBook(); | 117 | AddressBook(); |
118 | AddressBook( const QString &config ); | 118 | AddressBook( const QString &config ); |
119 | AddressBook( const QString &config, const QString &family ); | 119 | AddressBook( const QString &config, const QString &family ); |
120 | virtual ~AddressBook(); | 120 | virtual ~AddressBook(); |
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 | ||
201 | 202 | ||
202 | /** | 203 | /** |
203 | Returns a list of all addressees in the address book. This list can | 204 | Returns a list of all addressees in the address book. This list can |
204 | be sorted with @ref KABC::AddresseeList for example. | 205 | be sorted with @ref KABC::AddresseeList for example. |
205 | */ | 206 | */ |
206 | Addressee::List allAddressees(); | 207 | Addressee::List allAddressees(); |
207 | 208 | ||
208 | /** | 209 | /** |
209 | Find all entries with the specified name in the address book. Returns | 210 | Find all entries with the specified name in the address book. Returns |
210 | an empty list, if no entries could be found. | 211 | an empty list, if no entries could be found. |
211 | */ | 212 | */ |
212 | Addressee::List findByName( const QString & ); | 213 | Addressee::List findByName( const QString & ); |
213 | 214 | ||
214 | /** | 215 | /** |
215 | Find all entries with the specified email address in the address book. | 216 | Find all entries with the specified email address in the address book. |
216 | Returns an empty list, if no entries could be found. | 217 | Returns an empty list, if no entries could be found. |
217 | */ | 218 | */ |
218 | Addressee::List findByEmail( const QString & ); | 219 | Addressee::List findByEmail( const QString & ); |
219 | 220 | ||
220 | /** | 221 | /** |
221 | Find all entries wich have the specified category in the address book. | 222 | Find all entries wich have the specified category in the address book. |
222 | Returns an empty list, if no entries could be found. | 223 | Returns an empty list, if no entries could be found. |
223 | */ | 224 | */ |
224 | Addressee::List findByCategory( const QString & ); | 225 | Addressee::List findByCategory( const QString & ); |
225 | 226 | ||
226 | /** | 227 | /** |
227 | Return a string identifying this addressbook. | 228 | Return a string identifying this addressbook. |
228 | */ | 229 | */ |
229 | virtual QString identifier(); | 230 | virtual QString identifier(); |
230 | 231 | ||
231 | /** | 232 | /** |
232 | Used for debug output. | 233 | Used for debug output. |
233 | */ | 234 | */ |
234 | void dump() const; | 235 | void dump() const; |
235 | 236 | ||
236 | void emitAddressBookLocked() { emit addressBookLocked( this ); } | 237 | void emitAddressBookLocked() { emit addressBookLocked( this ); } |
237 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } | 238 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } |
238 | void emitAddressBookChanged() { emit addressBookChanged( this ); } | 239 | void emitAddressBookChanged() { emit addressBookChanged( this ); } |
239 | 240 | ||
240 | /** | 241 | /** |
241 | Return list of all Fields known to the address book which are associated | 242 | Return list of all Fields known to the address book which are associated |
242 | with the given field category. | 243 | with the given field category. |
243 | */ | 244 | */ |
244 | Field::List fields( int category = Field::All ); | 245 | Field::List fields( int category = Field::All ); |
245 | 246 | ||
246 | /** | 247 | /** |
247 | Add custom field to address book. | 248 | Add custom field to address book. |
248 | 249 | ||
249 | @param label User visible label of the field. | 250 | @param label User visible label of the field. |
250 | @param category Ored list of field categories. | 251 | @param category Ored list of field categories. |
251 | @param key Identifier used as key for reading and writing the field. | 252 | @param key Identifier used as key for reading and writing the field. |
252 | @param app String used as application key for reading and writing | 253 | @param app String used as application key for reading and writing |
253 | the field. | 254 | the field. |
254 | */ | 255 | */ |
255 | bool addCustomField( const QString &label, int category = Field::All, | 256 | bool addCustomField( const QString &label, int category = Field::All, |
256 | const QString &key = QString::null, | 257 | const QString &key = QString::null, |
257 | const QString &app = QString::null ); | 258 | const QString &app = QString::null ); |
258 | 259 | ||
259 | 260 | ||
260 | /** | 261 | /** |
261 | Add address book resource. | 262 | Add address book resource. |
262 | */ | 263 | */ |
263 | bool addResource( Resource * ); | 264 | bool addResource( Resource * ); |
264 | 265 | ||
265 | /** | 266 | /** |
266 | Remove address book resource. | 267 | Remove address book resource. |
267 | */ | 268 | */ |
268 | bool removeResource( Resource * ); | 269 | bool removeResource( Resource * ); |
269 | 270 | ||
270 | /** | 271 | /** |
271 | Return pointer list of all resources. | 272 | Return pointer list of all resources. |
272 | */ | 273 | */ |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 83fede4..6404410 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1590,195 +1590,195 @@ void KABCore::initGUI() | |||
1590 | viewMenu = new QPopupMenu( this ); | 1590 | viewMenu = new QPopupMenu( this ); |
1591 | settingsMenu = new QPopupMenu( this ); | 1591 | settingsMenu = new QPopupMenu( this ); |
1592 | //filterMenu = new QPopupMenu( this ); | 1592 | //filterMenu = new QPopupMenu( this ); |
1593 | ImportMenu = new QPopupMenu( this ); | 1593 | ImportMenu = new QPopupMenu( this ); |
1594 | ExportMenu = new QPopupMenu( this ); | 1594 | ExportMenu = new QPopupMenu( this ); |
1595 | syncMenu = new QPopupMenu( this ); | 1595 | syncMenu = new QPopupMenu( this ); |
1596 | changeMenu= new QPopupMenu( this ); | 1596 | changeMenu= new QPopupMenu( this ); |
1597 | 1597 | ||
1598 | //US since we have no splitter for the embedded system, setup | 1598 | //US since we have no splitter for the embedded system, setup |
1599 | // a layout with two frames. One left and one right. | 1599 | // a layout with two frames. One left and one right. |
1600 | 1600 | ||
1601 | QBoxLayout *topLayout; | 1601 | QBoxLayout *topLayout; |
1602 | 1602 | ||
1603 | // = new QHBoxLayout( this ); | 1603 | // = new QHBoxLayout( this ); |
1604 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1604 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1605 | 1605 | ||
1606 | // QWidget *mainBox = new QWidget( this ); | 1606 | // QWidget *mainBox = new QWidget( this ); |
1607 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1607 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1608 | 1608 | ||
1609 | #ifdef DESKTOP_VERSION | 1609 | #ifdef DESKTOP_VERSION |
1610 | topLayout = new QHBoxLayout( this ); | 1610 | topLayout = new QHBoxLayout( this ); |
1611 | 1611 | ||
1612 | 1612 | ||
1613 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1613 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1614 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1614 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1615 | 1615 | ||
1616 | topLayout->addWidget(mMiniSplitter ); | 1616 | topLayout->addWidget(mMiniSplitter ); |
1617 | 1617 | ||
1618 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1618 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1619 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1619 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1620 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1620 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1621 | mDetails = new ViewContainer( mMiniSplitter ); | 1621 | mDetails = new ViewContainer( mMiniSplitter ); |
1622 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1622 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1623 | #else | 1623 | #else |
1624 | if ( QApplication::desktop()->width() > 480 ) { | 1624 | if ( QApplication::desktop()->width() > 480 ) { |
1625 | topLayout = new QHBoxLayout( this ); | 1625 | topLayout = new QHBoxLayout( this ); |
1626 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1626 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1627 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1627 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1628 | } else { | 1628 | } else { |
1629 | 1629 | ||
1630 | topLayout = new QHBoxLayout( this ); | 1630 | topLayout = new QHBoxLayout( this ); |
1631 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1631 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1632 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1632 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1633 | } | 1633 | } |
1634 | 1634 | ||
1635 | topLayout->addWidget(mMiniSplitter ); | 1635 | topLayout->addWidget(mMiniSplitter ); |
1636 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1636 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1637 | mDetails = new ViewContainer( mMiniSplitter ); | 1637 | mDetails = new ViewContainer( mMiniSplitter ); |
1638 | 1638 | ||
1639 | 1639 | ||
1640 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1640 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1641 | #endif | 1641 | #endif |
1642 | //eh->hide(); | 1642 | //eh->hide(); |
1643 | // topLayout->addWidget(mExtensionManager ); | 1643 | // topLayout->addWidget(mExtensionManager ); |
1644 | 1644 | ||
1645 | 1645 | ||
1646 | /*US | 1646 | /*US |
1647 | #ifndef KAB_NOSPLITTER | 1647 | #ifndef KAB_NOSPLITTER |
1648 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1648 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1649 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1649 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1650 | topLayout->setSpacing( 10 ); | 1650 | topLayout->setSpacing( 10 ); |
1651 | 1651 | ||
1652 | mDetailsSplitter = new QSplitter( this ); | 1652 | mDetailsSplitter = new QSplitter( this ); |
1653 | 1653 | ||
1654 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1654 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1655 | 1655 | ||
1656 | mViewManager = new ViewManager( this, viewSpace ); | 1656 | mViewManager = new ViewManager( this, viewSpace ); |
1657 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1657 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1658 | 1658 | ||
1659 | mDetails = new ViewContainer( mDetailsSplitter ); | 1659 | mDetails = new ViewContainer( mDetailsSplitter ); |
1660 | 1660 | ||
1661 | topLayout->addWidget( mDetailsSplitter ); | 1661 | topLayout->addWidget( mDetailsSplitter ); |
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 ); |
1713 | 1713 | ||
1714 | // mMainWindow->getIconToolBar()->raise(); | 1714 | // mMainWindow->getIconToolBar()->raise(); |
1715 | 1715 | ||
1716 | #endif //KAB_EMBEDDED | 1716 | #endif //KAB_EMBEDDED |
1717 | 1717 | ||
1718 | } | 1718 | } |
1719 | void KABCore::initActions() | 1719 | void KABCore::initActions() |
1720 | { | 1720 | { |
1721 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1721 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1722 | 1722 | ||
1723 | #ifndef KAB_EMBEDDED | 1723 | #ifndef KAB_EMBEDDED |
1724 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1724 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1725 | SLOT( clipboardDataChanged() ) ); | 1725 | SLOT( clipboardDataChanged() ) ); |
1726 | #endif //KAB_EMBEDDED | 1726 | #endif //KAB_EMBEDDED |
1727 | 1727 | ||
1728 | // file menu | 1728 | // file menu |
1729 | if ( mIsPart ) { | 1729 | if ( mIsPart ) { |
1730 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1730 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1731 | SLOT( sendMail() ), actionCollection(), | 1731 | SLOT( sendMail() ), actionCollection(), |
1732 | "kaddressbook_mail" ); | 1732 | "kaddressbook_mail" ); |
1733 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1733 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1734 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1734 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1735 | 1735 | ||
1736 | } else { | 1736 | } else { |
1737 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1737 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1738 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1738 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1739 | } | 1739 | } |
1740 | 1740 | ||
1741 | 1741 | ||
1742 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1742 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1743 | SLOT( save() ), actionCollection(), "file_sync" ); | 1743 | SLOT( save() ), actionCollection(), "file_sync" ); |
1744 | 1744 | ||
1745 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1745 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1746 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1746 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1747 | 1747 | ||
1748 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1748 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1749 | this, SLOT( mailVCard() ), | 1749 | this, SLOT( mailVCard() ), |
1750 | actionCollection(), "file_mail_vcard"); | 1750 | actionCollection(), "file_mail_vcard"); |
1751 | 1751 | ||
1752 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, | 1752 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, |
1753 | SLOT( export2phone() ), actionCollection(), | 1753 | SLOT( export2phone() ), actionCollection(), |
1754 | "kaddressbook_ex2phone" ); | 1754 | "kaddressbook_ex2phone" ); |
1755 | 1755 | ||
1756 | mActionBeamVCard = 0; | 1756 | mActionBeamVCard = 0; |
1757 | mActionBeam = 0; | 1757 | mActionBeam = 0; |
1758 | 1758 | ||
1759 | #ifndef DESKTOP_VERSION | 1759 | #ifndef DESKTOP_VERSION |
1760 | if ( Ir::supported() ) { | 1760 | if ( Ir::supported() ) { |
1761 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1761 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1762 | SLOT( beamVCard() ), actionCollection(), | 1762 | SLOT( beamVCard() ), actionCollection(), |
1763 | "kaddressbook_beam_vcard" ); | 1763 | "kaddressbook_beam_vcard" ); |
1764 | 1764 | ||
1765 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1765 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1766 | SLOT( beamMySelf() ), actionCollection(), | 1766 | SLOT( beamMySelf() ), actionCollection(), |
1767 | "kaddressbook_beam_myself" ); | 1767 | "kaddressbook_beam_myself" ); |
1768 | } | 1768 | } |
1769 | #endif | 1769 | #endif |
1770 | 1770 | ||
1771 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1771 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1772 | this, SLOT( editContact2() ), | 1772 | this, SLOT( editContact2() ), |
1773 | actionCollection(), "file_properties" ); | 1773 | actionCollection(), "file_properties" ); |
1774 | 1774 | ||
1775 | #ifdef KAB_EMBEDDED | 1775 | #ifdef KAB_EMBEDDED |
1776 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1776 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1777 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1777 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1778 | mMainWindow, SLOT( exit() ), | 1778 | mMainWindow, SLOT( exit() ), |
1779 | actionCollection(), "quit" ); | 1779 | actionCollection(), "quit" ); |
1780 | #endif //KAB_EMBEDDED | 1780 | #endif //KAB_EMBEDDED |
1781 | 1781 | ||
1782 | // edit menu | 1782 | // edit menu |
1783 | if ( mIsPart ) { | 1783 | if ( mIsPart ) { |
1784 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1784 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
@@ -2769,103 +2769,113 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | |||
2769 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2769 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2770 | if ( (*it).revision().date().year() > 2003 ) { | 2770 | if ( (*it).revision().date().year() > 2003 ) { |
2771 | found = true; | 2771 | found = true; |
2772 | break; | 2772 | break; |
2773 | } | 2773 | } |
2774 | } | 2774 | } |
2775 | external = ! found; | 2775 | external = ! found; |
2776 | } | 2776 | } |
2777 | 2777 | ||
2778 | if ( external ) { | 2778 | if ( external ) { |
2779 | qDebug("Setting vcf mode to external "); | 2779 | qDebug("Setting vcf mode to external "); |
2780 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2780 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2781 | AddressBook::Iterator it; | 2781 | AddressBook::Iterator it; |
2782 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2782 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2783 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2783 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2784 | (*it).computeCsum( mCurrentSyncDevice ); | 2784 | (*it).computeCsum( mCurrentSyncDevice ); |
2785 | } | 2785 | } |
2786 | } | 2786 | } |
2787 | } | 2787 | } |
2788 | //AddressBook::Iterator it; | 2788 | //AddressBook::Iterator it; |
2789 | //QStringList vcards; | 2789 | //QStringList vcards; |
2790 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2790 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2791 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2791 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2792 | //} | 2792 | //} |
2793 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2793 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2794 | if ( syncOK ) { | 2794 | if ( syncOK ) { |
2795 | if ( syncManager->mWriteBackFile ) | 2795 | if ( syncManager->mWriteBackFile ) |
2796 | { | 2796 | { |
2797 | if ( external ) | 2797 | if ( external ) |
2798 | abLocal.removeSyncAddressees( !isXML); | 2798 | abLocal.removeSyncAddressees( !isXML); |
2799 | qDebug("Saving remote AB "); | 2799 | qDebug("Saving remote AB "); |
2800 | abLocal.saveAB(); | 2800 | abLocal.saveAB(); |
2801 | if ( isXML ) { | 2801 | if ( isXML ) { |
2802 | // afterwrite processing | 2802 | // afterwrite processing |
2803 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2803 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2804 | } | 2804 | } |
2805 | } | 2805 | } |
2806 | } | 2806 | } |
2807 | setModified(); | 2807 | setModified(); |
2808 | 2808 | ||
2809 | } | 2809 | } |
2810 | if ( syncOK ) | 2810 | if ( syncOK ) |
2811 | mViewManager->refreshView(); | 2811 | mViewManager->refreshView(); |
2812 | return syncOK; | 2812 | return syncOK; |
2813 | #if 0 | 2813 | #if 0 |
2814 | 2814 | ||
2815 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2815 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2816 | getEventViewerDialog()->setSyncMode( true ); | 2816 | getEventViewerDialog()->setSyncMode( true ); |
2817 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2817 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2818 | getEventViewerDialog()->setSyncMode( false ); | 2818 | getEventViewerDialog()->setSyncMode( false ); |
2819 | if ( syncOK ) { | 2819 | if ( syncOK ) { |
2820 | if ( KOPrefs::instance()->mWriteBackFile ) | 2820 | if ( KOPrefs::instance()->mWriteBackFile ) |
2821 | { | 2821 | { |
2822 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2822 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2823 | storage->save(); | 2823 | storage->save(); |
2824 | } | 2824 | } |
2825 | } | 2825 | } |
2826 | setModified(); | 2826 | setModified(); |
2827 | } | 2827 | } |
2828 | 2828 | ||
2829 | #endif | 2829 | #endif |
2830 | } | 2830 | } |
2831 | 2831 | ||
2832 | 2832 | ||
2833 | //this is a overwritten callbackmethods from the syncinterface | 2833 | //this is a overwritten callbackmethods from the syncinterface |
2834 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2834 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2835 | { | 2835 | { |
2836 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2836 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2837 | 2837 | ||
2838 | AddressBook abLocal( resource,"syncContact"); | 2838 | AddressBook abLocal( resource,"syncContact"); |
2839 | bool syncOK = false; | 2839 | bool syncOK = false; |
2840 | if ( abLocal.load() ) { | 2840 | if ( abLocal.load() ) { |
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 | |||
@@ -250,230 +250,232 @@ class KABCore : public QWidget, public KSyncInterface | |||
250 | Marks the address book as modified. | 250 | Marks the address book as modified. |
251 | */ | 251 | */ |
252 | void setModified(); | 252 | void setModified(); |
253 | /** | 253 | /** |
254 | Marks the address book as modified without refreshing the view. | 254 | Marks the address book as modified without refreshing the view. |
255 | */ | 255 | */ |
256 | void setModifiedWOrefresh(); | 256 | void setModifiedWOrefresh(); |
257 | 257 | ||
258 | /** | 258 | /** |
259 | Marks the address book as modified concerning the argument. | 259 | Marks the address book as modified concerning the argument. |
260 | */ | 260 | */ |
261 | void setModified( bool modified ); | 261 | void setModified( bool modified ); |
262 | 262 | ||
263 | /** | 263 | /** |
264 | Returns whether the address book is modified. | 264 | Returns whether the address book is modified. |
265 | */ | 265 | */ |
266 | bool modified() const; | 266 | bool modified() const; |
267 | 267 | ||
268 | /** | 268 | /** |
269 | Called whenever an contact is modified in the contact editor | 269 | Called whenever an contact is modified in the contact editor |
270 | dialog or the quick edit. | 270 | dialog or the quick edit. |
271 | */ | 271 | */ |
272 | void contactModified( const KABC::Addressee &addr ); | 272 | void contactModified( const KABC::Addressee &addr ); |
273 | 273 | ||
274 | /** | 274 | /** |
275 | DCOP METHODS. | 275 | DCOP METHODS. |
276 | */ | 276 | */ |
277 | void addEmail( QString addr ); | 277 | void addEmail( QString addr ); |
278 | void importVCard( const KURL& url, bool showPreview ); | 278 | void importVCard( const KURL& url, bool showPreview ); |
279 | void importVCard( const QString& vCard, bool showPreview ); | 279 | void importVCard( const QString& vCard, bool showPreview ); |
280 | void newContact(); | 280 | void newContact(); |
281 | QString getNameByPhone( const QString& phone ); | 281 | QString getNameByPhone( const QString& phone ); |
282 | /** | 282 | /** |
283 | END DCOP METHODS | 283 | END DCOP METHODS |
284 | */ | 284 | */ |
285 | 285 | ||
286 | /** | 286 | /** |
287 | Saves the contents of the AddressBook back to disk. | 287 | Saves the contents of the AddressBook back to disk. |
288 | */ | 288 | */ |
289 | void save(); | 289 | void save(); |
290 | 290 | ||
291 | /** | 291 | /** |
292 | Undos the last command using the undo stack. | 292 | Undos the last command using the undo stack. |
293 | */ | 293 | */ |
294 | void undo(); | 294 | void undo(); |
295 | 295 | ||
296 | /** | 296 | /** |
297 | Redos the last command that was undone, using the redo stack. | 297 | Redos the last command that was undone, using the redo stack. |
298 | */ | 298 | */ |
299 | void redo(); | 299 | void redo(); |
300 | 300 | ||
301 | /** | 301 | /** |
302 | Shows the edit dialog for the given uid. If the uid is QString::null, | 302 | Shows the edit dialog for the given uid. If the uid is QString::null, |
303 | the method will try to find a selected addressee in the view. | 303 | the method will try to find a selected addressee in the view. |
304 | */ | 304 | */ |
305 | void editContact( const QString &uid /*US = QString::null*/ ); | 305 | void editContact( const QString &uid /*US = QString::null*/ ); |
306 | //US added a second method without defaultparameter | 306 | //US added a second method without defaultparameter |
307 | void editContact2(); | 307 | void editContact2(); |
308 | 308 | ||
309 | /** | 309 | /** |
310 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 310 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
311 | the method will try to find a selected addressee in the view. | 311 | the method will try to find a selected addressee in the view. |
312 | */ | 312 | */ |
313 | void executeContact( const QString &uid /*US = QString::null*/ ); | 313 | void executeContact( const QString &uid /*US = QString::null*/ ); |
314 | 314 | ||
315 | /** | 315 | /** |
316 | Launches the configuration dialog. | 316 | Launches the configuration dialog. |
317 | */ | 317 | */ |
318 | void openConfigDialog(); | 318 | void openConfigDialog(); |
319 | 319 | ||
320 | /** | 320 | /** |
321 | Launches the ldap search dialog. | 321 | Launches the ldap search dialog. |
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 | ||
370 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, | 371 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, |
371 | const char *name = 0 ); | 372 | const char *name = 0 ); |
372 | 373 | ||
373 | KXMLGUIClient *mGUIClient; | 374 | KXMLGUIClient *mGUIClient; |
374 | 375 | ||
375 | KABC::AddressBook *mAddressBook; | 376 | KABC::AddressBook *mAddressBook; |
376 | 377 | ||
377 | ViewManager *mViewManager; | 378 | ViewManager *mViewManager; |
378 | // QSplitter *mDetailsSplitter; | 379 | // QSplitter *mDetailsSplitter; |
379 | KDGanttMinimizeSplitter *mExtensionBarSplitter; | 380 | KDGanttMinimizeSplitter *mExtensionBarSplitter; |
380 | ViewContainer *mDetails; | 381 | ViewContainer *mDetails; |
381 | KDGanttMinimizeSplitter* mMiniSplitter; | 382 | KDGanttMinimizeSplitter* mMiniSplitter; |
382 | XXPortManager *mXXPortManager; | 383 | XXPortManager *mXXPortManager; |
383 | JumpButtonBar *mJumpButtonBar; | 384 | JumpButtonBar *mJumpButtonBar; |
384 | IncSearchWidget *mIncSearchWidget; | 385 | IncSearchWidget *mIncSearchWidget; |
385 | ExtensionManager *mExtensionManager; | 386 | ExtensionManager *mExtensionManager; |
386 | 387 | ||
387 | KCMultiDialog *mConfigureDialog; | 388 | KCMultiDialog *mConfigureDialog; |
388 | 389 | ||
389 | #ifndef KAB_EMBEDDED | 390 | #ifndef KAB_EMBEDDED |
390 | LDAPSearchDialog *mLdapSearchDialog; | 391 | LDAPSearchDialog *mLdapSearchDialog; |
391 | #endif //KAB_EMBEDDED | 392 | #endif //KAB_EMBEDDED |
392 | // QDict<AddresseeEditorDialog> mEditorDict; | 393 | // QDict<AddresseeEditorDialog> mEditorDict; |
393 | AddresseeEditorDialog *mEditorDialog; | 394 | AddresseeEditorDialog *mEditorDialog; |
394 | bool mReadWrite; | 395 | bool mReadWrite; |
395 | bool mModified; | 396 | bool mModified; |
396 | bool mIsPart; | 397 | bool mIsPart; |
397 | bool mMultipleViewsAtOnce; | 398 | bool mMultipleViewsAtOnce; |
398 | 399 | ||
399 | 400 | ||
400 | //US file menu | 401 | //US file menu |
401 | KAction *mActionMail; | 402 | KAction *mActionMail; |
402 | KAction *mActionBeam; | 403 | KAction *mActionBeam; |
403 | KAction *mActionExport2phone; | 404 | KAction *mActionExport2phone; |
404 | KAction* mActionPrint; | 405 | KAction* mActionPrint; |
405 | KAction* mActionNewContact; | 406 | KAction* mActionNewContact; |
406 | KAction *mActionSave; | 407 | KAction *mActionSave; |
407 | KAction *mActionEditAddressee; | 408 | KAction *mActionEditAddressee; |
408 | KAction *mActionMailVCard; | 409 | KAction *mActionMailVCard; |
409 | KAction *mActionBeamVCard; | 410 | KAction *mActionBeamVCard; |
410 | 411 | ||
411 | KAction *mActionQuit; | 412 | KAction *mActionQuit; |
412 | 413 | ||
413 | //US edit menu | 414 | //US edit menu |
414 | KAction *mActionCopy; | 415 | KAction *mActionCopy; |
415 | KAction *mActionCut; | 416 | KAction *mActionCut; |
416 | KAction *mActionPaste; | 417 | KAction *mActionPaste; |
417 | KAction *mActionSelectAll; | 418 | KAction *mActionSelectAll; |
418 | KAction *mActionUndo; | 419 | KAction *mActionUndo; |
419 | KAction *mActionRedo; | 420 | KAction *mActionRedo; |
420 | KAction *mActionDelete; | 421 | KAction *mActionDelete; |
421 | 422 | ||
422 | //US settings menu | 423 | //US settings menu |
423 | KAction *mActionConfigResources; | 424 | KAction *mActionConfigResources; |
424 | KAction *mActionConfigKAddressbook; | 425 | KAction *mActionConfigKAddressbook; |
425 | KAction *mActionConfigShortcuts; | 426 | KAction *mActionConfigShortcuts; |
426 | KAction *mActionConfigureToolbars; | 427 | KAction *mActionConfigureToolbars; |
427 | KAction *mActionKeyBindings; | 428 | KAction *mActionKeyBindings; |
428 | KToggleAction *mActionJumpBar; | 429 | KToggleAction *mActionJumpBar; |
429 | KToggleAction *mActionDetails; | 430 | KToggleAction *mActionDetails; |
430 | KAction *mActionWhoAmI; | 431 | KAction *mActionWhoAmI; |
431 | KAction *mActionCategories; | 432 | KAction *mActionCategories; |
432 | KAction *mActionAboutKAddressbook; | 433 | KAction *mActionAboutKAddressbook; |
433 | KAction *mActionLicence; | 434 | KAction *mActionLicence; |
434 | KAction *mActionFaq; | 435 | KAction *mActionFaq; |
435 | 436 | ||
436 | KAction *mActionDeleteView; | 437 | KAction *mActionDeleteView; |
437 | 438 | ||
438 | QPopupMenu *viewMenu; | 439 | QPopupMenu *viewMenu; |
439 | QPopupMenu *filterMenu; | 440 | QPopupMenu *filterMenu; |
440 | QPopupMenu *settingsMenu; | 441 | QPopupMenu *settingsMenu; |
441 | QPopupMenu *changeMenu; | 442 | QPopupMenu *changeMenu; |
442 | //US QAction *mActionSave; | 443 | //US QAction *mActionSave; |
443 | QPopupMenu *ImportMenu; | 444 | QPopupMenu *ImportMenu; |
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 | |||
@@ -28,192 +28,193 @@ Copyright (c) 2004 Ulf Schenk | |||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | 33 | ||
34 | #include <kabc/vcardconverter.h> | 34 | #include <kabc/vcardconverter.h> |
35 | #include <kabc/vcardparser/vcardtool.h> | 35 | #include <kabc/vcardparser/vcardtool.h> |
36 | #include <kfiledialog.h> | 36 | #include <kfiledialog.h> |
37 | #ifndef KAB_EMBEDDED | 37 | #ifndef KAB_EMBEDDED |
38 | #include <kio/netaccess.h> | 38 | #include <kio/netaccess.h> |
39 | #endif //KAB_EMBEDDED | 39 | #endif //KAB_EMBEDDED |
40 | 40 | ||
41 | #include <klocale.h> | 41 | #include <klocale.h> |
42 | #include <kmessagebox.h> | 42 | #include <kmessagebox.h> |
43 | #include <ktempfile.h> | 43 | #include <ktempfile.h> |
44 | #include <kurl.h> | 44 | #include <kurl.h> |
45 | 45 | ||
46 | #include "xxportmanager.h" | 46 | #include "xxportmanager.h" |
47 | 47 | ||
48 | #include "vcard_xxport.h" | 48 | #include "vcard_xxport.h" |
49 | 49 | ||
50 | #ifndef KAB_EMBEDDED | 50 | #ifndef KAB_EMBEDDED |
51 | 51 | ||
52 | class VCardXXPortFactory : public XXPortFactory | 52 | class VCardXXPortFactory : public XXPortFactory |
53 | { | 53 | { |
54 | public: | 54 | public: |
55 | XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 55 | XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
56 | { | 56 | { |
57 | return new VCardXXPort( ab, parent, name ); | 57 | return new VCardXXPort( ab, parent, name ); |
58 | } | 58 | } |
59 | }; | 59 | }; |
60 | #endif //KAB_EMBEDDED | 60 | #endif //KAB_EMBEDDED |
61 | 61 | ||
62 | 62 | ||
63 | extern "C" | 63 | extern "C" |
64 | { | 64 | { |
65 | #ifndef KAB_EMBEDDED | 65 | #ifndef KAB_EMBEDDED |
66 | void *init_libkaddrbk_vcard_xxport() | 66 | void *init_libkaddrbk_vcard_xxport() |
67 | #else //KAB_EMBEDDED | 67 | #else //KAB_EMBEDDED |
68 | void *init_microkaddrbk_vcard_xxport() | 68 | void *init_microkaddrbk_vcard_xxport() |
69 | #endif //KAB_EMBEDDED | 69 | #endif //KAB_EMBEDDED |
70 | { | 70 | { |
71 | return ( new VCardXXPortFactory() ); | 71 | return ( new VCardXXPortFactory() ); |
72 | } | 72 | } |
73 | } | 73 | } |
74 | 74 | ||
75 | 75 | ||
76 | VCardXXPort::VCardXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 76 | VCardXXPort::VCardXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
77 | : XXPortObject( ab, parent, name ) | 77 | : XXPortObject( ab, parent, name ) |
78 | { | 78 | { |
79 | createImportAction( i18n( "Import vCard..." ) ); | 79 | createImportAction( i18n( "Import vCard..." ) ); |
80 | //US KABC::VCardConverter does not support the export of 2.1 addressbooks. | 80 | //US KABC::VCardConverter does not support the export of 2.1 addressbooks. |
81 | //US createExportAction( i18n( "Export vCard 2.1..." ), "v21" ); | 81 | //US createExportAction( i18n( "Export vCard 2.1..." ), "v21" ); |
82 | createExportAction( i18n( "Export vCard 3.0..." ), "v30" ); | 82 | createExportAction( i18n( "Export vCard 3.0..." ), "v30" ); |
83 | } | 83 | } |
84 | 84 | ||
85 | bool VCardXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) | 85 | bool VCardXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) |
86 | { | 86 | { |
87 | QString name; | 87 | QString name; |
88 | 88 | ||
89 | if ( list.count() == 1 ) | 89 | if ( list.count() == 1 ) |
90 | name = list[ 0 ].givenName() + "_" + list[ 0 ].familyName() + ".vcf"; | 90 | name = list[ 0 ].givenName() + "_" + list[ 0 ].familyName() + ".vcf"; |
91 | else | 91 | else |
92 | name = "addressbook.vcf"; | 92 | name = "addressbook.vcf"; |
93 | 93 | ||
94 | #ifndef KAB_EMBEDDED | 94 | #ifndef KAB_EMBEDDED |
95 | QString fileName = KFileDialog::getSaveFileName( name ); | 95 | QString fileName = KFileDialog::getSaveFileName( name ); |
96 | #else //KAB_EMBEDDED | 96 | #else //KAB_EMBEDDED |
97 | QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); | 97 | QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); |
98 | #endif //KAB_EMBEDDED | 98 | #endif //KAB_EMBEDDED |
99 | 99 | ||
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 |
148 | url = XXPortManager::importURL; | 149 | url = XXPortManager::importURL; |
149 | 150 | ||
150 | if ( url.isEmpty() ) | 151 | if ( url.isEmpty() ) |
151 | return addrList; | 152 | return addrList; |
152 | 153 | ||
153 | QString caption( i18n( "vCard Import Failed" ) ); | 154 | QString caption( i18n( "vCard Import Failed" ) ); |
154 | if ( KIO::NetAccess::download( url, fileName ) ) { | 155 | if ( KIO::NetAccess::download( url, fileName ) ) { |
155 | QFile file( fileName ); | 156 | QFile file( fileName ); |
156 | 157 | ||
157 | file.open( IO_ReadOnly ); | 158 | file.open( IO_ReadOnly ); |
158 | QByteArray rawData = file.readAll(); | 159 | QByteArray rawData = file.readAll(); |
159 | file.close(); | 160 | file.close(); |
160 | 161 | ||
161 | QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 162 | QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
162 | addrList = parseVCard( data ); | 163 | addrList = parseVCard( data ); |
163 | 164 | ||
164 | if ( !url.isLocalFile() ) | 165 | if ( !url.isLocalFile() ) |
165 | KIO::NetAccess::removeTempFile( fileName ); | 166 | KIO::NetAccess::removeTempFile( fileName ); |
166 | 167 | ||
167 | } else { | 168 | } else { |
168 | QString text = i18n( "<qt>Unable to access <b>%1</b>.</qt>" ); | 169 | QString text = i18n( "<qt>Unable to access <b>%1</b>.</qt>" ); |
169 | KMessageBox::error( parentWidget(), text.arg( url.url() ), caption ); | 170 | KMessageBox::error( parentWidget(), text.arg( url.url() ), caption ); |
170 | } | 171 | } |
171 | 172 | ||
172 | } | 173 | } |
173 | 174 | ||
174 | 175 | ||
175 | #else //KAB_EMBEDDED | 176 | #else //KAB_EMBEDDED |
176 | 177 | ||
177 | 178 | ||
178 | if ( !XXPortManager::importData.isEmpty() ) | 179 | if ( !XXPortManager::importData.isEmpty() ) |
179 | addrList = parseVCard( XXPortManager::importData ); | 180 | addrList = parseVCard( XXPortManager::importData ); |
180 | else { | 181 | else { |
181 | if ( XXPortManager::importURL.isEmpty() ) | 182 | if ( XXPortManager::importURL.isEmpty() ) |
182 | { | 183 | { |
183 | fileName = KFileDialog::getOpenFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); | 184 | fileName = KFileDialog::getOpenFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); |
184 | if ( fileName.isEmpty() ) | 185 | if ( fileName.isEmpty() ) |
185 | return addrList; | 186 | return addrList; |
186 | 187 | ||
187 | } | 188 | } |
188 | else | 189 | else |
189 | { | 190 | { |
190 | //US url = XXPortManager::importURL; | 191 | //US url = XXPortManager::importURL; |
191 | qDebug("VCardXXPort::importContacts Urls at the moment not supported"); | 192 | qDebug("VCardXXPort::importContacts Urls at the moment not supported"); |
192 | if ( url.isEmpty() ) | 193 | if ( url.isEmpty() ) |
193 | return addrList; | 194 | return addrList; |
194 | 195 | ||
195 | } | 196 | } |
196 | 197 | ||
197 | 198 | ||
198 | QFile file( fileName ); | 199 | QFile file( fileName ); |
199 | 200 | ||
200 | file.open( IO_ReadOnly ); | 201 | file.open( IO_ReadOnly ); |
201 | QByteArray rawData = file.readAll(); | 202 | QByteArray rawData = file.readAll(); |
202 | file.close(); | 203 | file.close(); |
203 | 204 | ||
204 | QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 205 | QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
205 | addrList = parseVCard( data ); | 206 | addrList = parseVCard( data ); |
206 | 207 | ||
207 | } | 208 | } |
208 | #endif //KAB_EMBEDDED | 209 | #endif //KAB_EMBEDDED |
209 | 210 | ||
210 | return addrList; | 211 | return addrList; |
211 | } | 212 | } |
212 | 213 | ||
213 | KABC::AddresseeList VCardXXPort::parseVCard( const QString &data ) const | 214 | KABC::AddresseeList VCardXXPort::parseVCard( const QString &data ) const |
214 | { | 215 | { |
215 | 216 | ||
216 | KABC::VCardTool tool; | 217 | KABC::VCardTool tool; |
217 | KABC::AddresseeList addrList; | 218 | KABC::AddresseeList addrList; |
218 | addrList = tool.parseVCards( data ); | 219 | addrList = tool.parseVCards( data ); |
219 | // LR : I switched to the code, which is in current cvs HEAD | 220 | // LR : I switched to the code, which is in current cvs HEAD |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 5d48884..ea543dd 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -182,193 +182,194 @@ void KSyncManager::slotSyncMenu( int action ) | |||
182 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 182 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
183 | if ( action == 1000 ) { | 183 | if ( action == 1000 ) { |
184 | syncSharp(); | 184 | syncSharp(); |
185 | 185 | ||
186 | } else if ( action == 1001 ) { | 186 | } else if ( action == 1001 ) { |
187 | syncLocalFile(); | 187 | syncLocalFile(); |
188 | 188 | ||
189 | } else if ( action == 1002 ) { | 189 | } else if ( action == 1002 ) { |
190 | quickSyncLocalFile(); | 190 | quickSyncLocalFile(); |
191 | 191 | ||
192 | } else if ( action >= 1003 ) { | 192 | } else if ( action >= 1003 ) { |
193 | if ( temp->getIsLocalFileSync() ) { | 193 | if ( temp->getIsLocalFileSync() ) { |
194 | switch(mTargetApp) | 194 | switch(mTargetApp) |
195 | { | 195 | { |
196 | case (KAPI): | 196 | case (KAPI): |
197 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 197 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
198 | mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 198 | mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
199 | break; | 199 | break; |
200 | case (KOPI): | 200 | case (KOPI): |
201 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 201 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
202 | mLastSyncedLocalFile = temp->getRemoteFileName(); | 202 | mLastSyncedLocalFile = temp->getRemoteFileName(); |
203 | break; | 203 | break; |
204 | case (PWMPI): | 204 | case (PWMPI): |
205 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 205 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
206 | mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 206 | mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
207 | break; | 207 | break; |
208 | default: | 208 | default: |
209 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 209 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
210 | break; | 210 | break; |
211 | 211 | ||
212 | } | 212 | } |
213 | } else { | 213 | } else { |
214 | if ( temp->getIsPhoneSync() ) { | 214 | if ( temp->getIsPhoneSync() ) { |
215 | mPhoneDevice = temp->getPhoneDevice( ) ; | 215 | mPhoneDevice = temp->getPhoneDevice( ) ; |
216 | mPhoneConnection = temp->getPhoneConnection( ); | 216 | mPhoneConnection = temp->getPhoneConnection( ); |
217 | mPhoneModel = temp->getPhoneModel( ); | 217 | mPhoneModel = temp->getPhoneModel( ); |
218 | syncPhone(); | 218 | syncPhone(); |
219 | } else if ( temp->getIsPiSync() ) { | 219 | } else if ( temp->getIsPiSync() ) { |
220 | mPassWordPiSync = temp->getRemotePw(); | 220 | mPassWordPiSync = temp->getRemotePw(); |
221 | mActiveSyncPort = temp->getRemotePort(); | 221 | mActiveSyncPort = temp->getRemotePort(); |
222 | mActiveSyncIP = temp->getRemoteIP(); | 222 | mActiveSyncIP = temp->getRemoteIP(); |
223 | syncPi(); | 223 | syncPi(); |
224 | } | 224 | } |
225 | syncRemote( temp ); | 225 | syncRemote( temp ); |
226 | 226 | ||
227 | } | 227 | } |
228 | } | 228 | } |
229 | delete temp; | 229 | delete temp; |
230 | setBlockSave(false); | 230 | setBlockSave(false); |
231 | } | 231 | } |
232 | void KSyncManager::enableQuick() | 232 | void KSyncManager::enableQuick() |
233 | { | 233 | { |
234 | QDialog dia ( 0, "input-dialog", true ); | 234 | QDialog dia ( 0, "input-dialog", true ); |
235 | QLineEdit lab ( &dia ); | 235 | QLineEdit lab ( &dia ); |
236 | QVBoxLayout lay( &dia ); | 236 | QVBoxLayout lay( &dia ); |
237 | lab.setText( mPrefs->mPassiveSyncPort ); | 237 | lab.setText( mPrefs->mPassiveSyncPort ); |
238 | lay.setMargin(7); | 238 | lay.setMargin(7); |
239 | lay.setSpacing(7); | 239 | lay.setSpacing(7); |
240 | int po = 9197+mTargetApp; | 240 | int po = 9197+mTargetApp; |
241 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); | 241 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); |
242 | lay.addWidget( &label); | 242 | lay.addWidget( &label); |
243 | lay.addWidget( &lab); | 243 | lay.addWidget( &lab); |
244 | 244 | ||
245 | QLineEdit lepw ( &dia ); | 245 | QLineEdit lepw ( &dia ); |
246 | lepw.setText( mPrefs->mPassiveSyncPw ); | 246 | lepw.setText( mPrefs->mPassiveSyncPw ); |
247 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 247 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
248 | lay.addWidget( &label2); | 248 | lay.addWidget( &label2); |
249 | lay.addWidget( &lepw); | 249 | lay.addWidget( &lepw); |
250 | dia.setFixedSize( 230,80 ); | 250 | dia.setFixedSize( 230,80 ); |
251 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 251 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
252 | QPushButton pb ( "OK", &dia); | 252 | QPushButton pb ( "OK", &dia); |
253 | lay.addWidget( &pb ); | 253 | lay.addWidget( &pb ); |
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 | ||
303 | } | 304 | } |
304 | 305 | ||
305 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 306 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
306 | if ( fn == "" ) | 307 | if ( fn == "" ) |
307 | return; | 308 | return; |
308 | if ( syncWithFile( fn, false ) ) { | 309 | if ( syncWithFile( fn, false ) ) { |
309 | qDebug("syncLocalFile() successful "); | 310 | qDebug("syncLocalFile() successful "); |
310 | } | 311 | } |
311 | 312 | ||
312 | } | 313 | } |
313 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 314 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
314 | { | 315 | { |
315 | bool ret = false; | 316 | bool ret = false; |
316 | QFileInfo info; | 317 | QFileInfo info; |
317 | info.setFile( fn ); | 318 | info.setFile( fn ); |
318 | QString mess; | 319 | QString mess; |
319 | bool loadbup = true; | 320 | bool loadbup = true; |
320 | if ( !info. exists() ) { | 321 | if ( !info. exists() ) { |
321 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 322 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
322 | int result = QMessageBox::warning( mParent, i18n("Warning!"), | 323 | int result = QMessageBox::warning( mParent, i18n("Warning!"), |
323 | mess ); | 324 | mess ); |
324 | return ret; | 325 | return ret; |
325 | } | 326 | } |
326 | int result = 0; | 327 | int result = 0; |
327 | if ( !quick ) { | 328 | if ( !quick ) { |
328 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 329 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
329 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 330 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
330 | mess, | 331 | mess, |
331 | i18n("Sync"), i18n("Cancel"), 0, | 332 | i18n("Sync"), i18n("Cancel"), 0, |
332 | 0, 1 ); | 333 | 0, 1 ); |
333 | if ( result ) | 334 | if ( result ) |
334 | return false; | 335 | return false; |
335 | } | 336 | } |
336 | if ( mAskForPreferences ) | 337 | if ( mAskForPreferences ) |
337 | edit_sync_options(); | 338 | edit_sync_options(); |
338 | if ( result == 0 ) { | 339 | if ( result == 0 ) { |
339 | //qDebug("Now sycing ... "); | 340 | //qDebug("Now sycing ... "); |
340 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) | 341 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
341 | mParent->setCaption( i18n("Synchronization successful") ); | 342 | mParent->setCaption( i18n("Synchronization successful") ); |
342 | else | 343 | else |
343 | mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 344 | mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
344 | if ( ! quick ) | 345 | if ( ! quick ) |
345 | mLastSyncedLocalFile = fn; | 346 | mLastSyncedLocalFile = fn; |
346 | } | 347 | } |
347 | return ret; | 348 | return ret; |
348 | } | 349 | } |
349 | void KSyncManager::quickSyncLocalFile() | 350 | void KSyncManager::quickSyncLocalFile() |
350 | { | 351 | { |
351 | 352 | ||
352 | if ( syncWithFile( mLastSyncedLocalFile, false ) ) { | 353 | if ( syncWithFile( mLastSyncedLocalFile, false ) ) { |
353 | qDebug("quick syncLocalFile() successful "); | 354 | qDebug("quick syncLocalFile() successful "); |
354 | 355 | ||
355 | } | 356 | } |
356 | } | 357 | } |
357 | void KSyncManager::multiSync( bool askforPrefs ) | 358 | void KSyncManager::multiSync( bool askforPrefs ) |
358 | { | 359 | { |
359 | if (blockSave()) | 360 | if (blockSave()) |
360 | return; | 361 | return; |
361 | setBlockSave(true); | 362 | setBlockSave(true); |
362 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 363 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
363 | if ( QMessageBox::information( mParent, i18n("Sync"), | 364 | if ( QMessageBox::information( mParent, i18n("Sync"), |
364 | question, | 365 | question, |
365 | i18n("Yes"), i18n("No"), | 366 | i18n("Yes"), i18n("No"), |
366 | 0, 0 ) != 0 ) { | 367 | 0, 0 ) != 0 ) { |
367 | setBlockSave(false); | 368 | setBlockSave(false); |
368 | mParent->setCaption(i18n("Aborted! Nothing synced!")); | 369 | mParent->setCaption(i18n("Aborted! Nothing synced!")); |
369 | return; | 370 | return; |
370 | } | 371 | } |
371 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 372 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
372 | mSyncAlgoPrefs = mRingSyncAlgoPrefs; | 373 | mSyncAlgoPrefs = mRingSyncAlgoPrefs; |
373 | if ( askforPrefs ) { | 374 | if ( askforPrefs ) { |
374 | edit_sync_options(); | 375 | edit_sync_options(); |
@@ -835,193 +836,193 @@ void KSyncManager::readFileFromSocket() | |||
835 | 836 | ||
836 | 837 | ||
837 | 838 | ||
838 | 839 | ||
839 | 840 | ||
840 | 841 | ||
841 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 842 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
842 | { | 843 | { |
843 | mPassWord = pw; | 844 | mPassWord = pw; |
844 | mSocket = 0; | 845 | mSocket = 0; |
845 | mSyncActionDialog = 0; | 846 | mSyncActionDialog = 0; |
846 | blockRC = false; | 847 | blockRC = false; |
847 | }; | 848 | }; |
848 | 849 | ||
849 | void KServerSocket::newConnection ( int socket ) | 850 | void KServerSocket::newConnection ( int socket ) |
850 | { | 851 | { |
851 | // qDebug("KServerSocket:New connection %d ", socket); | 852 | // qDebug("KServerSocket:New connection %d ", socket); |
852 | if ( mSocket ) { | 853 | if ( mSocket ) { |
853 | qDebug("KServerSocket::newConnection Socket deleted! "); | 854 | qDebug("KServerSocket::newConnection Socket deleted! "); |
854 | delete mSocket; | 855 | delete mSocket; |
855 | mSocket = 0; | 856 | mSocket = 0; |
856 | } | 857 | } |
857 | mSocket = new QSocket( this ); | 858 | mSocket = new QSocket( this ); |
858 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 859 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
859 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 860 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
860 | mSocket->setSocket( socket ); | 861 | mSocket->setSocket( socket ); |
861 | } | 862 | } |
862 | 863 | ||
863 | void KServerSocket::discardClient() | 864 | void KServerSocket::discardClient() |
864 | { | 865 | { |
865 | //qDebug(" KServerSocket::discardClient()"); | 866 | //qDebug(" KServerSocket::discardClient()"); |
866 | if ( mSocket ) { | 867 | if ( mSocket ) { |
867 | delete mSocket; | 868 | delete mSocket; |
868 | mSocket = 0; | 869 | mSocket = 0; |
869 | } | 870 | } |
870 | //emit endConnect(); | 871 | //emit endConnect(); |
871 | } | 872 | } |
872 | void KServerSocket::readClient() | 873 | void KServerSocket::readClient() |
873 | { | 874 | { |
874 | if ( blockRC ) | 875 | if ( blockRC ) |
875 | return; | 876 | return; |
876 | if ( mSocket == 0 ) { | 877 | if ( mSocket == 0 ) { |
877 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); | 878 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); |
878 | return; | 879 | return; |
879 | } | 880 | } |
880 | qDebug("KServerSocket readClient()"); | 881 | qDebug("KServerSocket readClient()"); |
881 | if ( mSocket->canReadLine() ) { | 882 | if ( mSocket->canReadLine() ) { |
882 | QString line = mSocket->readLine(); | 883 | QString line = mSocket->readLine(); |
883 | qDebug("KServerSocket readline: %s ", line.latin1()); | 884 | qDebug("KServerSocket readline: %s ", line.latin1()); |
884 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); | 885 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); |
885 | if ( tokens[0] == "GET" ) { | 886 | if ( tokens[0] == "GET" ) { |
886 | if ( tokens[1] == mPassWord ) | 887 | if ( tokens[1] == mPassWord ) |
887 | //emit sendFile( mSocket ); | 888 | //emit sendFile( mSocket ); |
888 | send_file(); | 889 | send_file(); |
889 | else { | 890 | else { |
890 | KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); | 891 | KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); |
891 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 892 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
892 | } | 893 | } |
893 | } | 894 | } |
894 | if ( tokens[0] == "PUT" ) { | 895 | if ( tokens[0] == "PUT" ) { |
895 | if ( tokens[1] == mPassWord ) { | 896 | if ( tokens[1] == mPassWord ) { |
896 | //emit getFile( mSocket ); | 897 | //emit getFile( mSocket ); |
897 | blockRC = true; | 898 | blockRC = true; |
898 | get_file(); | 899 | get_file(); |
899 | } | 900 | } |
900 | else { | 901 | else { |
901 | KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); | 902 | KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); |
902 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 903 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
903 | } | 904 | } |
904 | } | 905 | } |
905 | if ( tokens[0] == "STOP" ) { | 906 | if ( tokens[0] == "STOP" ) { |
906 | //emit endConnect(); | 907 | //emit endConnect(); |
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(); |
956 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | 957 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); |
957 | mSocket->close(); | 958 | mSocket->close(); |
958 | if ( mSocket->state() == QSocket::Idle ) | 959 | if ( mSocket->state() == QSocket::Idle ) |
959 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 960 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
960 | } | 961 | } |
961 | void KServerSocket::get_file() | 962 | void KServerSocket::get_file() |
962 | { | 963 | { |
963 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | 964 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); |
964 | 965 | ||
965 | piTime.start(); | 966 | piTime.start(); |
966 | piFileString = ""; | 967 | piFileString = ""; |
967 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | 968 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); |
968 | } | 969 | } |
969 | 970 | ||
970 | 971 | ||
971 | void KServerSocket::readBackFileFromSocket() | 972 | void KServerSocket::readBackFileFromSocket() |
972 | { | 973 | { |
973 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | 974 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); |
974 | while ( mSocket->canReadLine () ) { | 975 | while ( mSocket->canReadLine () ) { |
975 | piTime.restart(); | 976 | piTime.restart(); |
976 | QString line = mSocket->readLine (); | 977 | QString line = mSocket->readLine (); |
977 | piFileString += line; | 978 | piFileString += line; |
978 | //qDebug("readline: %s ", line.latin1()); | 979 | //qDebug("readline: %s ", line.latin1()); |
979 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | 980 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); |
980 | 981 | ||
981 | } | 982 | } |
982 | if ( piTime.elapsed () < 3000 ) { | 983 | if ( piTime.elapsed () < 3000 ) { |
983 | // wait for more | 984 | // wait for more |
984 | //qDebug("waitformore "); | 985 | //qDebug("waitformore "); |
985 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | 986 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); |
986 | return; | 987 | return; |
987 | } | 988 | } |
988 | QString fileName = mFileName; | 989 | QString fileName = mFileName; |
989 | QFile file ( fileName ); | 990 | QFile file ( fileName ); |
990 | if (!file.open( IO_WriteOnly ) ) { | 991 | if (!file.open( IO_WriteOnly ) ) { |
991 | delete mSyncActionDialog; | 992 | delete mSyncActionDialog; |
992 | mSyncActionDialog = 0; | 993 | mSyncActionDialog = 0; |
993 | qDebug("error open cal file "); | 994 | qDebug("error open cal file "); |
994 | piFileString = ""; | 995 | piFileString = ""; |
995 | emit file_received( false ); | 996 | emit file_received( false ); |
996 | blockRC = false; | 997 | blockRC = false; |
997 | return ; | 998 | return ; |
998 | 999 | ||
999 | } | 1000 | } |
1000 | 1001 | ||
1001 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1002 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1002 | QTextStream ts ( &file ); | 1003 | QTextStream ts ( &file ); |
1003 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 1004 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
1004 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | 1005 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); |
1005 | ts << piFileString; | 1006 | ts << piFileString; |
1006 | mSocket->close(); | 1007 | mSocket->close(); |
1007 | if ( mSocket->state() == QSocket::Idle ) | 1008 | if ( mSocket->state() == QSocket::Idle ) |
1008 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1009 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1009 | file.close(); | 1010 | file.close(); |
1010 | delete mSyncActionDialog; | 1011 | delete mSyncActionDialog; |
1011 | mSyncActionDialog = 0; | 1012 | mSyncActionDialog = 0; |
1012 | piFileString = ""; | 1013 | piFileString = ""; |
1013 | blockRC = false; | 1014 | blockRC = false; |
1014 | emit file_received( true ); | 1015 | emit file_received( true ); |
1015 | 1016 | ||
1016 | } | 1017 | } |
1017 | 1018 | ||
1018 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) | 1019 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) |
1019 | { | 1020 | { |
1020 | mPassWord = password; | 1021 | mPassWord = password; |
1021 | mSocket = 0; | 1022 | mSocket = 0; |
1022 | mPort = port; | 1023 | mPort = port; |
1023 | mHost = host; | 1024 | mHost = host; |
1024 | 1025 | ||
1025 | mRetVal = quiet; | 1026 | mRetVal = quiet; |
1026 | mTimerSocket = new QTimer ( this ); | 1027 | mTimerSocket = new QTimer ( this ); |
1027 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); | 1028 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); |
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 52e2772..0eb3323 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h | |||
@@ -1,228 +1,227 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
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 | $Id$ | 20 | $Id$ |
21 | */ | 21 | */ |
22 | #ifndef _KSYNCMANAGER_H | 22 | #ifndef _KSYNCMANAGER_H |
23 | #define _KSYNCMANAGER_H | 23 | #define _KSYNCMANAGER_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qsocket.h> | 27 | #include <qsocket.h> |
28 | #include <qdatetime.h> | 28 | #include <qdatetime.h> |
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 }; |
81 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); | 79 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); |
82 | void readFile( QString ); | 80 | void readFile( QString ); |
83 | void writeFile( QString ); | 81 | void writeFile( QString ); |
84 | void sendStop(); | 82 | void sendStop(); |
85 | 83 | ||
86 | 84 | ||
87 | signals: | 85 | signals: |
88 | void commandFinished( KCommandSocket*, int ); | 86 | void commandFinished( KCommandSocket*, int ); |
89 | private slots: | 87 | private slots: |
90 | void startReadFileFromSocket(); | 88 | void startReadFileFromSocket(); |
91 | void readFileFromSocket(); | 89 | void readFileFromSocket(); |
92 | void deleteSocket(); | 90 | void deleteSocket(); |
93 | void writeFileToSocket(); | 91 | void writeFileToSocket(); |
94 | private : | 92 | private : |
95 | QSocket* mSocket; | 93 | QSocket* mSocket; |
96 | QString mPassWord; | 94 | QString mPassWord; |
97 | Q_UINT16 mPort; | 95 | Q_UINT16 mPort; |
98 | QString mHost; | 96 | QString mHost; |
99 | QString mFileName; | 97 | QString mFileName; |
100 | QTimer* mTimerSocket; | 98 | QTimer* mTimerSocket; |
101 | int mRetVal; | 99 | int mRetVal; |
102 | QTime mTime; | 100 | QTime mTime; |
103 | QString mFileString; | 101 | QString mFileString; |
104 | bool mFirst; | 102 | bool mFirst; |
105 | }; | 103 | }; |
106 | 104 | ||
107 | 105 | ||
108 | class KSyncManager : public QObject | 106 | class KSyncManager : public QObject |
109 | { | 107 | { |
110 | Q_OBJECT | 108 | Q_OBJECT |
111 | 109 | ||
112 | public: | 110 | public: |
113 | enum TargetApp { | 111 | enum TargetApp { |
114 | KOPI = 0, | 112 | KOPI = 0, |
115 | KAPI = 1, | 113 | KAPI = 1, |
116 | PWMPI = 2 }; | 114 | PWMPI = 2 }; |
117 | 115 | ||
118 | 116 | ||
119 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); | 117 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); |
120 | ~KSyncManager() ; | 118 | ~KSyncManager() ; |
121 | 119 | ||
122 | bool blockSave() { return mBlockSaveFlag; } | 120 | bool blockSave() { return mBlockSaveFlag; } |
123 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } | 121 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } |
124 | void setDefaultFileName( QString s) { mDefFileName = s ;} | 122 | void setDefaultFileName( QString s) { mDefFileName = s ;} |
125 | QString defaultFileName() { return mDefFileName ;} | 123 | QString defaultFileName() { return mDefFileName ;} |
126 | QString syncFileName(); | 124 | QString syncFileName(); |
127 | void fillSyncMenu(); | 125 | void fillSyncMenu(); |
128 | 126 | ||
129 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } | 127 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } |
130 | QString getCurrentSyncName() { return mCurrentSyncName; } | 128 | QString getCurrentSyncName() { return mCurrentSyncName; } |
131 | 129 | ||
132 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); | 130 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); |
133 | void hideProgressBar(); | 131 | void hideProgressBar(); |
134 | bool isProgressBarCanceled(); | 132 | bool isProgressBarCanceled(); |
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 ); |
183 | int mCurrentSyncProfile ; | 182 | int mCurrentSyncProfile ; |
184 | void syncRemote( KSyncProfile* prof, bool ask = true); | 183 | void syncRemote( KSyncProfile* prof, bool ask = true); |
185 | void edit_sync_options(); | 184 | void edit_sync_options(); |
186 | int ringSync(); | 185 | int ringSync(); |
187 | QString getPassword( ); | 186 | QString getPassword( ); |
188 | 187 | ||
189 | private slots: | 188 | private slots: |
190 | void confSync(); | 189 | void confSync(); |
191 | // ********************* | 190 | // ********************* |
192 | 191 | ||
193 | private: | 192 | private: |
194 | bool mBlockSaveFlag; | 193 | bool mBlockSaveFlag; |
195 | 194 | ||
196 | 195 | ||
197 | QWidget* mParent; | 196 | QWidget* mParent; |
198 | KSyncInterface* mImplementation; | 197 | KSyncInterface* mImplementation; |
199 | TargetApp mTargetApp; | 198 | TargetApp mTargetApp; |
200 | QPopupMenu* mSyncMenu; | 199 | QPopupMenu* mSyncMenu; |
201 | 200 | ||
202 | QProgressBar* bar; | 201 | QProgressBar* bar; |
203 | 202 | ||
204 | 203 | ||
205 | 204 | ||
206 | 205 | ||
207 | 206 | ||
208 | }; | 207 | }; |
209 | 208 | ||
210 | 209 | ||
211 | class KSyncInterface | 210 | class KSyncInterface |
212 | { | 211 | { |
213 | 212 | ||
214 | 213 | ||
215 | public : | 214 | public : |
216 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; | 215 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; |
217 | 216 | ||
218 | virtual bool syncExternal(KSyncManager* manager, QString resource) | 217 | virtual bool syncExternal(KSyncManager* manager, QString resource) |
219 | { | 218 | { |
220 | // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager. | 219 | // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager. |
221 | return false; | 220 | return false; |
222 | } | 221 | } |
223 | 222 | ||
224 | 223 | ||
225 | }; | 224 | }; |
226 | 225 | ||
227 | 226 | ||
228 | #endif | 227 | #endif |