author | zautrix <zautrix> | 2004-09-18 13:13:58 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-18 13:13:58 (UTC) |
commit | bb16660f29fc709791aa0ee4cb63a40710a994a8 (patch) (unidiff) | |
tree | 5d7387987848039bb3594a624b819d136a38b0cd | |
parent | 4ec7c78ebd2c5a79ff224e9b07d9a3164f7fe602 (diff) | |
download | kdepimpi-bb16660f29fc709791aa0ee4cb63a40710a994a8.zip kdepimpi-bb16660f29fc709791aa0ee4cb63a40710a994a8.tar.gz kdepimpi-bb16660f29fc709791aa0ee4cb63a40710a994a8.tar.bz2 |
more AB syncing
-rw-r--r-- | kabc/addressbook.cpp | 27 | ||||
-rw-r--r-- | kabc/addressbook.h | 5 | ||||
-rw-r--r-- | kabc/addressee.cpp | 54 | ||||
-rw-r--r-- | kabc/addressee.h | 12 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 93 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 2 |
6 files changed, 156 insertions, 37 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 70eda1b..9332e21 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -1,236 +1,237 @@ | |||
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 | 41 | ||
42 | #include <kglobal.h> | 42 | #include <kglobal.h> |
43 | #include <klocale.h> | 43 | #include <klocale.h> |
44 | #include <kdebug.h> | 44 | #include <kdebug.h> |
45 | #include <libkcal/syncdefines.h> | ||
45 | #include "addressbook.h" | 46 | #include "addressbook.h" |
46 | #include "resource.h" | 47 | #include "resource.h" |
47 | 48 | ||
48 | //US #include "addressbook.moc" | 49 | //US #include "addressbook.moc" |
49 | 50 | ||
50 | using namespace KABC; | 51 | using namespace KABC; |
51 | 52 | ||
52 | struct AddressBook::AddressBookData | 53 | struct AddressBook::AddressBookData |
53 | { | 54 | { |
54 | Addressee::List mAddressees; | 55 | Addressee::List mAddressees; |
55 | Addressee::List mRemovedAddressees; | 56 | Addressee::List mRemovedAddressees; |
56 | Field::List mAllFields; | 57 | Field::List mAllFields; |
57 | KConfig *mConfig; | 58 | KConfig *mConfig; |
58 | KRES::Manager<Resource> *mManager; | 59 | KRES::Manager<Resource> *mManager; |
59 | //US ErrorHandler *mErrorHandler; | 60 | //US ErrorHandler *mErrorHandler; |
60 | }; | 61 | }; |
61 | 62 | ||
62 | struct AddressBook::Iterator::IteratorData | 63 | struct AddressBook::Iterator::IteratorData |
63 | { | 64 | { |
64 | Addressee::List::Iterator mIt; | 65 | Addressee::List::Iterator mIt; |
65 | }; | 66 | }; |
66 | 67 | ||
67 | struct AddressBook::ConstIterator::ConstIteratorData | 68 | struct AddressBook::ConstIterator::ConstIteratorData |
68 | { | 69 | { |
69 | Addressee::List::ConstIterator mIt; | 70 | Addressee::List::ConstIterator mIt; |
70 | }; | 71 | }; |
71 | 72 | ||
72 | AddressBook::Iterator::Iterator() | 73 | AddressBook::Iterator::Iterator() |
73 | { | 74 | { |
74 | d = new IteratorData; | 75 | d = new IteratorData; |
75 | } | 76 | } |
76 | 77 | ||
77 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) | 78 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) |
78 | { | 79 | { |
79 | d = new IteratorData; | 80 | d = new IteratorData; |
80 | d->mIt = i.d->mIt; | 81 | d->mIt = i.d->mIt; |
81 | } | 82 | } |
82 | 83 | ||
83 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) | 84 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) |
84 | { | 85 | { |
85 | if( this == &i ) return *this; // guard against self assignment | 86 | if( this == &i ) return *this; // guard against self assignment |
86 | delete d; // delete the old data the Iterator was completely constructed before | 87 | delete d; // delete the old data the Iterator was completely constructed before |
87 | d = new IteratorData; | 88 | d = new IteratorData; |
88 | d->mIt = i.d->mIt; | 89 | d->mIt = i.d->mIt; |
89 | return *this; | 90 | return *this; |
90 | } | 91 | } |
91 | 92 | ||
92 | AddressBook::Iterator::~Iterator() | 93 | AddressBook::Iterator::~Iterator() |
93 | { | 94 | { |
94 | delete d; | 95 | delete d; |
95 | } | 96 | } |
96 | 97 | ||
97 | const Addressee &AddressBook::Iterator::operator*() const | 98 | const Addressee &AddressBook::Iterator::operator*() const |
98 | { | 99 | { |
99 | return *(d->mIt); | 100 | return *(d->mIt); |
100 | } | 101 | } |
101 | 102 | ||
102 | Addressee &AddressBook::Iterator::operator*() | 103 | Addressee &AddressBook::Iterator::operator*() |
103 | { | 104 | { |
104 | return *(d->mIt); | 105 | return *(d->mIt); |
105 | } | 106 | } |
106 | 107 | ||
107 | Addressee *AddressBook::Iterator::operator->() | 108 | Addressee *AddressBook::Iterator::operator->() |
108 | { | 109 | { |
109 | return &(*(d->mIt)); | 110 | return &(*(d->mIt)); |
110 | } | 111 | } |
111 | 112 | ||
112 | AddressBook::Iterator &AddressBook::Iterator::operator++() | 113 | AddressBook::Iterator &AddressBook::Iterator::operator++() |
113 | { | 114 | { |
114 | (d->mIt)++; | 115 | (d->mIt)++; |
115 | return *this; | 116 | return *this; |
116 | } | 117 | } |
117 | 118 | ||
118 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) | 119 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) |
119 | { | 120 | { |
120 | (d->mIt)++; | 121 | (d->mIt)++; |
121 | return *this; | 122 | return *this; |
122 | } | 123 | } |
123 | 124 | ||
124 | AddressBook::Iterator &AddressBook::Iterator::operator--() | 125 | AddressBook::Iterator &AddressBook::Iterator::operator--() |
125 | { | 126 | { |
126 | (d->mIt)--; | 127 | (d->mIt)--; |
127 | return *this; | 128 | return *this; |
128 | } | 129 | } |
129 | 130 | ||
130 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) | 131 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) |
131 | { | 132 | { |
132 | (d->mIt)--; | 133 | (d->mIt)--; |
133 | return *this; | 134 | return *this; |
134 | } | 135 | } |
135 | 136 | ||
136 | bool AddressBook::Iterator::operator==( const Iterator &it ) | 137 | bool AddressBook::Iterator::operator==( const Iterator &it ) |
137 | { | 138 | { |
138 | return ( d->mIt == it.d->mIt ); | 139 | return ( d->mIt == it.d->mIt ); |
139 | } | 140 | } |
140 | 141 | ||
141 | bool AddressBook::Iterator::operator!=( const Iterator &it ) | 142 | bool AddressBook::Iterator::operator!=( const Iterator &it ) |
142 | { | 143 | { |
143 | return ( d->mIt != it.d->mIt ); | 144 | return ( d->mIt != it.d->mIt ); |
144 | } | 145 | } |
145 | 146 | ||
146 | 147 | ||
147 | AddressBook::ConstIterator::ConstIterator() | 148 | AddressBook::ConstIterator::ConstIterator() |
148 | { | 149 | { |
149 | d = new ConstIteratorData; | 150 | d = new ConstIteratorData; |
150 | } | 151 | } |
151 | 152 | ||
152 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) | 153 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) |
153 | { | 154 | { |
154 | d = new ConstIteratorData; | 155 | d = new ConstIteratorData; |
155 | d->mIt = i.d->mIt; | 156 | d->mIt = i.d->mIt; |
156 | } | 157 | } |
157 | 158 | ||
158 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) | 159 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) |
159 | { | 160 | { |
160 | if( this == &i ) return *this; // guard for self assignment | 161 | if( this == &i ) return *this; // guard for self assignment |
161 | delete d; // delete the old data because the Iterator was really constructed before | 162 | delete d; // delete the old data because the Iterator was really constructed before |
162 | d = new ConstIteratorData; | 163 | d = new ConstIteratorData; |
163 | d->mIt = i.d->mIt; | 164 | d->mIt = i.d->mIt; |
164 | return *this; | 165 | return *this; |
165 | } | 166 | } |
166 | 167 | ||
167 | AddressBook::ConstIterator::~ConstIterator() | 168 | AddressBook::ConstIterator::~ConstIterator() |
168 | { | 169 | { |
169 | delete d; | 170 | delete d; |
170 | } | 171 | } |
171 | 172 | ||
172 | const Addressee &AddressBook::ConstIterator::operator*() const | 173 | const Addressee &AddressBook::ConstIterator::operator*() const |
173 | { | 174 | { |
174 | return *(d->mIt); | 175 | return *(d->mIt); |
175 | } | 176 | } |
176 | 177 | ||
177 | const Addressee* AddressBook::ConstIterator::operator->() const | 178 | const Addressee* AddressBook::ConstIterator::operator->() const |
178 | { | 179 | { |
179 | return &(*(d->mIt)); | 180 | return &(*(d->mIt)); |
180 | } | 181 | } |
181 | 182 | ||
182 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() | 183 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() |
183 | { | 184 | { |
184 | (d->mIt)++; | 185 | (d->mIt)++; |
185 | return *this; | 186 | return *this; |
186 | } | 187 | } |
187 | 188 | ||
188 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) | 189 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) |
189 | { | 190 | { |
190 | (d->mIt)++; | 191 | (d->mIt)++; |
191 | return *this; | 192 | return *this; |
192 | } | 193 | } |
193 | 194 | ||
194 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() | 195 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() |
195 | { | 196 | { |
196 | (d->mIt)--; | 197 | (d->mIt)--; |
197 | return *this; | 198 | return *this; |
198 | } | 199 | } |
199 | 200 | ||
200 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) | 201 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) |
201 | { | 202 | { |
202 | (d->mIt)--; | 203 | (d->mIt)--; |
203 | return *this; | 204 | return *this; |
204 | } | 205 | } |
205 | 206 | ||
206 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) | 207 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) |
207 | { | 208 | { |
208 | return ( d->mIt == it.d->mIt ); | 209 | return ( d->mIt == it.d->mIt ); |
209 | } | 210 | } |
210 | 211 | ||
211 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 212 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) |
212 | { | 213 | { |
213 | return ( d->mIt != it.d->mIt ); | 214 | return ( d->mIt != it.d->mIt ); |
214 | } | 215 | } |
215 | 216 | ||
216 | 217 | ||
217 | AddressBook::AddressBook() | 218 | AddressBook::AddressBook() |
218 | { | 219 | { |
219 | init(0, "contact"); | 220 | init(0, "contact"); |
220 | } | 221 | } |
221 | 222 | ||
222 | AddressBook::AddressBook( const QString &config ) | 223 | AddressBook::AddressBook( const QString &config ) |
223 | { | 224 | { |
224 | init(config, "contact"); | 225 | init(config, "contact"); |
225 | } | 226 | } |
226 | 227 | ||
227 | AddressBook::AddressBook( const QString &config, const QString &family ) | 228 | AddressBook::AddressBook( const QString &config, const QString &family ) |
228 | { | 229 | { |
229 | init(config, family); | 230 | init(config, family); |
230 | 231 | ||
231 | } | 232 | } |
232 | 233 | ||
233 | // the default family is "contact" | 234 | // the default family is "contact" |
234 | void AddressBook::init(const QString &config, const QString &family ) | 235 | void AddressBook::init(const QString &config, const QString &family ) |
235 | { | 236 | { |
236 | d = new AddressBookData; | 237 | d = new AddressBookData; |
@@ -323,384 +324,410 @@ AddressBook::~AddressBook() | |||
323 | delete d->mManager; d->mManager = 0; | 324 | delete d->mManager; d->mManager = 0; |
324 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 325 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
325 | delete d; d = 0; | 326 | delete d; d = 0; |
326 | } | 327 | } |
327 | 328 | ||
328 | bool AddressBook::load() | 329 | bool AddressBook::load() |
329 | { | 330 | { |
330 | 331 | ||
331 | 332 | ||
332 | clear(); | 333 | clear(); |
333 | 334 | ||
334 | KRES::Manager<Resource>::ActiveIterator it; | 335 | KRES::Manager<Resource>::ActiveIterator it; |
335 | bool ok = true; | 336 | bool ok = true; |
336 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 337 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
337 | if ( !(*it)->load() ) { | 338 | if ( !(*it)->load() ) { |
338 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 339 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
339 | ok = false; | 340 | ok = false; |
340 | } | 341 | } |
341 | 342 | ||
342 | // mark all addressees as unchanged | 343 | // mark all addressees as unchanged |
343 | Addressee::List::Iterator addrIt; | 344 | Addressee::List::Iterator addrIt; |
344 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) | 345 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) |
345 | (*addrIt).setChanged( false ); | 346 | (*addrIt).setChanged( false ); |
346 | 347 | ||
347 | return ok; | 348 | return ok; |
348 | } | 349 | } |
349 | 350 | ||
350 | bool AddressBook::save( Ticket *ticket ) | 351 | bool AddressBook::save( Ticket *ticket ) |
351 | { | 352 | { |
352 | kdDebug(5700) << "AddressBook::save()"<< endl; | 353 | kdDebug(5700) << "AddressBook::save()"<< endl; |
353 | 354 | ||
354 | if ( ticket->resource() ) { | 355 | if ( ticket->resource() ) { |
355 | deleteRemovedAddressees(); | 356 | deleteRemovedAddressees(); |
356 | return ticket->resource()->save( ticket ); | 357 | return ticket->resource()->save( ticket ); |
357 | } | 358 | } |
358 | 359 | ||
359 | return false; | 360 | return false; |
360 | } | 361 | } |
361 | bool AddressBook::saveAB() | 362 | bool AddressBook::saveAB() |
362 | { | 363 | { |
363 | bool ok = true; | 364 | bool ok = true; |
364 | 365 | ||
365 | deleteRemovedAddressees(); | 366 | deleteRemovedAddressees(); |
366 | 367 | ||
367 | KRES::Manager<Resource>::ActiveIterator it; | 368 | KRES::Manager<Resource>::ActiveIterator it; |
368 | KRES::Manager<Resource> *manager = d->mManager; | 369 | KRES::Manager<Resource> *manager = d->mManager; |
369 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 370 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
370 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 371 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
371 | Ticket *ticket = requestSaveTicket( *it ); | 372 | Ticket *ticket = requestSaveTicket( *it ); |
372 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 373 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
373 | if ( !ticket ) { | 374 | if ( !ticket ) { |
374 | error( i18n( "Unable to save to resource '%1'. It is locked." ) | 375 | error( i18n( "Unable to save to resource '%1'. It is locked." ) |
375 | .arg( (*it)->resourceName() ) ); | 376 | .arg( (*it)->resourceName() ) ); |
376 | return false; | 377 | return false; |
377 | } | 378 | } |
378 | 379 | ||
379 | //if ( !save( ticket ) ) | 380 | //if ( !save( ticket ) ) |
380 | if ( ticket->resource() ) { | 381 | if ( ticket->resource() ) { |
381 | if ( ! ticket->resource()->save( ticket ) ) | 382 | if ( ! ticket->resource()->save( ticket ) ) |
382 | ok = false; | 383 | ok = false; |
383 | } else | 384 | } else |
384 | ok = false; | 385 | ok = false; |
385 | 386 | ||
386 | } | 387 | } |
387 | } | 388 | } |
388 | return ok; | 389 | return ok; |
389 | } | 390 | } |
390 | 391 | ||
391 | AddressBook::Iterator AddressBook::begin() | 392 | AddressBook::Iterator AddressBook::begin() |
392 | { | 393 | { |
393 | Iterator it = Iterator(); | 394 | Iterator it = Iterator(); |
394 | it.d->mIt = d->mAddressees.begin(); | 395 | it.d->mIt = d->mAddressees.begin(); |
395 | return it; | 396 | return it; |
396 | } | 397 | } |
397 | 398 | ||
398 | AddressBook::ConstIterator AddressBook::begin() const | 399 | AddressBook::ConstIterator AddressBook::begin() const |
399 | { | 400 | { |
400 | ConstIterator it = ConstIterator(); | 401 | ConstIterator it = ConstIterator(); |
401 | it.d->mIt = d->mAddressees.begin(); | 402 | it.d->mIt = d->mAddressees.begin(); |
402 | return it; | 403 | return it; |
403 | } | 404 | } |
404 | 405 | ||
405 | AddressBook::Iterator AddressBook::end() | 406 | AddressBook::Iterator AddressBook::end() |
406 | { | 407 | { |
407 | Iterator it = Iterator(); | 408 | Iterator it = Iterator(); |
408 | it.d->mIt = d->mAddressees.end(); | 409 | it.d->mIt = d->mAddressees.end(); |
409 | return it; | 410 | return it; |
410 | } | 411 | } |
411 | 412 | ||
412 | AddressBook::ConstIterator AddressBook::end() const | 413 | AddressBook::ConstIterator AddressBook::end() const |
413 | { | 414 | { |
414 | ConstIterator it = ConstIterator(); | 415 | ConstIterator it = ConstIterator(); |
415 | it.d->mIt = d->mAddressees.end(); | 416 | it.d->mIt = d->mAddressees.end(); |
416 | return it; | 417 | return it; |
417 | } | 418 | } |
418 | 419 | ||
419 | void AddressBook::clear() | 420 | void AddressBook::clear() |
420 | { | 421 | { |
421 | d->mAddressees.clear(); | 422 | d->mAddressees.clear(); |
422 | } | 423 | } |
423 | 424 | ||
424 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 425 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) |
425 | { | 426 | { |
426 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; | 427 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; |
427 | 428 | ||
428 | if ( !resource ) | 429 | if ( !resource ) |
429 | { | 430 | { |
430 | qDebug("AddressBook::requestSaveTicket no resource" ); | 431 | qDebug("AddressBook::requestSaveTicket no resource" ); |
431 | resource = standardResource(); | 432 | resource = standardResource(); |
432 | } | 433 | } |
433 | 434 | ||
434 | KRES::Manager<Resource>::ActiveIterator it; | 435 | KRES::Manager<Resource>::ActiveIterator it; |
435 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 436 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
436 | if ( (*it) == resource ) { | 437 | if ( (*it) == resource ) { |
437 | if ( (*it)->readOnly() || !(*it)->isOpen() ) | 438 | if ( (*it)->readOnly() || !(*it)->isOpen() ) |
438 | return 0; | 439 | return 0; |
439 | else | 440 | else |
440 | return (*it)->requestSaveTicket(); | 441 | return (*it)->requestSaveTicket(); |
441 | } | 442 | } |
442 | } | 443 | } |
443 | 444 | ||
444 | return 0; | 445 | return 0; |
445 | } | 446 | } |
446 | 447 | ||
447 | void AddressBook::insertAddressee( const Addressee &a ) | 448 | void AddressBook::insertAddressee( const Addressee &a ) |
448 | { | 449 | { |
449 | Addressee::List::Iterator it; | 450 | Addressee::List::Iterator it; |
450 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { | 451 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { |
451 | if ( a.uid() == (*it).uid() ) { | 452 | if ( a.uid() == (*it).uid() ) { |
452 | bool changed = false; | 453 | bool changed = false; |
453 | Addressee addr = a; | 454 | Addressee addr = a; |
454 | if ( addr != (*it) ) | 455 | if ( addr != (*it) ) |
455 | changed = true; | 456 | changed = true; |
456 | 457 | ||
457 | (*it) = a; | 458 | (*it) = a; |
458 | if ( (*it).resource() == 0 ) | 459 | if ( (*it).resource() == 0 ) |
459 | (*it).setResource( standardResource() ); | 460 | (*it).setResource( standardResource() ); |
460 | 461 | ||
461 | if ( changed ) { | 462 | if ( changed ) { |
462 | (*it).setRevision( QDateTime::currentDateTime() ); | 463 | (*it).setRevision( QDateTime::currentDateTime() ); |
463 | (*it).setChanged( true ); | 464 | (*it).setChanged( true ); |
464 | } | 465 | } |
465 | 466 | ||
466 | return; | 467 | return; |
467 | } | 468 | } |
468 | } | 469 | } |
469 | d->mAddressees.append( a ); | 470 | d->mAddressees.append( a ); |
470 | Addressee& addr = d->mAddressees.last(); | 471 | Addressee& addr = d->mAddressees.last(); |
471 | if ( addr.resource() == 0 ) | 472 | if ( addr.resource() == 0 ) |
472 | addr.setResource( standardResource() ); | 473 | addr.setResource( standardResource() ); |
473 | 474 | ||
474 | addr.setChanged( true ); | 475 | addr.setChanged( true ); |
475 | } | 476 | } |
476 | 477 | ||
477 | void AddressBook::removeAddressee( const Addressee &a ) | 478 | void AddressBook::removeAddressee( const Addressee &a ) |
478 | { | 479 | { |
479 | Iterator it; | 480 | Iterator it; |
480 | for ( it = begin(); it != end(); ++it ) { | 481 | for ( it = begin(); it != end(); ++it ) { |
481 | if ( a.uid() == (*it).uid() ) { | 482 | if ( a.uid() == (*it).uid() ) { |
482 | removeAddressee( it ); | 483 | removeAddressee( it ); |
483 | return; | 484 | return; |
484 | } | 485 | } |
485 | } | 486 | } |
486 | } | 487 | } |
487 | 488 | ||
488 | void AddressBook::removeAddressee( const Iterator &it ) | 489 | void AddressBook::removeAddressee( const Iterator &it ) |
489 | { | 490 | { |
490 | d->mRemovedAddressees.append( (*it) ); | 491 | d->mRemovedAddressees.append( (*it) ); |
491 | d->mAddressees.remove( it.d->mIt ); | 492 | d->mAddressees.remove( it.d->mIt ); |
492 | } | 493 | } |
493 | 494 | ||
494 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 495 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
495 | { | 496 | { |
496 | Iterator it; | 497 | Iterator it; |
497 | for ( it = begin(); it != end(); ++it ) { | 498 | for ( it = begin(); it != end(); ++it ) { |
498 | if ( a.uid() == (*it).uid() ) { | 499 | if ( a.uid() == (*it).uid() ) { |
499 | return it; | 500 | return it; |
500 | } | 501 | } |
501 | } | 502 | } |
502 | return end(); | 503 | return end(); |
503 | } | 504 | } |
504 | 505 | ||
505 | Addressee AddressBook::findByUid( const QString &uid ) | 506 | Addressee AddressBook::findByUid( const QString &uid ) |
506 | { | 507 | { |
507 | Iterator it; | 508 | Iterator it; |
508 | for ( it = begin(); it != end(); ++it ) { | 509 | for ( it = begin(); it != end(); ++it ) { |
509 | if ( uid == (*it).uid() ) { | 510 | if ( uid == (*it).uid() ) { |
510 | return *it; | 511 | return *it; |
511 | } | 512 | } |
512 | } | 513 | } |
513 | return Addressee(); | 514 | return Addressee(); |
514 | } | 515 | } |
516 | Addressee::List AddressBook::getExternLastSyncAddressees() | ||
517 | { | ||
518 | Addressee::List results; | ||
519 | |||
520 | Iterator it; | ||
521 | for ( it = begin(); it != end(); ++it ) { | ||
522 | if ( (*it).uid().left( 20 ) == "last-syncAddressee-" ) { | ||
523 | if ( (*it).familyName().left(3) == "E: " ) | ||
524 | results.append( *it ); | ||
525 | } | ||
526 | } | ||
527 | |||
528 | return results; | ||
529 | } | ||
530 | void AddressBook::resetTempSyncStat() | ||
531 | { | ||
532 | |||
533 | |||
534 | Iterator it; | ||
535 | for ( it = begin(); it != end(); ++it ) { | ||
536 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); | ||
537 | } | ||
538 | |||
539 | } | ||
540 | |||
541 | |||
515 | 542 | ||
516 | Addressee::List AddressBook::allAddressees() | 543 | Addressee::List AddressBook::allAddressees() |
517 | { | 544 | { |
518 | return d->mAddressees; | 545 | return d->mAddressees; |
519 | } | 546 | } |
520 | 547 | ||
521 | Addressee::List AddressBook::findByName( const QString &name ) | 548 | Addressee::List AddressBook::findByName( const QString &name ) |
522 | { | 549 | { |
523 | Addressee::List results; | 550 | Addressee::List results; |
524 | 551 | ||
525 | Iterator it; | 552 | Iterator it; |
526 | for ( it = begin(); it != end(); ++it ) { | 553 | for ( it = begin(); it != end(); ++it ) { |
527 | if ( name == (*it).realName() ) { | 554 | if ( name == (*it).realName() ) { |
528 | results.append( *it ); | 555 | results.append( *it ); |
529 | } | 556 | } |
530 | } | 557 | } |
531 | 558 | ||
532 | return results; | 559 | return results; |
533 | } | 560 | } |
534 | 561 | ||
535 | Addressee::List AddressBook::findByEmail( const QString &email ) | 562 | Addressee::List AddressBook::findByEmail( const QString &email ) |
536 | { | 563 | { |
537 | Addressee::List results; | 564 | Addressee::List results; |
538 | QStringList mailList; | 565 | QStringList mailList; |
539 | 566 | ||
540 | Iterator it; | 567 | Iterator it; |
541 | for ( it = begin(); it != end(); ++it ) { | 568 | for ( it = begin(); it != end(); ++it ) { |
542 | mailList = (*it).emails(); | 569 | mailList = (*it).emails(); |
543 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { | 570 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { |
544 | if ( email == (*ite) ) { | 571 | if ( email == (*ite) ) { |
545 | results.append( *it ); | 572 | results.append( *it ); |
546 | } | 573 | } |
547 | } | 574 | } |
548 | } | 575 | } |
549 | 576 | ||
550 | return results; | 577 | return results; |
551 | } | 578 | } |
552 | 579 | ||
553 | Addressee::List AddressBook::findByCategory( const QString &category ) | 580 | Addressee::List AddressBook::findByCategory( const QString &category ) |
554 | { | 581 | { |
555 | Addressee::List results; | 582 | Addressee::List results; |
556 | 583 | ||
557 | Iterator it; | 584 | Iterator it; |
558 | for ( it = begin(); it != end(); ++it ) { | 585 | for ( it = begin(); it != end(); ++it ) { |
559 | if ( (*it).hasCategory( category) ) { | 586 | if ( (*it).hasCategory( category) ) { |
560 | results.append( *it ); | 587 | results.append( *it ); |
561 | } | 588 | } |
562 | } | 589 | } |
563 | 590 | ||
564 | return results; | 591 | return results; |
565 | } | 592 | } |
566 | 593 | ||
567 | void AddressBook::dump() const | 594 | void AddressBook::dump() const |
568 | { | 595 | { |
569 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; | 596 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; |
570 | 597 | ||
571 | ConstIterator it; | 598 | ConstIterator it; |
572 | for( it = begin(); it != end(); ++it ) { | 599 | for( it = begin(); it != end(); ++it ) { |
573 | (*it).dump(); | 600 | (*it).dump(); |
574 | } | 601 | } |
575 | 602 | ||
576 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; | 603 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; |
577 | } | 604 | } |
578 | 605 | ||
579 | QString AddressBook::identifier() | 606 | QString AddressBook::identifier() |
580 | { | 607 | { |
581 | QStringList identifier; | 608 | QStringList identifier; |
582 | 609 | ||
583 | 610 | ||
584 | KRES::Manager<Resource>::ActiveIterator it; | 611 | KRES::Manager<Resource>::ActiveIterator it; |
585 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 612 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
586 | if ( !(*it)->identifier().isEmpty() ) | 613 | if ( !(*it)->identifier().isEmpty() ) |
587 | identifier.append( (*it)->identifier() ); | 614 | identifier.append( (*it)->identifier() ); |
588 | } | 615 | } |
589 | 616 | ||
590 | return identifier.join( ":" ); | 617 | return identifier.join( ":" ); |
591 | } | 618 | } |
592 | 619 | ||
593 | Field::List AddressBook::fields( int category ) | 620 | Field::List AddressBook::fields( int category ) |
594 | { | 621 | { |
595 | if ( d->mAllFields.isEmpty() ) { | 622 | if ( d->mAllFields.isEmpty() ) { |
596 | d->mAllFields = Field::allFields(); | 623 | d->mAllFields = Field::allFields(); |
597 | } | 624 | } |
598 | 625 | ||
599 | if ( category == Field::All ) return d->mAllFields; | 626 | if ( category == Field::All ) return d->mAllFields; |
600 | 627 | ||
601 | Field::List result; | 628 | Field::List result; |
602 | Field::List::ConstIterator it; | 629 | Field::List::ConstIterator it; |
603 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { | 630 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { |
604 | if ( (*it)->category() & category ) result.append( *it ); | 631 | if ( (*it)->category() & category ) result.append( *it ); |
605 | } | 632 | } |
606 | 633 | ||
607 | return result; | 634 | return result; |
608 | } | 635 | } |
609 | 636 | ||
610 | bool AddressBook::addCustomField( const QString &label, int category, | 637 | bool AddressBook::addCustomField( const QString &label, int category, |
611 | const QString &key, const QString &app ) | 638 | const QString &key, const QString &app ) |
612 | { | 639 | { |
613 | if ( d->mAllFields.isEmpty() ) { | 640 | if ( d->mAllFields.isEmpty() ) { |
614 | d->mAllFields = Field::allFields(); | 641 | d->mAllFields = Field::allFields(); |
615 | } | 642 | } |
616 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; | 643 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; |
617 | QString a = app.isNull() ? KGlobal::getAppName() : app; | 644 | QString a = app.isNull() ? KGlobal::getAppName() : app; |
618 | 645 | ||
619 | QString k = key.isNull() ? label : key; | 646 | QString k = key.isNull() ? label : key; |
620 | 647 | ||
621 | Field *field = Field::createCustomField( label, category, k, a ); | 648 | Field *field = Field::createCustomField( label, category, k, a ); |
622 | 649 | ||
623 | if ( !field ) return false; | 650 | if ( !field ) return false; |
624 | 651 | ||
625 | d->mAllFields.append( field ); | 652 | d->mAllFields.append( field ); |
626 | 653 | ||
627 | return true; | 654 | return true; |
628 | } | 655 | } |
629 | 656 | ||
630 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) | 657 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) |
631 | { | 658 | { |
632 | if (!ab.d) return s; | 659 | if (!ab.d) return s; |
633 | 660 | ||
634 | return s << ab.d->mAddressees; | 661 | return s << ab.d->mAddressees; |
635 | } | 662 | } |
636 | 663 | ||
637 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) | 664 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) |
638 | { | 665 | { |
639 | if (!ab.d) return s; | 666 | if (!ab.d) return s; |
640 | 667 | ||
641 | s >> ab.d->mAddressees; | 668 | s >> ab.d->mAddressees; |
642 | 669 | ||
643 | return s; | 670 | return s; |
644 | } | 671 | } |
645 | 672 | ||
646 | bool AddressBook::addResource( Resource *resource ) | 673 | bool AddressBook::addResource( Resource *resource ) |
647 | { | 674 | { |
648 | if ( !resource->open() ) { | 675 | if ( !resource->open() ) { |
649 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; | 676 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; |
650 | return false; | 677 | return false; |
651 | } | 678 | } |
652 | 679 | ||
653 | resource->setAddressBook( this ); | 680 | resource->setAddressBook( this ); |
654 | 681 | ||
655 | d->mManager->add( resource ); | 682 | d->mManager->add( resource ); |
656 | return true; | 683 | return true; |
657 | } | 684 | } |
658 | 685 | ||
659 | bool AddressBook::removeResource( Resource *resource ) | 686 | bool AddressBook::removeResource( Resource *resource ) |
660 | { | 687 | { |
661 | resource->close(); | 688 | resource->close(); |
662 | 689 | ||
663 | if ( resource == standardResource() ) | 690 | if ( resource == standardResource() ) |
664 | d->mManager->setStandardResource( 0 ); | 691 | d->mManager->setStandardResource( 0 ); |
665 | 692 | ||
666 | resource->setAddressBook( 0 ); | 693 | resource->setAddressBook( 0 ); |
667 | 694 | ||
668 | d->mManager->remove( resource ); | 695 | d->mManager->remove( resource ); |
669 | return true; | 696 | return true; |
670 | } | 697 | } |
671 | 698 | ||
672 | QPtrList<Resource> AddressBook::resources() | 699 | QPtrList<Resource> AddressBook::resources() |
673 | { | 700 | { |
674 | QPtrList<Resource> list; | 701 | QPtrList<Resource> list; |
675 | 702 | ||
676 | // qDebug("AddressBook::resources() 1"); | 703 | // qDebug("AddressBook::resources() 1"); |
677 | 704 | ||
678 | KRES::Manager<Resource>::ActiveIterator it; | 705 | KRES::Manager<Resource>::ActiveIterator it; |
679 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 706 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
680 | list.append( *it ); | 707 | list.append( *it ); |
681 | 708 | ||
682 | return list; | 709 | return list; |
683 | } | 710 | } |
684 | 711 | ||
685 | /*US | 712 | /*US |
686 | void AddressBook::setErrorHandler( ErrorHandler *handler ) | 713 | void AddressBook::setErrorHandler( ErrorHandler *handler ) |
687 | { | 714 | { |
688 | delete d->mErrorHandler; | 715 | delete d->mErrorHandler; |
689 | d->mErrorHandler = handler; | 716 | d->mErrorHandler = handler; |
690 | } | 717 | } |
691 | */ | 718 | */ |
692 | 719 | ||
693 | void AddressBook::error( const QString& msg ) | 720 | void AddressBook::error( const QString& msg ) |
694 | { | 721 | { |
695 | /*US | 722 | /*US |
696 | if ( !d->mErrorHandler ) // create default error handler | 723 | if ( !d->mErrorHandler ) // create default error handler |
697 | d->mErrorHandler = new ConsoleErrorHandler; | 724 | d->mErrorHandler = new ConsoleErrorHandler; |
698 | 725 | ||
699 | if ( d->mErrorHandler ) | 726 | if ( d->mErrorHandler ) |
700 | d->mErrorHandler->error( msg ); | 727 | d->mErrorHandler->error( msg ); |
701 | else | 728 | else |
702 | kdError(5700) << "no error handler defined" << endl; | 729 | kdError(5700) << "no error handler defined" << endl; |
703 | */ | 730 | */ |
704 | kdDebug(5700) << "msg" << endl; | 731 | kdDebug(5700) << "msg" << endl; |
705 | qDebug(msg); | 732 | qDebug(msg); |
706 | } | 733 | } |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index e43de31..05225f9 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -99,230 +99,235 @@ class AddressBook : public QObject | |||
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 | ||
146 | /** | 146 | /** |
147 | Returns a iterator for first entry of address book. | 147 | Returns a iterator for first entry of address book. |
148 | */ | 148 | */ |
149 | Iterator begin(); | 149 | Iterator begin(); |
150 | 150 | ||
151 | /** | 151 | /** |
152 | Returns a const iterator for first entry of address book. | 152 | Returns a const iterator for first entry of address book. |
153 | */ | 153 | */ |
154 | ConstIterator begin() const; | 154 | ConstIterator begin() const; |
155 | 155 | ||
156 | /** | 156 | /** |
157 | Returns a iterator for first entry of address book. | 157 | Returns a iterator for first entry of address book. |
158 | */ | 158 | */ |
159 | Iterator end(); | 159 | Iterator end(); |
160 | 160 | ||
161 | /** | 161 | /** |
162 | Returns a const iterator for first entry of address book. | 162 | Returns a const iterator for first entry of address book. |
163 | */ | 163 | */ |
164 | ConstIterator end() const; | 164 | ConstIterator end() const; |
165 | 165 | ||
166 | /** | 166 | /** |
167 | Removes all entries from address book. | 167 | Removes all entries from address book. |
168 | */ | 168 | */ |
169 | void clear(); | 169 | void clear(); |
170 | 170 | ||
171 | /** | 171 | /** |
172 | Insert an Addressee object into address book. If an object with the same | 172 | 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 | 173 | 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. | 174 | one. If not the new object is appended to the address book. |
175 | */ | 175 | */ |
176 | void insertAddressee( const Addressee & ); | 176 | void insertAddressee( const Addressee & ); |
177 | 177 | ||
178 | /** | 178 | /** |
179 | Removes entry from the address book. | 179 | Removes entry from the address book. |
180 | */ | 180 | */ |
181 | void removeAddressee( const Addressee & ); | 181 | void removeAddressee( const Addressee & ); |
182 | 182 | ||
183 | /** | 183 | /** |
184 | This is like @ref removeAddressee() just above, with the difference that | 184 | This is like @ref removeAddressee() just above, with the difference that |
185 | the first element is a iterator, returned by @ref begin(). | 185 | the first element is a iterator, returned by @ref begin(). |
186 | */ | 186 | */ |
187 | void removeAddressee( const Iterator & ); | 187 | void removeAddressee( const Iterator & ); |
188 | 188 | ||
189 | /** | 189 | /** |
190 | Find the specified entry in address book. Returns end(), if the entry | 190 | Find the specified entry in address book. Returns end(), if the entry |
191 | couldn't be found. | 191 | couldn't be found. |
192 | */ | 192 | */ |
193 | Iterator find( const Addressee & ); | 193 | Iterator find( const Addressee & ); |
194 | 194 | ||
195 | /** | 195 | /** |
196 | Find the entry specified by an unique id. Returns an empty Addressee | 196 | 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. | 197 | object, if the address book does not contain an entry with this id. |
198 | */ | 198 | */ |
199 | Addressee findByUid( const QString & ); | 199 | Addressee findByUid( const QString & ); |
200 | 200 | ||
201 | 201 | ||
202 | /** | 202 | /** |
203 | Returns a list of all addressees in the address book. This list can | 203 | Returns a list of all addressees in the address book. This list can |
204 | be sorted with @ref KABC::AddresseeList for example. | 204 | be sorted with @ref KABC::AddresseeList for example. |
205 | */ | 205 | */ |
206 | Addressee::List allAddressees(); | 206 | Addressee::List allAddressees(); |
207 | 207 | ||
208 | /** | 208 | /** |
209 | Find all entries with the specified name in the address book. Returns | 209 | Find all entries with the specified name in the address book. Returns |
210 | an empty list, if no entries could be found. | 210 | an empty list, if no entries could be found. |
211 | */ | 211 | */ |
212 | Addressee::List findByName( const QString & ); | 212 | Addressee::List findByName( const QString & ); |
213 | 213 | ||
214 | /** | 214 | /** |
215 | Find all entries with the specified email address in the address book. | 215 | Find all entries with the specified email address in the address book. |
216 | Returns an empty list, if no entries could be found. | 216 | Returns an empty list, if no entries could be found. |
217 | */ | 217 | */ |
218 | Addressee::List findByEmail( const QString & ); | 218 | Addressee::List findByEmail( const QString & ); |
219 | 219 | ||
220 | /** | 220 | /** |
221 | Find all entries wich have the specified category in the address book. | 221 | Find all entries wich have the specified category in the address book. |
222 | Returns an empty list, if no entries could be found. | 222 | Returns an empty list, if no entries could be found. |
223 | */ | 223 | */ |
224 | Addressee::List findByCategory( const QString & ); | 224 | Addressee::List findByCategory( const QString & ); |
225 | 225 | ||
226 | /** | 226 | /** |
227 | Return a string identifying this addressbook. | 227 | Return a string identifying this addressbook. |
228 | */ | 228 | */ |
229 | virtual QString identifier(); | 229 | virtual QString identifier(); |
230 | 230 | ||
231 | /** | 231 | /** |
232 | Used for debug output. | 232 | Used for debug output. |
233 | */ | 233 | */ |
234 | void dump() const; | 234 | void dump() const; |
235 | 235 | ||
236 | void emitAddressBookLocked() { emit addressBookLocked( this ); } | 236 | void emitAddressBookLocked() { emit addressBookLocked( this ); } |
237 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } | 237 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } |
238 | void emitAddressBookChanged() { emit addressBookChanged( this ); } | 238 | void emitAddressBookChanged() { emit addressBookChanged( this ); } |
239 | 239 | ||
240 | /** | 240 | /** |
241 | Return list of all Fields known to the address book which are associated | 241 | Return list of all Fields known to the address book which are associated |
242 | with the given field category. | 242 | with the given field category. |
243 | */ | 243 | */ |
244 | Field::List fields( int category = Field::All ); | 244 | Field::List fields( int category = Field::All ); |
245 | 245 | ||
246 | /** | 246 | /** |
247 | Add custom field to address book. | 247 | Add custom field to address book. |
248 | 248 | ||
249 | @param label User visible label of the field. | 249 | @param label User visible label of the field. |
250 | @param category Ored list of field categories. | 250 | @param category Ored list of field categories. |
251 | @param key Identifier used as key for reading and writing the field. | 251 | @param key Identifier used as key for reading and writing the field. |
252 | @param app String used as application key for reading and writing | 252 | @param app String used as application key for reading and writing |
253 | the field. | 253 | the field. |
254 | */ | 254 | */ |
255 | bool addCustomField( const QString &label, int category = Field::All, | 255 | bool addCustomField( const QString &label, int category = Field::All, |
256 | const QString &key = QString::null, | 256 | const QString &key = QString::null, |
257 | const QString &app = QString::null ); | 257 | const QString &app = QString::null ); |
258 | 258 | ||
259 | 259 | ||
260 | /** | 260 | /** |
261 | Add address book resource. | 261 | Add address book resource. |
262 | */ | 262 | */ |
263 | bool addResource( Resource * ); | 263 | bool addResource( Resource * ); |
264 | 264 | ||
265 | /** | 265 | /** |
266 | Remove address book resource. | 266 | Remove address book resource. |
267 | */ | 267 | */ |
268 | bool removeResource( Resource * ); | 268 | bool removeResource( Resource * ); |
269 | 269 | ||
270 | /** | 270 | /** |
271 | Return pointer list of all resources. | 271 | Return pointer list of all resources. |
272 | */ | 272 | */ |
273 | QPtrList<Resource> resources(); | 273 | QPtrList<Resource> resources(); |
274 | 274 | ||
275 | /** | 275 | /** |
276 | Set the @p ErrorHandler, that is used by @ref error() to | 276 | Set the @p ErrorHandler, that is used by @ref error() to |
277 | provide gui-independend error messages. | 277 | provide gui-independend error messages. |
278 | */ | 278 | */ |
279 | void setErrorHandler( ErrorHandler * ); | 279 | void setErrorHandler( ErrorHandler * ); |
280 | 280 | ||
281 | /** | 281 | /** |
282 | Shows gui independend error messages. | 282 | Shows gui independend error messages. |
283 | */ | 283 | */ |
284 | void error( const QString& ); | 284 | void error( const QString& ); |
285 | 285 | ||
286 | /** | 286 | /** |
287 | Query all resources to clean up their lock files | 287 | Query all resources to clean up their lock files |
288 | */ | 288 | */ |
289 | void cleanUp(); | 289 | void cleanUp(); |
290 | 290 | ||
291 | // sync stuff | ||
292 | Addressee::List getExternLastSyncAddressees(); | ||
293 | void resetTempSyncStat(); | ||
294 | |||
295 | |||
291 | signals: | 296 | signals: |
292 | /** | 297 | /** |
293 | Emitted, when the address book has changed on disk. | 298 | Emitted, when the address book has changed on disk. |
294 | */ | 299 | */ |
295 | void addressBookChanged( AddressBook * ); | 300 | void addressBookChanged( AddressBook * ); |
296 | 301 | ||
297 | /** | 302 | /** |
298 | Emitted, when the address book has been locked for writing. | 303 | Emitted, when the address book has been locked for writing. |
299 | */ | 304 | */ |
300 | void addressBookLocked( AddressBook * ); | 305 | void addressBookLocked( AddressBook * ); |
301 | 306 | ||
302 | /** | 307 | /** |
303 | Emitted, when the address book has been unlocked. | 308 | Emitted, when the address book has been unlocked. |
304 | */ | 309 | */ |
305 | void addressBookUnlocked( AddressBook * ); | 310 | void addressBookUnlocked( AddressBook * ); |
306 | 311 | ||
307 | protected: | 312 | protected: |
308 | void deleteRemovedAddressees(); | 313 | void deleteRemovedAddressees(); |
309 | void setStandardResource( Resource * ); | 314 | void setStandardResource( Resource * ); |
310 | Resource *standardResource(); | 315 | Resource *standardResource(); |
311 | KRES::Manager<Resource> *resourceManager(); | 316 | KRES::Manager<Resource> *resourceManager(); |
312 | 317 | ||
313 | void init(const QString &config, const QString &family); | 318 | void init(const QString &config, const QString &family); |
314 | 319 | ||
315 | private: | 320 | private: |
316 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 | 321 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 |
317 | 322 | ||
318 | 323 | ||
319 | struct AddressBookData; | 324 | struct AddressBookData; |
320 | AddressBookData *d; | 325 | AddressBookData *d; |
321 | }; | 326 | }; |
322 | 327 | ||
323 | QDataStream &operator<<( QDataStream &, const AddressBook & ); | 328 | QDataStream &operator<<( QDataStream &, const AddressBook & ); |
324 | QDataStream &operator>>( QDataStream &, AddressBook & ); | 329 | QDataStream &operator>>( QDataStream &, AddressBook & ); |
325 | 330 | ||
326 | } | 331 | } |
327 | 332 | ||
328 | #endif | 333 | #endif |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 4cdd5e5..fb32f6e 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,362 +1,414 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 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 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | 30 | ||
31 | #include <ksharedptr.h> | 31 | #include <ksharedptr.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kidmanager.h> | ||
35 | //US | 36 | //US |
36 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | ||
37 | 39 | ||
38 | //US #include "resource.h" | 40 | //US #include "resource.h" |
39 | #include "addressee.h" | 41 | #include "addressee.h" |
40 | 42 | ||
41 | using namespace KABC; | 43 | using namespace KABC; |
42 | 44 | ||
43 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
44 | 46 | ||
45 | struct Addressee::AddresseeData : public KShared | 47 | struct Addressee::AddresseeData : public KShared |
46 | { | 48 | { |
47 | QString uid; | 49 | QString uid; |
48 | QString name; | 50 | QString name; |
49 | QString formattedName; | 51 | QString formattedName; |
50 | QString familyName; | 52 | QString familyName; |
51 | QString givenName; | 53 | QString givenName; |
52 | QString additionalName; | 54 | QString additionalName; |
53 | QString prefix; | 55 | QString prefix; |
54 | QString suffix; | 56 | QString suffix; |
55 | QString nickName; | 57 | QString nickName; |
56 | QDateTime birthday; | 58 | QDateTime birthday; |
57 | QString mailer; | 59 | QString mailer; |
58 | TimeZone timeZone; | 60 | TimeZone timeZone; |
59 | Geo geo; | 61 | Geo geo; |
60 | QString title; | 62 | QString title; |
61 | QString role; | 63 | QString role; |
62 | QString organization; | 64 | QString organization; |
63 | QString note; | 65 | QString note; |
64 | QString productId; | 66 | QString productId; |
65 | QDateTime revision; | 67 | QDateTime revision; |
66 | QString sortString; | 68 | QString sortString; |
67 | KURL url; | 69 | KURL url; |
68 | Secrecy secrecy; | 70 | Secrecy secrecy; |
69 | Picture logo; | 71 | Picture logo; |
70 | Picture photo; | 72 | Picture photo; |
71 | Sound sound; | 73 | Sound sound; |
72 | Agent agent; | 74 | Agent agent; |
73 | 75 | QString mExternalId; | |
74 | PhoneNumber::List phoneNumbers; | 76 | PhoneNumber::List phoneNumbers; |
75 | Address::List addresses; | 77 | Address::List addresses; |
76 | Key::List keys; | 78 | Key::List keys; |
77 | QStringList emails; | 79 | QStringList emails; |
78 | QStringList categories; | 80 | QStringList categories; |
79 | QStringList custom; | 81 | QStringList custom; |
80 | 82 | ||
81 | Resource *resource; | 83 | Resource *resource; |
82 | 84 | ||
83 | bool empty :1; | 85 | bool empty :1; |
84 | bool changed :1; | 86 | bool changed :1; |
85 | }; | 87 | }; |
86 | 88 | ||
87 | Addressee::Addressee() | 89 | Addressee::Addressee() |
88 | { | 90 | { |
89 | mData = new AddresseeData; | 91 | mData = new AddresseeData; |
90 | mData->empty = true; | 92 | mData->empty = true; |
91 | mData->changed = false; | 93 | mData->changed = false; |
92 | mData->resource = 0; | 94 | mData->resource = 0; |
95 | mData->mExternalId = ":"; | ||
96 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | ||
93 | } | 97 | } |
94 | 98 | ||
95 | Addressee::~Addressee() | 99 | Addressee::~Addressee() |
96 | { | 100 | { |
97 | } | 101 | } |
98 | 102 | ||
99 | Addressee::Addressee( const Addressee &a ) | 103 | Addressee::Addressee( const Addressee &a ) |
100 | { | 104 | { |
101 | mData = a.mData; | 105 | mData = a.mData; |
106 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | ||
102 | } | 107 | } |
103 | 108 | ||
104 | Addressee &Addressee::operator=( const Addressee &a ) | 109 | Addressee &Addressee::operator=( const Addressee &a ) |
105 | { | 110 | { |
106 | mData = a.mData; | 111 | mData = a.mData; |
107 | return (*this); | 112 | return (*this); |
108 | } | 113 | } |
109 | 114 | ||
110 | Addressee Addressee::copy() | 115 | Addressee Addressee::copy() |
111 | { | 116 | { |
112 | Addressee a; | 117 | Addressee a; |
113 | *(a.mData) = *mData; | 118 | *(a.mData) = *mData; |
114 | return a; | 119 | return a; |
115 | } | 120 | } |
116 | 121 | ||
117 | void Addressee::detach() | 122 | void Addressee::detach() |
118 | { | 123 | { |
119 | if ( mData.count() == 1 ) return; | 124 | if ( mData.count() == 1 ) return; |
120 | *this = copy(); | 125 | *this = copy(); |
121 | } | 126 | } |
122 | 127 | ||
123 | bool Addressee::operator==( const Addressee &a ) const | 128 | bool Addressee::operator==( const Addressee &a ) const |
124 | { | 129 | { |
125 | if ( uid() != a.uid() ) return false; | 130 | if ( uid() != a.uid() ) return false; |
126 | if ( mData->name != a.mData->name ) return false; | 131 | if ( mData->name != a.mData->name ) return false; |
127 | if ( mData->formattedName != a.mData->formattedName ) return false; | 132 | if ( mData->formattedName != a.mData->formattedName ) return false; |
128 | if ( mData->familyName != a.mData->familyName ) return false; | 133 | if ( mData->familyName != a.mData->familyName ) return false; |
129 | if ( mData->givenName != a.mData->givenName ) return false; | 134 | if ( mData->givenName != a.mData->givenName ) return false; |
130 | if ( mData->additionalName != a.mData->additionalName ) return false; | 135 | if ( mData->additionalName != a.mData->additionalName ) return false; |
131 | if ( mData->prefix != a.mData->prefix ) return false; | 136 | if ( mData->prefix != a.mData->prefix ) return false; |
132 | if ( mData->suffix != a.mData->suffix ) return false; | 137 | if ( mData->suffix != a.mData->suffix ) return false; |
133 | if ( mData->nickName != a.mData->nickName ) return false; | 138 | if ( mData->nickName != a.mData->nickName ) return false; |
134 | if ( mData->birthday != a.mData->birthday ) return false; | 139 | if ( mData->birthday != a.mData->birthday ) return false; |
135 | if ( mData->mailer != a.mData->mailer ) return false; | 140 | if ( mData->mailer != a.mData->mailer ) return false; |
136 | if ( mData->timeZone != a.mData->timeZone ) return false; | 141 | if ( mData->timeZone != a.mData->timeZone ) return false; |
137 | if ( mData->geo != a.mData->geo ) return false; | 142 | if ( mData->geo != a.mData->geo ) return false; |
138 | if ( mData->title != a.mData->title ) return false; | 143 | if ( mData->title != a.mData->title ) return false; |
139 | if ( mData->role != a.mData->role ) return false; | 144 | if ( mData->role != a.mData->role ) return false; |
140 | if ( mData->organization != a.mData->organization ) return false; | 145 | if ( mData->organization != a.mData->organization ) return false; |
141 | if ( mData->note != a.mData->note ) return false; | 146 | if ( mData->note != a.mData->note ) return false; |
142 | if ( mData->productId != a.mData->productId ) return false; | 147 | if ( mData->productId != a.mData->productId ) return false; |
143 | if ( mData->revision != a.mData->revision ) return false; | 148 | if ( mData->revision != a.mData->revision ) return false; |
144 | if ( mData->sortString != a.mData->sortString ) return false; | 149 | if ( mData->sortString != a.mData->sortString ) return false; |
145 | if ( mData->secrecy != a.mData->secrecy ) return false; | 150 | if ( mData->secrecy != a.mData->secrecy ) return false; |
146 | if ( mData->logo != a.mData->logo ) return false; | 151 | if ( mData->logo != a.mData->logo ) return false; |
147 | if ( mData->photo != a.mData->photo ) return false; | 152 | if ( mData->photo != a.mData->photo ) return false; |
148 | if ( mData->sound != a.mData->sound ) return false; | 153 | if ( mData->sound != a.mData->sound ) return false; |
149 | if ( mData->agent != a.mData->agent ) return false; | 154 | if ( mData->agent != a.mData->agent ) return false; |
150 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 155 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
151 | ( mData->url != a.mData->url ) ) return false; | 156 | ( mData->url != a.mData->url ) ) return false; |
152 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 157 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
153 | if ( mData->addresses != a.mData->addresses ) return false; | 158 | if ( mData->addresses != a.mData->addresses ) return false; |
154 | if ( mData->keys != a.mData->keys ) return false; | 159 | if ( mData->keys != a.mData->keys ) return false; |
155 | if ( mData->emails != a.mData->emails ) return false; | 160 | if ( mData->emails != a.mData->emails ) return false; |
156 | if ( mData->categories != a.mData->categories ) return false; | 161 | if ( mData->categories != a.mData->categories ) return false; |
157 | if ( mData->custom != a.mData->custom ) return false; | 162 | if ( mData->custom != a.mData->custom ) return false; |
158 | 163 | ||
159 | return true; | 164 | return true; |
160 | } | 165 | } |
161 | 166 | ||
162 | bool Addressee::operator!=( const Addressee &a ) const | 167 | bool Addressee::operator!=( const Addressee &a ) const |
163 | { | 168 | { |
164 | return !( a == *this ); | 169 | return !( a == *this ); |
165 | } | 170 | } |
166 | 171 | ||
167 | bool Addressee::isEmpty() const | 172 | bool Addressee::isEmpty() const |
168 | { | 173 | { |
169 | return mData->empty; | 174 | return mData->empty; |
170 | } | 175 | } |
176 | void Addressee::removeID(const QString &prof) | ||
177 | { | ||
178 | detach(); | ||
179 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | ||
180 | |||
181 | } | ||
182 | void Addressee::setID( const QString & prof , const QString & id ) | ||
183 | { | ||
184 | detach(); | ||
185 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | ||
186 | } | ||
187 | void Addressee::setTempSyncStat( int id ) | ||
188 | { | ||
189 | mTempSyncStat = id; | ||
190 | } | ||
191 | int Addressee::tempSyncStat() const | ||
192 | { | ||
193 | return mTempSyncStat; | ||
194 | } | ||
195 | |||
196 | QString Addressee::getID( const QString & prof) | ||
197 | { | ||
198 | return KIdManager::getId ( mData->mExternalId, prof ); | ||
199 | } | ||
200 | |||
201 | void Addressee::setCsum( const QString & prof , const QString & id ) | ||
202 | { | ||
203 | detach(); | ||
204 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | ||
205 | } | ||
206 | |||
207 | QString Addressee::getCsum( const QString & prof) | ||
208 | { | ||
209 | return KIdManager::getCsum ( mData->mExternalId, prof ); | ||
210 | } | ||
211 | |||
212 | void Addressee::setIDStr( const QString & s ) | ||
213 | { | ||
214 | detach(); | ||
215 | mData->mExternalId = s; | ||
216 | } | ||
217 | |||
218 | QString Addressee::IDStr() const | ||
219 | { | ||
220 | return mData->mExternalId; | ||
221 | } | ||
222 | |||
171 | 223 | ||
172 | void Addressee::setUid( const QString &id ) | 224 | void Addressee::setUid( const QString &id ) |
173 | { | 225 | { |
174 | if ( id == mData->uid ) return; | 226 | if ( id == mData->uid ) return; |
175 | detach(); | 227 | detach(); |
176 | mData->empty = false; | 228 | mData->empty = false; |
177 | mData->uid = id; | 229 | mData->uid = id; |
178 | } | 230 | } |
179 | 231 | ||
180 | QString Addressee::uid() const | 232 | QString Addressee::uid() const |
181 | { | 233 | { |
182 | if ( mData->uid.isEmpty() ) | 234 | if ( mData->uid.isEmpty() ) |
183 | mData->uid = KApplication::randomString( 10 ); | 235 | mData->uid = KApplication::randomString( 10 ); |
184 | 236 | ||
185 | return mData->uid; | 237 | return mData->uid; |
186 | } | 238 | } |
187 | 239 | ||
188 | QString Addressee::uidLabel() | 240 | QString Addressee::uidLabel() |
189 | { | 241 | { |
190 | return i18n("Unique Identifier"); | 242 | return i18n("Unique Identifier"); |
191 | } | 243 | } |
192 | 244 | ||
193 | void Addressee::setName( const QString &name ) | 245 | void Addressee::setName( const QString &name ) |
194 | { | 246 | { |
195 | if ( name == mData->name ) return; | 247 | if ( name == mData->name ) return; |
196 | detach(); | 248 | detach(); |
197 | mData->empty = false; | 249 | mData->empty = false; |
198 | mData->name = name; | 250 | mData->name = name; |
199 | } | 251 | } |
200 | 252 | ||
201 | QString Addressee::name() const | 253 | QString Addressee::name() const |
202 | { | 254 | { |
203 | return mData->name; | 255 | return mData->name; |
204 | } | 256 | } |
205 | 257 | ||
206 | QString Addressee::nameLabel() | 258 | QString Addressee::nameLabel() |
207 | { | 259 | { |
208 | return i18n("Name"); | 260 | return i18n("Name"); |
209 | } | 261 | } |
210 | 262 | ||
211 | 263 | ||
212 | void Addressee::setFormattedName( const QString &formattedName ) | 264 | void Addressee::setFormattedName( const QString &formattedName ) |
213 | { | 265 | { |
214 | if ( formattedName == mData->formattedName ) return; | 266 | if ( formattedName == mData->formattedName ) return; |
215 | detach(); | 267 | detach(); |
216 | mData->empty = false; | 268 | mData->empty = false; |
217 | mData->formattedName = formattedName; | 269 | mData->formattedName = formattedName; |
218 | } | 270 | } |
219 | 271 | ||
220 | QString Addressee::formattedName() const | 272 | QString Addressee::formattedName() const |
221 | { | 273 | { |
222 | return mData->formattedName; | 274 | return mData->formattedName; |
223 | } | 275 | } |
224 | 276 | ||
225 | QString Addressee::formattedNameLabel() | 277 | QString Addressee::formattedNameLabel() |
226 | { | 278 | { |
227 | return i18n("Formatted Name"); | 279 | return i18n("Formatted Name"); |
228 | } | 280 | } |
229 | 281 | ||
230 | 282 | ||
231 | void Addressee::setFamilyName( const QString &familyName ) | 283 | void Addressee::setFamilyName( const QString &familyName ) |
232 | { | 284 | { |
233 | if ( familyName == mData->familyName ) return; | 285 | if ( familyName == mData->familyName ) return; |
234 | detach(); | 286 | detach(); |
235 | mData->empty = false; | 287 | mData->empty = false; |
236 | mData->familyName = familyName; | 288 | mData->familyName = familyName; |
237 | } | 289 | } |
238 | 290 | ||
239 | QString Addressee::familyName() const | 291 | QString Addressee::familyName() const |
240 | { | 292 | { |
241 | return mData->familyName; | 293 | return mData->familyName; |
242 | } | 294 | } |
243 | 295 | ||
244 | QString Addressee::familyNameLabel() | 296 | QString Addressee::familyNameLabel() |
245 | { | 297 | { |
246 | return i18n("Family Name"); | 298 | return i18n("Family Name"); |
247 | } | 299 | } |
248 | 300 | ||
249 | 301 | ||
250 | void Addressee::setGivenName( const QString &givenName ) | 302 | void Addressee::setGivenName( const QString &givenName ) |
251 | { | 303 | { |
252 | if ( givenName == mData->givenName ) return; | 304 | if ( givenName == mData->givenName ) return; |
253 | detach(); | 305 | detach(); |
254 | mData->empty = false; | 306 | mData->empty = false; |
255 | mData->givenName = givenName; | 307 | mData->givenName = givenName; |
256 | } | 308 | } |
257 | 309 | ||
258 | QString Addressee::givenName() const | 310 | QString Addressee::givenName() const |
259 | { | 311 | { |
260 | return mData->givenName; | 312 | return mData->givenName; |
261 | } | 313 | } |
262 | 314 | ||
263 | QString Addressee::givenNameLabel() | 315 | QString Addressee::givenNameLabel() |
264 | { | 316 | { |
265 | return i18n("Given Name"); | 317 | return i18n("Given Name"); |
266 | } | 318 | } |
267 | 319 | ||
268 | 320 | ||
269 | void Addressee::setAdditionalName( const QString &additionalName ) | 321 | void Addressee::setAdditionalName( const QString &additionalName ) |
270 | { | 322 | { |
271 | if ( additionalName == mData->additionalName ) return; | 323 | if ( additionalName == mData->additionalName ) return; |
272 | detach(); | 324 | detach(); |
273 | mData->empty = false; | 325 | mData->empty = false; |
274 | mData->additionalName = additionalName; | 326 | mData->additionalName = additionalName; |
275 | } | 327 | } |
276 | 328 | ||
277 | QString Addressee::additionalName() const | 329 | QString Addressee::additionalName() const |
278 | { | 330 | { |
279 | return mData->additionalName; | 331 | return mData->additionalName; |
280 | } | 332 | } |
281 | 333 | ||
282 | QString Addressee::additionalNameLabel() | 334 | QString Addressee::additionalNameLabel() |
283 | { | 335 | { |
284 | return i18n("Additional Names"); | 336 | return i18n("Additional Names"); |
285 | } | 337 | } |
286 | 338 | ||
287 | 339 | ||
288 | void Addressee::setPrefix( const QString &prefix ) | 340 | void Addressee::setPrefix( const QString &prefix ) |
289 | { | 341 | { |
290 | if ( prefix == mData->prefix ) return; | 342 | if ( prefix == mData->prefix ) return; |
291 | detach(); | 343 | detach(); |
292 | mData->empty = false; | 344 | mData->empty = false; |
293 | mData->prefix = prefix; | 345 | mData->prefix = prefix; |
294 | } | 346 | } |
295 | 347 | ||
296 | QString Addressee::prefix() const | 348 | QString Addressee::prefix() const |
297 | { | 349 | { |
298 | return mData->prefix; | 350 | return mData->prefix; |
299 | } | 351 | } |
300 | 352 | ||
301 | QString Addressee::prefixLabel() | 353 | QString Addressee::prefixLabel() |
302 | { | 354 | { |
303 | return i18n("Honorific Prefixes"); | 355 | return i18n("Honorific Prefixes"); |
304 | } | 356 | } |
305 | 357 | ||
306 | 358 | ||
307 | void Addressee::setSuffix( const QString &suffix ) | 359 | void Addressee::setSuffix( const QString &suffix ) |
308 | { | 360 | { |
309 | if ( suffix == mData->suffix ) return; | 361 | if ( suffix == mData->suffix ) return; |
310 | detach(); | 362 | detach(); |
311 | mData->empty = false; | 363 | mData->empty = false; |
312 | mData->suffix = suffix; | 364 | mData->suffix = suffix; |
313 | } | 365 | } |
314 | 366 | ||
315 | QString Addressee::suffix() const | 367 | QString Addressee::suffix() const |
316 | { | 368 | { |
317 | return mData->suffix; | 369 | return mData->suffix; |
318 | } | 370 | } |
319 | 371 | ||
320 | QString Addressee::suffixLabel() | 372 | QString Addressee::suffixLabel() |
321 | { | 373 | { |
322 | return i18n("Honorific Suffixes"); | 374 | return i18n("Honorific Suffixes"); |
323 | } | 375 | } |
324 | 376 | ||
325 | 377 | ||
326 | void Addressee::setNickName( const QString &nickName ) | 378 | void Addressee::setNickName( const QString &nickName ) |
327 | { | 379 | { |
328 | if ( nickName == mData->nickName ) return; | 380 | if ( nickName == mData->nickName ) return; |
329 | detach(); | 381 | detach(); |
330 | mData->empty = false; | 382 | mData->empty = false; |
331 | mData->nickName = nickName; | 383 | mData->nickName = nickName; |
332 | } | 384 | } |
333 | 385 | ||
334 | QString Addressee::nickName() const | 386 | QString Addressee::nickName() const |
335 | { | 387 | { |
336 | return mData->nickName; | 388 | return mData->nickName; |
337 | } | 389 | } |
338 | 390 | ||
339 | QString Addressee::nickNameLabel() | 391 | QString Addressee::nickNameLabel() |
340 | { | 392 | { |
341 | return i18n("Nick Name"); | 393 | return i18n("Nick Name"); |
342 | } | 394 | } |
343 | 395 | ||
344 | 396 | ||
345 | void Addressee::setBirthday( const QDateTime &birthday ) | 397 | void Addressee::setBirthday( const QDateTime &birthday ) |
346 | { | 398 | { |
347 | if ( birthday == mData->birthday ) return; | 399 | if ( birthday == mData->birthday ) return; |
348 | detach(); | 400 | detach(); |
349 | mData->empty = false; | 401 | mData->empty = false; |
350 | mData->birthday = birthday; | 402 | mData->birthday = birthday; |
351 | } | 403 | } |
352 | 404 | ||
353 | QDateTime Addressee::birthday() const | 405 | QDateTime Addressee::birthday() const |
354 | { | 406 | { |
355 | return mData->birthday; | 407 | return mData->birthday; |
356 | } | 408 | } |
357 | 409 | ||
358 | QString Addressee::birthdayLabel() | 410 | QString Addressee::birthdayLabel() |
359 | { | 411 | { |
360 | return i18n("Birthday"); | 412 | return i18n("Birthday"); |
361 | } | 413 | } |
362 | 414 | ||
diff --git a/kabc/addressee.h b/kabc/addressee.h index 27782f9..f098371 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -1,291 +1,300 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 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 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef KABC_ADDRESSEE_H | 29 | #ifndef KABC_ADDRESSEE_H |
30 | #define KABC_ADDRESSEE_H | 30 | #define KABC_ADDRESSEE_H |
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qstring.h> | 33 | #include <qstring.h> |
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
36 | 36 | ||
37 | #include <ksharedptr.h> | 37 | #include <ksharedptr.h> |
38 | #include <kurl.h> | 38 | #include <kurl.h> |
39 | 39 | ||
40 | #include "address.h" | 40 | #include "address.h" |
41 | #include "agent.h" | 41 | #include "agent.h" |
42 | #include "geo.h" | 42 | #include "geo.h" |
43 | #include "key.h" | 43 | #include "key.h" |
44 | #include "phonenumber.h" | 44 | #include "phonenumber.h" |
45 | #include "picture.h" | 45 | #include "picture.h" |
46 | #include "secrecy.h" | 46 | #include "secrecy.h" |
47 | #include "sound.h" | 47 | #include "sound.h" |
48 | #include "timezone.h" | 48 | #include "timezone.h" |
49 | 49 | ||
50 | namespace KABC { | 50 | namespace KABC { |
51 | 51 | ||
52 | class Resource; | 52 | class Resource; |
53 | 53 | ||
54 | /** | 54 | /** |
55 | @short address book entry | 55 | @short address book entry |
56 | 56 | ||
57 | This class represents an entry in the address book. | 57 | This class represents an entry in the address book. |
58 | 58 | ||
59 | The data of this class is implicitly shared. You can pass this class by value. | 59 | The data of this class is implicitly shared. You can pass this class by value. |
60 | 60 | ||
61 | If you need the name of a field for presenting it to the user you should use | 61 | If you need the name of a field for presenting it to the user you should use |
62 | the functions ending in Label(). They return a translated string which can be | 62 | the functions ending in Label(). They return a translated string which can be |
63 | used as label for the corresponding field. | 63 | used as label for the corresponding field. |
64 | 64 | ||
65 | About the name fields: | 65 | About the name fields: |
66 | 66 | ||
67 | givenName() is the first name and familyName() the last name. In some | 67 | givenName() is the first name and familyName() the last name. In some |
68 | countries the family name comes first, that's the reason for the | 68 | countries the family name comes first, that's the reason for the |
69 | naming. formattedName() is the full name with the correct formatting. | 69 | naming. formattedName() is the full name with the correct formatting. |
70 | It is used as an override, when the correct formatting can't be generated | 70 | It is used as an override, when the correct formatting can't be generated |
71 | from the other name fields automatically. | 71 | from the other name fields automatically. |
72 | 72 | ||
73 | realName() returns a fully formatted name(). It uses formattedName, if set, | 73 | realName() returns a fully formatted name(). It uses formattedName, if set, |
74 | otherwise it constucts the name from the name fields. As fallback, if | 74 | otherwise it constucts the name from the name fields. As fallback, if |
75 | nothing else is set it uses name(). | 75 | nothing else is set it uses name(). |
76 | 76 | ||
77 | name() is the NAME type of RFC2426. It can be used as internal name for the | 77 | name() is the NAME type of RFC2426. It can be used as internal name for the |
78 | data enty, but shouldn't be used for displaying the data to the user. | 78 | data enty, but shouldn't be used for displaying the data to the user. |
79 | */ | 79 | */ |
80 | class Addressee | 80 | class Addressee |
81 | { | 81 | { |
82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); | 82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); |
83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); | 83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); |
84 | 84 | ||
85 | public: | 85 | public: |
86 | typedef QValueList<Addressee> List; | 86 | typedef QValueList<Addressee> List; |
87 | 87 | ||
88 | /** | 88 | /** |
89 | Construct an empty address book entry. | 89 | Construct an empty address book entry. |
90 | */ | 90 | */ |
91 | Addressee(); | 91 | Addressee(); |
92 | ~Addressee(); | 92 | ~Addressee(); |
93 | 93 | ||
94 | Addressee( const Addressee & ); | 94 | Addressee( const Addressee & ); |
95 | Addressee &operator=( const Addressee & ); | 95 | Addressee &operator=( const Addressee & ); |
96 | 96 | ||
97 | bool operator==( const Addressee & ) const; | 97 | bool operator==( const Addressee & ) const; |
98 | bool operator!=( const Addressee & ) const; | 98 | bool operator!=( const Addressee & ) const; |
99 | 99 | // sync stuff | |
100 | void setTempSyncStat(int id); | ||
101 | int tempSyncStat() const; | ||
102 | void setIDStr( const QString & ); | ||
103 | QString IDStr() const; | ||
104 | void setID( const QString &, const QString & ); | ||
105 | QString getID( const QString & ); | ||
106 | void setCsum( const QString &, const QString & ); | ||
107 | QString getCsum( const QString & ); | ||
108 | void removeID(const QString &); | ||
100 | /** | 109 | /** |
101 | Return, if the address book entry is empty. | 110 | Return, if the address book entry is empty. |
102 | */ | 111 | */ |
103 | bool isEmpty() const; | 112 | bool isEmpty() const; |
104 | 113 | ||
105 | /** | 114 | /** |
106 | Set unique identifier. | 115 | Set unique identifier. |
107 | */ | 116 | */ |
108 | void setUid( const QString &uid ); | 117 | void setUid( const QString &uid ); |
109 | /** | 118 | /** |
110 | Return unique identifier. | 119 | Return unique identifier. |
111 | */ | 120 | */ |
112 | QString uid() const; | 121 | QString uid() const; |
113 | /** | 122 | /** |
114 | Return translated label for uid field. | 123 | Return translated label for uid field. |
115 | */ | 124 | */ |
116 | static QString uidLabel(); | 125 | static QString uidLabel(); |
117 | 126 | ||
118 | /** | 127 | /** |
119 | Set name. | 128 | Set name. |
120 | */ | 129 | */ |
121 | void setName( const QString &name ); | 130 | void setName( const QString &name ); |
122 | /** | 131 | /** |
123 | Return name. | 132 | Return name. |
124 | */ | 133 | */ |
125 | QString name() const; | 134 | QString name() const; |
126 | /** | 135 | /** |
127 | Return translated label for name field. | 136 | Return translated label for name field. |
128 | */ | 137 | */ |
129 | static QString nameLabel(); | 138 | static QString nameLabel(); |
130 | 139 | ||
131 | /** | 140 | /** |
132 | Set formatted name. | 141 | Set formatted name. |
133 | */ | 142 | */ |
134 | void setFormattedName( const QString &formattedName ); | 143 | void setFormattedName( const QString &formattedName ); |
135 | /** | 144 | /** |
136 | Return formatted name. | 145 | Return formatted name. |
137 | */ | 146 | */ |
138 | QString formattedName() const; | 147 | QString formattedName() const; |
139 | /** | 148 | /** |
140 | Return translated label for formattedName field. | 149 | Return translated label for formattedName field. |
141 | */ | 150 | */ |
142 | static QString formattedNameLabel(); | 151 | static QString formattedNameLabel(); |
143 | 152 | ||
144 | /** | 153 | /** |
145 | Set family name. | 154 | Set family name. |
146 | */ | 155 | */ |
147 | void setFamilyName( const QString &familyName ); | 156 | void setFamilyName( const QString &familyName ); |
148 | /** | 157 | /** |
149 | Return family name. | 158 | Return family name. |
150 | */ | 159 | */ |
151 | QString familyName() const; | 160 | QString familyName() const; |
152 | /** | 161 | /** |
153 | Return translated label for familyName field. | 162 | Return translated label for familyName field. |
154 | */ | 163 | */ |
155 | static QString familyNameLabel(); | 164 | static QString familyNameLabel(); |
156 | 165 | ||
157 | /** | 166 | /** |
158 | Set given name. | 167 | Set given name. |
159 | */ | 168 | */ |
160 | void setGivenName( const QString &givenName ); | 169 | void setGivenName( const QString &givenName ); |
161 | /** | 170 | /** |
162 | Return given name. | 171 | Return given name. |
163 | */ | 172 | */ |
164 | QString givenName() const; | 173 | QString givenName() const; |
165 | /** | 174 | /** |
166 | Return translated label for givenName field. | 175 | Return translated label for givenName field. |
167 | */ | 176 | */ |
168 | static QString givenNameLabel(); | 177 | static QString givenNameLabel(); |
169 | 178 | ||
170 | /** | 179 | /** |
171 | Set additional names. | 180 | Set additional names. |
172 | */ | 181 | */ |
173 | void setAdditionalName( const QString &additionalName ); | 182 | void setAdditionalName( const QString &additionalName ); |
174 | /** | 183 | /** |
175 | Return additional names. | 184 | Return additional names. |
176 | */ | 185 | */ |
177 | QString additionalName() const; | 186 | QString additionalName() const; |
178 | /** | 187 | /** |
179 | Return translated label for additionalName field. | 188 | Return translated label for additionalName field. |
180 | */ | 189 | */ |
181 | static QString additionalNameLabel(); | 190 | static QString additionalNameLabel(); |
182 | 191 | ||
183 | /** | 192 | /** |
184 | Set honorific prefixes. | 193 | Set honorific prefixes. |
185 | */ | 194 | */ |
186 | void setPrefix( const QString &prefix ); | 195 | void setPrefix( const QString &prefix ); |
187 | /** | 196 | /** |
188 | Return honorific prefixes. | 197 | Return honorific prefixes. |
189 | */ | 198 | */ |
190 | QString prefix() const; | 199 | QString prefix() const; |
191 | /** | 200 | /** |
192 | Return translated label for prefix field. | 201 | Return translated label for prefix field. |
193 | */ | 202 | */ |
194 | static QString prefixLabel(); | 203 | static QString prefixLabel(); |
195 | 204 | ||
196 | /** | 205 | /** |
197 | Set honorific suffixes. | 206 | Set honorific suffixes. |
198 | */ | 207 | */ |
199 | void setSuffix( const QString &suffix ); | 208 | void setSuffix( const QString &suffix ); |
200 | /** | 209 | /** |
201 | Return honorific suffixes. | 210 | Return honorific suffixes. |
202 | */ | 211 | */ |
203 | QString suffix() const; | 212 | QString suffix() const; |
204 | /** | 213 | /** |
205 | Return translated label for suffix field. | 214 | Return translated label for suffix field. |
206 | */ | 215 | */ |
207 | static QString suffixLabel(); | 216 | static QString suffixLabel(); |
208 | 217 | ||
209 | /** | 218 | /** |
210 | Set nick name. | 219 | Set nick name. |
211 | */ | 220 | */ |
212 | void setNickName( const QString &nickName ); | 221 | void setNickName( const QString &nickName ); |
213 | /** | 222 | /** |
214 | Return nick name. | 223 | Return nick name. |
215 | */ | 224 | */ |
216 | QString nickName() const; | 225 | QString nickName() const; |
217 | /** | 226 | /** |
218 | Return translated label for nickName field. | 227 | Return translated label for nickName field. |
219 | */ | 228 | */ |
220 | static QString nickNameLabel(); | 229 | static QString nickNameLabel(); |
221 | 230 | ||
222 | /** | 231 | /** |
223 | Set birthday. | 232 | Set birthday. |
224 | */ | 233 | */ |
225 | void setBirthday( const QDateTime &birthday ); | 234 | void setBirthday( const QDateTime &birthday ); |
226 | /** | 235 | /** |
227 | Return birthday. | 236 | Return birthday. |
228 | */ | 237 | */ |
229 | QDateTime birthday() const; | 238 | QDateTime birthday() const; |
230 | /** | 239 | /** |
231 | Return translated label for birthday field. | 240 | Return translated label for birthday field. |
232 | */ | 241 | */ |
233 | static QString birthdayLabel(); | 242 | static QString birthdayLabel(); |
234 | 243 | ||
235 | /** | 244 | /** |
236 | Return translated label for homeAddressStreet field. | 245 | Return translated label for homeAddressStreet field. |
237 | */ | 246 | */ |
238 | static QString homeAddressStreetLabel(); | 247 | static QString homeAddressStreetLabel(); |
239 | 248 | ||
240 | /** | 249 | /** |
241 | Return translated label for homeAddressLocality field. | 250 | Return translated label for homeAddressLocality field. |
242 | */ | 251 | */ |
243 | static QString homeAddressLocalityLabel(); | 252 | static QString homeAddressLocalityLabel(); |
244 | 253 | ||
245 | /** | 254 | /** |
246 | Return translated label for homeAddressRegion field. | 255 | Return translated label for homeAddressRegion field. |
247 | */ | 256 | */ |
248 | static QString homeAddressRegionLabel(); | 257 | static QString homeAddressRegionLabel(); |
249 | 258 | ||
250 | /** | 259 | /** |
251 | Return translated label for homeAddressPostalCode field. | 260 | Return translated label for homeAddressPostalCode field. |
252 | */ | 261 | */ |
253 | static QString homeAddressPostalCodeLabel(); | 262 | static QString homeAddressPostalCodeLabel(); |
254 | 263 | ||
255 | /** | 264 | /** |
256 | Return translated label for homeAddressCountry field. | 265 | Return translated label for homeAddressCountry field. |
257 | */ | 266 | */ |
258 | static QString homeAddressCountryLabel(); | 267 | static QString homeAddressCountryLabel(); |
259 | 268 | ||
260 | /** | 269 | /** |
261 | Return translated label for homeAddressLabel field. | 270 | Return translated label for homeAddressLabel field. |
262 | */ | 271 | */ |
263 | static QString homeAddressLabelLabel(); | 272 | static QString homeAddressLabelLabel(); |
264 | 273 | ||
265 | /** | 274 | /** |
266 | Return translated label for businessAddressStreet field. | 275 | Return translated label for businessAddressStreet field. |
267 | */ | 276 | */ |
268 | static QString businessAddressStreetLabel(); | 277 | static QString businessAddressStreetLabel(); |
269 | 278 | ||
270 | /** | 279 | /** |
271 | Return translated label for businessAddressLocality field. | 280 | Return translated label for businessAddressLocality field. |
272 | */ | 281 | */ |
273 | static QString businessAddressLocalityLabel(); | 282 | static QString businessAddressLocalityLabel(); |
274 | 283 | ||
275 | /** | 284 | /** |
276 | Return translated label for businessAddressRegion field. | 285 | Return translated label for businessAddressRegion field. |
277 | */ | 286 | */ |
278 | static QString businessAddressRegionLabel(); | 287 | static QString businessAddressRegionLabel(); |
279 | 288 | ||
280 | /** | 289 | /** |
281 | Return translated label for businessAddressPostalCode field. | 290 | Return translated label for businessAddressPostalCode field. |
282 | */ | 291 | */ |
283 | static QString businessAddressPostalCodeLabel(); | 292 | static QString businessAddressPostalCodeLabel(); |
284 | 293 | ||
285 | /** | 294 | /** |
286 | Return translated label for businessAddressCountry field. | 295 | Return translated label for businessAddressCountry field. |
287 | */ | 296 | */ |
288 | static QString businessAddressCountryLabel(); | 297 | static QString businessAddressCountryLabel(); |
289 | 298 | ||
290 | /** | 299 | /** |
291 | Return translated label for businessAddressLabel field. | 300 | Return translated label for businessAddressLabel field. |
@@ -626,203 +635,204 @@ class Addressee | |||
626 | */ | 635 | */ |
627 | PhoneNumber phoneNumber( int type ) const; | 636 | PhoneNumber phoneNumber( int type ) const; |
628 | 637 | ||
629 | /** | 638 | /** |
630 | Return list of all phone numbers. | 639 | Return list of all phone numbers. |
631 | */ | 640 | */ |
632 | PhoneNumber::List phoneNumbers() const; | 641 | PhoneNumber::List phoneNumbers() const; |
633 | 642 | ||
634 | /** | 643 | /** |
635 | Return list of phone numbers with a special type. | 644 | Return list of phone numbers with a special type. |
636 | */ | 645 | */ |
637 | PhoneNumber::List phoneNumbers( int type ) const; | 646 | PhoneNumber::List phoneNumbers( int type ) const; |
638 | 647 | ||
639 | /** | 648 | /** |
640 | Return phone number with the given id. | 649 | Return phone number with the given id. |
641 | */ | 650 | */ |
642 | PhoneNumber findPhoneNumber( const QString &id ) const; | 651 | PhoneNumber findPhoneNumber( const QString &id ) const; |
643 | 652 | ||
644 | /** | 653 | /** |
645 | Insert a key. If a key with the same id already exists | 654 | Insert a key. If a key with the same id already exists |
646 | in this addressee it is not duplicated. | 655 | in this addressee it is not duplicated. |
647 | */ | 656 | */ |
648 | void insertKey( const Key &key ); | 657 | void insertKey( const Key &key ); |
649 | 658 | ||
650 | /** | 659 | /** |
651 | Remove a key. If no key with the given id exists for this | 660 | Remove a key. If no key with the given id exists for this |
652 | addresse nothing happens. | 661 | addresse nothing happens. |
653 | */ | 662 | */ |
654 | void removeKey( const Key &key ); | 663 | void removeKey( const Key &key ); |
655 | 664 | ||
656 | /** | 665 | /** |
657 | Return key, which matches the given type. | 666 | Return key, which matches the given type. |
658 | If @p type == Key::Custom you can specify a string | 667 | If @p type == Key::Custom you can specify a string |
659 | that should match. If you leave the string empty, the first | 668 | that should match. If you leave the string empty, the first |
660 | key with a custom value is returned. | 669 | key with a custom value is returned. |
661 | */ | 670 | */ |
662 | Key key( int type, QString customTypeString = QString::null ) const; | 671 | Key key( int type, QString customTypeString = QString::null ) const; |
663 | 672 | ||
664 | /** | 673 | /** |
665 | Return list of all keys. | 674 | Return list of all keys. |
666 | */ | 675 | */ |
667 | Key::List keys() const; | 676 | Key::List keys() const; |
668 | 677 | ||
669 | /** | 678 | /** |
670 | Set the list of keys | 679 | Set the list of keys |
671 | @param keys The keys to be set. | 680 | @param keys The keys to be set. |
672 | */ | 681 | */ |
673 | void setKeys( const Key::List& keys); | 682 | void setKeys( const Key::List& keys); |
674 | 683 | ||
675 | /** | 684 | /** |
676 | Return list of keys with a special type. | 685 | Return list of keys with a special type. |
677 | If @p type == Key::Custom you can specify a string | 686 | If @p type == Key::Custom you can specify a string |
678 | that should match. If you leave the string empty, all custom | 687 | that should match. If you leave the string empty, all custom |
679 | keys will be returned. | 688 | keys will be returned. |
680 | */ | 689 | */ |
681 | Key::List keys( int type, QString customTypeString = QString::null ) const; | 690 | Key::List keys( int type, QString customTypeString = QString::null ) const; |
682 | 691 | ||
683 | /** | 692 | /** |
684 | Return key with the given id. | 693 | Return key with the given id. |
685 | */ | 694 | */ |
686 | Key findKey( const QString &id ) const; | 695 | Key findKey( const QString &id ) const; |
687 | 696 | ||
688 | /** | 697 | /** |
689 | Insert an address. If an address with the same id already exists | 698 | Insert an address. If an address with the same id already exists |
690 | in this addressee it is not duplicated. | 699 | in this addressee it is not duplicated. |
691 | */ | 700 | */ |
692 | void insertAddress( const Address &address ); | 701 | void insertAddress( const Address &address ); |
693 | 702 | ||
694 | /** | 703 | /** |
695 | Remove address. If no address with the given id exists for this | 704 | Remove address. If no address with the given id exists for this |
696 | addresse nothing happens. | 705 | addresse nothing happens. |
697 | */ | 706 | */ |
698 | void removeAddress( const Address &address ); | 707 | void removeAddress( const Address &address ); |
699 | 708 | ||
700 | /** | 709 | /** |
701 | Return address, which matches the given type. | 710 | Return address, which matches the given type. |
702 | */ | 711 | */ |
703 | Address address( int type ) const; | 712 | Address address( int type ) const; |
704 | 713 | ||
705 | /** | 714 | /** |
706 | Return list of all addresses. | 715 | Return list of all addresses. |
707 | */ | 716 | */ |
708 | Address::List addresses() const; | 717 | Address::List addresses() const; |
709 | 718 | ||
710 | /** | 719 | /** |
711 | Return list of addresses with a special type. | 720 | Return list of addresses with a special type. |
712 | */ | 721 | */ |
713 | Address::List addresses( int type ) const; | 722 | Address::List addresses( int type ) const; |
714 | 723 | ||
715 | /** | 724 | /** |
716 | Return address with the given id. | 725 | Return address with the given id. |
717 | */ | 726 | */ |
718 | Address findAddress( const QString &id ) const; | 727 | Address findAddress( const QString &id ) const; |
719 | 728 | ||
720 | /** | 729 | /** |
721 | Insert category. If the category already exists it is not duplicated. | 730 | Insert category. If the category already exists it is not duplicated. |
722 | */ | 731 | */ |
723 | void insertCategory( const QString & ); | 732 | void insertCategory( const QString & ); |
724 | 733 | ||
725 | /** | 734 | /** |
726 | Remove category. | 735 | Remove category. |
727 | */ | 736 | */ |
728 | void removeCategory( const QString & ); | 737 | void removeCategory( const QString & ); |
729 | 738 | ||
730 | /** | 739 | /** |
731 | Return, if addressee has the given category. | 740 | Return, if addressee has the given category. |
732 | */ | 741 | */ |
733 | bool hasCategory( const QString & ) const; | 742 | bool hasCategory( const QString & ) const; |
734 | 743 | ||
735 | /** | 744 | /** |
736 | Set categories to given value. | 745 | Set categories to given value. |
737 | */ | 746 | */ |
738 | void setCategories( const QStringList & ); | 747 | void setCategories( const QStringList & ); |
739 | 748 | ||
740 | /** | 749 | /** |
741 | Return list of all set categories. | 750 | Return list of all set categories. |
742 | */ | 751 | */ |
743 | QStringList categories() const; | 752 | QStringList categories() const; |
744 | 753 | ||
745 | /** | 754 | /** |
746 | Insert custom entry. The entry is identified by the name of the inserting | 755 | Insert custom entry. The entry is identified by the name of the inserting |
747 | application and a unique name. If an entry with the given app and name | 756 | application and a unique name. If an entry with the given app and name |
748 | already exists its value is replaced with the new given value. | 757 | already exists its value is replaced with the new given value. |
749 | */ | 758 | */ |
750 | void insertCustom( const QString &app, const QString &name, | 759 | void insertCustom( const QString &app, const QString &name, |
751 | const QString &value ); | 760 | const QString &value ); |
752 | 761 | ||
753 | /** | 762 | /** |
754 | Remove custom entry. | 763 | Remove custom entry. |
755 | */ | 764 | */ |
756 | void removeCustom( const QString &app, const QString &name ); | 765 | void removeCustom( const QString &app, const QString &name ); |
757 | 766 | ||
758 | /** | 767 | /** |
759 | Return value of custom entry, identified by app and entry name. | 768 | Return value of custom entry, identified by app and entry name. |
760 | */ | 769 | */ |
761 | QString custom( const QString &app, const QString &name ) const; | 770 | QString custom( const QString &app, const QString &name ) const; |
762 | 771 | ||
763 | /** | 772 | /** |
764 | Set all custom entries. | 773 | Set all custom entries. |
765 | */ | 774 | */ |
766 | void setCustoms( const QStringList & ); | 775 | void setCustoms( const QStringList & ); |
767 | 776 | ||
768 | /** | 777 | /** |
769 | Return list of all custom entries. | 778 | Return list of all custom entries. |
770 | */ | 779 | */ |
771 | QStringList customs() const; | 780 | QStringList customs() const; |
772 | 781 | ||
773 | /** | 782 | /** |
774 | Parse full email address. The result is given back in fullName and email. | 783 | Parse full email address. The result is given back in fullName and email. |
775 | */ | 784 | */ |
776 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, | 785 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, |
777 | QString &email ); | 786 | QString &email ); |
778 | 787 | ||
779 | /** | 788 | /** |
780 | Debug output. | 789 | Debug output. |
781 | */ | 790 | */ |
782 | void dump() const; | 791 | void dump() const; |
783 | 792 | ||
784 | /** | 793 | /** |
785 | Returns string representation of the addressee. | 794 | Returns string representation of the addressee. |
786 | */ | 795 | */ |
787 | QString asString() const; | 796 | QString asString() const; |
788 | 797 | ||
789 | /** | 798 | /** |
790 | Set resource where the addressee is from. | 799 | Set resource where the addressee is from. |
791 | */ | 800 | */ |
792 | void setResource( Resource *resource ); | 801 | void setResource( Resource *resource ); |
793 | 802 | ||
794 | /** | 803 | /** |
795 | Return pointer to resource. | 804 | Return pointer to resource. |
796 | */ | 805 | */ |
797 | Resource *resource() const; | 806 | Resource *resource() const; |
798 | 807 | ||
799 | /** | 808 | /** |
800 | Return resourcelabel. | 809 | Return resourcelabel. |
801 | */ | 810 | */ |
802 | //US | 811 | //US |
803 | static QString resourceLabel(); | 812 | static QString resourceLabel(); |
804 | 813 | ||
805 | /** | 814 | /** |
806 | Mark addressee as changed. | 815 | Mark addressee as changed. |
807 | */ | 816 | */ |
808 | void setChanged( bool value ); | 817 | void setChanged( bool value ); |
809 | 818 | ||
810 | /** | 819 | /** |
811 | Return whether the addressee is changed. | 820 | Return whether the addressee is changed. |
812 | */ | 821 | */ |
813 | bool changed() const; | 822 | bool changed() const; |
814 | 823 | ||
815 | private: | 824 | private: |
816 | Addressee copy(); | 825 | Addressee copy(); |
817 | void detach(); | 826 | void detach(); |
827 | int mTempSyncStat; | ||
818 | 828 | ||
819 | struct AddresseeData; | 829 | struct AddresseeData; |
820 | mutable KSharedPtr<AddresseeData> mData; | 830 | mutable KSharedPtr<AddresseeData> mData; |
821 | }; | 831 | }; |
822 | 832 | ||
823 | QDataStream &operator<<( QDataStream &, const Addressee & ); | 833 | QDataStream &operator<<( QDataStream &, const Addressee & ); |
824 | QDataStream &operator>>( QDataStream &, Addressee & ); | 834 | QDataStream &operator>>( QDataStream &, Addressee & ); |
825 | 835 | ||
826 | } | 836 | } |
827 | 837 | ||
828 | #endif | 838 | #endif |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 1196360..53c63ff 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2324,550 +2324,573 @@ int KABCore::ringSync() | |||
2324 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 2324 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
2325 | ++syncedProfiles; | 2325 | ++syncedProfiles; |
2326 | // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 2326 | // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
2327 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 2327 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
2328 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 2328 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
2329 | KABPrefs::instance()->mWriteBackInFuture = 0; | 2329 | KABPrefs::instance()->mWriteBackInFuture = 0; |
2330 | if ( temp->getWriteBackFuture() ) | 2330 | if ( temp->getWriteBackFuture() ) |
2331 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 2331 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
2332 | KABPrefs::instance()->mShowSyncSummary = false; | 2332 | KABPrefs::instance()->mShowSyncSummary = false; |
2333 | mCurrentSyncDevice = syncProfileNames[i] ; | 2333 | mCurrentSyncDevice = syncProfileNames[i] ; |
2334 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; | 2334 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; |
2335 | if ( i == 0 ) { | 2335 | if ( i == 0 ) { |
2336 | syncSharp(); | 2336 | syncSharp(); |
2337 | } else { | 2337 | } else { |
2338 | if ( temp->getIsLocalFileSync() ) { | 2338 | if ( temp->getIsLocalFileSync() ) { |
2339 | if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) ) | 2339 | if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) ) |
2340 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 2340 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
2341 | } else { | 2341 | } else { |
2342 | if ( temp->getIsPhoneSync() ) { | 2342 | if ( temp->getIsPhoneSync() ) { |
2343 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 2343 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
2344 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 2344 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
2345 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 2345 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
2346 | syncPhone(); | 2346 | syncPhone(); |
2347 | } else | 2347 | } else |
2348 | syncRemote( temp, false ); | 2348 | syncRemote( temp, false ); |
2349 | 2349 | ||
2350 | } | 2350 | } |
2351 | } | 2351 | } |
2352 | timer.start(); | 2352 | timer.start(); |
2353 | setCaption(i18n("Multiple sync in progress ... please wait!") ); | 2353 | setCaption(i18n("Multiple sync in progress ... please wait!") ); |
2354 | while ( timer.elapsed () < 2000 ) { | 2354 | while ( timer.elapsed () < 2000 ) { |
2355 | qApp->processEvents(); | 2355 | qApp->processEvents(); |
2356 | #ifndef _WIN32_ | 2356 | #ifndef _WIN32_ |
2357 | sleep (1); | 2357 | sleep (1); |
2358 | #endif | 2358 | #endif |
2359 | } | 2359 | } |
2360 | 2360 | ||
2361 | } | 2361 | } |
2362 | 2362 | ||
2363 | } | 2363 | } |
2364 | delete temp; | 2364 | delete temp; |
2365 | return syncedProfiles; | 2365 | return syncedProfiles; |
2366 | } | 2366 | } |
2367 | 2367 | ||
2368 | void KABCore::syncRemote( KSyncProfile* prof, bool ask) | 2368 | void KABCore::syncRemote( KSyncProfile* prof, bool ask) |
2369 | { | 2369 | { |
2370 | QString question; | 2370 | QString question; |
2371 | if ( ask ) { | 2371 | if ( ask ) { |
2372 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 2372 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
2373 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 2373 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
2374 | question, | 2374 | question, |
2375 | i18n("Yes"), i18n("No"), | 2375 | i18n("Yes"), i18n("No"), |
2376 | 0, 0 ) != 0 ) | 2376 | 0, 0 ) != 0 ) |
2377 | return; | 2377 | return; |
2378 | } | 2378 | } |
2379 | QString command = prof->getPreSyncCommandAB(); | 2379 | QString command = prof->getPreSyncCommandAB(); |
2380 | int fi; | 2380 | int fi; |
2381 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2381 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2382 | QString pwd = getPassword(); | 2382 | QString pwd = getPassword(); |
2383 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2383 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2384 | 2384 | ||
2385 | } | 2385 | } |
2386 | int maxlen = 30; | 2386 | int maxlen = 30; |
2387 | if ( QApplication::desktop()->width() > 320 ) | 2387 | if ( QApplication::desktop()->width() > 320 ) |
2388 | maxlen += 25; | 2388 | maxlen += 25; |
2389 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | 2389 | setCaption ( i18n( "Copy remote file to local machine..." ) ); |
2390 | int fileSize = 0; | 2390 | int fileSize = 0; |
2391 | int result = system ( command ); | 2391 | int result = system ( command ); |
2392 | // 0 : okay | 2392 | // 0 : okay |
2393 | // 256: no such file or dir | 2393 | // 256: no such file or dir |
2394 | // | 2394 | // |
2395 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 2395 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
2396 | if ( result != 0 ) { | 2396 | if ( result != 0 ) { |
2397 | int len = maxlen; | 2397 | int len = maxlen; |
2398 | while ( len < command.length() ) { | 2398 | while ( len < command.length() ) { |
2399 | command.insert( len , "\n" ); | 2399 | command.insert( len , "\n" ); |
2400 | len += maxlen +2; | 2400 | len += maxlen +2; |
2401 | } | 2401 | } |
2402 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; | 2402 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; |
2403 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2403 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2404 | question, | 2404 | question, |
2405 | i18n("Okay!")) ; | 2405 | i18n("Okay!")) ; |
2406 | setCaption ("KO/Pi"); | 2406 | setCaption ("KO/Pi"); |
2407 | return; | 2407 | return; |
2408 | } | 2408 | } |
2409 | setCaption ( i18n( "Copying succeed." ) ); | 2409 | setCaption ( i18n( "Copying succeed." ) ); |
2410 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 2410 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
2411 | if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) { | 2411 | if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) { |
2412 | // Event* e = mView->getLastSyncEvent(); | 2412 | // Event* e = mView->getLastSyncEvent(); |
2413 | // e->setReadOnly( false ); | 2413 | // e->setReadOnly( false ); |
2414 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2414 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2415 | // e->setReadOnly( true ); | 2415 | // e->setReadOnly( true ); |
2416 | if ( KABPrefs::instance()->mWriteBackFile ) { | 2416 | if ( KABPrefs::instance()->mWriteBackFile ) { |
2417 | command = prof->getPostSyncCommandAB(); | 2417 | command = prof->getPostSyncCommandAB(); |
2418 | int fi; | 2418 | int fi; |
2419 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2419 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2420 | QString pwd = getPassword(); | 2420 | QString pwd = getPassword(); |
2421 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2421 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2422 | 2422 | ||
2423 | } | 2423 | } |
2424 | setCaption ( i18n( "Writing back file ..." ) ); | 2424 | setCaption ( i18n( "Writing back file ..." ) ); |
2425 | result = system ( command ); | 2425 | result = system ( command ); |
2426 | qDebug("KO: Writing back file result: %d ", result); | 2426 | qDebug("KO: Writing back file result: %d ", result); |
2427 | if ( result != 0 ) { | 2427 | if ( result != 0 ) { |
2428 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 2428 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
2429 | return; | 2429 | return; |
2430 | } else { | 2430 | } else { |
2431 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 2431 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
2432 | } | 2432 | } |
2433 | } | 2433 | } |
2434 | } | 2434 | } |
2435 | return; | 2435 | return; |
2436 | } | 2436 | } |
2437 | #include <qpushbutton.h> | 2437 | #include <qpushbutton.h> |
2438 | #include <qradiobutton.h> | 2438 | #include <qradiobutton.h> |
2439 | #include <qbuttongroup.h> | 2439 | #include <qbuttongroup.h> |
2440 | void KABCore::edit_sync_options() | 2440 | void KABCore::edit_sync_options() |
2441 | { | 2441 | { |
2442 | //mDialogManager->showSyncOptions(); | 2442 | //mDialogManager->showSyncOptions(); |
2443 | //KABPrefs::instance()->mSyncAlgoPrefs | 2443 | //KABPrefs::instance()->mSyncAlgoPrefs |
2444 | QDialog dia( this, "dia", true ); | 2444 | QDialog dia( this, "dia", true ); |
2445 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 2445 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
2446 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 2446 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
2447 | QVBoxLayout lay ( &dia ); | 2447 | QVBoxLayout lay ( &dia ); |
2448 | lay.setSpacing( 2 ); | 2448 | lay.setSpacing( 2 ); |
2449 | lay.setMargin( 3 ); | 2449 | lay.setMargin( 3 ); |
2450 | lay.addWidget(&gr); | 2450 | lay.addWidget(&gr); |
2451 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 2451 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
2452 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 2452 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
2453 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 2453 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
2454 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 2454 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
2455 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 2455 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
2456 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 2456 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
2457 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 2457 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
2458 | QPushButton pb ( "OK", &dia); | 2458 | QPushButton pb ( "OK", &dia); |
2459 | lay.addWidget( &pb ); | 2459 | lay.addWidget( &pb ); |
2460 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2460 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2461 | switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { | 2461 | switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { |
2462 | case 0: | 2462 | case 0: |
2463 | loc.setChecked( true); | 2463 | loc.setChecked( true); |
2464 | break; | 2464 | break; |
2465 | case 1: | 2465 | case 1: |
2466 | rem.setChecked( true ); | 2466 | rem.setChecked( true ); |
2467 | break; | 2467 | break; |
2468 | case 2: | 2468 | case 2: |
2469 | newest.setChecked( true); | 2469 | newest.setChecked( true); |
2470 | break; | 2470 | break; |
2471 | case 3: | 2471 | case 3: |
2472 | ask.setChecked( true); | 2472 | ask.setChecked( true); |
2473 | break; | 2473 | break; |
2474 | case 4: | 2474 | case 4: |
2475 | f_loc.setChecked( true); | 2475 | f_loc.setChecked( true); |
2476 | break; | 2476 | break; |
2477 | case 5: | 2477 | case 5: |
2478 | f_rem.setChecked( true); | 2478 | f_rem.setChecked( true); |
2479 | break; | 2479 | break; |
2480 | case 6: | 2480 | case 6: |
2481 | // both.setChecked( true); | 2481 | // both.setChecked( true); |
2482 | break; | 2482 | break; |
2483 | default: | 2483 | default: |
2484 | break; | 2484 | break; |
2485 | } | 2485 | } |
2486 | if ( dia.exec() ) { | 2486 | if ( dia.exec() ) { |
2487 | KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 2487 | KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
2488 | } | 2488 | } |
2489 | 2489 | ||
2490 | 2490 | ||
2491 | } | 2491 | } |
2492 | QString KABCore::getPassword( ) | 2492 | QString KABCore::getPassword( ) |
2493 | { | 2493 | { |
2494 | QString retfile = ""; | 2494 | QString retfile = ""; |
2495 | QDialog dia ( this, "input-dialog", true ); | 2495 | QDialog dia ( this, "input-dialog", true ); |
2496 | QLineEdit lab ( &dia ); | 2496 | QLineEdit lab ( &dia ); |
2497 | lab.setEchoMode( QLineEdit::Password ); | 2497 | lab.setEchoMode( QLineEdit::Password ); |
2498 | QVBoxLayout lay( &dia ); | 2498 | QVBoxLayout lay( &dia ); |
2499 | lay.setMargin(7); | 2499 | lay.setMargin(7); |
2500 | lay.setSpacing(7); | 2500 | lay.setSpacing(7); |
2501 | lay.addWidget( &lab); | 2501 | lay.addWidget( &lab); |
2502 | dia.setFixedSize( 230,50 ); | 2502 | dia.setFixedSize( 230,50 ); |
2503 | dia.setCaption( i18n("Enter password") ); | 2503 | dia.setCaption( i18n("Enter password") ); |
2504 | QPushButton pb ( "OK", &dia); | 2504 | QPushButton pb ( "OK", &dia); |
2505 | lay.addWidget( &pb ); | 2505 | lay.addWidget( &pb ); |
2506 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2506 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2507 | dia.show(); | 2507 | dia.show(); |
2508 | int res = dia.exec(); | 2508 | int res = dia.exec(); |
2509 | if ( res ) | 2509 | if ( res ) |
2510 | retfile = lab.text(); | 2510 | retfile = lab.text(); |
2511 | dia.hide(); | 2511 | dia.hide(); |
2512 | qApp->processEvents(); | 2512 | qApp->processEvents(); |
2513 | return retfile; | 2513 | return retfile; |
2514 | 2514 | ||
2515 | } | 2515 | } |
2516 | #include <libkcal/syncdefines.h> | ||
2517 | |||
2518 | KABC::Addressee KABCore::getLastSyncAddressee() | ||
2519 | { | ||
2520 | Addressee lse; | ||
2521 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | ||
2522 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | ||
2523 | if (lse.isEmpty()) { | ||
2524 | lse.setUid( "last-syncEvent-"+mCurrentSyncDevice ); | ||
2525 | QString sum = ""; | ||
2526 | if ( KABPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | ||
2527 | sum = "E: "; | ||
2528 | lse.setFamilyName(sum+mCurrentSyncDevice + i18n(" - sync event")); | ||
2529 | lse.setRevision( mLastAddressbookSync ); | ||
2530 | lse.setCategories( i18n("SyncEvent") ); | ||
2531 | mAddressBook->insertAddressee( lse ); | ||
2532 | } | ||
2533 | return lse; | ||
2534 | } | ||
2535 | |||
2516 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2536 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2517 | { | 2537 | { |
2518 | #if 0 | ||
2519 | bool syncOK = true; | 2538 | bool syncOK = true; |
2520 | int addedAddressee = 0; | 2539 | int addedAddressee = 0; |
2521 | int addedAddresseeR = 0; | 2540 | int addedAddresseeR = 0; |
2522 | int deletedAddresseeR = 0; | 2541 | int deletedAddresseeR = 0; |
2523 | int deletedAddresseeL = 0; | 2542 | int deletedAddresseeL = 0; |
2524 | int changedLocal = 0; | 2543 | int changedLocal = 0; |
2525 | int changedRemote = 0; | 2544 | int changedRemote = 0; |
2526 | //QPtrList<Addressee> el = local->rawAddressees(); | 2545 | //QPtrList<Addressee> el = local->rawAddressees(); |
2527 | Addressee* addresseeR; | 2546 | Addressee addresseeR; |
2528 | QString uid; | 2547 | QString uid; |
2529 | int take; | 2548 | int take; |
2530 | Addressee* addresseeL; | 2549 | Addressee addresseeL; |
2531 | Addressee* addresseeRSync; | 2550 | Addressee addresseeRSync; |
2532 | Addressee* addresseeLSync; | 2551 | Addressee addresseeLSync; |
2533 | QPtrList<Addressee> addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2552 | KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2534 | QPtrList<Addressee> addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2553 | KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2535 | bool fullDateRange = false; | 2554 | bool fullDateRange = false; |
2536 | local->resetTempSyncStat(); | 2555 | local->resetTempSyncStat(); |
2537 | mLastCalendarSync = QDateTime::currentDateTime(); | 2556 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2538 | QDateTime modifiedCalendar = mLastCalendarSync;; | 2557 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2539 | addresseeLSync = getLastSyncAddressee(); | 2558 | addresseeLSync = getLastSyncAddressee(); |
2540 | addresseeR = remote->addressee("last-syncAddressee-"+mCurrentSyncName ); | 2559 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2541 | if ( addresseeR ) { | 2560 | if ( !addresseeR.isEmpty() ) { |
2542 | addresseeRSync = (Addressee*) addresseeR->clone(); | 2561 | addresseeRSync = addresseeR; |
2543 | remote->deleteAddressee(addresseeR ); | 2562 | remote->removeAddressee(addresseeR ); |
2544 | 2563 | ||
2545 | } else { | 2564 | } else { |
2546 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2565 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2547 | addresseeRSync = (Addressee*)addresseeLSync->clone(); | 2566 | addresseeRSync = addresseeLSync ; |
2548 | } else { | 2567 | } else { |
2549 | fullDateRange = true; | 2568 | fullDateRange = true; |
2550 | addresseeRSync = new Addressee(); | 2569 | Addressee newAdd; |
2551 | addresseeRSync->setSummary(mCurrentSyncName + i18n(" - sync addressee")); | 2570 | addresseeRSync = newAdd; |
2552 | addresseeRSync->setUid("last-syncAddressee-"+mCurrentSyncName ); | 2571 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2553 | addresseeRSync->setDtStart( mLastCalendarSync ); | 2572 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2554 | addresseeRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 2573 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2555 | addresseeRSync->setCategories( i18n("SyncAddressee") ); | 2574 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2556 | } | 2575 | } |
2557 | } | 2576 | } |
2558 | if ( addresseeLSync->dtStart() == mLastCalendarSync ) | 2577 | if ( addresseeLSync.revision() == mLastAddressbookSync ) |
2559 | fullDateRange = true; | 2578 | fullDateRange = true; |
2560 | |||
2561 | if ( ! fullDateRange ) { | 2579 | if ( ! fullDateRange ) { |
2562 | if ( addresseeLSync->dtStart() != addresseeRSync->dtStart() ) { | 2580 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2563 | 2581 | ||
2564 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2582 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2565 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2583 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2566 | fullDateRange = true; | 2584 | fullDateRange = true; |
2567 | } | 2585 | } |
2568 | } | 2586 | } |
2569 | if ( fullDateRange ) | 2587 | if ( fullDateRange ) |
2570 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 2588 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2571 | else | 2589 | else |
2572 | mLastCalendarSync = addresseeLSync->dtStart(); | 2590 | mLastAddressbookSync = addresseeLSync.revision(); |
2573 | // for resyncing if own file has changed | 2591 | // for resyncing if own file has changed |
2592 | // PENDING fixme later when implemented | ||
2593 | #if 0 | ||
2574 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2594 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2575 | mLastCalendarSync = loadedFileVersion; | 2595 | mLastAddressbookSync = loadedFileVersion; |
2576 | qDebug("setting mLastCalendarSync "); | 2596 | qDebug("setting mLastAddressbookSync "); |
2577 | } | 2597 | } |
2598 | #endif | ||
2599 | |||
2600 | #if 0 | ||
2578 | //qDebug("*************************** "); | 2601 | //qDebug("*************************** "); |
2579 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 2602 | qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2580 | QPtrList<Incidence> er = remote->rawIncidences(); | 2603 | QPtrList<Incidence> er = remote->rawIncidences(); |
2581 | Incidence* inR = er.first(); | 2604 | Incidence* inR = er.first(); |
2582 | Incidence* inL; | 2605 | Incidence* inL; |
2583 | QProgressBar bar( er.count(),0 ); | 2606 | QProgressBar bar( er.count(),0 ); |
2584 | bar.setCaption (i18n("Syncing - close to abort!") ); | 2607 | bar.setCaption (i18n("Syncing - close to abort!") ); |
2585 | 2608 | ||
2586 | int w = 300; | 2609 | int w = 300; |
2587 | if ( QApplication::desktop()->width() < 320 ) | 2610 | if ( QApplication::desktop()->width() < 320 ) |
2588 | w = 220; | 2611 | w = 220; |
2589 | int h = bar.sizeHint().height() ; | 2612 | int h = bar.sizeHint().height() ; |
2590 | int dw = QApplication::desktop()->width(); | 2613 | int dw = QApplication::desktop()->width(); |
2591 | int dh = QApplication::desktop()->height(); | 2614 | int dh = QApplication::desktop()->height(); |
2592 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2615 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2593 | bar.show(); | 2616 | bar.show(); |
2594 | int modulo = (er.count()/10)+1; | 2617 | int modulo = (er.count()/10)+1; |
2595 | int incCounter = 0; | 2618 | int incCounter = 0; |
2596 | while ( inR ) { | 2619 | while ( inR ) { |
2597 | if ( ! bar.isVisible() ) | 2620 | if ( ! bar.isVisible() ) |
2598 | return false; | 2621 | return false; |
2599 | if ( incCounter % modulo == 0 ) | 2622 | if ( incCounter % modulo == 0 ) |
2600 | bar.setProgress( incCounter ); | 2623 | bar.setProgress( incCounter ); |
2601 | ++incCounter; | 2624 | ++incCounter; |
2602 | uid = inR->uid(); | 2625 | uid = inR->uid(); |
2603 | bool skipIncidence = false; | 2626 | bool skipIncidence = false; |
2604 | if ( uid.left(15) == QString("last-syncAddressee-") ) | 2627 | if ( uid.left(15) == QString("last-syncAddressee-") ) |
2605 | skipIncidence = true; | 2628 | skipIncidence = true; |
2606 | QString idS; | 2629 | QString idS; |
2607 | qApp->processAddressees(); | 2630 | qApp->processAddressees(); |
2608 | if ( !skipIncidence ) { | 2631 | if ( !skipIncidence ) { |
2609 | inL = local->incidence( uid ); | 2632 | inL = local->incidence( uid ); |
2610 | if ( inL ) { // maybe conflict - same uid in both calendars | 2633 | if ( inL ) { // maybe conflict - same uid in both calendars |
2611 | int maxrev = inL->revision(); | 2634 | int maxrev = inL->revision(); |
2612 | if ( maxrev < inR->revision() ) | 2635 | if ( maxrev < inR->revision() ) |
2613 | maxrev = inR->revision(); | 2636 | maxrev = inR->revision(); |
2614 | if ( (take = takeAddressee( inL, inR, mode, fullDateRange )) > 0 ) { | 2637 | if ( (take = takeAddressee( inL, inR, mode, fullDateRange )) > 0 ) { |
2615 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 2638 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
2616 | if ( take == 3 ) | 2639 | if ( take == 3 ) |
2617 | return false; | 2640 | return false; |
2618 | if ( take == 1 ) {// take local | 2641 | if ( take == 1 ) {// take local |
2619 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2642 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2620 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 2643 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
2621 | else | 2644 | else |
2622 | idS = inR->IDStr(); | 2645 | idS = inR->IDStr(); |
2623 | remote->deleteIncidence( inR ); | 2646 | remote->deleteIncidence( inR ); |
2624 | if ( inL->revision() < maxrev ) | 2647 | if ( inL->revision() < maxrev ) |
2625 | inL->setRevision( maxrev ); | 2648 | inL->setRevision( maxrev ); |
2626 | inR = inL->clone(); | 2649 | inR = inL->clone(); |
2627 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2650 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2628 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 2651 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
2629 | inR->setIDStr( idS ); | 2652 | inR->setIDStr( idS ); |
2630 | remote->addIncidence( inR ); | 2653 | remote->addIncidence( inR ); |
2631 | ++changedRemote; | 2654 | ++changedRemote; |
2632 | } else { | 2655 | } else { |
2633 | if ( inR->revision() < maxrev ) | 2656 | if ( inR->revision() < maxrev ) |
2634 | inR->setRevision( maxrev ); | 2657 | inR->setRevision( maxrev ); |
2635 | idS = inL->IDStr(); | 2658 | idS = inL->IDStr(); |
2636 | local->deleteIncidence( inL ); | 2659 | local->deleteIncidence( inL ); |
2637 | inL = inR->clone(); | 2660 | inL = inR->clone(); |
2638 | inL->setIDStr( idS ); | 2661 | inL->setIDStr( idS ); |
2639 | local->addIncidence( inL ); | 2662 | local->addIncidence( inL ); |
2640 | ++changedLocal; | 2663 | ++changedLocal; |
2641 | } | 2664 | } |
2642 | } | 2665 | } |
2643 | } else { // no conflict | 2666 | } else { // no conflict |
2644 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2667 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2645 | QString des = addresseeLSync->description(); | 2668 | QString des = addresseeLSync->description(); |
2646 | QString pref = "e"; | 2669 | QString pref = "e"; |
2647 | if ( inR->type() == "Todo" ) | 2670 | if ( inR->type() == "Todo" ) |
2648 | pref = "t"; | 2671 | pref = "t"; |
2649 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2672 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2650 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2673 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2651 | //remote->deleteIncidence( inR ); | 2674 | //remote->deleteIncidence( inR ); |
2652 | ++deletedAddresseeR; | 2675 | ++deletedAddresseeR; |
2653 | } else { | 2676 | } else { |
2654 | inR->setLastModified( modifiedCalendar ); | 2677 | inR->setLastModified( modifiedCalendar ); |
2655 | inL = inR->clone(); | 2678 | inL = inR->clone(); |
2656 | local->addIncidence( inL ); | 2679 | local->addIncidence( inL ); |
2657 | ++addedAddressee; | 2680 | ++addedAddressee; |
2658 | } | 2681 | } |
2659 | } else { | 2682 | } else { |
2660 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 2683 | if ( inR->lastModified() > mLastAddressbookSync || mode == 5 ) { |
2661 | inR->setLastModified( modifiedCalendar ); | 2684 | inR->setLastModified( modifiedCalendar ); |
2662 | local->addIncidence( inR->clone() ); | 2685 | local->addIncidence( inR->clone() ); |
2663 | ++addedAddressee; | 2686 | ++addedAddressee; |
2664 | } else { | 2687 | } else { |
2665 | checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2688 | checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2666 | remote->deleteIncidence( inR ); | 2689 | remote->deleteIncidence( inR ); |
2667 | ++deletedAddresseeR; | 2690 | ++deletedAddresseeR; |
2668 | } | 2691 | } |
2669 | } | 2692 | } |
2670 | } | 2693 | } |
2671 | } | 2694 | } |
2672 | inR = er.next(); | 2695 | inR = er.next(); |
2673 | } | 2696 | } |
2674 | QPtrList<Incidence> el = local->rawIncidences(); | 2697 | QPtrList<Incidence> el = local->rawIncidences(); |
2675 | inL = el.first(); | 2698 | inL = el.first(); |
2676 | modulo = (el.count()/10)+1; | 2699 | modulo = (el.count()/10)+1; |
2677 | bar.setCaption (i18n("Add / remove addressees") ); | 2700 | bar.setCaption (i18n("Add / remove addressees") ); |
2678 | bar.setTotalSteps ( el.count() ) ; | 2701 | bar.setTotalSteps ( el.count() ) ; |
2679 | bar.show(); | 2702 | bar.show(); |
2680 | incCounter = 0; | 2703 | incCounter = 0; |
2681 | 2704 | ||
2682 | while ( inL ) { | 2705 | while ( inL ) { |
2683 | 2706 | ||
2684 | qApp->processAddressees(); | 2707 | qApp->processAddressees(); |
2685 | if ( ! bar.isVisible() ) | 2708 | if ( ! bar.isVisible() ) |
2686 | return false; | 2709 | return false; |
2687 | if ( incCounter % modulo == 0 ) | 2710 | if ( incCounter % modulo == 0 ) |
2688 | bar.setProgress( incCounter ); | 2711 | bar.setProgress( incCounter ); |
2689 | ++incCounter; | 2712 | ++incCounter; |
2690 | uid = inL->uid(); | 2713 | uid = inL->uid(); |
2691 | bool skipIncidence = false; | 2714 | bool skipIncidence = false; |
2692 | if ( uid.left(15) == QString("last-syncAddressee-") ) | 2715 | if ( uid.left(15) == QString("last-syncAddressee-") ) |
2693 | skipIncidence = true; | 2716 | skipIncidence = true; |
2694 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 2717 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
2695 | skipIncidence = true; | 2718 | skipIncidence = true; |
2696 | if ( !skipIncidence ) { | 2719 | if ( !skipIncidence ) { |
2697 | inR = remote->incidence( uid ); | 2720 | inR = remote->incidence( uid ); |
2698 | if ( ! inR ) { | 2721 | if ( ! inR ) { |
2699 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2722 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2700 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2723 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2701 | checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2724 | checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2702 | local->deleteIncidence( inL ); | 2725 | local->deleteIncidence( inL ); |
2703 | ++deletedAddresseeL; | 2726 | ++deletedAddresseeL; |
2704 | } else { | 2727 | } else { |
2705 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 2728 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
2706 | inL->removeID(mCurrentSyncDevice ); | 2729 | inL->removeID(mCurrentSyncDevice ); |
2707 | ++addedAddresseeR; | 2730 | ++addedAddresseeR; |
2708 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 2731 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
2709 | inL->setLastModified( modifiedCalendar ); | 2732 | inL->setLastModified( modifiedCalendar ); |
2710 | inR = inL->clone(); | 2733 | inR = inL->clone(); |
2711 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2734 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2712 | remote->addIncidence( inR ); | 2735 | remote->addIncidence( inR ); |
2713 | } | 2736 | } |
2714 | } | 2737 | } |
2715 | } else { | 2738 | } else { |
2716 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 2739 | if ( inL->lastModified() < mLastAddressbookSync && mode != 4 ) { |
2717 | checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2740 | checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2718 | local->deleteIncidence( inL ); | 2741 | local->deleteIncidence( inL ); |
2719 | ++deletedAddresseeL; | 2742 | ++deletedAddresseeL; |
2720 | } else { | 2743 | } else { |
2721 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 2744 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
2722 | ++addedAddresseeR; | 2745 | ++addedAddresseeR; |
2723 | inL->setLastModified( modifiedCalendar ); | 2746 | inL->setLastModified( modifiedCalendar ); |
2724 | remote->addIncidence( inL->clone() ); | 2747 | remote->addIncidence( inL->clone() ); |
2725 | } | 2748 | } |
2726 | } | 2749 | } |
2727 | } | 2750 | } |
2728 | } | 2751 | } |
2729 | } | 2752 | } |
2730 | inL = el.next(); | 2753 | inL = el.next(); |
2731 | } | 2754 | } |
2732 | int delFut = 0; | 2755 | int delFut = 0; |
2733 | if ( KOPrefs::instance()->mWriteBackInFuture ) { | 2756 | if ( KOPrefs::instance()->mWriteBackInFuture ) { |
2734 | er = remote->rawIncidences(); | 2757 | er = remote->rawIncidences(); |
2735 | inR = er.first(); | 2758 | inR = er.first(); |
2736 | QDateTime dt; | 2759 | QDateTime dt; |
2737 | QDateTime cur = QDateTime::currentDateTime(); | 2760 | QDateTime cur = QDateTime::currentDateTime(); |
2738 | QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); | 2761 | QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); |
2739 | while ( inR ) { | 2762 | while ( inR ) { |
2740 | if ( inR->type() == "Todo" ) { | 2763 | if ( inR->type() == "Todo" ) { |
2741 | Todo * t = (Todo*)inR; | 2764 | Todo * t = (Todo*)inR; |
2742 | if ( t->hasDueDate() ) | 2765 | if ( t->hasDueDate() ) |
2743 | dt = t->dtDue(); | 2766 | dt = t->dtDue(); |
2744 | else | 2767 | else |
2745 | dt = cur.addSecs( 62 ); | 2768 | dt = cur.addSecs( 62 ); |
2746 | } | 2769 | } |
2747 | else if (inR->type() == "Addressee" ) { | 2770 | else if (inR->type() == "Addressee" ) { |
2748 | bool ok; | 2771 | bool ok; |
2749 | dt = inR->getNextOccurence( cur, &ok ); | 2772 | dt = inR->getNextOccurence( cur, &ok ); |
2750 | if ( !ok ) | 2773 | if ( !ok ) |
2751 | dt = cur.addSecs( -62 ); | 2774 | dt = cur.addSecs( -62 ); |
2752 | } | 2775 | } |
2753 | else | 2776 | else |
2754 | dt = inR->dtStart(); | 2777 | dt = inR->dtStart(); |
2755 | if ( dt < cur || dt > end ) { | 2778 | if ( dt < cur || dt > end ) { |
2756 | remote->deleteIncidence( inR ); | 2779 | remote->deleteIncidence( inR ); |
2757 | ++delFut; | 2780 | ++delFut; |
2758 | } | 2781 | } |
2759 | inR = er.next(); | 2782 | inR = er.next(); |
2760 | } | 2783 | } |
2761 | } | 2784 | } |
2762 | bar.hide(); | 2785 | bar.hide(); |
2763 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 2786 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2764 | addresseeLSync->setReadOnly( false ); | 2787 | addresseeLSync->setReadOnly( false ); |
2765 | addresseeLSync->setDtStart( mLastCalendarSync ); | 2788 | addresseeLSync->setDtStart( mLastAddressbookSync ); |
2766 | addresseeRSync->setDtStart( mLastCalendarSync ); | 2789 | addresseeRSync->setDtStart( mLastAddressbookSync ); |
2767 | addresseeLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 2790 | addresseeLSync->setDtEnd( mLastAddressbookSync.addSecs( 3600 ) ); |
2768 | addresseeRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 2791 | addresseeRSync->setDtEnd( mLastAddressbookSync.addSecs( 3600 ) ); |
2769 | addresseeRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 2792 | addresseeRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
2770 | addresseeLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 2793 | addresseeLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
2771 | addresseeLSync->setReadOnly( true ); | 2794 | addresseeLSync->setReadOnly( true ); |
2772 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2795 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2773 | remote->addAddressee( addresseeRSync ); | 2796 | remote->addAddressee( addresseeRSync ); |
2774 | QString mes; | 2797 | QString mes; |
2775 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); | 2798 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); |
2776 | QString delmess; | 2799 | QString delmess; |
2777 | if ( delFut ) { | 2800 | if ( delFut ) { |
2778 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); | 2801 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); |
2779 | mes += delmess; | 2802 | mes += delmess; |
2780 | } | 2803 | } |
2781 | if ( KOPrefs::instance()->mShowSyncSummary ) { | 2804 | if ( KOPrefs::instance()->mShowSyncSummary ) { |
2782 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 2805 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
2783 | } | 2806 | } |
2784 | qDebug( mes ); | 2807 | qDebug( mes ); |
2785 | mCalendar->checkAlarmForIncidence( 0, true ); | 2808 | mCalendar->checkAlarmForIncidence( 0, true ); |
2786 | return syncOK; | 2809 | return syncOK; |
2787 | #endif | 2810 | #endif |
2788 | return false; | 2811 | return false; |
2789 | } | 2812 | } |
2790 | bool KABCore::syncAB(QString filename, int mode) | 2813 | bool KABCore::syncAB(QString filename, int mode) |
2791 | { | 2814 | { |
2792 | 2815 | ||
2793 | //pending prepare addresseeview for output | 2816 | //pending prepare addresseeview for output |
2794 | //pending detect, if remote file has REV field. if not switch to external sync | 2817 | //pending detect, if remote file has REV field. if not switch to external sync |
2795 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2818 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2796 | AddressBook abLocal(filename,"syncContact"); | 2819 | AddressBook abLocal(filename,"syncContact"); |
2797 | bool syncOK = false; | 2820 | bool syncOK = false; |
2798 | if ( abLocal.load() ) { | 2821 | if ( abLocal.load() ) { |
2799 | qDebug("AB loaded %s mode %d",filename.latin1(), mode ); | 2822 | qDebug("AB loaded %s mode %d",filename.latin1(), mode ); |
2800 | AddressBook::Iterator it; | 2823 | AddressBook::Iterator it; |
2801 | QStringList vcards; | 2824 | QStringList vcards; |
2802 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2825 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2803 | qDebug("Name %s ", (*it).familyName().latin1()); | 2826 | qDebug("Name %s ", (*it).familyName().latin1()); |
2804 | } | 2827 | } |
2805 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2828 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2806 | if ( syncOK ) { | 2829 | if ( syncOK ) { |
2807 | if ( KABPrefs::instance()->mWriteBackFile ) | 2830 | if ( KABPrefs::instance()->mWriteBackFile ) |
2808 | { | 2831 | { |
2809 | qDebug("saving remote AB "); | 2832 | qDebug("saving remote AB "); |
2810 | abLocal.saveAB(); | 2833 | abLocal.saveAB(); |
2811 | } | 2834 | } |
2812 | } | 2835 | } |
2813 | setModified(); | 2836 | setModified(); |
2814 | 2837 | ||
2815 | } | 2838 | } |
2816 | if ( syncOK ) | 2839 | if ( syncOK ) |
2817 | mViewManager->refreshView(); | 2840 | mViewManager->refreshView(); |
2818 | return syncOK; | 2841 | return syncOK; |
2819 | #if 0 | 2842 | #if 0 |
2820 | 2843 | ||
2821 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2844 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2822 | getEventViewerDialog()->setSyncMode( true ); | 2845 | getEventViewerDialog()->setSyncMode( true ); |
2823 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2846 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2824 | getEventViewerDialog()->setSyncMode( false ); | 2847 | getEventViewerDialog()->setSyncMode( false ); |
2825 | if ( syncOK ) { | 2848 | if ( syncOK ) { |
2826 | if ( KOPrefs::instance()->mWriteBackFile ) | 2849 | if ( KOPrefs::instance()->mWriteBackFile ) |
2827 | { | 2850 | { |
2828 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2851 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2829 | storage->save(); | 2852 | storage->save(); |
2830 | } | 2853 | } |
2831 | } | 2854 | } |
2832 | setModified(); | 2855 | setModified(); |
2833 | } | 2856 | } |
2834 | 2857 | ||
2835 | #endif | 2858 | #endif |
2836 | } | 2859 | } |
2837 | 2860 | ||
2838 | 2861 | ||
2839 | void KABCore::confSync() | 2862 | void KABCore::confSync() |
2840 | { | 2863 | { |
2841 | static KSyncPrefsDialog* sp = 0; | 2864 | static KSyncPrefsDialog* sp = 0; |
2842 | if ( ! sp ) { | 2865 | if ( ! sp ) { |
2843 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | 2866 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
2844 | } | 2867 | } |
2845 | sp->usrReadConfig(); | 2868 | sp->usrReadConfig(); |
2846 | #ifndef DESKTOP_VERSION | 2869 | #ifndef DESKTOP_VERSION |
2847 | sp->showMaximized(); | 2870 | sp->showMaximized(); |
2848 | #else | 2871 | #else |
2849 | sp->show(); | 2872 | sp->show(); |
2850 | #endif | 2873 | #endif |
2851 | sp->exec(); | 2874 | sp->exec(); |
2852 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 2875 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
2853 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 2876 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
2854 | fillSyncMenu(); | 2877 | fillSyncMenu(); |
2855 | } | 2878 | } |
2856 | void KABCore::syncSharp() | 2879 | void KABCore::syncSharp() |
2857 | { | 2880 | { |
2858 | if ( mModified ) | 2881 | if ( mModified ) |
2859 | save(); | 2882 | save(); |
2860 | qDebug("pending syncSharp() "); | 2883 | qDebug("pending syncSharp() "); |
2861 | //mView->syncSharp(); | 2884 | //mView->syncSharp(); |
2862 | setModified(); | 2885 | setModified(); |
2863 | 2886 | ||
2864 | } | 2887 | } |
2865 | void KABCore::syncPhone() | 2888 | void KABCore::syncPhone() |
2866 | { | 2889 | { |
2867 | if ( mModified ) | 2890 | if ( mModified ) |
2868 | save(); | 2891 | save(); |
2869 | qDebug("pending syncPhone(); "); | 2892 | qDebug("pending syncPhone(); "); |
2870 | //mView->syncPhone(); | 2893 | //mView->syncPhone(); |
2871 | setModified(); | 2894 | setModified(); |
2872 | 2895 | ||
2873 | } | 2896 | } |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 4487a8a..c67cee6 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -283,199 +283,201 @@ class KABCore : public QWidget | |||
283 | 283 | ||
284 | /** | 284 | /** |
285 | Saves the contents of the AddressBook back to disk. | 285 | Saves the contents of the AddressBook back to disk. |
286 | */ | 286 | */ |
287 | void save(); | 287 | void save(); |
288 | 288 | ||
289 | /** | 289 | /** |
290 | Undos the last command using the undo stack. | 290 | Undos the last command using the undo stack. |
291 | */ | 291 | */ |
292 | void undo(); | 292 | void undo(); |
293 | 293 | ||
294 | /** | 294 | /** |
295 | Redos the last command that was undone, using the redo stack. | 295 | Redos the last command that was undone, using the redo stack. |
296 | */ | 296 | */ |
297 | void redo(); | 297 | void redo(); |
298 | 298 | ||
299 | /** | 299 | /** |
300 | Shows the edit dialog for the given uid. If the uid is QString::null, | 300 | Shows the edit dialog for the given uid. If the uid is QString::null, |
301 | the method will try to find a selected addressee in the view. | 301 | the method will try to find a selected addressee in the view. |
302 | */ | 302 | */ |
303 | void editContact( const QString &uid /*US = QString::null*/ ); | 303 | void editContact( const QString &uid /*US = QString::null*/ ); |
304 | //US added a second method without defaultparameter | 304 | //US added a second method without defaultparameter |
305 | void editContact2(); | 305 | void editContact2(); |
306 | 306 | ||
307 | /** | 307 | /** |
308 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 308 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
309 | the method will try to find a selected addressee in the view. | 309 | the method will try to find a selected addressee in the view. |
310 | */ | 310 | */ |
311 | void executeContact( const QString &uid /*US = QString::null*/ ); | 311 | void executeContact( const QString &uid /*US = QString::null*/ ); |
312 | 312 | ||
313 | /** | 313 | /** |
314 | Launches the configuration dialog. | 314 | Launches the configuration dialog. |
315 | */ | 315 | */ |
316 | void openConfigDialog(); | 316 | void openConfigDialog(); |
317 | 317 | ||
318 | /** | 318 | /** |
319 | Launches the ldap search dialog. | 319 | Launches the ldap search dialog. |
320 | */ | 320 | */ |
321 | void openLDAPDialog(); | 321 | void openLDAPDialog(); |
322 | 322 | ||
323 | /** | 323 | /** |
324 | Creates a KAddressBookPrinter, which will display the print | 324 | Creates a KAddressBookPrinter, which will display the print |
325 | dialog and do the printing. | 325 | dialog and do the printing. |
326 | */ | 326 | */ |
327 | void print(); | 327 | void print(); |
328 | 328 | ||
329 | /** | 329 | /** |
330 | Registers a new GUI client, so plugins can register its actions. | 330 | Registers a new GUI client, so plugins can register its actions. |
331 | */ | 331 | */ |
332 | void addGUIClient( KXMLGUIClient *client ); | 332 | void addGUIClient( KXMLGUIClient *client ); |
333 | 333 | ||
334 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); | 334 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); |
335 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); | 335 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); |
336 | 336 | ||
337 | 337 | ||
338 | signals: | 338 | signals: |
339 | void contactSelected( const QString &name ); | 339 | void contactSelected( const QString &name ); |
340 | void contactSelected( const QPixmap &pixmap ); | 340 | void contactSelected( const QPixmap &pixmap ); |
341 | public slots: | 341 | public slots: |
342 | void setDetailsVisible( bool visible ); | 342 | void setDetailsVisible( bool visible ); |
343 | void setDetailsToState(); | 343 | void setDetailsToState(); |
344 | void slotSyncMenu( int ); | 344 | void slotSyncMenu( int ); |
345 | private slots: | 345 | private slots: |
346 | void setJumpButtonBarVisible( bool visible ); | 346 | void setJumpButtonBarVisible( bool visible ); |
347 | void importFromOL(); | 347 | void importFromOL(); |
348 | void extensionModified( const KABC::Addressee::List &list ); | 348 | void extensionModified( const KABC::Addressee::List &list ); |
349 | void extensionChanged( int id ); | 349 | void extensionChanged( int id ); |
350 | void clipboardDataChanged(); | 350 | void clipboardDataChanged(); |
351 | void updateActionMenu(); | 351 | void updateActionMenu(); |
352 | void configureKeyBindings(); | 352 | void configureKeyBindings(); |
353 | void removeVoice(); | 353 | void removeVoice(); |
354 | #ifdef KAB_EMBEDDED | 354 | #ifdef KAB_EMBEDDED |
355 | void configureResources(); | 355 | void configureResources(); |
356 | #endif //KAB_EMBEDDED | 356 | #endif //KAB_EMBEDDED |
357 | 357 | ||
358 | void slotEditorDestroyed( const QString &uid ); | 358 | void slotEditorDestroyed( const QString &uid ); |
359 | void configurationChanged(); | 359 | void configurationChanged(); |
360 | void addressBookChanged(); | 360 | void addressBookChanged(); |
361 | 361 | ||
362 | private: | 362 | private: |
363 | void initGUI(); | 363 | void initGUI(); |
364 | void initActions(); | 364 | void initActions(); |
365 | 365 | ||
366 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, | 366 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, |
367 | const char *name = 0 ); | 367 | const char *name = 0 ); |
368 | 368 | ||
369 | KXMLGUIClient *mGUIClient; | 369 | KXMLGUIClient *mGUIClient; |
370 | 370 | ||
371 | KABC::AddressBook *mAddressBook; | 371 | KABC::AddressBook *mAddressBook; |
372 | 372 | ||
373 | ViewManager *mViewManager; | 373 | ViewManager *mViewManager; |
374 | // QSplitter *mDetailsSplitter; | 374 | // QSplitter *mDetailsSplitter; |
375 | KDGanttMinimizeSplitter *mExtensionBarSplitter; | 375 | KDGanttMinimizeSplitter *mExtensionBarSplitter; |
376 | ViewContainer *mDetails; | 376 | ViewContainer *mDetails; |
377 | KDGanttMinimizeSplitter* mMiniSplitter; | 377 | KDGanttMinimizeSplitter* mMiniSplitter; |
378 | XXPortManager *mXXPortManager; | 378 | XXPortManager *mXXPortManager; |
379 | JumpButtonBar *mJumpButtonBar; | 379 | JumpButtonBar *mJumpButtonBar; |
380 | IncSearchWidget *mIncSearchWidget; | 380 | IncSearchWidget *mIncSearchWidget; |
381 | ExtensionManager *mExtensionManager; | 381 | ExtensionManager *mExtensionManager; |
382 | 382 | ||
383 | KCMultiDialog *mConfigureDialog; | 383 | KCMultiDialog *mConfigureDialog; |
384 | 384 | ||
385 | #ifndef KAB_EMBEDDED | 385 | #ifndef KAB_EMBEDDED |
386 | LDAPSearchDialog *mLdapSearchDialog; | 386 | LDAPSearchDialog *mLdapSearchDialog; |
387 | #endif //KAB_EMBEDDED | 387 | #endif //KAB_EMBEDDED |
388 | // QDict<AddresseeEditorDialog> mEditorDict; | 388 | // QDict<AddresseeEditorDialog> mEditorDict; |
389 | AddresseeEditorDialog *mEditorDialog; | 389 | AddresseeEditorDialog *mEditorDialog; |
390 | bool mReadWrite; | 390 | bool mReadWrite; |
391 | bool mModified; | 391 | bool mModified; |
392 | bool mIsPart; | 392 | bool mIsPart; |
393 | bool mMultipleViewsAtOnce; | 393 | bool mMultipleViewsAtOnce; |
394 | 394 | ||
395 | 395 | ||
396 | //US file menu | 396 | //US file menu |
397 | KAction *mActionMail; | 397 | KAction *mActionMail; |
398 | KAction *mActionBeam; | 398 | KAction *mActionBeam; |
399 | KAction* mActionPrint; | 399 | KAction* mActionPrint; |
400 | KAction* mActionNewContact; | 400 | KAction* mActionNewContact; |
401 | KAction *mActionSave; | 401 | KAction *mActionSave; |
402 | KAction *mActionEditAddressee; | 402 | KAction *mActionEditAddressee; |
403 | KAction *mActionMailVCard; | 403 | KAction *mActionMailVCard; |
404 | KAction *mActionBeamVCard; | 404 | KAction *mActionBeamVCard; |
405 | 405 | ||
406 | KAction *mActionQuit; | 406 | KAction *mActionQuit; |
407 | 407 | ||
408 | //US edit menu | 408 | //US edit menu |
409 | KAction *mActionCopy; | 409 | KAction *mActionCopy; |
410 | KAction *mActionCut; | 410 | KAction *mActionCut; |
411 | KAction *mActionPaste; | 411 | KAction *mActionPaste; |
412 | KAction *mActionSelectAll; | 412 | KAction *mActionSelectAll; |
413 | KAction *mActionUndo; | 413 | KAction *mActionUndo; |
414 | KAction *mActionRedo; | 414 | KAction *mActionRedo; |
415 | KAction *mActionDelete; | 415 | KAction *mActionDelete; |
416 | 416 | ||
417 | //US settings menu | 417 | //US settings menu |
418 | KAction *mActionConfigResources; | 418 | KAction *mActionConfigResources; |
419 | KAction *mActionConfigKAddressbook; | 419 | KAction *mActionConfigKAddressbook; |
420 | KAction *mActionConfigShortcuts; | 420 | KAction *mActionConfigShortcuts; |
421 | KAction *mActionConfigureToolbars; | 421 | KAction *mActionConfigureToolbars; |
422 | KAction *mActionKeyBindings; | 422 | KAction *mActionKeyBindings; |
423 | KToggleAction *mActionJumpBar; | 423 | KToggleAction *mActionJumpBar; |
424 | KToggleAction *mActionDetails; | 424 | KToggleAction *mActionDetails; |
425 | KAction *mActionWhoAmI; | 425 | KAction *mActionWhoAmI; |
426 | KAction *mActionCategories; | 426 | KAction *mActionCategories; |
427 | KAction *mActionAboutKAddressbook; | 427 | KAction *mActionAboutKAddressbook; |
428 | KAction *mActionLicence; | 428 | KAction *mActionLicence; |
429 | KAction *mActionFaq; | 429 | KAction *mActionFaq; |
430 | 430 | ||
431 | KAction *mActionDeleteView; | 431 | KAction *mActionDeleteView; |
432 | 432 | ||
433 | QPopupMenu *viewMenu; | 433 | QPopupMenu *viewMenu; |
434 | QPopupMenu *filterMenu; | 434 | QPopupMenu *filterMenu; |
435 | QPopupMenu *settingsMenu; | 435 | QPopupMenu *settingsMenu; |
436 | QPopupMenu *changeMenu; | 436 | QPopupMenu *changeMenu; |
437 | //US QAction *mActionSave; | 437 | //US QAction *mActionSave; |
438 | QPopupMenu *ImportMenu; | 438 | QPopupMenu *ImportMenu; |
439 | QPopupMenu *ExportMenu; | 439 | QPopupMenu *ExportMenu; |
440 | //LR additional methods | 440 | //LR additional methods |
441 | KAction *mActionRemoveVoice; | 441 | KAction *mActionRemoveVoice; |
442 | KAction * mActionImportOL; | 442 | KAction * mActionImportOL; |
443 | 443 | ||
444 | #ifndef KAB_EMBEDDED | 444 | #ifndef KAB_EMBEDDED |
445 | KAddressBookService *mAddressBookService; | 445 | KAddressBookService *mAddressBookService; |
446 | #endif //KAB_EMBEDDED | 446 | #endif //KAB_EMBEDDED |
447 | 447 | ||
448 | class KABCorePrivate; | 448 | class KABCorePrivate; |
449 | KABCorePrivate *d; | 449 | KABCorePrivate *d; |
450 | bool mBlockSaveFlag; | 450 | bool mBlockSaveFlag; |
451 | 451 | ||
452 | #ifdef KAB_EMBEDDED | 452 | #ifdef KAB_EMBEDDED |
453 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 453 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
454 | #endif //KAB_EMBEDDED | 454 | #endif //KAB_EMBEDDED |
455 | // LR ******************************* | 455 | // LR ******************************* |
456 | // sync stuff! | 456 | // sync stuff! |
457 | QPopupMenu *syncMenu; | 457 | QPopupMenu *syncMenu; |
458 | void fillSyncMenu(); | 458 | void fillSyncMenu(); |
459 | QString mCurrentSyncDevice; | 459 | QString mCurrentSyncDevice; |
460 | QString mCurrentSyncName; | 460 | QString mCurrentSyncName; |
461 | void quickSyncLocalFile(); | 461 | void quickSyncLocalFile(); |
462 | bool syncWithFile( QString fn , bool quick ); | 462 | bool syncWithFile( QString fn , bool quick ); |
463 | void KABCore::syncLocalFile(); | 463 | void KABCore::syncLocalFile(); |
464 | void KABCore::syncPhone(); | 464 | void KABCore::syncPhone(); |
465 | void KABCore::syncSharp(); | 465 | void KABCore::syncSharp(); |
466 | void multiSync( bool askforPrefs ); | 466 | void multiSync( bool askforPrefs ); |
467 | int mCurrentSyncProfile ; | 467 | int mCurrentSyncProfile ; |
468 | void syncRemote( KSyncProfile* prof, bool ask = true); | 468 | void syncRemote( KSyncProfile* prof, bool ask = true); |
469 | void edit_sync_options(); | 469 | void edit_sync_options(); |
470 | bool syncAB(QString filename, int mode); | 470 | bool syncAB(QString filename, int mode); |
471 | int ringSync(); | 471 | int ringSync(); |
472 | QString getPassword( ); | 472 | QString getPassword( ); |
473 | int mGlobalSyncMode; | 473 | int mGlobalSyncMode; |
474 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); | 474 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); |
475 | KABC::Addressee getLastSyncAddressee(); | ||
476 | QDateTime mLastAddressbookSync; | ||
475 | public slots: | 477 | public slots: |
476 | void confSync(); | 478 | void confSync(); |
477 | // ********************* | 479 | // ********************* |
478 | 480 | ||
479 | }; | 481 | }; |
480 | 482 | ||
481 | #endif | 483 | #endif |