author | zautrix <zautrix> | 2004-10-09 21:35:22 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-09 21:35:22 (UTC) |
commit | 213a9d993e5a4751b64e18320cfbebb000681d13 (patch) (unidiff) | |
tree | 995b465797464e689b73d3271ff4a3f8f0d3749b | |
parent | d68435216e1ebc5a7fed391157197994e13992b3 (diff) | |
download | kdepimpi-213a9d993e5a4751b64e18320cfbebb000681d13.zip kdepimpi-213a9d993e5a4751b64e18320cfbebb000681d13.tar.gz kdepimpi-213a9d993e5a4751b64e18320cfbebb000681d13.tar.bz2 |
ab phone sync implemented
-rw-r--r-- | kabc/addressbook.cpp | 44 | ||||
-rw-r--r-- | kabc/addressbook.h | 3 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 65 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 3 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 12 | ||||
-rw-r--r-- | libkdepim/phoneaccess.cpp | 24 | ||||
-rw-r--r-- | libkdepim/phoneaccess.h | 2 |
7 files changed, 123 insertions, 30 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 16927e2..d037d2f 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -2,96 +2,97 @@ | |||
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> | 41 | #include <qtextstream.h> |
42 | #include <qfile.h> | 42 | #include <qfile.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | 44 | ||
45 | #include <kglobal.h> | 45 | #include <kglobal.h> |
46 | #include <klocale.h> | 46 | #include <klocale.h> |
47 | #include <kmessagebox.h> | 47 | #include <kmessagebox.h> |
48 | #include <kdebug.h> | 48 | #include <kdebug.h> |
49 | #include <libkcal/syncdefines.h> | 49 | #include <libkcal/syncdefines.h> |
50 | #include <libkdepim/phoneaccess.h> | ||
50 | #include "addressbook.h" | 51 | #include "addressbook.h" |
51 | #include "resource.h" | 52 | #include "resource.h" |
52 | #include "vcardconverter.h" | 53 | #include "vcardconverter.h" |
53 | #include "vcardparser/vcardtool.h" | 54 | #include "vcardparser/vcardtool.h" |
54 | 55 | ||
55 | //US #include "addressbook.moc" | 56 | //US #include "addressbook.moc" |
56 | 57 | ||
57 | using namespace KABC; | 58 | using namespace KABC; |
58 | 59 | ||
59 | struct AddressBook::AddressBookData | 60 | struct AddressBook::AddressBookData |
60 | { | 61 | { |
61 | Addressee::List mAddressees; | 62 | Addressee::List mAddressees; |
62 | Addressee::List mRemovedAddressees; | 63 | Addressee::List mRemovedAddressees; |
63 | Field::List mAllFields; | 64 | Field::List mAllFields; |
64 | KConfig *mConfig; | 65 | KConfig *mConfig; |
65 | KRES::Manager<Resource> *mManager; | 66 | KRES::Manager<Resource> *mManager; |
66 | //US ErrorHandler *mErrorHandler; | 67 | //US ErrorHandler *mErrorHandler; |
67 | }; | 68 | }; |
68 | 69 | ||
69 | struct AddressBook::Iterator::IteratorData | 70 | struct AddressBook::Iterator::IteratorData |
70 | { | 71 | { |
71 | Addressee::List::Iterator mIt; | 72 | Addressee::List::Iterator mIt; |
72 | }; | 73 | }; |
73 | 74 | ||
74 | struct AddressBook::ConstIterator::ConstIteratorData | 75 | struct AddressBook::ConstIterator::ConstIteratorData |
75 | { | 76 | { |
76 | Addressee::List::ConstIterator mIt; | 77 | Addressee::List::ConstIterator mIt; |
77 | }; | 78 | }; |
78 | 79 | ||
79 | AddressBook::Iterator::Iterator() | 80 | AddressBook::Iterator::Iterator() |
80 | { | 81 | { |
81 | d = new IteratorData; | 82 | d = new IteratorData; |
82 | } | 83 | } |
83 | 84 | ||
84 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) | 85 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) |
85 | { | 86 | { |
86 | d = new IteratorData; | 87 | d = new IteratorData; |
87 | d->mIt = i.d->mIt; | 88 | d->mIt = i.d->mIt; |
88 | } | 89 | } |
89 | 90 | ||
90 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) | 91 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) |
91 | { | 92 | { |
92 | if( this == &i ) return *this; // guard against self assignment | 93 | if( this == &i ) return *this; // guard against self assignment |
93 | delete d; // delete the old data the Iterator was completely constructed before | 94 | delete d; // delete the old data the Iterator was completely constructed before |
94 | d = new IteratorData; | 95 | d = new IteratorData; |
95 | d->mIt = i.d->mIt; | 96 | d->mIt = i.d->mIt; |
96 | return *this; | 97 | return *this; |
97 | } | 98 | } |
@@ -414,96 +415,139 @@ void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool rem | |||
414 | QByteArray rawData = file.readAll(); | 415 | QByteArray rawData = file.readAll(); |
415 | file.close(); | 416 | file.close(); |
416 | QString data; | 417 | QString data; |
417 | if ( replaceLabel ) { | 418 | if ( replaceLabel ) { |
418 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); | 419 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); |
419 | data.replace ( QRegExp("LABEL") , "ADR" ); | 420 | data.replace ( QRegExp("LABEL") , "ADR" ); |
420 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); | 421 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); |
421 | } else | 422 | } else |
422 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 423 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
423 | KABC::VCardTool tool; | 424 | KABC::VCardTool tool; |
424 | list = tool.parseVCards( data ); | 425 | list = tool.parseVCards( data ); |
425 | KABC::Addressee::List::Iterator it; | 426 | KABC::Addressee::List::Iterator it; |
426 | for ( it = list.begin(); it != list.end(); ++it ) { | 427 | for ( it = list.begin(); it != list.end(); ++it ) { |
427 | (*it).setResource( 0 ); | 428 | (*it).setResource( 0 ); |
428 | if ( replaceLabel ) | 429 | if ( replaceLabel ) |
429 | (*it).removeVoice(); | 430 | (*it).removeVoice(); |
430 | if ( removeOld ) | 431 | if ( removeOld ) |
431 | (*it).setTagged( true ); | 432 | (*it).setTagged( true ); |
432 | insertAddressee( (*it), false, true ); | 433 | insertAddressee( (*it), false, true ); |
433 | } | 434 | } |
434 | if ( removeOld ) | 435 | if ( removeOld ) |
435 | removeUntagged(); | 436 | removeUntagged(); |
436 | } | 437 | } |
437 | void AddressBook::setUntagged() | 438 | void AddressBook::setUntagged() |
438 | { | 439 | { |
439 | Iterator ait; | 440 | Iterator ait; |
440 | for ( ait = begin(); ait != end(); ++ait ) { | 441 | for ( ait = begin(); ait != end(); ++ait ) { |
441 | (*ait).setTagged( false ); | 442 | (*ait).setTagged( false ); |
442 | } | 443 | } |
443 | } | 444 | } |
444 | void AddressBook::removeUntagged() | 445 | void AddressBook::removeUntagged() |
445 | { | 446 | { |
446 | Iterator ait; | 447 | Iterator ait; |
447 | bool todelete = false; | 448 | bool todelete = false; |
448 | Iterator todel; | 449 | Iterator todel; |
449 | for ( ait = begin(); ait != end(); ++ait ) { | 450 | for ( ait = begin(); ait != end(); ++ait ) { |
450 | if ( todelete ) | 451 | if ( todelete ) |
451 | removeAddressee( todel ); | 452 | removeAddressee( todel ); |
452 | if (!(*ait).tagged()) { | 453 | if (!(*ait).tagged()) { |
453 | todelete = true; | 454 | todelete = true; |
454 | todel = ait; | 455 | todel = ait; |
455 | } else | 456 | } else |
456 | todelete = false; | 457 | todelete = false; |
457 | } | 458 | } |
458 | if ( todelete ) | 459 | if ( todelete ) |
459 | removeAddressee( todel ); | 460 | removeAddressee( todel ); |
460 | deleteRemovedAddressees(); | 461 | deleteRemovedAddressees(); |
461 | } | 462 | } |
463 | void AddressBook::smplifyAddressees() | ||
464 | { | ||
465 | Iterator ait; | ||
466 | for ( ait = begin(); ait != end(); ++ait ) { | ||
467 | (*ait).simplifyEmails(); | ||
468 | (*ait).simplifyPhoneNumbers(); | ||
469 | (*ait).simplifyPhoneNumberTypes(); | ||
470 | (*ait).simplifyAddresses(); | ||
471 | } | ||
472 | } | ||
473 | void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) | ||
474 | { | ||
475 | Iterator ait; | ||
476 | for ( ait = begin(); ait != end(); ++ait ) { | ||
477 | QString id = (*ait).IDStr(); | ||
478 | (*ait).setIDStr( ":"); | ||
479 | (*ait).setExternalUID( id ); | ||
480 | (*ait).setOriginalExternalUID( id ); | ||
481 | if ( isPreSync ) | ||
482 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | ||
483 | else | ||
484 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | ||
485 | } | ||
486 | } | ||
487 | bool AddressBook::saveABphone( QString fileName ) | ||
488 | { | ||
489 | smplifyAddressees(); | ||
490 | qDebug("saveABphone:: saving AB... "); | ||
491 | if ( ! saveAB() ) | ||
492 | return false; | ||
493 | qDebug("saveABphone:: writing to phone... "); | ||
494 | if ( !PhoneAccess::writeToPhone( fileName) ) { | ||
495 | return false; | ||
496 | } | ||
497 | qDebug("saveABphone:: re-reading from phone... "); | ||
498 | if ( !PhoneAccess::readFromPhone( fileName) ) { | ||
499 | return false; | ||
500 | } | ||
501 | qDebug("reloading phone book... "); | ||
502 | if ( !load() ) | ||
503 | return false; | ||
504 | return true; | ||
505 | } | ||
462 | bool AddressBook::saveAB() | 506 | bool AddressBook::saveAB() |
463 | { | 507 | { |
464 | bool ok = true; | 508 | bool ok = true; |
465 | 509 | ||
466 | deleteRemovedAddressees(); | 510 | deleteRemovedAddressees(); |
467 | Iterator ait; | 511 | Iterator ait; |
468 | for ( ait = begin(); ait != end(); ++ait ) { | 512 | for ( ait = begin(); ait != end(); ++ait ) { |
469 | if ( !(*ait).IDStr().isEmpty() ) { | 513 | if ( !(*ait).IDStr().isEmpty() ) { |
470 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); | 514 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); |
471 | } | 515 | } |
472 | } | 516 | } |
473 | KRES::Manager<Resource>::ActiveIterator it; | 517 | KRES::Manager<Resource>::ActiveIterator it; |
474 | KRES::Manager<Resource> *manager = d->mManager; | 518 | KRES::Manager<Resource> *manager = d->mManager; |
475 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 519 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
476 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 520 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
477 | Ticket *ticket = requestSaveTicket( *it ); | 521 | Ticket *ticket = requestSaveTicket( *it ); |
478 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 522 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
479 | if ( !ticket ) { | 523 | if ( !ticket ) { |
480 | error( i18n( "Unable to save to resource '%1'. It is locked." ) | 524 | error( i18n( "Unable to save to resource '%1'. It is locked." ) |
481 | .arg( (*it)->resourceName() ) ); | 525 | .arg( (*it)->resourceName() ) ); |
482 | return false; | 526 | return false; |
483 | } | 527 | } |
484 | 528 | ||
485 | //if ( !save( ticket ) ) | 529 | //if ( !save( ticket ) ) |
486 | if ( ticket->resource() ) { | 530 | if ( ticket->resource() ) { |
487 | if ( ! ticket->resource()->save( ticket ) ) | 531 | if ( ! ticket->resource()->save( ticket ) ) |
488 | ok = false; | 532 | ok = false; |
489 | } else | 533 | } else |
490 | ok = false; | 534 | ok = false; |
491 | 535 | ||
492 | } | 536 | } |
493 | } | 537 | } |
494 | return ok; | 538 | return ok; |
495 | } | 539 | } |
496 | 540 | ||
497 | AddressBook::Iterator AddressBook::begin() | 541 | AddressBook::Iterator AddressBook::begin() |
498 | { | 542 | { |
499 | Iterator it = Iterator(); | 543 | Iterator it = Iterator(); |
500 | it.d->mIt = d->mAddressees.begin(); | 544 | it.d->mIt = d->mAddressees.begin(); |
501 | return it; | 545 | return it; |
502 | } | 546 | } |
503 | 547 | ||
504 | AddressBook::ConstIterator AddressBook::begin() const | 548 | AddressBook::ConstIterator AddressBook::begin() const |
505 | { | 549 | { |
506 | ConstIterator it = ConstIterator(); | 550 | ConstIterator it = ConstIterator(); |
507 | it.d->mIt = d->mAddressees.begin(); | 551 | it.d->mIt = d->mAddressees.begin(); |
508 | return it; | 552 | return it; |
509 | } | 553 | } |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 532e05d..cc755d1 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -97,96 +97,99 @@ class AddressBook : public QObject | |||
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 | bool saveABphone( QString fileName ); | ||
146 | void smplifyAddressees(); | ||
147 | void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); | ||
145 | void export2File( QString fileName ); | 148 | void export2File( QString fileName ); |
146 | void importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); | 149 | void importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); |
147 | void setUntagged(); | 150 | void setUntagged(); |
148 | void removeUntagged(); | 151 | void removeUntagged(); |
149 | /** | 152 | /** |
150 | Returns a iterator for first entry of address book. | 153 | Returns a iterator for first entry of address book. |
151 | */ | 154 | */ |
152 | Iterator begin(); | 155 | Iterator begin(); |
153 | 156 | ||
154 | /** | 157 | /** |
155 | Returns a const iterator for first entry of address book. | 158 | Returns a const iterator for first entry of address book. |
156 | */ | 159 | */ |
157 | ConstIterator begin() const; | 160 | ConstIterator begin() const; |
158 | 161 | ||
159 | /** | 162 | /** |
160 | Returns a iterator for first entry of address book. | 163 | Returns a iterator for first entry of address book. |
161 | */ | 164 | */ |
162 | Iterator end(); | 165 | Iterator end(); |
163 | 166 | ||
164 | /** | 167 | /** |
165 | Returns a const iterator for first entry of address book. | 168 | Returns a const iterator for first entry of address book. |
166 | */ | 169 | */ |
167 | ConstIterator end() const; | 170 | ConstIterator end() const; |
168 | 171 | ||
169 | /** | 172 | /** |
170 | Removes all entries from address book. | 173 | Removes all entries from address book. |
171 | */ | 174 | */ |
172 | void clear(); | 175 | void clear(); |
173 | 176 | ||
174 | /** | 177 | /** |
175 | Insert an Addressee object into address book. If an object with the same | 178 | Insert an Addressee object into address book. If an object with the same |
176 | unique id already exists in the address book it it replaced by the new | 179 | unique id already exists in the address book it it replaced by the new |
177 | one. If not the new object is appended to the address book. | 180 | one. If not the new object is appended to the address book. |
178 | */ | 181 | */ |
179 | void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); | 182 | void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); |
180 | 183 | ||
181 | /** | 184 | /** |
182 | Removes entry from the address book. | 185 | Removes entry from the address book. |
183 | */ | 186 | */ |
184 | void removeAddressee( const Addressee & ); | 187 | void removeAddressee( const Addressee & ); |
185 | 188 | ||
186 | /** | 189 | /** |
187 | This is like @ref removeAddressee() just above, with the difference that | 190 | This is like @ref removeAddressee() just above, with the difference that |
188 | the first element is a iterator, returned by @ref begin(). | 191 | the first element is a iterator, returned by @ref begin(). |
189 | */ | 192 | */ |
190 | void removeAddressee( const Iterator & ); | 193 | void removeAddressee( const Iterator & ); |
191 | 194 | ||
192 | /** | 195 | /** |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 452f1bc..a7967cb 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2778,122 +2778,147 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | |||
2778 | } else { | 2778 | } else { |
2779 | bool found = false; | 2779 | bool found = false; |
2780 | AddressBook::Iterator it; | 2780 | AddressBook::Iterator it; |
2781 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2781 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2782 | if ( (*it).revision().date().year() > 2003 ) { | 2782 | if ( (*it).revision().date().year() > 2003 ) { |
2783 | found = true; | 2783 | found = true; |
2784 | break; | 2784 | break; |
2785 | } | 2785 | } |
2786 | } | 2786 | } |
2787 | external = ! found; | 2787 | external = ! found; |
2788 | } | 2788 | } |
2789 | 2789 | ||
2790 | if ( external ) { | 2790 | if ( external ) { |
2791 | qDebug("Setting vcf mode to external "); | 2791 | qDebug("Setting vcf mode to external "); |
2792 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2792 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2793 | AddressBook::Iterator it; | 2793 | AddressBook::Iterator it; |
2794 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2794 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2795 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2795 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2796 | (*it).computeCsum( mCurrentSyncDevice ); | 2796 | (*it).computeCsum( mCurrentSyncDevice ); |
2797 | } | 2797 | } |
2798 | } | 2798 | } |
2799 | } | 2799 | } |
2800 | //AddressBook::Iterator it; | 2800 | //AddressBook::Iterator it; |
2801 | //QStringList vcards; | 2801 | //QStringList vcards; |
2802 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2802 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2803 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2803 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2804 | //} | 2804 | //} |
2805 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2805 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2806 | if ( syncOK ) { | 2806 | if ( syncOK ) { |
2807 | if ( syncManager->mWriteBackFile ) | 2807 | if ( syncManager->mWriteBackFile ) |
2808 | { | 2808 | { |
2809 | if ( external ) | 2809 | if ( external ) |
2810 | abLocal.removeSyncAddressees( !isXML); | 2810 | abLocal.removeSyncAddressees( !isXML); |
2811 | qDebug("Saving remote AB "); | 2811 | qDebug("Saving remote AB "); |
2812 | if ( ! abLocal.saveAB()) | 2812 | if ( ! abLocal.saveAB()) |
2813 | qDebug("Error writing back AB to file "); | 2813 | qDebug("Error writing back AB to file "); |
2814 | if ( isXML ) { | 2814 | if ( isXML ) { |
2815 | // afterwrite processing | 2815 | // afterwrite processing |
2816 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2816 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2817 | } | 2817 | } |
2818 | } | 2818 | } |
2819 | } | 2819 | } |
2820 | setModified(); | 2820 | setModified(); |
2821 | 2821 | ||
2822 | } | 2822 | } |
2823 | if ( syncOK ) | 2823 | if ( syncOK ) |
2824 | mViewManager->refreshView(); | 2824 | mViewManager->refreshView(); |
2825 | return syncOK; | 2825 | return syncOK; |
2826 | #if 0 | ||
2827 | 2826 | ||
2828 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | ||
2829 | getEventViewerDialog()->setSyncMode( true ); | ||
2830 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | ||
2831 | getEventViewerDialog()->setSyncMode( false ); | ||
2832 | if ( syncOK ) { | ||
2833 | if ( KOPrefs::instance()->mWriteBackFile ) | ||
2834 | { | ||
2835 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | ||
2836 | storage->save(); | ||
2837 | } | ||
2838 | } | ||
2839 | setModified(); | ||
2840 | } | ||
2841 | |||
2842 | #endif | ||
2843 | } | 2827 | } |
2844 | 2828 | ||
2845 | 2829 | ||
2846 | //this is a overwritten callbackmethods from the syncinterface | 2830 | //this is a overwritten callbackmethods from the syncinterface |
2847 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2831 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2848 | { | 2832 | { |
2833 | if ( resource == "phone" ) | ||
2834 | return syncPhone(); | ||
2849 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2835 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2850 | 2836 | ||
2851 | AddressBook abLocal( resource,"syncContact"); | 2837 | AddressBook abLocal( resource,"syncContact"); |
2852 | bool syncOK = false; | 2838 | bool syncOK = false; |
2853 | if ( abLocal.load() ) { | 2839 | if ( abLocal.load() ) { |
2854 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2840 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2855 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2841 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2856 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2842 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2857 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2843 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2858 | if ( syncOK ) { | 2844 | if ( syncOK ) { |
2859 | if ( syncManager->mWriteBackFile ) { | 2845 | if ( syncManager->mWriteBackFile ) { |
2860 | abLocal.saveAB(); | 2846 | abLocal.saveAB(); |
2861 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2847 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2862 | } | 2848 | } |
2863 | } | 2849 | } |
2864 | setModified(); | 2850 | setModified(); |
2865 | } | 2851 | } |
2866 | if ( syncOK ) | 2852 | if ( syncOK ) |
2867 | mViewManager->refreshView(); | 2853 | mViewManager->refreshView(); |
2868 | return syncOK; | 2854 | return syncOK; |
2869 | 2855 | ||
2870 | } | 2856 | } |
2871 | 2857 | void KABCore::message( QString m ) | |
2872 | void KABCore::getFile( bool success ) | ||
2873 | { | 2858 | { |
2859 | |||
2860 | topLevelWidget()->setCaption( m ); | ||
2874 | QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); | 2861 | QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); |
2862 | } | ||
2863 | bool KABCore::syncPhone() | ||
2864 | { | ||
2865 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | ||
2866 | QString fileName; | ||
2867 | #ifdef _WIN32_ | ||
2868 | fileName = locateLocal("tmp", "phonefile.vcf"); | ||
2869 | #else | ||
2870 | fileName = "/tmp/phonefile.vcf"; | ||
2871 | #endif | ||
2872 | if ( !PhoneAccess::readFromPhone( fileName) ) { | ||
2873 | message(i18n("Phone access failed!")); | ||
2874 | return false; | ||
2875 | } | ||
2876 | AddressBook abLocal( fileName,"syncContact"); | ||
2877 | bool syncOK = false; | ||
2878 | if ( abLocal.load() ) { | ||
2879 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | ||
2880 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | ||
2881 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | ||
2882 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | ||
2883 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | ||
2884 | if ( syncOK ) { | ||
2885 | if ( syncManager->mWriteBackFile ) { | ||
2886 | abLocal.saveABphone( fileName ); | ||
2887 | abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | ||
2888 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | ||
2889 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | ||
2890 | } | ||
2891 | } | ||
2892 | setModified(); | ||
2893 | } | ||
2894 | if ( syncOK ) | ||
2895 | mViewManager->refreshView(); | ||
2896 | return syncOK; | ||
2897 | } | ||
2898 | void KABCore::getFile( bool success ) | ||
2899 | { | ||
2875 | if ( ! success ) { | 2900 | if ( ! success ) { |
2876 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2901 | message( i18n("Error receiving file. Nothing changed!") ); |
2877 | return; | 2902 | return; |
2878 | } | 2903 | } |
2879 | mAddressBook->importFromFile( sentSyncFile() , false, true ); | 2904 | mAddressBook->importFromFile( sentSyncFile() , false, true ); |
2880 | topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); | 2905 | message( i18n("Pi-Sync successful!") ); |
2881 | mViewManager->refreshView(); | 2906 | mViewManager->refreshView(); |
2882 | } | 2907 | } |
2883 | void KABCore::syncFileRequest() | 2908 | void KABCore::syncFileRequest() |
2884 | { | 2909 | { |
2885 | mAddressBook->export2File( sentSyncFile() ); | 2910 | mAddressBook->export2File( sentSyncFile() ); |
2886 | } | 2911 | } |
2887 | QString KABCore::sentSyncFile() | 2912 | QString KABCore::sentSyncFile() |
2888 | { | 2913 | { |
2889 | #ifdef _WIN32_ | 2914 | #ifdef _WIN32_ |
2890 | return locateLocal( "tmp", "copysyncab.vcf" ); | 2915 | return locateLocal( "tmp", "copysyncab.vcf" ); |
2891 | #else | 2916 | #else |
2892 | return QString( "/tmp/copysyncab.vcf" ); | 2917 | return QString( "/tmp/copysyncab.vcf" ); |
2893 | #endif | 2918 | #endif |
2894 | } | 2919 | } |
2895 | 2920 | ||
2896 | void KABCore::setCaptionBack() | 2921 | void KABCore::setCaptionBack() |
2897 | { | 2922 | { |
2898 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 2923 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
2899 | } | 2924 | } |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 43c5f99..04ce33d 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -419,65 +419,66 @@ class KABCore : public QWidget, public KSyncInterface | |||
419 | KAction *mActionPaste; | 419 | KAction *mActionPaste; |
420 | KAction *mActionSelectAll; | 420 | KAction *mActionSelectAll; |
421 | KAction *mActionUndo; | 421 | KAction *mActionUndo; |
422 | KAction *mActionRedo; | 422 | KAction *mActionRedo; |
423 | KAction *mActionDelete; | 423 | KAction *mActionDelete; |
424 | 424 | ||
425 | //US settings menu | 425 | //US settings menu |
426 | KAction *mActionConfigResources; | 426 | KAction *mActionConfigResources; |
427 | KAction *mActionConfigKAddressbook; | 427 | KAction *mActionConfigKAddressbook; |
428 | KAction *mActionConfigShortcuts; | 428 | KAction *mActionConfigShortcuts; |
429 | KAction *mActionConfigureToolbars; | 429 | KAction *mActionConfigureToolbars; |
430 | KAction *mActionKeyBindings; | 430 | KAction *mActionKeyBindings; |
431 | KToggleAction *mActionJumpBar; | 431 | KToggleAction *mActionJumpBar; |
432 | KToggleAction *mActionDetails; | 432 | KToggleAction *mActionDetails; |
433 | KAction *mActionWhoAmI; | 433 | KAction *mActionWhoAmI; |
434 | KAction *mActionCategories; | 434 | KAction *mActionCategories; |
435 | KAction *mActionAboutKAddressbook; | 435 | KAction *mActionAboutKAddressbook; |
436 | KAction *mActionLicence; | 436 | KAction *mActionLicence; |
437 | KAction *mActionFaq; | 437 | KAction *mActionFaq; |
438 | 438 | ||
439 | KAction *mActionDeleteView; | 439 | KAction *mActionDeleteView; |
440 | 440 | ||
441 | QPopupMenu *viewMenu; | 441 | QPopupMenu *viewMenu; |
442 | QPopupMenu *filterMenu; | 442 | QPopupMenu *filterMenu; |
443 | QPopupMenu *settingsMenu; | 443 | QPopupMenu *settingsMenu; |
444 | QPopupMenu *changeMenu; | 444 | QPopupMenu *changeMenu; |
445 | //US QAction *mActionSave; | 445 | //US QAction *mActionSave; |
446 | QPopupMenu *ImportMenu; | 446 | QPopupMenu *ImportMenu; |
447 | QPopupMenu *ExportMenu; | 447 | QPopupMenu *ExportMenu; |
448 | //LR additional methods | 448 | //LR additional methods |
449 | KAction *mActionRemoveVoice; | 449 | KAction *mActionRemoveVoice; |
450 | KAction * mActionImportOL; | 450 | KAction * mActionImportOL; |
451 | 451 | ||
452 | #ifndef KAB_EMBEDDED | 452 | #ifndef KAB_EMBEDDED |
453 | KAddressBookService *mAddressBookService; | 453 | KAddressBookService *mAddressBookService; |
454 | #endif //KAB_EMBEDDED | 454 | #endif //KAB_EMBEDDED |
455 | 455 | ||
456 | class KABCorePrivate; | 456 | class KABCorePrivate; |
457 | KABCorePrivate *d; | 457 | KABCorePrivate *d; |
458 | //US bool mBlockSaveFlag; | 458 | //US bool mBlockSaveFlag; |
459 | 459 | ||
460 | #ifdef KAB_EMBEDDED | 460 | #ifdef KAB_EMBEDDED |
461 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 461 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
462 | #endif //KAB_EMBEDDED | 462 | #endif //KAB_EMBEDDED |
463 | 463 | ||
464 | //this are the overwritten callbackmethods from the syncinterface | 464 | //this are the overwritten callbackmethods from the syncinterface |
465 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 465 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
466 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 466 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
467 | 467 | bool syncPhone(); | |
468 | void message( QString m ); | ||
468 | 469 | ||
469 | // LR ******************************* | 470 | // LR ******************************* |
470 | // sync stuff! | 471 | // sync stuff! |
471 | QString sentSyncFile(); | 472 | QString sentSyncFile(); |
472 | QPopupMenu *syncMenu; | 473 | QPopupMenu *syncMenu; |
473 | KSyncManager* syncManager; | 474 | KSyncManager* syncManager; |
474 | int mGlobalSyncMode; | 475 | int mGlobalSyncMode; |
475 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); | 476 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); |
476 | KABC::Addressee getLastSyncAddressee(); | 477 | KABC::Addressee getLastSyncAddressee(); |
477 | QDateTime mLastAddressbookSync; | 478 | QDateTime mLastAddressbookSync; |
478 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); | 479 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); |
479 | // ********************* | 480 | // ********************* |
480 | 481 | ||
481 | }; | 482 | }; |
482 | 483 | ||
483 | #endif | 484 | #endif |
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index c39413e..3555dc6 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -246,106 +246,102 @@ ulong PhoneFormat::getCsumEvent( Event* event ) | |||
246 | list.append( "0" ); | 246 | list.append( "0" ); |
247 | list.append( "20991231T000000" ); | 247 | list.append( "20991231T000000" ); |
248 | } | 248 | } |
249 | 249 | ||
250 | } | 250 | } |
251 | attList << list.join(""); | 251 | attList << list.join(""); |
252 | attList << event->categoriesStr(); | 252 | attList << event->categoriesStr(); |
253 | //qDebug("csum cat %s", event->categoriesStr().latin1()); | 253 | //qDebug("csum cat %s", event->categoriesStr().latin1()); |
254 | 254 | ||
255 | attList << event->secrecyStr(); | 255 | attList << event->secrecyStr(); |
256 | return PhoneFormat::getCsum(attList ); | 256 | return PhoneFormat::getCsum(attList ); |
257 | } | 257 | } |
258 | ulong PhoneFormat::getCsum( const QStringList & attList) | 258 | ulong PhoneFormat::getCsum( const QStringList & attList) |
259 | { | 259 | { |
260 | int max = attList.count(); | 260 | int max = attList.count(); |
261 | ulong cSum = 0; | 261 | ulong cSum = 0; |
262 | int j,k,i; | 262 | int j,k,i; |
263 | int add; | 263 | int add; |
264 | for ( i = 0; i < max ; ++i ) { | 264 | for ( i = 0; i < max ; ++i ) { |
265 | QString s = attList[i]; | 265 | QString s = attList[i]; |
266 | if ( ! s.isEmpty() ){ | 266 | if ( ! s.isEmpty() ){ |
267 | j = s.length(); | 267 | j = s.length(); |
268 | for ( k = 0; k < j; ++k ) { | 268 | for ( k = 0; k < j; ++k ) { |
269 | int mul = k +1; | 269 | int mul = k +1; |
270 | add = s[k].unicode (); | 270 | add = s[k].unicode (); |
271 | if ( k < 16 ) | 271 | if ( k < 16 ) |
272 | mul = mul * mul; | 272 | mul = mul * mul; |
273 | int ii = i+1; | 273 | int ii = i+1; |
274 | add = add * mul *ii*ii*ii; | 274 | add = add * mul *ii*ii*ii; |
275 | cSum += add; | 275 | cSum += add; |
276 | } | 276 | } |
277 | } | 277 | } |
278 | 278 | ||
279 | } | 279 | } |
280 | //QString dump = attList.join(","); | 280 | //QString dump = attList.join(","); |
281 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 281 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
282 | 282 | ||
283 | return cSum; | 283 | return cSum; |
284 | 284 | ||
285 | } | 285 | } |
286 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); | 286 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); |
287 | #include <stdlib.h> | 287 | #include <stdlib.h> |
288 | #define DEBUGMODE false | 288 | #define DEBUGMODE false |
289 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | 289 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) |
290 | { | 290 | { |
291 | 291 | ||
292 | QString fileName; | 292 | QString fileName; |
293 | #ifdef _WIN32_ | 293 | #ifdef _WIN32_ |
294 | fileName = locateLocal("tmp", "tempfile.vcs"); | 294 | fileName = locateLocal("tmp", "phonefile.vcs"); |
295 | #else | 295 | #else |
296 | fileName = "/tmp/kdepimtemp.vcs"; | 296 | fileName = "/tmp/phonefile.vcs"; |
297 | #endif | 297 | #endif |
298 | #ifdef DESKTOP_VERSION | 298 | QString command; |
299 | QString command ="./kammu --backup " + fileName + " -yes" ; | 299 | int ret = PhoneAccess::readFromPhone( fileName ); |
300 | #else | ||
301 | QString command ="kammu --backup " + fileName + " -yes" ; | ||
302 | #endif | ||
303 | int ret = system ( command.latin1() ); | ||
304 | if ( ret != 0 ) { | 300 | if ( ret != 0 ) { |
305 | qDebug("Error::command returned %d", ret); | 301 | qDebug("Error::command returned %d", ret); |
306 | return false; | 302 | return false; |
307 | } | 303 | } |
308 | VCalFormat vfload; | 304 | VCalFormat vfload; |
309 | vfload.setLocalTime ( true ); | 305 | vfload.setLocalTime ( true ); |
310 | qDebug("loading file ..."); | 306 | qDebug("loading file ..."); |
311 | 307 | ||
312 | if ( ! vfload.load( calendar, fileName ) ) | 308 | if ( ! vfload.load( calendar, fileName ) ) |
313 | return false; | 309 | return false; |
314 | QPtrList<Event> er = calendar->rawEvents(); | 310 | QPtrList<Event> er = calendar->rawEvents(); |
315 | Event* ev = er.first(); | 311 | Event* ev = er.first(); |
316 | qDebug("reading events... "); | 312 | qDebug("reading events... "); |
317 | while ( ev ) { | 313 | while ( ev ) { |
318 | QStringList cat = ev->categories(); | 314 | QStringList cat = ev->categories(); |
319 | if ( cat.contains( "MeetingDEF" )) { | 315 | if ( cat.contains( "MeetingDEF" )) { |
320 | ev->setCategories( QStringList() ); | 316 | ev->setCategories( QStringList() ); |
321 | } | 317 | } |
322 | int id = ev->pilotId(); | 318 | int id = ev->pilotId(); |
323 | Event *event; | 319 | Event *event; |
324 | event = existingCal->event( mProfileName ,QString::number( id ) ); | 320 | event = existingCal->event( mProfileName ,QString::number( id ) ); |
325 | if ( event ) { | 321 | if ( event ) { |
326 | event = (Event*)event->clone(); | 322 | event = (Event*)event->clone(); |
327 | copyEvent( event, ev ); | 323 | copyEvent( event, ev ); |
328 | calendar->deleteEvent( ev ); | 324 | calendar->deleteEvent( ev ); |
329 | calendar->addEvent( event); | 325 | calendar->addEvent( event); |
330 | } | 326 | } |
331 | else | 327 | else |
332 | event = ev; | 328 | event = ev; |
333 | uint cSum; | 329 | uint cSum; |
334 | cSum = PhoneFormat::getCsumEvent( event ); | 330 | cSum = PhoneFormat::getCsumEvent( event ); |
335 | event->setCsum( mProfileName, QString::number( cSum )); | 331 | event->setCsum( mProfileName, QString::number( cSum )); |
336 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 332 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
337 | event->setID( mProfileName,QString::number( id ) ); | 333 | event->setID( mProfileName,QString::number( id ) ); |
338 | ev = er.next(); | 334 | ev = er.next(); |
339 | } | 335 | } |
340 | { | 336 | { |
341 | qDebug("reading todos... "); | 337 | qDebug("reading todos... "); |
342 | QPtrList<Todo> tr = calendar->rawTodos(); | 338 | QPtrList<Todo> tr = calendar->rawTodos(); |
343 | Todo* ev = tr.first(); | 339 | Todo* ev = tr.first(); |
344 | while ( ev ) { | 340 | while ( ev ) { |
345 | 341 | ||
346 | QStringList cat = ev->categories(); | 342 | QStringList cat = ev->categories(); |
347 | if ( cat.contains( "MeetingDEF" )) { | 343 | if ( cat.contains( "MeetingDEF" )) { |
348 | ev->setCategories( QStringList() ); | 344 | ev->setCategories( QStringList() ); |
349 | } | 345 | } |
350 | int id = ev->pilotId(); | 346 | int id = ev->pilotId(); |
351 | Todo *event; | 347 | Todo *event; |
diff --git a/libkdepim/phoneaccess.cpp b/libkdepim/phoneaccess.cpp index fe914dd..5fafa1f 100644 --- a/libkdepim/phoneaccess.cpp +++ b/libkdepim/phoneaccess.cpp | |||
@@ -98,54 +98,76 @@ void PhoneAccess::writeConfig( QString device, QString connection, QString model | |||
98 | write = true; | 98 | write = true; |
99 | content += "connection = "; | 99 | content += "connection = "; |
100 | content += connection; | 100 | content += connection; |
101 | content += "\n"; | 101 | content += "\n"; |
102 | } | 102 | } |
103 | if ( addPort ) { | 103 | if ( addPort ) { |
104 | write = true; | 104 | write = true; |
105 | content += "port = "; | 105 | content += "port = "; |
106 | content += device; | 106 | content += device; |
107 | content += "\n"; | 107 | content += "\n"; |
108 | 108 | ||
109 | } | 109 | } |
110 | if ( addModel ) { | 110 | if ( addModel ) { |
111 | write = true; | 111 | write = true; |
112 | content += "model = "; | 112 | content += "model = "; |
113 | content += model; | 113 | content += model; |
114 | content += "\n"; | 114 | content += "\n"; |
115 | } | 115 | } |
116 | if ( write ) { | 116 | if ( write ) { |
117 | if (!file.open( IO_WriteOnly ) ) { | 117 | if (!file.open( IO_WriteOnly ) ) { |
118 | qDebug("Error: cannot write file %s ", fileName.latin1() ); | 118 | qDebug("Error: cannot write file %s ", fileName.latin1() ); |
119 | return; | 119 | return; |
120 | } | 120 | } |
121 | qDebug("Writing file %s ", fileName.latin1() ); | 121 | qDebug("Writing file %s ", fileName.latin1() ); |
122 | QTextStream ts( &file ); | 122 | QTextStream ts( &file ); |
123 | ts << content ; | 123 | ts << content ; |
124 | file.close(); | 124 | file.close(); |
125 | } | 125 | } |
126 | 126 | ||
127 | } | 127 | } |
128 | 128 | ||
129 | 129 | ||
130 | bool PhoneAccess::writeToPhone( QString fileName) | 130 | bool PhoneAccess::writeToPhone( QString fileName) |
131 | { | 131 | { |
132 | 132 | ||
133 | #ifdef DESKTOP_VERSION | 133 | #ifdef DESKTOP_VERSION |
134 | #ifdef _WIN32_ | 134 | #ifdef _WIN32_ |
135 | QString command ="kammu --restore " + fileName ; | 135 | QString command ="kammu --restore " + fileName ; |
136 | #else | 136 | #else |
137 | QString command ="./kammu --restore " + fileName ; | 137 | QString command ="./kammu --restore " + fileName ; |
138 | #endif | 138 | #endif |
139 | #else | 139 | #else |
140 | QString command ="kammu --restore " + fileName ; | 140 | QString command ="kammu --restore " + fileName ; |
141 | #endif | 141 | #endif |
142 | int ret; | 142 | int ret; |
143 | while ( (ret = system ( command.latin1())) != 0 ) { | 143 | while ( (ret = system ( command.latin1())) != 0 ) { |
144 | qDebug("Error S::command returned %d.", ret); | 144 | qDebug("Error S::command returned %d.", ret); |
145 | int retval = KMessageBox::warningContinueCancel(0, | 145 | int retval = KMessageBox::warningContinueCancel(0, |
146 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone access"),i18n("Retry"),i18n("Cancel")); | 146 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); |
147 | if ( retval != KMessageBox::Continue ) | ||
148 | return false; | ||
149 | } | ||
150 | return true; | ||
151 | } | ||
152 | bool PhoneAccess::readFromPhone( QString fileName) | ||
153 | { | ||
154 | |||
155 | #ifdef DESKTOP_VERSION | ||
156 | #ifdef _WIN32_ | ||
157 | QString command ="kammu --backup " + fileName + " -yes" ; | ||
158 | #else | ||
159 | QString command ="./kammu --backup " + fileName + " -yes" ; | ||
160 | #endif | ||
161 | #else | ||
162 | QString command ="kammu --backup " + fileName + " -yes" ; | ||
163 | #endif | ||
164 | int ret; | ||
165 | while ( (ret = system ( command.latin1())) != 0 ) { | ||
166 | qDebug("Error S::command returned %d.", ret); | ||
167 | int retval = KMessageBox::warningContinueCancel(0, | ||
168 | i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KDE/Pim phone access"),i18n("Retry"),i18n("Cancel")); | ||
147 | if ( retval != KMessageBox::Continue ) | 169 | if ( retval != KMessageBox::Continue ) |
148 | return false; | 170 | return false; |
149 | } | 171 | } |
150 | return true; | 172 | return true; |
151 | } | 173 | } |
diff --git a/libkdepim/phoneaccess.h b/libkdepim/phoneaccess.h index b7c4732..80840e2 100644 --- a/libkdepim/phoneaccess.h +++ b/libkdepim/phoneaccess.h | |||
@@ -1,42 +1,44 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | #ifndef PHONEACCESS_H | 21 | #ifndef PHONEACCESS_H |
22 | #define PHONEACCESS_H | 22 | #define PHONEACCESS_H |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qobject.h> | ||
25 | 26 | ||
26 | 27 | ||
27 | 28 | ||
28 | /** | 29 | /** |
29 | This class implements the calendar format used by Phone. | 30 | This class implements the calendar format used by Phone. |
30 | */ | 31 | */ |
31 | 32 | ||
32 | class PhoneAccess : public QObject { | 33 | class PhoneAccess : public QObject { |
33 | public: | 34 | public: |
34 | 35 | ||
35 | static void writeConfig( QString device,QString connection, QString model ); | 36 | static void writeConfig( QString device,QString connection, QString model ); |
36 | static bool writeToPhone( QString fileName ); | 37 | static bool writeToPhone( QString fileName ); |
38 | static bool readFromPhone( QString fileName ); | ||
37 | 39 | ||
38 | }; | 40 | }; |
39 | 41 | ||
40 | 42 | ||
41 | 43 | ||
42 | #endif | 44 | #endif |