-rw-r--r-- | kabc/addressbook.cpp | 1 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 2 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 2 |
3 files changed, 2 insertions, 3 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 295cf03..03a86f9 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -1,996 +1,995 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | /*US | 28 | /*US |
29 | 29 | ||
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | ||
34 | #include <kapplication.h> | 34 | #include <kapplication.h> |
35 | #include <kinstance.h> | 35 | #include <kinstance.h> |
36 | #include <kstandarddirs.h> | 36 | #include <kstandarddirs.h> |
37 | 37 | ||
38 | #include "errorhandler.h" | 38 | #include "errorhandler.h" |
39 | */ | 39 | */ |
40 | #include <qptrlist.h> | 40 | #include <qptrlist.h> |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | #include <qfile.h> | 42 | #include <qfile.h> |
43 | 43 | ||
44 | #include <kglobal.h> | 44 | #include <kglobal.h> |
45 | #include <klocale.h>> | 45 | #include <klocale.h>> |
46 | #include <kmessagebox.h> | 46 | #include <kmessagebox.h> |
47 | #include <kdebug.h> | 47 | #include <kdebug.h> |
48 | #include <libkcal/syncdefines.h> | 48 | #include <libkcal/syncdefines.h> |
49 | #include "addressbook.h" | 49 | #include "addressbook.h" |
50 | #include "resource.h" | 50 | #include "resource.h" |
51 | #include "vcardconverter.h" | 51 | #include "vcardconverter.h" |
52 | #include "vcardparser/vcardtool.h" | 52 | #include "vcardparser/vcardtool.h" |
53 | 53 | ||
54 | //US #include "addressbook.moc" | 54 | //US #include "addressbook.moc" |
55 | 55 | ||
56 | using namespace KABC; | 56 | using namespace KABC; |
57 | 57 | ||
58 | struct AddressBook::AddressBookData | 58 | struct AddressBook::AddressBookData |
59 | { | 59 | { |
60 | Addressee::List mAddressees; | 60 | Addressee::List mAddressees; |
61 | Addressee::List mRemovedAddressees; | 61 | Addressee::List mRemovedAddressees; |
62 | Field::List mAllFields; | 62 | Field::List mAllFields; |
63 | KConfig *mConfig; | 63 | KConfig *mConfig; |
64 | KRES::Manager<Resource> *mManager; | 64 | KRES::Manager<Resource> *mManager; |
65 | //US ErrorHandler *mErrorHandler; | 65 | //US ErrorHandler *mErrorHandler; |
66 | }; | 66 | }; |
67 | 67 | ||
68 | struct AddressBook::Iterator::IteratorData | 68 | struct AddressBook::Iterator::IteratorData |
69 | { | 69 | { |
70 | Addressee::List::Iterator mIt; | 70 | Addressee::List::Iterator mIt; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | struct AddressBook::ConstIterator::ConstIteratorData | 73 | struct AddressBook::ConstIterator::ConstIteratorData |
74 | { | 74 | { |
75 | Addressee::List::ConstIterator mIt; | 75 | Addressee::List::ConstIterator mIt; |
76 | }; | 76 | }; |
77 | 77 | ||
78 | AddressBook::Iterator::Iterator() | 78 | AddressBook::Iterator::Iterator() |
79 | { | 79 | { |
80 | d = new IteratorData; | 80 | d = new IteratorData; |
81 | } | 81 | } |
82 | 82 | ||
83 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) | 83 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) |
84 | { | 84 | { |
85 | d = new IteratorData; | 85 | d = new IteratorData; |
86 | d->mIt = i.d->mIt; | 86 | d->mIt = i.d->mIt; |
87 | } | 87 | } |
88 | 88 | ||
89 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) | 89 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) |
90 | { | 90 | { |
91 | if( this == &i ) return *this; // guard against self assignment | 91 | if( this == &i ) return *this; // guard against self assignment |
92 | delete d; // delete the old data the Iterator was completely constructed before | 92 | delete d; // delete the old data the Iterator was completely constructed before |
93 | d = new IteratorData; | 93 | d = new IteratorData; |
94 | d->mIt = i.d->mIt; | 94 | d->mIt = i.d->mIt; |
95 | return *this; | 95 | return *this; |
96 | } | 96 | } |
97 | 97 | ||
98 | AddressBook::Iterator::~Iterator() | 98 | AddressBook::Iterator::~Iterator() |
99 | { | 99 | { |
100 | delete d; | 100 | delete d; |
101 | } | 101 | } |
102 | 102 | ||
103 | const Addressee &AddressBook::Iterator::operator*() const | 103 | const Addressee &AddressBook::Iterator::operator*() const |
104 | { | 104 | { |
105 | return *(d->mIt); | 105 | return *(d->mIt); |
106 | } | 106 | } |
107 | 107 | ||
108 | Addressee &AddressBook::Iterator::operator*() | 108 | Addressee &AddressBook::Iterator::operator*() |
109 | { | 109 | { |
110 | return *(d->mIt); | 110 | return *(d->mIt); |
111 | } | 111 | } |
112 | 112 | ||
113 | Addressee *AddressBook::Iterator::operator->() | 113 | Addressee *AddressBook::Iterator::operator->() |
114 | { | 114 | { |
115 | return &(*(d->mIt)); | 115 | return &(*(d->mIt)); |
116 | } | 116 | } |
117 | 117 | ||
118 | AddressBook::Iterator &AddressBook::Iterator::operator++() | 118 | AddressBook::Iterator &AddressBook::Iterator::operator++() |
119 | { | 119 | { |
120 | (d->mIt)++; | 120 | (d->mIt)++; |
121 | return *this; | 121 | return *this; |
122 | } | 122 | } |
123 | 123 | ||
124 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) | 124 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) |
125 | { | 125 | { |
126 | (d->mIt)++; | 126 | (d->mIt)++; |
127 | return *this; | 127 | return *this; |
128 | } | 128 | } |
129 | 129 | ||
130 | AddressBook::Iterator &AddressBook::Iterator::operator--() | 130 | AddressBook::Iterator &AddressBook::Iterator::operator--() |
131 | { | 131 | { |
132 | (d->mIt)--; | 132 | (d->mIt)--; |
133 | return *this; | 133 | return *this; |
134 | } | 134 | } |
135 | 135 | ||
136 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) | 136 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) |
137 | { | 137 | { |
138 | (d->mIt)--; | 138 | (d->mIt)--; |
139 | return *this; | 139 | return *this; |
140 | } | 140 | } |
141 | 141 | ||
142 | bool AddressBook::Iterator::operator==( const Iterator &it ) | 142 | bool AddressBook::Iterator::operator==( const Iterator &it ) |
143 | { | 143 | { |
144 | return ( d->mIt == it.d->mIt ); | 144 | return ( d->mIt == it.d->mIt ); |
145 | } | 145 | } |
146 | 146 | ||
147 | bool AddressBook::Iterator::operator!=( const Iterator &it ) | 147 | bool AddressBook::Iterator::operator!=( const Iterator &it ) |
148 | { | 148 | { |
149 | return ( d->mIt != it.d->mIt ); | 149 | return ( d->mIt != it.d->mIt ); |
150 | } | 150 | } |
151 | 151 | ||
152 | 152 | ||
153 | AddressBook::ConstIterator::ConstIterator() | 153 | AddressBook::ConstIterator::ConstIterator() |
154 | { | 154 | { |
155 | d = new ConstIteratorData; | 155 | d = new ConstIteratorData; |
156 | } | 156 | } |
157 | 157 | ||
158 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) | 158 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) |
159 | { | 159 | { |
160 | d = new ConstIteratorData; | 160 | d = new ConstIteratorData; |
161 | d->mIt = i.d->mIt; | 161 | d->mIt = i.d->mIt; |
162 | } | 162 | } |
163 | 163 | ||
164 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) | 164 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) |
165 | { | 165 | { |
166 | if( this == &i ) return *this; // guard for self assignment | 166 | if( this == &i ) return *this; // guard for self assignment |
167 | delete d; // delete the old data because the Iterator was really constructed before | 167 | delete d; // delete the old data because the Iterator was really constructed before |
168 | d = new ConstIteratorData; | 168 | d = new ConstIteratorData; |
169 | d->mIt = i.d->mIt; | 169 | d->mIt = i.d->mIt; |
170 | return *this; | 170 | return *this; |
171 | } | 171 | } |
172 | 172 | ||
173 | AddressBook::ConstIterator::~ConstIterator() | 173 | AddressBook::ConstIterator::~ConstIterator() |
174 | { | 174 | { |
175 | delete d; | 175 | delete d; |
176 | } | 176 | } |
177 | 177 | ||
178 | const Addressee &AddressBook::ConstIterator::operator*() const | 178 | const Addressee &AddressBook::ConstIterator::operator*() const |
179 | { | 179 | { |
180 | return *(d->mIt); | 180 | return *(d->mIt); |
181 | } | 181 | } |
182 | 182 | ||
183 | const Addressee* AddressBook::ConstIterator::operator->() const | 183 | const Addressee* AddressBook::ConstIterator::operator->() const |
184 | { | 184 | { |
185 | return &(*(d->mIt)); | 185 | return &(*(d->mIt)); |
186 | } | 186 | } |
187 | 187 | ||
188 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() | 188 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() |
189 | { | 189 | { |
190 | (d->mIt)++; | 190 | (d->mIt)++; |
191 | return *this; | 191 | return *this; |
192 | } | 192 | } |
193 | 193 | ||
194 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) | 194 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) |
195 | { | 195 | { |
196 | (d->mIt)++; | 196 | (d->mIt)++; |
197 | return *this; | 197 | return *this; |
198 | } | 198 | } |
199 | 199 | ||
200 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() | 200 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() |
201 | { | 201 | { |
202 | (d->mIt)--; | 202 | (d->mIt)--; |
203 | return *this; | 203 | return *this; |
204 | } | 204 | } |
205 | 205 | ||
206 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) | 206 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) |
207 | { | 207 | { |
208 | (d->mIt)--; | 208 | (d->mIt)--; |
209 | return *this; | 209 | return *this; |
210 | } | 210 | } |
211 | 211 | ||
212 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) | 212 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) |
213 | { | 213 | { |
214 | return ( d->mIt == it.d->mIt ); | 214 | return ( d->mIt == it.d->mIt ); |
215 | } | 215 | } |
216 | 216 | ||
217 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 217 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) |
218 | { | 218 | { |
219 | return ( d->mIt != it.d->mIt ); | 219 | return ( d->mIt != it.d->mIt ); |
220 | } | 220 | } |
221 | 221 | ||
222 | 222 | ||
223 | AddressBook::AddressBook() | 223 | AddressBook::AddressBook() |
224 | { | 224 | { |
225 | init(0, "contact"); | 225 | init(0, "contact"); |
226 | } | 226 | } |
227 | 227 | ||
228 | AddressBook::AddressBook( const QString &config ) | 228 | AddressBook::AddressBook( const QString &config ) |
229 | { | 229 | { |
230 | init(config, "contact"); | 230 | init(config, "contact"); |
231 | } | 231 | } |
232 | 232 | ||
233 | AddressBook::AddressBook( const QString &config, const QString &family ) | 233 | AddressBook::AddressBook( const QString &config, const QString &family ) |
234 | { | 234 | { |
235 | init(config, family); | 235 | init(config, family); |
236 | 236 | ||
237 | } | 237 | } |
238 | 238 | ||
239 | // the default family is "contact" | 239 | // the default family is "contact" |
240 | void AddressBook::init(const QString &config, const QString &family ) | 240 | void AddressBook::init(const QString &config, const QString &family ) |
241 | { | 241 | { |
242 | blockLSEchange = false; | 242 | blockLSEchange = false; |
243 | d = new AddressBookData; | 243 | d = new AddressBookData; |
244 | QString fami = family; | 244 | QString fami = family; |
245 | if (config != 0) { | 245 | if (config != 0) { |
246 | if ( family == "syncContact" ) { | 246 | if ( family == "syncContact" ) { |
247 | qDebug("creating sync config "); | 247 | qDebug("creating sync config "); |
248 | fami = "contact"; | 248 | fami = "contact"; |
249 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); | 249 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); |
250 | con->setGroup( "General" ); | 250 | con->setGroup( "General" ); |
251 | con->writeEntry( "ResourceKeys", QString("sync") ); | 251 | con->writeEntry( "ResourceKeys", QString("sync") ); |
252 | con->writeEntry( "Standard", QString("sync") ); | 252 | con->writeEntry( "Standard", QString("sync") ); |
253 | con->setGroup( "Resource_sync" ); | 253 | con->setGroup( "Resource_sync" ); |
254 | con->writeEntry( "FileName", config ); | 254 | con->writeEntry( "FileName", config ); |
255 | con->writeEntry( "FileFormat", QString("vcard") ); | 255 | con->writeEntry( "FileFormat", QString("vcard") ); |
256 | con->writeEntry( "ResourceIdentifier", QString("sync") ); | 256 | con->writeEntry( "ResourceIdentifier", QString("sync") ); |
257 | con->writeEntry( "ResourceName", QString("sync_res") ); | 257 | con->writeEntry( "ResourceName", QString("sync_res") ); |
258 | if ( config.right(4) == ".xml" ) | 258 | if ( config.right(4) == ".xml" ) |
259 | con->writeEntry( "ResourceType", QString("qtopia") ); | 259 | con->writeEntry( "ResourceType", QString("qtopia") ); |
260 | else if ( config == "sharp" ) { | 260 | else if ( config == "sharp" ) { |
261 | con->writeEntry( "ResourceType", QString("sharp") ); | 261 | con->writeEntry( "ResourceType", QString("sharp") ); |
262 | } else { | 262 | } else { |
263 | con->writeEntry( "ResourceType", QString("file") ); | 263 | con->writeEntry( "ResourceType", QString("file") ); |
264 | } | 264 | } |
265 | //con->sync(); | 265 | //con->sync(); |
266 | d->mConfig = con; | 266 | d->mConfig = con; |
267 | } | 267 | } |
268 | else | 268 | else |
269 | d->mConfig = new KConfig( locateLocal("config", config) ); | 269 | d->mConfig = new KConfig( locateLocal("config", config) ); |
270 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 270 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
271 | } | 271 | } |
272 | else { | 272 | else { |
273 | d->mConfig = 0; | 273 | d->mConfig = 0; |
274 | // qDebug("AddressBook::init 1 config=0"); | 274 | // qDebug("AddressBook::init 1 config=0"); |
275 | } | 275 | } |
276 | 276 | ||
277 | //US d->mErrorHandler = 0; | 277 | //US d->mErrorHandler = 0; |
278 | d->mManager = new KRES::Manager<Resource>( fami, false ); | 278 | d->mManager = new KRES::Manager<Resource>( fami, false ); |
279 | d->mManager->readConfig( d->mConfig ); | 279 | d->mManager->readConfig( d->mConfig ); |
280 | if ( family == "syncContact" ) { | 280 | if ( family == "syncContact" ) { |
281 | KRES::Manager<Resource> *manager = d->mManager; | 281 | KRES::Manager<Resource> *manager = d->mManager; |
282 | KRES::Manager<Resource>::ActiveIterator it; | 282 | KRES::Manager<Resource>::ActiveIterator it; |
283 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 283 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
284 | (*it)->setAddressBook( this ); | 284 | (*it)->setAddressBook( this ); |
285 | if ( !(*it)->open() ) | 285 | if ( !(*it)->open() ) |
286 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 286 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
287 | } | 287 | } |
288 | Resource *res = standardResource(); | 288 | Resource *res = standardResource(); |
289 | if ( !res ) { | 289 | if ( !res ) { |
290 | qDebug("ERROR: no standard resource"); | 290 | qDebug("ERROR: no standard resource"); |
291 | res = manager->createResource( "file" ); | 291 | res = manager->createResource( "file" ); |
292 | if ( res ) | 292 | if ( res ) |
293 | { | 293 | { |
294 | addResource( res ); | 294 | addResource( res ); |
295 | } | 295 | } |
296 | else | 296 | else |
297 | qDebug(" No resource available!!!"); | 297 | qDebug(" No resource available!!!"); |
298 | } | 298 | } |
299 | setStandardResource( res ); | 299 | setStandardResource( res ); |
300 | manager->writeConfig(); | 300 | manager->writeConfig(); |
301 | } | 301 | } |
302 | addCustomField( i18n( "Department" ), KABC::Field::Organization, | 302 | addCustomField( i18n( "Department" ), KABC::Field::Organization, |
303 | "X-Department", "KADDRESSBOOK" ); | 303 | "X-Department", "KADDRESSBOOK" ); |
304 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 304 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
305 | "X-Profession", "KADDRESSBOOK" ); | 305 | "X-Profession", "KADDRESSBOOK" ); |
306 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 306 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
307 | "X-AssistantsName", "KADDRESSBOOK" ); | 307 | "X-AssistantsName", "KADDRESSBOOK" ); |
308 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 308 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
309 | "X-ManagersName", "KADDRESSBOOK" ); | 309 | "X-ManagersName", "KADDRESSBOOK" ); |
310 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 310 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
311 | "X-SpousesName", "KADDRESSBOOK" ); | 311 | "X-SpousesName", "KADDRESSBOOK" ); |
312 | addCustomField( i18n( "Office" ), KABC::Field::Personal, | 312 | addCustomField( i18n( "Office" ), KABC::Field::Personal, |
313 | "X-Office", "KADDRESSBOOK" ); | 313 | "X-Office", "KADDRESSBOOK" ); |
314 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 314 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
315 | "X-IMAddress", "KADDRESSBOOK" ); | 315 | "X-IMAddress", "KADDRESSBOOK" ); |
316 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 316 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
317 | "X-Anniversary", "KADDRESSBOOK" ); | 317 | "X-Anniversary", "KADDRESSBOOK" ); |
318 | 318 | ||
319 | //US added this field to become compatible with Opie/qtopia addressbook | 319 | //US added this field to become compatible with Opie/qtopia addressbook |
320 | // values can be "female" or "male" or "". An empty field represents undefined. | 320 | // values can be "female" or "male" or "". An empty field represents undefined. |
321 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 321 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
322 | "X-Gender", "KADDRESSBOOK" ); | 322 | "X-Gender", "KADDRESSBOOK" ); |
323 | addCustomField( i18n( "Children" ), KABC::Field::Personal, | 323 | addCustomField( i18n( "Children" ), KABC::Field::Personal, |
324 | "X-Children", "KADDRESSBOOK" ); | 324 | "X-Children", "KADDRESSBOOK" ); |
325 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 325 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
326 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 326 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
327 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, | 327 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, |
328 | "X-ExternalID", "KADDRESSBOOK" ); | 328 | "X-ExternalID", "KADDRESSBOOK" ); |
329 | } | 329 | } |
330 | 330 | ||
331 | AddressBook::~AddressBook() | 331 | AddressBook::~AddressBook() |
332 | { | 332 | { |
333 | delete d->mConfig; d->mConfig = 0; | 333 | delete d->mConfig; d->mConfig = 0; |
334 | delete d->mManager; d->mManager = 0; | 334 | delete d->mManager; d->mManager = 0; |
335 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 335 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
336 | delete d; d = 0; | 336 | delete d; d = 0; |
337 | } | 337 | } |
338 | 338 | ||
339 | bool AddressBook::load() | 339 | bool AddressBook::load() |
340 | { | 340 | { |
341 | 341 | ||
342 | 342 | ||
343 | clear(); | 343 | clear(); |
344 | 344 | ||
345 | KRES::Manager<Resource>::ActiveIterator it; | 345 | KRES::Manager<Resource>::ActiveIterator it; |
346 | bool ok = true; | 346 | bool ok = true; |
347 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 347 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
348 | if ( !(*it)->load() ) { | 348 | if ( !(*it)->load() ) { |
349 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 349 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
350 | ok = false; | 350 | ok = false; |
351 | } | 351 | } |
352 | 352 | ||
353 | // mark all addressees as unchanged | 353 | // mark all addressees as unchanged |
354 | Addressee::List::Iterator addrIt; | 354 | Addressee::List::Iterator addrIt; |
355 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { | 355 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { |
356 | (*addrIt).setChanged( false ); | 356 | (*addrIt).setChanged( false ); |
357 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); | 357 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); |
358 | if ( !id.isEmpty() ) { | 358 | if ( !id.isEmpty() ) { |
359 | //qDebug("setId aa %s ", id.latin1()); | 359 | //qDebug("setId aa %s ", id.latin1()); |
360 | (*addrIt).setIDStr(id ); | 360 | (*addrIt).setIDStr(id ); |
361 | } | 361 | } |
362 | } | 362 | } |
363 | blockLSEchange = true; | 363 | blockLSEchange = true; |
364 | return ok; | 364 | return ok; |
365 | } | 365 | } |
366 | 366 | ||
367 | bool AddressBook::save( Ticket *ticket ) | 367 | bool AddressBook::save( Ticket *ticket ) |
368 | { | 368 | { |
369 | kdDebug(5700) << "AddressBook::save()"<< endl; | 369 | kdDebug(5700) << "AddressBook::save()"<< endl; |
370 | 370 | ||
371 | if ( ticket->resource() ) { | 371 | if ( ticket->resource() ) { |
372 | deleteRemovedAddressees(); | 372 | deleteRemovedAddressees(); |
373 | return ticket->resource()->save( ticket ); | 373 | return ticket->resource()->save( ticket ); |
374 | } | 374 | } |
375 | 375 | ||
376 | return false; | 376 | return false; |
377 | } | 377 | } |
378 | void AddressBook::export2File( QString fileName ) | 378 | void AddressBook::export2File( QString fileName ) |
379 | { | 379 | { |
380 | 380 | ||
381 | QFile outFile( fileName ); | 381 | QFile outFile( fileName ); |
382 | if ( !outFile.open( IO_WriteOnly ) ) { | 382 | if ( !outFile.open( IO_WriteOnly ) ) { |
383 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); | 383 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); |
384 | KMessageBox::error( 0, text.arg( fileName ) ); | 384 | KMessageBox::error( 0, text.arg( fileName ) ); |
385 | return ; | 385 | return ; |
386 | } | 386 | } |
387 | QTextStream t( &outFile ); | 387 | QTextStream t( &outFile ); |
388 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 388 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
389 | Iterator it; | 389 | Iterator it; |
390 | KABC::VCardConverter::Version version; | 390 | KABC::VCardConverter::Version version; |
391 | version = KABC::VCardConverter::v3_0; | 391 | version = KABC::VCardConverter::v3_0; |
392 | for ( it = begin(); it != end(); ++it ) { | 392 | for ( it = begin(); it != end(); ++it ) { |
393 | if ( !(*it).IDStr().isEmpty() ) { | 393 | if ( !(*it).IDStr().isEmpty() ) { |
394 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); | 394 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); |
395 | } | 395 | } |
396 | KABC::VCardConverter converter; | 396 | KABC::VCardConverter converter; |
397 | QString vcard; | 397 | QString vcard; |
398 | //Resource *resource() const; | 398 | //Resource *resource() const; |
399 | converter.addresseeToVCard( *it, vcard, version ); | 399 | converter.addresseeToVCard( *it, vcard, version ); |
400 | t << vcard << "\r\n"; | 400 | t << vcard << "\r\n"; |
401 | } | 401 | } |
402 | outFile.close(); | 402 | outFile.close(); |
403 | } | 403 | } |
404 | void AddressBook::importFromFile( QString fileName ) | 404 | void AddressBook::importFromFile( QString fileName ) |
405 | { | 405 | { |
406 | 406 | ||
407 | KABC::Addressee::List list; | 407 | KABC::Addressee::List list; |
408 | QFile file( fileName ); | 408 | QFile file( fileName ); |
409 | 409 | ||
410 | file.open( IO_ReadOnly ); | 410 | file.open( IO_ReadOnly ); |
411 | QByteArray rawData = file.readAll(); | 411 | QByteArray rawData = file.readAll(); |
412 | file.close(); | 412 | file.close(); |
413 | 413 | ||
414 | QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 414 | QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
415 | KABC::VCardTool tool; | 415 | KABC::VCardTool tool; |
416 | list = tool.parseVCards( data ); | 416 | list = tool.parseVCards( data ); |
417 | |||
418 | KABC::Addressee::List::Iterator it; | 417 | KABC::Addressee::List::Iterator it; |
419 | for ( it = list.begin(); it != list.end(); ++it ) { | 418 | for ( it = list.begin(); it != list.end(); ++it ) { |
420 | (*it).setResource( 0 ); | 419 | (*it).setResource( 0 ); |
421 | insertAddressee( (*it), false, true ); | 420 | insertAddressee( (*it), false, true ); |
422 | } | 421 | } |
423 | 422 | ||
424 | } | 423 | } |
425 | 424 | ||
426 | bool AddressBook::saveAB() | 425 | bool AddressBook::saveAB() |
427 | { | 426 | { |
428 | bool ok = true; | 427 | bool ok = true; |
429 | 428 | ||
430 | deleteRemovedAddressees(); | 429 | deleteRemovedAddressees(); |
431 | Iterator ait; | 430 | Iterator ait; |
432 | for ( ait = begin(); ait != end(); ++ait ) { | 431 | for ( ait = begin(); ait != end(); ++ait ) { |
433 | if ( !(*ait).IDStr().isEmpty() ) { | 432 | if ( !(*ait).IDStr().isEmpty() ) { |
434 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); | 433 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); |
435 | } | 434 | } |
436 | } | 435 | } |
437 | KRES::Manager<Resource>::ActiveIterator it; | 436 | KRES::Manager<Resource>::ActiveIterator it; |
438 | KRES::Manager<Resource> *manager = d->mManager; | 437 | KRES::Manager<Resource> *manager = d->mManager; |
439 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 438 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
440 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 439 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
441 | Ticket *ticket = requestSaveTicket( *it ); | 440 | Ticket *ticket = requestSaveTicket( *it ); |
442 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 441 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
443 | if ( !ticket ) { | 442 | if ( !ticket ) { |
444 | error( i18n( "Unable to save to resource '%1'. It is locked." ) | 443 | error( i18n( "Unable to save to resource '%1'. It is locked." ) |
445 | .arg( (*it)->resourceName() ) ); | 444 | .arg( (*it)->resourceName() ) ); |
446 | return false; | 445 | return false; |
447 | } | 446 | } |
448 | 447 | ||
449 | //if ( !save( ticket ) ) | 448 | //if ( !save( ticket ) ) |
450 | if ( ticket->resource() ) { | 449 | if ( ticket->resource() ) { |
451 | if ( ! ticket->resource()->save( ticket ) ) | 450 | if ( ! ticket->resource()->save( ticket ) ) |
452 | ok = false; | 451 | ok = false; |
453 | } else | 452 | } else |
454 | ok = false; | 453 | ok = false; |
455 | 454 | ||
456 | } | 455 | } |
457 | } | 456 | } |
458 | return ok; | 457 | return ok; |
459 | } | 458 | } |
460 | 459 | ||
461 | AddressBook::Iterator AddressBook::begin() | 460 | AddressBook::Iterator AddressBook::begin() |
462 | { | 461 | { |
463 | Iterator it = Iterator(); | 462 | Iterator it = Iterator(); |
464 | it.d->mIt = d->mAddressees.begin(); | 463 | it.d->mIt = d->mAddressees.begin(); |
465 | return it; | 464 | return it; |
466 | } | 465 | } |
467 | 466 | ||
468 | AddressBook::ConstIterator AddressBook::begin() const | 467 | AddressBook::ConstIterator AddressBook::begin() const |
469 | { | 468 | { |
470 | ConstIterator it = ConstIterator(); | 469 | ConstIterator it = ConstIterator(); |
471 | it.d->mIt = d->mAddressees.begin(); | 470 | it.d->mIt = d->mAddressees.begin(); |
472 | return it; | 471 | return it; |
473 | } | 472 | } |
474 | 473 | ||
475 | AddressBook::Iterator AddressBook::end() | 474 | AddressBook::Iterator AddressBook::end() |
476 | { | 475 | { |
477 | Iterator it = Iterator(); | 476 | Iterator it = Iterator(); |
478 | it.d->mIt = d->mAddressees.end(); | 477 | it.d->mIt = d->mAddressees.end(); |
479 | return it; | 478 | return it; |
480 | } | 479 | } |
481 | 480 | ||
482 | AddressBook::ConstIterator AddressBook::end() const | 481 | AddressBook::ConstIterator AddressBook::end() const |
483 | { | 482 | { |
484 | ConstIterator it = ConstIterator(); | 483 | ConstIterator it = ConstIterator(); |
485 | it.d->mIt = d->mAddressees.end(); | 484 | it.d->mIt = d->mAddressees.end(); |
486 | return it; | 485 | return it; |
487 | } | 486 | } |
488 | 487 | ||
489 | void AddressBook::clear() | 488 | void AddressBook::clear() |
490 | { | 489 | { |
491 | d->mAddressees.clear(); | 490 | d->mAddressees.clear(); |
492 | } | 491 | } |
493 | 492 | ||
494 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 493 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) |
495 | { | 494 | { |
496 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; | 495 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; |
497 | 496 | ||
498 | if ( !resource ) | 497 | if ( !resource ) |
499 | { | 498 | { |
500 | qDebug("AddressBook::requestSaveTicket no resource" ); | 499 | qDebug("AddressBook::requestSaveTicket no resource" ); |
501 | resource = standardResource(); | 500 | resource = standardResource(); |
502 | } | 501 | } |
503 | 502 | ||
504 | KRES::Manager<Resource>::ActiveIterator it; | 503 | KRES::Manager<Resource>::ActiveIterator it; |
505 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 504 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
506 | if ( (*it) == resource ) { | 505 | if ( (*it) == resource ) { |
507 | if ( (*it)->readOnly() || !(*it)->isOpen() ) | 506 | if ( (*it)->readOnly() || !(*it)->isOpen() ) |
508 | return 0; | 507 | return 0; |
509 | else | 508 | else |
510 | return (*it)->requestSaveTicket(); | 509 | return (*it)->requestSaveTicket(); |
511 | } | 510 | } |
512 | } | 511 | } |
513 | 512 | ||
514 | return 0; | 513 | return 0; |
515 | } | 514 | } |
516 | 515 | ||
517 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) | 516 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) |
518 | { | 517 | { |
519 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { | 518 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { |
520 | //qDebug("block insert "); | 519 | //qDebug("block insert "); |
521 | return; | 520 | return; |
522 | } | 521 | } |
523 | //qDebug("inserting.... %s ",a.uid().latin1() ); | 522 | //qDebug("inserting.... %s ",a.uid().latin1() ); |
524 | bool found = false; | 523 | bool found = false; |
525 | Addressee::List::Iterator it; | 524 | Addressee::List::Iterator it; |
526 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { | 525 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { |
527 | if ( a.uid() == (*it).uid() ) { | 526 | if ( a.uid() == (*it).uid() ) { |
528 | 527 | ||
529 | bool changed = false; | 528 | bool changed = false; |
530 | Addressee addr = a; | 529 | Addressee addr = a; |
531 | if ( addr != (*it) ) | 530 | if ( addr != (*it) ) |
532 | changed = true; | 531 | changed = true; |
533 | 532 | ||
534 | if ( takeResource ) { | 533 | if ( takeResource ) { |
535 | Resource * res = (*it).resource(); | 534 | Resource * res = (*it).resource(); |
536 | (*it) = a; | 535 | (*it) = a; |
537 | (*it).setResource( res ); | 536 | (*it).setResource( res ); |
538 | } else { | 537 | } else { |
539 | (*it) = a; | 538 | (*it) = a; |
540 | if ( (*it).resource() == 0 ) | 539 | if ( (*it).resource() == 0 ) |
541 | (*it).setResource( standardResource() ); | 540 | (*it).setResource( standardResource() ); |
542 | } | 541 | } |
543 | if ( changed ) { | 542 | if ( changed ) { |
544 | if ( setRev ) { | 543 | if ( setRev ) { |
545 | 544 | ||
546 | // get rid of micro seconds | 545 | // get rid of micro seconds |
547 | QDateTime dt = QDateTime::currentDateTime(); | 546 | QDateTime dt = QDateTime::currentDateTime(); |
548 | QTime t = dt.time(); | 547 | QTime t = dt.time(); |
549 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 548 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
550 | (*it).setRevision( dt ); | 549 | (*it).setRevision( dt ); |
551 | } | 550 | } |
552 | (*it).setChanged( true ); | 551 | (*it).setChanged( true ); |
553 | } | 552 | } |
554 | 553 | ||
555 | found = true; | 554 | found = true; |
556 | } else { | 555 | } else { |
557 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 556 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
558 | QString name = (*it).uid().mid( 19 ); | 557 | QString name = (*it).uid().mid( 19 ); |
559 | Addressee b = a; | 558 | Addressee b = a; |
560 | QString id = b.getID( name ); | 559 | QString id = b.getID( name ); |
561 | if ( ! id.isEmpty() ) { | 560 | if ( ! id.isEmpty() ) { |
562 | QString des = (*it).note(); | 561 | QString des = (*it).note(); |
563 | int startN; | 562 | int startN; |
564 | if( (startN = des.find( id ) ) >= 0 ) { | 563 | if( (startN = des.find( id ) ) >= 0 ) { |
565 | int endN = des.find( ",", startN+1 ); | 564 | int endN = des.find( ",", startN+1 ); |
566 | des = des.left( startN ) + des.mid( endN+1 ); | 565 | des = des.left( startN ) + des.mid( endN+1 ); |
567 | (*it).setNote( des ); | 566 | (*it).setNote( des ); |
568 | } | 567 | } |
569 | } | 568 | } |
570 | } | 569 | } |
571 | } | 570 | } |
572 | } | 571 | } |
573 | if ( found ) | 572 | if ( found ) |
574 | return; | 573 | return; |
575 | d->mAddressees.append( a ); | 574 | d->mAddressees.append( a ); |
576 | Addressee& addr = d->mAddressees.last(); | 575 | Addressee& addr = d->mAddressees.last(); |
577 | if ( addr.resource() == 0 ) | 576 | if ( addr.resource() == 0 ) |
578 | addr.setResource( standardResource() ); | 577 | addr.setResource( standardResource() ); |
579 | 578 | ||
580 | addr.setChanged( true ); | 579 | addr.setChanged( true ); |
581 | } | 580 | } |
582 | 581 | ||
583 | void AddressBook::removeAddressee( const Addressee &a ) | 582 | void AddressBook::removeAddressee( const Addressee &a ) |
584 | { | 583 | { |
585 | Iterator it; | 584 | Iterator it; |
586 | Iterator it2; | 585 | Iterator it2; |
587 | bool found = false; | 586 | bool found = false; |
588 | for ( it = begin(); it != end(); ++it ) { | 587 | for ( it = begin(); it != end(); ++it ) { |
589 | if ( a.uid() == (*it).uid() ) { | 588 | if ( a.uid() == (*it).uid() ) { |
590 | found = true; | 589 | found = true; |
591 | it2 = it; | 590 | it2 = it; |
592 | } else { | 591 | } else { |
593 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 592 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
594 | QString name = (*it).uid().mid( 19 ); | 593 | QString name = (*it).uid().mid( 19 ); |
595 | Addressee b = a; | 594 | Addressee b = a; |
596 | QString id = b.getID( name ); | 595 | QString id = b.getID( name ); |
597 | if ( ! id.isEmpty() ) { | 596 | if ( ! id.isEmpty() ) { |
598 | QString des = (*it).note(); | 597 | QString des = (*it).note(); |
599 | if( des.find( id ) < 0 ) { | 598 | if( des.find( id ) < 0 ) { |
600 | des += id + ","; | 599 | des += id + ","; |
601 | (*it).setNote( des ); | 600 | (*it).setNote( des ); |
602 | } | 601 | } |
603 | } | 602 | } |
604 | } | 603 | } |
605 | 604 | ||
606 | } | 605 | } |
607 | } | 606 | } |
608 | 607 | ||
609 | if ( found ) | 608 | if ( found ) |
610 | removeAddressee( it2 ); | 609 | removeAddressee( it2 ); |
611 | 610 | ||
612 | } | 611 | } |
613 | 612 | ||
614 | void AddressBook::removeSyncAddressees( bool removeDeleted ) | 613 | void AddressBook::removeSyncAddressees( bool removeDeleted ) |
615 | { | 614 | { |
616 | Iterator it = begin(); | 615 | Iterator it = begin(); |
617 | Iterator it2 ; | 616 | Iterator it2 ; |
618 | QDateTime dt ( QDate( 2004,1,1) ); | 617 | QDateTime dt ( QDate( 2004,1,1) ); |
619 | while ( it != end() ) { | 618 | while ( it != end() ) { |
620 | (*it).setRevision( dt ); | 619 | (*it).setRevision( dt ); |
621 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 620 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
622 | (*it).setIDStr(""); | 621 | (*it).setIDStr(""); |
623 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { | 622 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { |
624 | it2 = it; | 623 | it2 = it; |
625 | //qDebug("removing %s ",(*it).uid().latin1() ); | 624 | //qDebug("removing %s ",(*it).uid().latin1() ); |
626 | ++it; | 625 | ++it; |
627 | removeAddressee( it2 ); | 626 | removeAddressee( it2 ); |
628 | } else { | 627 | } else { |
629 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 628 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
630 | ++it; | 629 | ++it; |
631 | } | 630 | } |
632 | } | 631 | } |
633 | deleteRemovedAddressees(); | 632 | deleteRemovedAddressees(); |
634 | } | 633 | } |
635 | 634 | ||
636 | void AddressBook::removeAddressee( const Iterator &it ) | 635 | void AddressBook::removeAddressee( const Iterator &it ) |
637 | { | 636 | { |
638 | d->mRemovedAddressees.append( (*it) ); | 637 | d->mRemovedAddressees.append( (*it) ); |
639 | d->mAddressees.remove( it.d->mIt ); | 638 | d->mAddressees.remove( it.d->mIt ); |
640 | } | 639 | } |
641 | 640 | ||
642 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 641 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
643 | { | 642 | { |
644 | Iterator it; | 643 | Iterator it; |
645 | for ( it = begin(); it != end(); ++it ) { | 644 | for ( it = begin(); it != end(); ++it ) { |
646 | if ( a.uid() == (*it).uid() ) { | 645 | if ( a.uid() == (*it).uid() ) { |
647 | return it; | 646 | return it; |
648 | } | 647 | } |
649 | } | 648 | } |
650 | return end(); | 649 | return end(); |
651 | } | 650 | } |
652 | 651 | ||
653 | Addressee AddressBook::findByUid( const QString &uid ) | 652 | Addressee AddressBook::findByUid( const QString &uid ) |
654 | { | 653 | { |
655 | Iterator it; | 654 | Iterator it; |
656 | for ( it = begin(); it != end(); ++it ) { | 655 | for ( it = begin(); it != end(); ++it ) { |
657 | if ( uid == (*it).uid() ) { | 656 | if ( uid == (*it).uid() ) { |
658 | return *it; | 657 | return *it; |
659 | } | 658 | } |
660 | } | 659 | } |
661 | return Addressee(); | 660 | return Addressee(); |
662 | } | 661 | } |
663 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) | 662 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) |
664 | { | 663 | { |
665 | //qDebug("AddressBook::preExternSync "); | 664 | //qDebug("AddressBook::preExternSync "); |
666 | AddressBook::Iterator it; | 665 | AddressBook::Iterator it; |
667 | for ( it = begin(); it != end(); ++it ) { | 666 | for ( it = begin(); it != end(); ++it ) { |
668 | (*it).setID( csd, (*it).externalUID() ); | 667 | (*it).setID( csd, (*it).externalUID() ); |
669 | (*it).computeCsum( csd ); | 668 | (*it).computeCsum( csd ); |
670 | } | 669 | } |
671 | mergeAB( aBook ,csd ); | 670 | mergeAB( aBook ,csd ); |
672 | } | 671 | } |
673 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) | 672 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) |
674 | { | 673 | { |
675 | //qDebug("AddressBook::postExternSync "); | 674 | //qDebug("AddressBook::postExternSync "); |
676 | AddressBook::Iterator it; | 675 | AddressBook::Iterator it; |
677 | for ( it = begin(); it != end(); ++it ) { | 676 | for ( it = begin(); it != end(); ++it ) { |
678 | // qDebug("check uid %s ", (*it).uid().latin1() ); | 677 | // qDebug("check uid %s ", (*it).uid().latin1() ); |
679 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || | 678 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || |
680 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { | 679 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { |
681 | Addressee ad = aBook->findByUid( ( (*it).uid() )); | 680 | Addressee ad = aBook->findByUid( ( (*it).uid() )); |
682 | if ( ad.isEmpty() ) { | 681 | if ( ad.isEmpty() ) { |
683 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); | 682 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); |
684 | } else { | 683 | } else { |
685 | (*it).computeCsum( csd ); | 684 | (*it).computeCsum( csd ); |
686 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) | 685 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) |
687 | ad.setID( csd, (*it).externalUID() ); | 686 | ad.setID( csd, (*it).externalUID() ); |
688 | ad.setCsum( csd, (*it).getCsum( csd ) ); | 687 | ad.setCsum( csd, (*it).getCsum( csd ) ); |
689 | aBook->insertAddressee( ad ); | 688 | aBook->insertAddressee( ad ); |
690 | } | 689 | } |
691 | } | 690 | } |
692 | } | 691 | } |
693 | } | 692 | } |
694 | 693 | ||
695 | bool AddressBook::containsExternalUid( const QString& uid ) | 694 | bool AddressBook::containsExternalUid( const QString& uid ) |
696 | { | 695 | { |
697 | Iterator it; | 696 | Iterator it; |
698 | for ( it = begin(); it != end(); ++it ) { | 697 | for ( it = begin(); it != end(); ++it ) { |
699 | if ( uid == (*it).externalUID( ) ) | 698 | if ( uid == (*it).externalUID( ) ) |
700 | return true; | 699 | return true; |
701 | } | 700 | } |
702 | return false; | 701 | return false; |
703 | } | 702 | } |
704 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) | 703 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) |
705 | { | 704 | { |
706 | Iterator it; | 705 | Iterator it; |
707 | for ( it = begin(); it != end(); ++it ) { | 706 | for ( it = begin(); it != end(); ++it ) { |
708 | if ( uid == (*it).getID( profile ) ) | 707 | if ( uid == (*it).getID( profile ) ) |
709 | return (*it); | 708 | return (*it); |
710 | } | 709 | } |
711 | return Addressee(); | 710 | return Addressee(); |
712 | } | 711 | } |
713 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) | 712 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) |
714 | { | 713 | { |
715 | Iterator it; | 714 | Iterator it; |
716 | Addressee ad; | 715 | Addressee ad; |
717 | for ( it = begin(); it != end(); ++it ) { | 716 | for ( it = begin(); it != end(); ++it ) { |
718 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); | 717 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); |
719 | if ( !ad.isEmpty() ) { | 718 | if ( !ad.isEmpty() ) { |
720 | (*it).mergeContact( ad ); | 719 | (*it).mergeContact( ad ); |
721 | } | 720 | } |
722 | } | 721 | } |
723 | #if 0 | 722 | #if 0 |
724 | // test only | 723 | // test only |
725 | for ( it = begin(); it != end(); ++it ) { | 724 | for ( it = begin(); it != end(); ++it ) { |
726 | 725 | ||
727 | qDebug("uid %s ", (*it).uid().latin1()); | 726 | qDebug("uid %s ", (*it).uid().latin1()); |
728 | } | 727 | } |
729 | #endif | 728 | #endif |
730 | } | 729 | } |
731 | 730 | ||
732 | #if 0 | 731 | #if 0 |
733 | Addressee::List AddressBook::getExternLastSyncAddressees() | 732 | Addressee::List AddressBook::getExternLastSyncAddressees() |
734 | { | 733 | { |
735 | Addressee::List results; | 734 | Addressee::List results; |
736 | 735 | ||
737 | Iterator it; | 736 | Iterator it; |
738 | for ( it = begin(); it != end(); ++it ) { | 737 | for ( it = begin(); it != end(); ++it ) { |
739 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { | 738 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { |
740 | if ( (*it).familyName().left(4) == "!E: " ) | 739 | if ( (*it).familyName().left(4) == "!E: " ) |
741 | results.append( *it ); | 740 | results.append( *it ); |
742 | } | 741 | } |
743 | } | 742 | } |
744 | 743 | ||
745 | return results; | 744 | return results; |
746 | } | 745 | } |
747 | #endif | 746 | #endif |
748 | void AddressBook::resetTempSyncStat() | 747 | void AddressBook::resetTempSyncStat() |
749 | { | 748 | { |
750 | Iterator it; | 749 | Iterator it; |
751 | for ( it = begin(); it != end(); ++it ) { | 750 | for ( it = begin(); it != end(); ++it ) { |
752 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); | 751 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); |
753 | } | 752 | } |
754 | 753 | ||
755 | } | 754 | } |
756 | 755 | ||
757 | QStringList AddressBook:: uidList() | 756 | QStringList AddressBook:: uidList() |
758 | { | 757 | { |
759 | QStringList results; | 758 | QStringList results; |
760 | Iterator it; | 759 | Iterator it; |
761 | for ( it = begin(); it != end(); ++it ) { | 760 | for ( it = begin(); it != end(); ++it ) { |
762 | results.append( (*it).uid() ); | 761 | results.append( (*it).uid() ); |
763 | } | 762 | } |
764 | return results; | 763 | return results; |
765 | } | 764 | } |
766 | 765 | ||
767 | 766 | ||
768 | Addressee::List AddressBook::allAddressees() | 767 | Addressee::List AddressBook::allAddressees() |
769 | { | 768 | { |
770 | return d->mAddressees; | 769 | return d->mAddressees; |
771 | 770 | ||
772 | } | 771 | } |
773 | 772 | ||
774 | Addressee::List AddressBook::findByName( const QString &name ) | 773 | Addressee::List AddressBook::findByName( const QString &name ) |
775 | { | 774 | { |
776 | Addressee::List results; | 775 | Addressee::List results; |
777 | 776 | ||
778 | Iterator it; | 777 | Iterator it; |
779 | for ( it = begin(); it != end(); ++it ) { | 778 | for ( it = begin(); it != end(); ++it ) { |
780 | if ( name == (*it).realName() ) { | 779 | if ( name == (*it).realName() ) { |
781 | results.append( *it ); | 780 | results.append( *it ); |
782 | } | 781 | } |
783 | } | 782 | } |
784 | 783 | ||
785 | return results; | 784 | return results; |
786 | } | 785 | } |
787 | 786 | ||
788 | Addressee::List AddressBook::findByEmail( const QString &email ) | 787 | Addressee::List AddressBook::findByEmail( const QString &email ) |
789 | { | 788 | { |
790 | Addressee::List results; | 789 | Addressee::List results; |
791 | QStringList mailList; | 790 | QStringList mailList; |
792 | 791 | ||
793 | Iterator it; | 792 | Iterator it; |
794 | for ( it = begin(); it != end(); ++it ) { | 793 | for ( it = begin(); it != end(); ++it ) { |
795 | mailList = (*it).emails(); | 794 | mailList = (*it).emails(); |
796 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { | 795 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { |
797 | if ( email == (*ite) ) { | 796 | if ( email == (*ite) ) { |
798 | results.append( *it ); | 797 | results.append( *it ); |
799 | } | 798 | } |
800 | } | 799 | } |
801 | } | 800 | } |
802 | 801 | ||
803 | return results; | 802 | return results; |
804 | } | 803 | } |
805 | 804 | ||
806 | Addressee::List AddressBook::findByCategory( const QString &category ) | 805 | Addressee::List AddressBook::findByCategory( const QString &category ) |
807 | { | 806 | { |
808 | Addressee::List results; | 807 | Addressee::List results; |
809 | 808 | ||
810 | Iterator it; | 809 | Iterator it; |
811 | for ( it = begin(); it != end(); ++it ) { | 810 | for ( it = begin(); it != end(); ++it ) { |
812 | if ( (*it).hasCategory( category) ) { | 811 | if ( (*it).hasCategory( category) ) { |
813 | results.append( *it ); | 812 | results.append( *it ); |
814 | } | 813 | } |
815 | } | 814 | } |
816 | 815 | ||
817 | return results; | 816 | return results; |
818 | } | 817 | } |
819 | 818 | ||
820 | void AddressBook::dump() const | 819 | void AddressBook::dump() const |
821 | { | 820 | { |
822 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; | 821 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; |
823 | 822 | ||
824 | ConstIterator it; | 823 | ConstIterator it; |
825 | for( it = begin(); it != end(); ++it ) { | 824 | for( it = begin(); it != end(); ++it ) { |
826 | (*it).dump(); | 825 | (*it).dump(); |
827 | } | 826 | } |
828 | 827 | ||
829 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; | 828 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; |
830 | } | 829 | } |
831 | 830 | ||
832 | QString AddressBook::identifier() | 831 | QString AddressBook::identifier() |
833 | { | 832 | { |
834 | QStringList identifier; | 833 | QStringList identifier; |
835 | 834 | ||
836 | 835 | ||
837 | KRES::Manager<Resource>::ActiveIterator it; | 836 | KRES::Manager<Resource>::ActiveIterator it; |
838 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 837 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
839 | if ( !(*it)->identifier().isEmpty() ) | 838 | if ( !(*it)->identifier().isEmpty() ) |
840 | identifier.append( (*it)->identifier() ); | 839 | identifier.append( (*it)->identifier() ); |
841 | } | 840 | } |
842 | 841 | ||
843 | return identifier.join( ":" ); | 842 | return identifier.join( ":" ); |
844 | } | 843 | } |
845 | 844 | ||
846 | Field::List AddressBook::fields( int category ) | 845 | Field::List AddressBook::fields( int category ) |
847 | { | 846 | { |
848 | if ( d->mAllFields.isEmpty() ) { | 847 | if ( d->mAllFields.isEmpty() ) { |
849 | d->mAllFields = Field::allFields(); | 848 | d->mAllFields = Field::allFields(); |
850 | } | 849 | } |
851 | 850 | ||
852 | if ( category == Field::All ) return d->mAllFields; | 851 | if ( category == Field::All ) return d->mAllFields; |
853 | 852 | ||
854 | Field::List result; | 853 | Field::List result; |
855 | Field::List::ConstIterator it; | 854 | Field::List::ConstIterator it; |
856 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { | 855 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { |
857 | if ( (*it)->category() & category ) result.append( *it ); | 856 | if ( (*it)->category() & category ) result.append( *it ); |
858 | } | 857 | } |
859 | 858 | ||
860 | return result; | 859 | return result; |
861 | } | 860 | } |
862 | 861 | ||
863 | bool AddressBook::addCustomField( const QString &label, int category, | 862 | bool AddressBook::addCustomField( const QString &label, int category, |
864 | const QString &key, const QString &app ) | 863 | const QString &key, const QString &app ) |
865 | { | 864 | { |
866 | if ( d->mAllFields.isEmpty() ) { | 865 | if ( d->mAllFields.isEmpty() ) { |
867 | d->mAllFields = Field::allFields(); | 866 | d->mAllFields = Field::allFields(); |
868 | } | 867 | } |
869 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; | 868 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; |
870 | QString a = app.isNull() ? KGlobal::getAppName() : app; | 869 | QString a = app.isNull() ? KGlobal::getAppName() : app; |
871 | 870 | ||
872 | QString k = key.isNull() ? label : key; | 871 | QString k = key.isNull() ? label : key; |
873 | 872 | ||
874 | Field *field = Field::createCustomField( label, category, k, a ); | 873 | Field *field = Field::createCustomField( label, category, k, a ); |
875 | 874 | ||
876 | if ( !field ) return false; | 875 | if ( !field ) return false; |
877 | 876 | ||
878 | d->mAllFields.append( field ); | 877 | d->mAllFields.append( field ); |
879 | 878 | ||
880 | return true; | 879 | return true; |
881 | } | 880 | } |
882 | 881 | ||
883 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) | 882 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) |
884 | { | 883 | { |
885 | if (!ab.d) return s; | 884 | if (!ab.d) return s; |
886 | 885 | ||
887 | return s << ab.d->mAddressees; | 886 | return s << ab.d->mAddressees; |
888 | } | 887 | } |
889 | 888 | ||
890 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) | 889 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) |
891 | { | 890 | { |
892 | if (!ab.d) return s; | 891 | if (!ab.d) return s; |
893 | 892 | ||
894 | s >> ab.d->mAddressees; | 893 | s >> ab.d->mAddressees; |
895 | 894 | ||
896 | return s; | 895 | return s; |
897 | } | 896 | } |
898 | 897 | ||
899 | bool AddressBook::addResource( Resource *resource ) | 898 | bool AddressBook::addResource( Resource *resource ) |
900 | { | 899 | { |
901 | if ( !resource->open() ) { | 900 | if ( !resource->open() ) { |
902 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; | 901 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; |
903 | return false; | 902 | return false; |
904 | } | 903 | } |
905 | 904 | ||
906 | resource->setAddressBook( this ); | 905 | resource->setAddressBook( this ); |
907 | 906 | ||
908 | d->mManager->add( resource ); | 907 | d->mManager->add( resource ); |
909 | return true; | 908 | return true; |
910 | } | 909 | } |
911 | 910 | ||
912 | bool AddressBook::removeResource( Resource *resource ) | 911 | bool AddressBook::removeResource( Resource *resource ) |
913 | { | 912 | { |
914 | resource->close(); | 913 | resource->close(); |
915 | 914 | ||
916 | if ( resource == standardResource() ) | 915 | if ( resource == standardResource() ) |
917 | d->mManager->setStandardResource( 0 ); | 916 | d->mManager->setStandardResource( 0 ); |
918 | 917 | ||
919 | resource->setAddressBook( 0 ); | 918 | resource->setAddressBook( 0 ); |
920 | 919 | ||
921 | d->mManager->remove( resource ); | 920 | d->mManager->remove( resource ); |
922 | return true; | 921 | return true; |
923 | } | 922 | } |
924 | 923 | ||
925 | QPtrList<Resource> AddressBook::resources() | 924 | QPtrList<Resource> AddressBook::resources() |
926 | { | 925 | { |
927 | QPtrList<Resource> list; | 926 | QPtrList<Resource> list; |
928 | 927 | ||
929 | // qDebug("AddressBook::resources() 1"); | 928 | // qDebug("AddressBook::resources() 1"); |
930 | 929 | ||
931 | KRES::Manager<Resource>::ActiveIterator it; | 930 | KRES::Manager<Resource>::ActiveIterator it; |
932 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 931 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
933 | list.append( *it ); | 932 | list.append( *it ); |
934 | 933 | ||
935 | return list; | 934 | return list; |
936 | } | 935 | } |
937 | 936 | ||
938 | /*US | 937 | /*US |
939 | void AddressBook::setErrorHandler( ErrorHandler *handler ) | 938 | void AddressBook::setErrorHandler( ErrorHandler *handler ) |
940 | { | 939 | { |
941 | delete d->mErrorHandler; | 940 | delete d->mErrorHandler; |
942 | d->mErrorHandler = handler; | 941 | d->mErrorHandler = handler; |
943 | } | 942 | } |
944 | */ | 943 | */ |
945 | 944 | ||
946 | void AddressBook::error( const QString& msg ) | 945 | void AddressBook::error( const QString& msg ) |
947 | { | 946 | { |
948 | /*US | 947 | /*US |
949 | if ( !d->mErrorHandler ) // create default error handler | 948 | if ( !d->mErrorHandler ) // create default error handler |
950 | d->mErrorHandler = new ConsoleErrorHandler; | 949 | d->mErrorHandler = new ConsoleErrorHandler; |
951 | 950 | ||
952 | if ( d->mErrorHandler ) | 951 | if ( d->mErrorHandler ) |
953 | d->mErrorHandler->error( msg ); | 952 | d->mErrorHandler->error( msg ); |
954 | else | 953 | else |
955 | kdError(5700) << "no error handler defined" << endl; | 954 | kdError(5700) << "no error handler defined" << endl; |
956 | */ | 955 | */ |
957 | kdDebug(5700) << "msg" << endl; | 956 | kdDebug(5700) << "msg" << endl; |
958 | qDebug(msg); | 957 | qDebug(msg); |
959 | } | 958 | } |
960 | 959 | ||
961 | void AddressBook::deleteRemovedAddressees() | 960 | void AddressBook::deleteRemovedAddressees() |
962 | { | 961 | { |
963 | Addressee::List::Iterator it; | 962 | Addressee::List::Iterator it; |
964 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { | 963 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { |
965 | Resource *resource = (*it).resource(); | 964 | Resource *resource = (*it).resource(); |
966 | if ( resource && !resource->readOnly() && resource->isOpen() ) | 965 | if ( resource && !resource->readOnly() && resource->isOpen() ) |
967 | resource->removeAddressee( *it ); | 966 | resource->removeAddressee( *it ); |
968 | } | 967 | } |
969 | 968 | ||
970 | d->mRemovedAddressees.clear(); | 969 | d->mRemovedAddressees.clear(); |
971 | } | 970 | } |
972 | 971 | ||
973 | void AddressBook::setStandardResource( Resource *resource ) | 972 | void AddressBook::setStandardResource( Resource *resource ) |
974 | { | 973 | { |
975 | // qDebug("AddressBook::setStandardResource 1"); | 974 | // qDebug("AddressBook::setStandardResource 1"); |
976 | d->mManager->setStandardResource( resource ); | 975 | d->mManager->setStandardResource( resource ); |
977 | } | 976 | } |
978 | 977 | ||
979 | Resource *AddressBook::standardResource() | 978 | Resource *AddressBook::standardResource() |
980 | { | 979 | { |
981 | return d->mManager->standardResource(); | 980 | return d->mManager->standardResource(); |
982 | } | 981 | } |
983 | 982 | ||
984 | KRES::Manager<Resource> *AddressBook::resourceManager() | 983 | KRES::Manager<Resource> *AddressBook::resourceManager() |
985 | { | 984 | { |
986 | return d->mManager; | 985 | return d->mManager; |
987 | } | 986 | } |
988 | 987 | ||
989 | void AddressBook::cleanUp() | 988 | void AddressBook::cleanUp() |
990 | { | 989 | { |
991 | KRES::Manager<Resource>::ActiveIterator it; | 990 | KRES::Manager<Resource>::ActiveIterator it; |
992 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 991 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
993 | if ( !(*it)->readOnly() && (*it)->isOpen() ) | 992 | if ( !(*it)->readOnly() && (*it)->isOpen() ) |
994 | (*it)->cleanUp(); | 993 | (*it)->cleanUp(); |
995 | } | 994 | } |
996 | } | 995 | } |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index fa80f5c..12502b0 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,2887 +1,2887 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program 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 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /*s | 24 | /*s |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "kabcore.h" | 31 | #include "kabcore.h" |
32 | 32 | ||
33 | #include <stdaddressbook.h> | 33 | #include <stdaddressbook.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kfiledialog.h> | 35 | #include <kfiledialog.h> |
36 | #include <qtimer.h> | 36 | #include <qtimer.h> |
37 | #include <qlabel.h> | 37 | #include <qlabel.h> |
38 | #include <qregexp.h> | 38 | #include <qregexp.h> |
39 | #include <qlineedit.h> | 39 | #include <qlineedit.h> |
40 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qprogressbar.h> | 42 | #include <qprogressbar.h> |
43 | #include <libkdepim/phoneaccess.h> | 43 | #include <libkdepim/phoneaccess.h> |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | #include <qclipboard.h> | 46 | #include <qclipboard.h> |
47 | #include <qdir.h> | 47 | #include <qdir.h> |
48 | #include <qfile.h> | 48 | #include <qfile.h> |
49 | #include <qapplicaton.h> | 49 | #include <qapplicaton.h> |
50 | #include <qprogressbar.h> | 50 | #include <qprogressbar.h> |
51 | #include <qlayout.h> | 51 | #include <qlayout.h> |
52 | #include <qregexp.h> | 52 | #include <qregexp.h> |
53 | #include <qvbox.h> | 53 | #include <qvbox.h> |
54 | #include <kabc/addresseelist.h> | 54 | #include <kabc/addresseelist.h> |
55 | #include <kabc/errorhandler.h> | 55 | #include <kabc/errorhandler.h> |
56 | #include <kabc/resource.h> | 56 | #include <kabc/resource.h> |
57 | #include <kabc/vcardconverter.h> | 57 | #include <kabc/vcardconverter.h> |
58 | #include <kapplication.h> | 58 | #include <kapplication.h> |
59 | #include <kactionclasses.h> | 59 | #include <kactionclasses.h> |
60 | #include <kcmultidialog.h> | 60 | #include <kcmultidialog.h> |
61 | #include <kdebug.h> | 61 | #include <kdebug.h> |
62 | #include <kdeversion.h> | 62 | #include <kdeversion.h> |
63 | #include <kkeydialog.h> | 63 | #include <kkeydialog.h> |
64 | #include <kmessagebox.h> | 64 | #include <kmessagebox.h> |
65 | #include <kprinter.h> | 65 | #include <kprinter.h> |
66 | #include <kprotocolinfo.h> | 66 | #include <kprotocolinfo.h> |
67 | #include <kresources/selectdialog.h> | 67 | #include <kresources/selectdialog.h> |
68 | #include <kstandarddirs.h> | 68 | #include <kstandarddirs.h> |
69 | #include <ktempfile.h> | 69 | #include <ktempfile.h> |
70 | #include <kxmlguiclient.h> | 70 | #include <kxmlguiclient.h> |
71 | #include <kaboutdata.h> | 71 | #include <kaboutdata.h> |
72 | #include <libkdepim/categoryselectdialog.h> | 72 | #include <libkdepim/categoryselectdialog.h> |
73 | 73 | ||
74 | #include "addresseeutil.h" | 74 | #include "addresseeutil.h" |
75 | #include "addresseeeditordialog.h" | 75 | #include "addresseeeditordialog.h" |
76 | #include "extensionmanager.h" | 76 | #include "extensionmanager.h" |
77 | #include "kstdaction.h" | 77 | #include "kstdaction.h" |
78 | #include "kaddressbookservice.h" | 78 | #include "kaddressbookservice.h" |
79 | #include "ldapsearchdialog.h" | 79 | #include "ldapsearchdialog.h" |
80 | #include "printing/printingwizard.h" | 80 | #include "printing/printingwizard.h" |
81 | #else // KAB_EMBEDDED | 81 | #else // KAB_EMBEDDED |
82 | 82 | ||
83 | #include <kapplication.h> | 83 | #include <kapplication.h> |
84 | #include "KDGanttMinimizeSplitter.h" | 84 | #include "KDGanttMinimizeSplitter.h" |
85 | #include "kaddressbookmain.h" | 85 | #include "kaddressbookmain.h" |
86 | #include "kactioncollection.h" | 86 | #include "kactioncollection.h" |
87 | #include "addresseedialog.h" | 87 | #include "addresseedialog.h" |
88 | //US | 88 | //US |
89 | #include <addresseeview.h> | 89 | #include <addresseeview.h> |
90 | 90 | ||
91 | #include <qapp.h> | 91 | #include <qapp.h> |
92 | #include <qmenubar.h> | 92 | #include <qmenubar.h> |
93 | //#include <qtoolbar.h> | 93 | //#include <qtoolbar.h> |
94 | #include <qmessagebox.h> | 94 | #include <qmessagebox.h> |
95 | #include <kdebug.h> | 95 | #include <kdebug.h> |
96 | #include <kiconloader.h> // needed for SmallIcon | 96 | #include <kiconloader.h> // needed for SmallIcon |
97 | #include <kresources/kcmkresources.h> | 97 | #include <kresources/kcmkresources.h> |
98 | #include <ktoolbar.h> | 98 | #include <ktoolbar.h> |
99 | 99 | ||
100 | 100 | ||
101 | //#include <qlabel.h> | 101 | //#include <qlabel.h> |
102 | 102 | ||
103 | 103 | ||
104 | #ifndef DESKTOP_VERSION | 104 | #ifndef DESKTOP_VERSION |
105 | #include <qpe/ir.h> | 105 | #include <qpe/ir.h> |
106 | #include <qpe/qpemenubar.h> | 106 | #include <qpe/qpemenubar.h> |
107 | #include <qtopia/qcopenvelope_qws.h> | 107 | #include <qtopia/qcopenvelope_qws.h> |
108 | #else | 108 | #else |
109 | 109 | ||
110 | #include <qmenubar.h> | 110 | #include <qmenubar.h> |
111 | #endif | 111 | #endif |
112 | 112 | ||
113 | #endif // KAB_EMBEDDED | 113 | #endif // KAB_EMBEDDED |
114 | #include "kcmconfigs/kcmkabconfig.h" | 114 | #include "kcmconfigs/kcmkabconfig.h" |
115 | #include "kcmconfigs/kcmkdepimconfig.h" | 115 | #include "kcmconfigs/kcmkdepimconfig.h" |
116 | #include "kpimglobalprefs.h" | 116 | #include "kpimglobalprefs.h" |
117 | #include "externalapphandler.h" | 117 | #include "externalapphandler.h" |
118 | 118 | ||
119 | 119 | ||
120 | #include <kresources/selectdialog.h> | 120 | #include <kresources/selectdialog.h> |
121 | #include <kmessagebox.h> | 121 | #include <kmessagebox.h> |
122 | 122 | ||
123 | #include <picture.h> | 123 | #include <picture.h> |
124 | #include <resource.h> | 124 | #include <resource.h> |
125 | 125 | ||
126 | //US#include <qsplitter.h> | 126 | //US#include <qsplitter.h> |
127 | #include <qmap.h> | 127 | #include <qmap.h> |
128 | #include <qdir.h> | 128 | #include <qdir.h> |
129 | #include <qfile.h> | 129 | #include <qfile.h> |
130 | #include <qvbox.h> | 130 | #include <qvbox.h> |
131 | #include <qlayout.h> | 131 | #include <qlayout.h> |
132 | #include <qclipboard.h> | 132 | #include <qclipboard.h> |
133 | #include <qtextstream.h> | 133 | #include <qtextstream.h> |
134 | 134 | ||
135 | #include <libkdepim/categoryselectdialog.h> | 135 | #include <libkdepim/categoryselectdialog.h> |
136 | #include <kabc/vcardconverter.h> | 136 | #include <kabc/vcardconverter.h> |
137 | 137 | ||
138 | 138 | ||
139 | #include "addresseeutil.h" | 139 | #include "addresseeutil.h" |
140 | #include "undocmds.h" | 140 | #include "undocmds.h" |
141 | #include "addresseeeditordialog.h" | 141 | #include "addresseeeditordialog.h" |
142 | #include "viewmanager.h" | 142 | #include "viewmanager.h" |
143 | #include "details/detailsviewcontainer.h" | 143 | #include "details/detailsviewcontainer.h" |
144 | #include "kabprefs.h" | 144 | #include "kabprefs.h" |
145 | #include "xxportmanager.h" | 145 | #include "xxportmanager.h" |
146 | #include "incsearchwidget.h" | 146 | #include "incsearchwidget.h" |
147 | #include "jumpbuttonbar.h" | 147 | #include "jumpbuttonbar.h" |
148 | #include "extensionmanager.h" | 148 | #include "extensionmanager.h" |
149 | #include "addresseeconfig.h" | 149 | #include "addresseeconfig.h" |
150 | #include <kcmultidialog.h> | 150 | #include <kcmultidialog.h> |
151 | 151 | ||
152 | #ifdef _WIN32_ | 152 | #ifdef _WIN32_ |
153 | 153 | ||
154 | #include "kaimportoldialog.h" | 154 | #include "kaimportoldialog.h" |
155 | #else | 155 | #else |
156 | #include <unistd.h> | 156 | #include <unistd.h> |
157 | #endif | 157 | #endif |
158 | // sync includes | 158 | // sync includes |
159 | #include <libkdepim/ksyncprofile.h> | 159 | #include <libkdepim/ksyncprofile.h> |
160 | #include <libkdepim/ksyncprefsdialog.h> | 160 | #include <libkdepim/ksyncprefsdialog.h> |
161 | 161 | ||
162 | class KAex2phonePrefs : public QDialog | 162 | class KAex2phonePrefs : public QDialog |
163 | { | 163 | { |
164 | public: | 164 | public: |
165 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 165 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
166 | QDialog( parent, name, true ) | 166 | QDialog( parent, name, true ) |
167 | { | 167 | { |
168 | setCaption( i18n("Export to phone options") ); | 168 | setCaption( i18n("Export to phone options") ); |
169 | QVBoxLayout* lay = new QVBoxLayout( this ); | 169 | QVBoxLayout* lay = new QVBoxLayout( this ); |
170 | lay->setSpacing( 3 ); | 170 | lay->setSpacing( 3 ); |
171 | lay->setMargin( 3 ); | 171 | lay->setMargin( 3 ); |
172 | QLabel *lab; | 172 | QLabel *lab; |
173 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 173 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
174 | lab->setAlignment (AlignHCenter ); | 174 | lab->setAlignment (AlignHCenter ); |
175 | QHBox* temphb; | 175 | QHBox* temphb; |
176 | temphb = new QHBox( this ); | 176 | temphb = new QHBox( this ); |
177 | new QLabel( i18n("I/O device: "), temphb ); | 177 | new QLabel( i18n("I/O device: "), temphb ); |
178 | mPhoneDevice = new QLineEdit( temphb); | 178 | mPhoneDevice = new QLineEdit( temphb); |
179 | lay->addWidget( temphb ); | 179 | lay->addWidget( temphb ); |
180 | temphb = new QHBox( this ); | 180 | temphb = new QHBox( this ); |
181 | new QLabel( i18n("Connection: "), temphb ); | 181 | new QLabel( i18n("Connection: "), temphb ); |
182 | mPhoneConnection = new QLineEdit( temphb); | 182 | mPhoneConnection = new QLineEdit( temphb); |
183 | lay->addWidget( temphb ); | 183 | lay->addWidget( temphb ); |
184 | temphb = new QHBox( this ); | 184 | temphb = new QHBox( this ); |
185 | new QLabel( i18n("Model(opt.): "), temphb ); | 185 | new QLabel( i18n("Model(opt.): "), temphb ); |
186 | mPhoneModel = new QLineEdit( temphb); | 186 | mPhoneModel = new QLineEdit( temphb); |
187 | lay->addWidget( temphb ); | 187 | lay->addWidget( temphb ); |
188 | mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); | 188 | mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); |
189 | lay->addWidget( mWriteToSim ); | 189 | lay->addWidget( mWriteToSim ); |
190 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); | 190 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); |
191 | lab->setAlignment (AlignHCenter ); | 191 | lab->setAlignment (AlignHCenter ); |
192 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 192 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
193 | lay->addWidget( ok ); | 193 | lay->addWidget( ok ); |
194 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 194 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
195 | lay->addWidget( cancel ); | 195 | lay->addWidget( cancel ); |
196 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 196 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
197 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 197 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
198 | resize( 220, 240 ); | 198 | resize( 220, 240 ); |
199 | 199 | ||
200 | } | 200 | } |
201 | 201 | ||
202 | public: | 202 | public: |
203 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 203 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
204 | QCheckBox* mWriteToSim; | 204 | QCheckBox* mWriteToSim; |
205 | }; | 205 | }; |
206 | 206 | ||
207 | bool pasteWithNewUid = true; | 207 | bool pasteWithNewUid = true; |
208 | 208 | ||
209 | #ifdef KAB_EMBEDDED | 209 | #ifdef KAB_EMBEDDED |
210 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 210 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
211 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 211 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
212 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 212 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
213 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 213 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
214 | #else //KAB_EMBEDDED | 214 | #else //KAB_EMBEDDED |
215 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 215 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
216 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 216 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
217 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 217 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
218 | mReadWrite( readWrite ), mModified( false ) | 218 | mReadWrite( readWrite ), mModified( false ) |
219 | #endif //KAB_EMBEDDED | 219 | #endif //KAB_EMBEDDED |
220 | { | 220 | { |
221 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 221 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
222 | // syncManager->setBlockSave(false); | 222 | // syncManager->setBlockSave(false); |
223 | mExtensionBarSplitter = 0; | 223 | mExtensionBarSplitter = 0; |
224 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 224 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
225 | 225 | ||
226 | mAddressBook = KABC::StdAddressBook::self(); | 226 | mAddressBook = KABC::StdAddressBook::self(); |
227 | KABC::StdAddressBook::setAutomaticSave( false ); | 227 | KABC::StdAddressBook::setAutomaticSave( false ); |
228 | 228 | ||
229 | #ifndef KAB_EMBEDDED | 229 | #ifndef KAB_EMBEDDED |
230 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 230 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
231 | #endif //KAB_EMBEDDED | 231 | #endif //KAB_EMBEDDED |
232 | 232 | ||
233 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 233 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
234 | SLOT( addressBookChanged() ) ); | 234 | SLOT( addressBookChanged() ) ); |
235 | 235 | ||
236 | #if 0 | 236 | #if 0 |
237 | // LP moved to addressbook init method | 237 | // LP moved to addressbook init method |
238 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 238 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
239 | "X-Department", "KADDRESSBOOK" ); | 239 | "X-Department", "KADDRESSBOOK" ); |
240 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 240 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
241 | "X-Profession", "KADDRESSBOOK" ); | 241 | "X-Profession", "KADDRESSBOOK" ); |
242 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 242 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
243 | "X-AssistantsName", "KADDRESSBOOK" ); | 243 | "X-AssistantsName", "KADDRESSBOOK" ); |
244 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 244 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
245 | "X-ManagersName", "KADDRESSBOOK" ); | 245 | "X-ManagersName", "KADDRESSBOOK" ); |
246 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 246 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
247 | "X-SpousesName", "KADDRESSBOOK" ); | 247 | "X-SpousesName", "KADDRESSBOOK" ); |
248 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 248 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
249 | "X-Office", "KADDRESSBOOK" ); | 249 | "X-Office", "KADDRESSBOOK" ); |
250 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 250 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
251 | "X-IMAddress", "KADDRESSBOOK" ); | 251 | "X-IMAddress", "KADDRESSBOOK" ); |
252 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 252 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
253 | "X-Anniversary", "KADDRESSBOOK" ); | 253 | "X-Anniversary", "KADDRESSBOOK" ); |
254 | 254 | ||
255 | //US added this field to become compatible with Opie/qtopia addressbook | 255 | //US added this field to become compatible with Opie/qtopia addressbook |
256 | // values can be "female" or "male" or "". An empty field represents undefined. | 256 | // values can be "female" or "male" or "". An empty field represents undefined. |
257 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 257 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
258 | "X-Gender", "KADDRESSBOOK" ); | 258 | "X-Gender", "KADDRESSBOOK" ); |
259 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 259 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
260 | "X-Children", "KADDRESSBOOK" ); | 260 | "X-Children", "KADDRESSBOOK" ); |
261 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 261 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
262 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 262 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
263 | #endif | 263 | #endif |
264 | initGUI(); | 264 | initGUI(); |
265 | 265 | ||
266 | mIncSearchWidget->setFocus(); | 266 | mIncSearchWidget->setFocus(); |
267 | 267 | ||
268 | 268 | ||
269 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 269 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
270 | SLOT( setContactSelected( const QString& ) ) ); | 270 | SLOT( setContactSelected( const QString& ) ) ); |
271 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 271 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
272 | SLOT( executeContact( const QString& ) ) ); | 272 | SLOT( executeContact( const QString& ) ) ); |
273 | 273 | ||
274 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 274 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
275 | SLOT( deleteContacts( ) ) ); | 275 | SLOT( deleteContacts( ) ) ); |
276 | connect( mViewManager, SIGNAL( modified() ), | 276 | connect( mViewManager, SIGNAL( modified() ), |
277 | SLOT( setModified() ) ); | 277 | SLOT( setModified() ) ); |
278 | 278 | ||
279 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 279 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
280 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 280 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
281 | 281 | ||
282 | connect( mXXPortManager, SIGNAL( modified() ), | 282 | connect( mXXPortManager, SIGNAL( modified() ), |
283 | SLOT( setModified() ) ); | 283 | SLOT( setModified() ) ); |
284 | 284 | ||
285 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 285 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
286 | SLOT( incrementalSearch( const QString& ) ) ); | 286 | SLOT( incrementalSearch( const QString& ) ) ); |
287 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 287 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
288 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 288 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
289 | 289 | ||
290 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 290 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
291 | SLOT( sendMail( const QString& ) ) ); | 291 | SLOT( sendMail( const QString& ) ) ); |
292 | 292 | ||
293 | 293 | ||
294 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 294 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
295 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); | 295 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); |
296 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); | 296 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); |
297 | 297 | ||
298 | 298 | ||
299 | #ifndef KAB_EMBEDDED | 299 | #ifndef KAB_EMBEDDED |
300 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 300 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
301 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 301 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
302 | 302 | ||
303 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 303 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
304 | SLOT( browse( const QString& ) ) ); | 304 | SLOT( browse( const QString& ) ) ); |
305 | 305 | ||
306 | 306 | ||
307 | mAddressBookService = new KAddressBookService( this ); | 307 | mAddressBookService = new KAddressBookService( this ); |
308 | 308 | ||
309 | #endif //KAB_EMBEDDED | 309 | #endif //KAB_EMBEDDED |
310 | mEditorDialog = 0; | 310 | mEditorDialog = 0; |
311 | createAddresseeEditorDialog( this ); | 311 | createAddresseeEditorDialog( this ); |
312 | setModified( false ); | 312 | setModified( false ); |
313 | } | 313 | } |
314 | 314 | ||
315 | KABCore::~KABCore() | 315 | KABCore::~KABCore() |
316 | { | 316 | { |
317 | // save(); | 317 | // save(); |
318 | //saveSettings(); | 318 | //saveSettings(); |
319 | //KABPrefs::instance()->writeConfig(); | 319 | //KABPrefs::instance()->writeConfig(); |
320 | delete AddresseeConfig::instance(); | 320 | delete AddresseeConfig::instance(); |
321 | mAddressBook = 0; | 321 | mAddressBook = 0; |
322 | KABC::StdAddressBook::close(); | 322 | KABC::StdAddressBook::close(); |
323 | 323 | ||
324 | delete syncManager; | 324 | delete syncManager; |
325 | } | 325 | } |
326 | 326 | ||
327 | void KABCore::restoreSettings() | 327 | void KABCore::restoreSettings() |
328 | { | 328 | { |
329 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 329 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
330 | 330 | ||
331 | bool state; | 331 | bool state; |
332 | 332 | ||
333 | if (mMultipleViewsAtOnce) | 333 | if (mMultipleViewsAtOnce) |
334 | state = KABPrefs::instance()->mDetailsPageVisible; | 334 | state = KABPrefs::instance()->mDetailsPageVisible; |
335 | else | 335 | else |
336 | state = false; | 336 | state = false; |
337 | 337 | ||
338 | mActionDetails->setChecked( state ); | 338 | mActionDetails->setChecked( state ); |
339 | setDetailsVisible( state ); | 339 | setDetailsVisible( state ); |
340 | 340 | ||
341 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 341 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
342 | 342 | ||
343 | mActionJumpBar->setChecked( state ); | 343 | mActionJumpBar->setChecked( state ); |
344 | setJumpButtonBarVisible( state ); | 344 | setJumpButtonBarVisible( state ); |
345 | /*US | 345 | /*US |
346 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 346 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
347 | if ( splitterSize.count() == 0 ) { | 347 | if ( splitterSize.count() == 0 ) { |
348 | splitterSize.append( width() / 2 ); | 348 | splitterSize.append( width() / 2 ); |
349 | splitterSize.append( width() / 2 ); | 349 | splitterSize.append( width() / 2 ); |
350 | } | 350 | } |
351 | mMiniSplitter->setSizes( splitterSize ); | 351 | mMiniSplitter->setSizes( splitterSize ); |
352 | if ( mExtensionBarSplitter ) { | 352 | if ( mExtensionBarSplitter ) { |
353 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 353 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
354 | if ( splitterSize.count() == 0 ) { | 354 | if ( splitterSize.count() == 0 ) { |
355 | splitterSize.append( width() / 2 ); | 355 | splitterSize.append( width() / 2 ); |
356 | splitterSize.append( width() / 2 ); | 356 | splitterSize.append( width() / 2 ); |
357 | } | 357 | } |
358 | mExtensionBarSplitter->setSizes( splitterSize ); | 358 | mExtensionBarSplitter->setSizes( splitterSize ); |
359 | 359 | ||
360 | } | 360 | } |
361 | */ | 361 | */ |
362 | mViewManager->restoreSettings(); | 362 | mViewManager->restoreSettings(); |
363 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 363 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
364 | mExtensionManager->restoreSettings(); | 364 | mExtensionManager->restoreSettings(); |
365 | #ifdef DESKTOP_VERSION | 365 | #ifdef DESKTOP_VERSION |
366 | int wid = width(); | 366 | int wid = width(); |
367 | if ( wid < 10 ) | 367 | if ( wid < 10 ) |
368 | wid = 400; | 368 | wid = 400; |
369 | #else | 369 | #else |
370 | int wid = QApplication::desktop()->width(); | 370 | int wid = QApplication::desktop()->width(); |
371 | if ( wid < 640 ) | 371 | if ( wid < 640 ) |
372 | wid = QApplication::desktop()->height(); | 372 | wid = QApplication::desktop()->height(); |
373 | #endif | 373 | #endif |
374 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 374 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
375 | if ( true /*splitterSize.count() == 0*/ ) { | 375 | if ( true /*splitterSize.count() == 0*/ ) { |
376 | splitterSize.append( wid / 2 ); | 376 | splitterSize.append( wid / 2 ); |
377 | splitterSize.append( wid / 2 ); | 377 | splitterSize.append( wid / 2 ); |
378 | } | 378 | } |
379 | mMiniSplitter->setSizes( splitterSize ); | 379 | mMiniSplitter->setSizes( splitterSize ); |
380 | if ( mExtensionBarSplitter ) { | 380 | if ( mExtensionBarSplitter ) { |
381 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 381 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
382 | if ( true /*splitterSize.count() == 0*/ ) { | 382 | if ( true /*splitterSize.count() == 0*/ ) { |
383 | splitterSize.append( wid / 2 ); | 383 | splitterSize.append( wid / 2 ); |
384 | splitterSize.append( wid / 2 ); | 384 | splitterSize.append( wid / 2 ); |
385 | } | 385 | } |
386 | mExtensionBarSplitter->setSizes( splitterSize ); | 386 | mExtensionBarSplitter->setSizes( splitterSize ); |
387 | 387 | ||
388 | } | 388 | } |
389 | 389 | ||
390 | 390 | ||
391 | } | 391 | } |
392 | 392 | ||
393 | void KABCore::saveSettings() | 393 | void KABCore::saveSettings() |
394 | { | 394 | { |
395 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 395 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
396 | if ( mExtensionBarSplitter ) | 396 | if ( mExtensionBarSplitter ) |
397 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 397 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
398 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 398 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
399 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 399 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
400 | #ifndef KAB_EMBEDDED | 400 | #ifndef KAB_EMBEDDED |
401 | 401 | ||
402 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 402 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
403 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 403 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
404 | #endif //KAB_EMBEDDED | 404 | #endif //KAB_EMBEDDED |
405 | mExtensionManager->saveSettings(); | 405 | mExtensionManager->saveSettings(); |
406 | mViewManager->saveSettings(); | 406 | mViewManager->saveSettings(); |
407 | 407 | ||
408 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 408 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
409 | } | 409 | } |
410 | 410 | ||
411 | KABC::AddressBook *KABCore::addressBook() const | 411 | KABC::AddressBook *KABCore::addressBook() const |
412 | { | 412 | { |
413 | return mAddressBook; | 413 | return mAddressBook; |
414 | } | 414 | } |
415 | 415 | ||
416 | KConfig *KABCore::config() | 416 | KConfig *KABCore::config() |
417 | { | 417 | { |
418 | #ifndef KAB_EMBEDDED | 418 | #ifndef KAB_EMBEDDED |
419 | return KABPrefs::instance()->config(); | 419 | return KABPrefs::instance()->config(); |
420 | #else //KAB_EMBEDDED | 420 | #else //KAB_EMBEDDED |
421 | return KABPrefs::instance()->getConfig(); | 421 | return KABPrefs::instance()->getConfig(); |
422 | #endif //KAB_EMBEDDED | 422 | #endif //KAB_EMBEDDED |
423 | } | 423 | } |
424 | 424 | ||
425 | KActionCollection *KABCore::actionCollection() const | 425 | KActionCollection *KABCore::actionCollection() const |
426 | { | 426 | { |
427 | return mGUIClient->actionCollection(); | 427 | return mGUIClient->actionCollection(); |
428 | } | 428 | } |
429 | 429 | ||
430 | KABC::Field *KABCore::currentSearchField() const | 430 | KABC::Field *KABCore::currentSearchField() const |
431 | { | 431 | { |
432 | if (mIncSearchWidget) | 432 | if (mIncSearchWidget) |
433 | return mIncSearchWidget->currentField(); | 433 | return mIncSearchWidget->currentField(); |
434 | else | 434 | else |
435 | return 0; | 435 | return 0; |
436 | } | 436 | } |
437 | 437 | ||
438 | QStringList KABCore::selectedUIDs() const | 438 | QStringList KABCore::selectedUIDs() const |
439 | { | 439 | { |
440 | return mViewManager->selectedUids(); | 440 | return mViewManager->selectedUids(); |
441 | } | 441 | } |
442 | 442 | ||
443 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 443 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
444 | { | 444 | { |
445 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 445 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
446 | 446 | ||
447 | QPtrList<KRES::Resource> kresResources; | 447 | QPtrList<KRES::Resource> kresResources; |
448 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 448 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
449 | KABC::Resource *resource; | 449 | KABC::Resource *resource; |
450 | while ( ( resource = resIt.current() ) != 0 ) { | 450 | while ( ( resource = resIt.current() ) != 0 ) { |
451 | ++resIt; | 451 | ++resIt; |
452 | if ( !resource->readOnly() ) { | 452 | if ( !resource->readOnly() ) { |
453 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 453 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
454 | if ( res ) | 454 | if ( res ) |
455 | kresResources.append( res ); | 455 | kresResources.append( res ); |
456 | } | 456 | } |
457 | } | 457 | } |
458 | 458 | ||
459 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 459 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
460 | return static_cast<KABC::Resource*>( res ); | 460 | return static_cast<KABC::Resource*>( res ); |
461 | } | 461 | } |
462 | 462 | ||
463 | #ifndef KAB_EMBEDDED | 463 | #ifndef KAB_EMBEDDED |
464 | KAboutData *KABCore::createAboutData() | 464 | KAboutData *KABCore::createAboutData() |
465 | #else //KAB_EMBEDDED | 465 | #else //KAB_EMBEDDED |
466 | void KABCore::createAboutData() | 466 | void KABCore::createAboutData() |
467 | #endif //KAB_EMBEDDED | 467 | #endif //KAB_EMBEDDED |
468 | { | 468 | { |
469 | #ifndef KAB_EMBEDDED | 469 | #ifndef KAB_EMBEDDED |
470 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 470 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
471 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 471 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
472 | KAboutData::License_GPL_V2, | 472 | KAboutData::License_GPL_V2, |
473 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 473 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
474 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 474 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
475 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 475 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
476 | about->addAuthor( "Cornelius Schumacher", | 476 | about->addAuthor( "Cornelius Schumacher", |
477 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 477 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
478 | "schumacher@kde.org" ); | 478 | "schumacher@kde.org" ); |
479 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 479 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
480 | "mpilone@slac.com" ); | 480 | "mpilone@slac.com" ); |
481 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 481 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
482 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 482 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
483 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 483 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
484 | "michel@klaralvdalens-datakonsult.se" ); | 484 | "michel@klaralvdalens-datakonsult.se" ); |
485 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 485 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
486 | "hansen@kde.org" ); | 486 | "hansen@kde.org" ); |
487 | 487 | ||
488 | return about; | 488 | return about; |
489 | #endif //KAB_EMBEDDED | 489 | #endif //KAB_EMBEDDED |
490 | 490 | ||
491 | QString version; | 491 | QString version; |
492 | #include <../version> | 492 | #include <../version> |
493 | QMessageBox::about( this, "About KAddressbook/Pi", | 493 | QMessageBox::about( this, "About KAddressbook/Pi", |
494 | "KAddressbook/Platform-independent\n" | 494 | "KAddressbook/Platform-independent\n" |
495 | "(KA/Pi) " +version + " - " + | 495 | "(KA/Pi) " +version + " - " + |
496 | #ifdef DESKTOP_VERSION | 496 | #ifdef DESKTOP_VERSION |
497 | "Desktop Edition\n" | 497 | "Desktop Edition\n" |
498 | #else | 498 | #else |
499 | "PDA-Edition\n" | 499 | "PDA-Edition\n" |
500 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 500 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
501 | #endif | 501 | #endif |
502 | 502 | ||
503 | "(c) 2004 Ulf Schenk\n" | 503 | "(c) 2004 Ulf Schenk\n" |
504 | "(c) 2004 Lutz Rogowski\n" | 504 | "(c) 2004 Lutz Rogowski\n" |
505 | "(c) 1997-2003, The KDE PIM Team\n" | 505 | "(c) 1997-2003, The KDE PIM Team\n" |
506 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 506 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
507 | "Don Sanders Original author\n" | 507 | "Don Sanders Original author\n" |
508 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 508 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
509 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 509 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
510 | "Greg Stern DCOP interface\n" | 510 | "Greg Stern DCOP interface\n" |
511 | "Mark Westcot Contact pinning\n" | 511 | "Mark Westcot Contact pinning\n" |
512 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 512 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
513 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 513 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
514 | #ifdef _WIN32_ | 514 | #ifdef _WIN32_ |
515 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 515 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
516 | #endif | 516 | #endif |
517 | ); | 517 | ); |
518 | } | 518 | } |
519 | 519 | ||
520 | void KABCore::setContactSelected( const QString &uid ) | 520 | void KABCore::setContactSelected( const QString &uid ) |
521 | { | 521 | { |
522 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 522 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
523 | if ( !mDetails->isHidden() ) | 523 | if ( !mDetails->isHidden() ) |
524 | mDetails->setAddressee( addr ); | 524 | mDetails->setAddressee( addr ); |
525 | 525 | ||
526 | if ( !addr.isEmpty() ) { | 526 | if ( !addr.isEmpty() ) { |
527 | emit contactSelected( addr.formattedName() ); | 527 | emit contactSelected( addr.formattedName() ); |
528 | KABC::Picture pic = addr.photo(); | 528 | KABC::Picture pic = addr.photo(); |
529 | if ( pic.isIntern() ) { | 529 | if ( pic.isIntern() ) { |
530 | //US emit contactSelected( pic.data() ); | 530 | //US emit contactSelected( pic.data() ); |
531 | //US instead use: | 531 | //US instead use: |
532 | QPixmap px; | 532 | QPixmap px; |
533 | if (pic.data().isNull() != true) | 533 | if (pic.data().isNull() != true) |
534 | { | 534 | { |
535 | px.convertFromImage(pic.data()); | 535 | px.convertFromImage(pic.data()); |
536 | } | 536 | } |
537 | 537 | ||
538 | emit contactSelected( px ); | 538 | emit contactSelected( px ); |
539 | } | 539 | } |
540 | } | 540 | } |
541 | 541 | ||
542 | 542 | ||
543 | mExtensionManager->setSelectionChanged(); | 543 | mExtensionManager->setSelectionChanged(); |
544 | 544 | ||
545 | // update the actions | 545 | // update the actions |
546 | bool selected = !uid.isEmpty(); | 546 | bool selected = !uid.isEmpty(); |
547 | 547 | ||
548 | if ( mReadWrite ) { | 548 | if ( mReadWrite ) { |
549 | mActionCut->setEnabled( selected ); | 549 | mActionCut->setEnabled( selected ); |
550 | mActionPaste->setEnabled( selected ); | 550 | mActionPaste->setEnabled( selected ); |
551 | } | 551 | } |
552 | 552 | ||
553 | mActionCopy->setEnabled( selected ); | 553 | mActionCopy->setEnabled( selected ); |
554 | mActionDelete->setEnabled( selected ); | 554 | mActionDelete->setEnabled( selected ); |
555 | mActionEditAddressee->setEnabled( selected ); | 555 | mActionEditAddressee->setEnabled( selected ); |
556 | mActionMail->setEnabled( selected ); | 556 | mActionMail->setEnabled( selected ); |
557 | mActionMailVCard->setEnabled( selected ); | 557 | mActionMailVCard->setEnabled( selected ); |
558 | //if (mActionBeam) | 558 | //if (mActionBeam) |
559 | //mActionBeam->setEnabled( selected ); | 559 | //mActionBeam->setEnabled( selected ); |
560 | 560 | ||
561 | if (mActionBeamVCard) | 561 | if (mActionBeamVCard) |
562 | mActionBeamVCard->setEnabled( selected ); | 562 | mActionBeamVCard->setEnabled( selected ); |
563 | 563 | ||
564 | mActionExport2phone->setEnabled( selected ); | 564 | mActionExport2phone->setEnabled( selected ); |
565 | mActionWhoAmI->setEnabled( selected ); | 565 | mActionWhoAmI->setEnabled( selected ); |
566 | mActionCategories->setEnabled( selected ); | 566 | mActionCategories->setEnabled( selected ); |
567 | } | 567 | } |
568 | 568 | ||
569 | void KABCore::sendMail() | 569 | void KABCore::sendMail() |
570 | { | 570 | { |
571 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 571 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
572 | } | 572 | } |
573 | 573 | ||
574 | void KABCore::sendMail( const QString& emaillist ) | 574 | void KABCore::sendMail( const QString& emaillist ) |
575 | { | 575 | { |
576 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 576 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
577 | if (emaillist.contains(",") > 0) | 577 | if (emaillist.contains(",") > 0) |
578 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 578 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
579 | else | 579 | else |
580 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 580 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
581 | } | 581 | } |
582 | 582 | ||
583 | 583 | ||
584 | 584 | ||
585 | void KABCore::mailVCard() | 585 | void KABCore::mailVCard() |
586 | { | 586 | { |
587 | QStringList uids = mViewManager->selectedUids(); | 587 | QStringList uids = mViewManager->selectedUids(); |
588 | if ( !uids.isEmpty() ) | 588 | if ( !uids.isEmpty() ) |
589 | mailVCard( uids ); | 589 | mailVCard( uids ); |
590 | } | 590 | } |
591 | 591 | ||
592 | void KABCore::mailVCard( const QStringList& uids ) | 592 | void KABCore::mailVCard( const QStringList& uids ) |
593 | { | 593 | { |
594 | QStringList urls; | 594 | QStringList urls; |
595 | 595 | ||
596 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 596 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
597 | 597 | ||
598 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 598 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
599 | 599 | ||
600 | 600 | ||
601 | 601 | ||
602 | QDir().mkdir( dirName, true ); | 602 | QDir().mkdir( dirName, true ); |
603 | 603 | ||
604 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 604 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
605 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 605 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
606 | 606 | ||
607 | if ( a.isEmpty() ) | 607 | if ( a.isEmpty() ) |
608 | continue; | 608 | continue; |
609 | 609 | ||
610 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 610 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
611 | 611 | ||
612 | QString fileName = dirName + "/" + name; | 612 | QString fileName = dirName + "/" + name; |
613 | 613 | ||
614 | QFile outFile(fileName); | 614 | QFile outFile(fileName); |
615 | 615 | ||
616 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 616 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
617 | KABC::VCardConverter converter; | 617 | KABC::VCardConverter converter; |
618 | QString vcard; | 618 | QString vcard; |
619 | 619 | ||
620 | converter.addresseeToVCard( a, vcard ); | 620 | converter.addresseeToVCard( a, vcard ); |
621 | 621 | ||
622 | QTextStream t( &outFile ); // use a text stream | 622 | QTextStream t( &outFile ); // use a text stream |
623 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 623 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
624 | t << vcard; | 624 | t << vcard; |
625 | 625 | ||
626 | outFile.close(); | 626 | outFile.close(); |
627 | 627 | ||
628 | urls.append( fileName ); | 628 | urls.append( fileName ); |
629 | } | 629 | } |
630 | } | 630 | } |
631 | 631 | ||
632 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 632 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
633 | 633 | ||
634 | 634 | ||
635 | /*US | 635 | /*US |
636 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 636 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
637 | QString::null, // subject | 637 | QString::null, // subject |
638 | QString::null, // body | 638 | QString::null, // body |
639 | QString::null, | 639 | QString::null, |
640 | urls ); // attachments | 640 | urls ); // attachments |
641 | */ | 641 | */ |
642 | 642 | ||
643 | } | 643 | } |
644 | 644 | ||
645 | /** | 645 | /** |
646 | Beams the "WhoAmI contact. | 646 | Beams the "WhoAmI contact. |
647 | */ | 647 | */ |
648 | void KABCore::beamMySelf() | 648 | void KABCore::beamMySelf() |
649 | { | 649 | { |
650 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 650 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
651 | if (!a.isEmpty()) | 651 | if (!a.isEmpty()) |
652 | { | 652 | { |
653 | QStringList uids; | 653 | QStringList uids; |
654 | uids << a.uid(); | 654 | uids << a.uid(); |
655 | 655 | ||
656 | beamVCard(uids); | 656 | beamVCard(uids); |
657 | } else { | 657 | } else { |
658 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 658 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
659 | 659 | ||
660 | 660 | ||
661 | } | 661 | } |
662 | } | 662 | } |
663 | 663 | ||
664 | void KABCore::export2phone() | 664 | void KABCore::export2phone() |
665 | { | 665 | { |
666 | 666 | ||
667 | KAex2phonePrefs ex2phone; | 667 | KAex2phonePrefs ex2phone; |
668 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 668 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
669 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 669 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
670 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 670 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
671 | 671 | ||
672 | if ( !ex2phone.exec() ) { | 672 | if ( !ex2phone.exec() ) { |
673 | return; | 673 | return; |
674 | } | 674 | } |
675 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 675 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
676 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 676 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
677 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 677 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
678 | 678 | ||
679 | 679 | ||
680 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 680 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
681 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 681 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
682 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 682 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
683 | 683 | ||
684 | QStringList uids = mViewManager->selectedUids(); | 684 | QStringList uids = mViewManager->selectedUids(); |
685 | if ( uids.isEmpty() ) | 685 | if ( uids.isEmpty() ) |
686 | return; | 686 | return; |
687 | 687 | ||
688 | #ifdef _WIN32_ | 688 | #ifdef _WIN32_ |
689 | QString fileName = locateLocal("tmp", "tempfile.vcf"); | 689 | QString fileName = locateLocal("tmp", "tempfile.vcf"); |
690 | #else | 690 | #else |
691 | QString fileName = "/tmp/kdepimtemp.vcf"; | 691 | QString fileName = "/tmp/kdepimtemp.vcf"; |
692 | #endif | 692 | #endif |
693 | 693 | ||
694 | KABC::VCardConverter converter; | 694 | KABC::VCardConverter converter; |
695 | QString description; | 695 | QString description; |
696 | QString datastream; | 696 | QString datastream; |
697 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 697 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
698 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 698 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
699 | 699 | ||
700 | if ( a.isEmpty() ) | 700 | if ( a.isEmpty() ) |
701 | continue; | 701 | continue; |
702 | 702 | ||
703 | if (description.isEmpty()) | 703 | if (description.isEmpty()) |
704 | description = a.formattedName(); | 704 | description = a.formattedName(); |
705 | 705 | ||
706 | QString vcard; | 706 | QString vcard; |
707 | converter.addresseeToVCard( a, vcard ); | 707 | converter.addresseeToVCard( a, vcard ); |
708 | int start = 0; | 708 | int start = 0; |
709 | int next; | 709 | int next; |
710 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 710 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
711 | int semi = vcard.find(";", next); | 711 | int semi = vcard.find(";", next); |
712 | int dopp = vcard.find(":", next); | 712 | int dopp = vcard.find(":", next); |
713 | int sep; | 713 | int sep; |
714 | if ( semi < dopp && semi >= 0 ) | 714 | if ( semi < dopp && semi >= 0 ) |
715 | sep = semi ; | 715 | sep = semi ; |
716 | else | 716 | else |
717 | sep = dopp; | 717 | sep = dopp; |
718 | datastream +=vcard.mid( start, next - start); | 718 | datastream +=vcard.mid( start, next - start); |
719 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 719 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
720 | start = sep; | 720 | start = sep; |
721 | } | 721 | } |
722 | datastream += vcard.mid( start,vcard.length() ); | 722 | datastream += vcard.mid( start,vcard.length() ); |
723 | } | 723 | } |
724 | QFile outFile(fileName); | 724 | QFile outFile(fileName); |
725 | if ( outFile.open(IO_WriteOnly) ) { | 725 | if ( outFile.open(IO_WriteOnly) ) { |
726 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 726 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
727 | QTextStream t( &outFile ); // use a text stream | 727 | QTextStream t( &outFile ); // use a text stream |
728 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 728 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
729 | t <<datastream; | 729 | t <<datastream; |
730 | outFile.close(); | 730 | outFile.close(); |
731 | if ( PhoneAccess::writeToPhone( fileName ) ) | 731 | if ( PhoneAccess::writeToPhone( fileName ) ) |
732 | qDebug("Export okay "); | 732 | qDebug("Export okay "); |
733 | else | 733 | else |
734 | qDebug("Error export contacts "); | 734 | qDebug("Error export contacts "); |
735 | 735 | ||
736 | } else { | 736 | } else { |
737 | qDebug("Error open temp file "); | 737 | qDebug("Error open temp file "); |
738 | return; | 738 | return; |
739 | } | 739 | } |
740 | 740 | ||
741 | 741 | ||
742 | #if 0 | 742 | #if 0 |
743 | 743 | ||
744 | setCaption( i18n("Writing to phone...")); | 744 | setCaption( i18n("Writing to phone...")); |
745 | if ( PhoneFormat::writeToPhone( cal ) ) | 745 | if ( PhoneFormat::writeToPhone( cal ) ) |
746 | setCaption( i18n("Export to phone successful!")); | 746 | setCaption( i18n("Export to phone successful!")); |
747 | else | 747 | else |
748 | setCaption( i18n("Error exporting to phone!")); | 748 | setCaption( i18n("Error exporting to phone!")); |
749 | #endif | 749 | #endif |
750 | 750 | ||
751 | 751 | ||
752 | } | 752 | } |
753 | void KABCore::beamVCard() | 753 | void KABCore::beamVCard() |
754 | { | 754 | { |
755 | QStringList uids = mViewManager->selectedUids(); | 755 | QStringList uids = mViewManager->selectedUids(); |
756 | if ( !uids.isEmpty() ) | 756 | if ( !uids.isEmpty() ) |
757 | beamVCard( uids ); | 757 | beamVCard( uids ); |
758 | } | 758 | } |
759 | 759 | ||
760 | 760 | ||
761 | void KABCore::beamVCard(const QStringList& uids) | 761 | void KABCore::beamVCard(const QStringList& uids) |
762 | { | 762 | { |
763 | /*US | 763 | /*US |
764 | QString beamFilename; | 764 | QString beamFilename; |
765 | Opie::OPimContact c; | 765 | Opie::OPimContact c; |
766 | if ( actionPersonal->isOn() ) { | 766 | if ( actionPersonal->isOn() ) { |
767 | beamFilename = addressbookPersonalVCardName(); | 767 | beamFilename = addressbookPersonalVCardName(); |
768 | if ( !QFile::exists( beamFilename ) ) | 768 | if ( !QFile::exists( beamFilename ) ) |
769 | return; // can't beam a non-existent file | 769 | return; // can't beam a non-existent file |
770 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 770 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
771 | beamFilename ); | 771 | beamFilename ); |
772 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 772 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
773 | Opie::OPimContactAccess::List allList = access->allRecords(); | 773 | Opie::OPimContactAccess::List allList = access->allRecords(); |
774 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 774 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
775 | c = *it; | 775 | c = *it; |
776 | 776 | ||
777 | delete access; | 777 | delete access; |
778 | } else { | 778 | } else { |
779 | unlink( beamfile ); // delete if exists | 779 | unlink( beamfile ); // delete if exists |
780 | mkdir("/tmp/obex/", 0755); | 780 | mkdir("/tmp/obex/", 0755); |
781 | c = m_abView -> currentEntry(); | 781 | c = m_abView -> currentEntry(); |
782 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 782 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
783 | beamfile ); | 783 | beamfile ); |
784 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 784 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
785 | access->add( c ); | 785 | access->add( c ); |
786 | access->save(); | 786 | access->save(); |
787 | delete access; | 787 | delete access; |
788 | 788 | ||
789 | beamFilename = beamfile; | 789 | beamFilename = beamfile; |
790 | } | 790 | } |
791 | 791 | ||
792 | owarn << "Beaming: " << beamFilename << oendl; | 792 | owarn << "Beaming: " << beamFilename << oendl; |
793 | */ | 793 | */ |
794 | 794 | ||
795 | #if 0 | 795 | #if 0 |
796 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 796 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
797 | 797 | ||
798 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | 798 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); |
799 | 799 | ||
800 | QString name = "contact.vcf"; | 800 | QString name = "contact.vcf"; |
801 | 801 | ||
802 | QString fileName = dirName + "/" + name; | 802 | QString fileName = dirName + "/" + name; |
803 | #endif | 803 | #endif |
804 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | 804 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory |
805 | // | 805 | // |
806 | QString fileName = "/tmp/kapibeamfile.vcf"; | 806 | QString fileName = "/tmp/kapibeamfile.vcf"; |
807 | 807 | ||
808 | 808 | ||
809 | //QDir().mkdir( dirName, true ); | 809 | //QDir().mkdir( dirName, true ); |
810 | 810 | ||
811 | 811 | ||
812 | KABC::VCardConverter converter; | 812 | KABC::VCardConverter converter; |
813 | QString description; | 813 | QString description; |
814 | QString datastream; | 814 | QString datastream; |
815 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 815 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
816 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 816 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
817 | 817 | ||
818 | if ( a.isEmpty() ) | 818 | if ( a.isEmpty() ) |
819 | continue; | 819 | continue; |
820 | 820 | ||
821 | if (description.isEmpty()) | 821 | if (description.isEmpty()) |
822 | description = a.formattedName(); | 822 | description = a.formattedName(); |
823 | 823 | ||
824 | QString vcard; | 824 | QString vcard; |
825 | converter.addresseeToVCard( a, vcard ); | 825 | converter.addresseeToVCard( a, vcard ); |
826 | int start = 0; | 826 | int start = 0; |
827 | int next; | 827 | int next; |
828 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 828 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
829 | int semi = vcard.find(";", next); | 829 | int semi = vcard.find(";", next); |
830 | int dopp = vcard.find(":", next); | 830 | int dopp = vcard.find(":", next); |
831 | int sep; | 831 | int sep; |
832 | if ( semi < dopp && semi >= 0 ) | 832 | if ( semi < dopp && semi >= 0 ) |
833 | sep = semi ; | 833 | sep = semi ; |
834 | else | 834 | else |
835 | sep = dopp; | 835 | sep = dopp; |
836 | datastream +=vcard.mid( start, next - start); | 836 | datastream +=vcard.mid( start, next - start); |
837 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 837 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
838 | start = sep; | 838 | start = sep; |
839 | } | 839 | } |
840 | datastream += vcard.mid( start,vcard.length() ); | 840 | datastream += vcard.mid( start,vcard.length() ); |
841 | } | 841 | } |
842 | #ifndef DESKTOP_VERSION | 842 | #ifndef DESKTOP_VERSION |
843 | QFile outFile(fileName); | 843 | QFile outFile(fileName); |
844 | if ( outFile.open(IO_WriteOnly) ) { | 844 | if ( outFile.open(IO_WriteOnly) ) { |
845 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 845 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
846 | QTextStream t( &outFile ); // use a text stream | 846 | QTextStream t( &outFile ); // use a text stream |
847 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 847 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
848 | t <<datastream; | 848 | t <<datastream; |
849 | outFile.close(); | 849 | outFile.close(); |
850 | Ir *ir = new Ir( this ); | 850 | Ir *ir = new Ir( this ); |
851 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 851 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
852 | ir->send( fileName, description, "text/x-vCard" ); | 852 | ir->send( fileName, description, "text/x-vCard" ); |
853 | } else { | 853 | } else { |
854 | qDebug("Error open temp beam file "); | 854 | qDebug("Error open temp beam file "); |
855 | return; | 855 | return; |
856 | } | 856 | } |
857 | #endif | 857 | #endif |
858 | 858 | ||
859 | } | 859 | } |
860 | 860 | ||
861 | void KABCore::beamDone( Ir *ir ) | 861 | void KABCore::beamDone( Ir *ir ) |
862 | { | 862 | { |
863 | #ifndef DESKTOP_VERSION | 863 | #ifndef DESKTOP_VERSION |
864 | delete ir; | 864 | delete ir; |
865 | #endif | 865 | #endif |
866 | } | 866 | } |
867 | 867 | ||
868 | 868 | ||
869 | void KABCore::browse( const QString& url ) | 869 | void KABCore::browse( const QString& url ) |
870 | { | 870 | { |
871 | #ifndef KAB_EMBEDDED | 871 | #ifndef KAB_EMBEDDED |
872 | kapp->invokeBrowser( url ); | 872 | kapp->invokeBrowser( url ); |
873 | #else //KAB_EMBEDDED | 873 | #else //KAB_EMBEDDED |
874 | qDebug("KABCore::browse must be fixed"); | 874 | qDebug("KABCore::browse must be fixed"); |
875 | #endif //KAB_EMBEDDED | 875 | #endif //KAB_EMBEDDED |
876 | } | 876 | } |
877 | 877 | ||
878 | void KABCore::selectAllContacts() | 878 | void KABCore::selectAllContacts() |
879 | { | 879 | { |
880 | mViewManager->setSelected( QString::null, true ); | 880 | mViewManager->setSelected( QString::null, true ); |
881 | } | 881 | } |
882 | 882 | ||
883 | void KABCore::deleteContacts() | 883 | void KABCore::deleteContacts() |
884 | { | 884 | { |
885 | QStringList uidList = mViewManager->selectedUids(); | 885 | QStringList uidList = mViewManager->selectedUids(); |
886 | deleteContacts( uidList ); | 886 | deleteContacts( uidList ); |
887 | } | 887 | } |
888 | 888 | ||
889 | void KABCore::deleteContacts( const QStringList &uids ) | 889 | void KABCore::deleteContacts( const QStringList &uids ) |
890 | { | 890 | { |
891 | if ( uids.count() > 0 ) { | 891 | if ( uids.count() > 0 ) { |
892 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 892 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
893 | UndoStack::instance()->push( command ); | 893 | UndoStack::instance()->push( command ); |
894 | RedoStack::instance()->clear(); | 894 | RedoStack::instance()->clear(); |
895 | 895 | ||
896 | // now if we deleted anything, refresh | 896 | // now if we deleted anything, refresh |
897 | setContactSelected( QString::null ); | 897 | setContactSelected( QString::null ); |
898 | setModified( true ); | 898 | setModified( true ); |
899 | } | 899 | } |
900 | } | 900 | } |
901 | 901 | ||
902 | void KABCore::copyContacts() | 902 | void KABCore::copyContacts() |
903 | { | 903 | { |
904 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 904 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
905 | 905 | ||
906 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 906 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
907 | 907 | ||
908 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 908 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
909 | 909 | ||
910 | QClipboard *cb = QApplication::clipboard(); | 910 | QClipboard *cb = QApplication::clipboard(); |
911 | cb->setText( clipText ); | 911 | cb->setText( clipText ); |
912 | } | 912 | } |
913 | 913 | ||
914 | void KABCore::cutContacts() | 914 | void KABCore::cutContacts() |
915 | { | 915 | { |
916 | QStringList uidList = mViewManager->selectedUids(); | 916 | QStringList uidList = mViewManager->selectedUids(); |
917 | 917 | ||
918 | //US if ( uidList.size() > 0 ) { | 918 | //US if ( uidList.size() > 0 ) { |
919 | if ( uidList.count() > 0 ) { | 919 | if ( uidList.count() > 0 ) { |
920 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 920 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
921 | UndoStack::instance()->push( command ); | 921 | UndoStack::instance()->push( command ); |
922 | RedoStack::instance()->clear(); | 922 | RedoStack::instance()->clear(); |
923 | 923 | ||
924 | setModified( true ); | 924 | setModified( true ); |
925 | } | 925 | } |
926 | } | 926 | } |
927 | 927 | ||
928 | void KABCore::pasteContacts() | 928 | void KABCore::pasteContacts() |
929 | { | 929 | { |
930 | QClipboard *cb = QApplication::clipboard(); | 930 | QClipboard *cb = QApplication::clipboard(); |
931 | 931 | ||
932 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 932 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
933 | 933 | ||
934 | pasteContacts( list ); | 934 | pasteContacts( list ); |
935 | } | 935 | } |
936 | 936 | ||
937 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 937 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
938 | { | 938 | { |
939 | KABC::Resource *resource = requestResource( this ); | 939 | KABC::Resource *resource = requestResource( this ); |
940 | KABC::Addressee::List::Iterator it; | 940 | KABC::Addressee::List::Iterator it; |
941 | for ( it = list.begin(); it != list.end(); ++it ) | 941 | for ( it = list.begin(); it != list.end(); ++it ) |
942 | (*it).setResource( resource ); | 942 | (*it).setResource( resource ); |
943 | 943 | ||
944 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 944 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
945 | UndoStack::instance()->push( command ); | 945 | UndoStack::instance()->push( command ); |
946 | RedoStack::instance()->clear(); | 946 | RedoStack::instance()->clear(); |
947 | 947 | ||
948 | setModified( true ); | 948 | setModified( true ); |
949 | } | 949 | } |
950 | 950 | ||
951 | void KABCore::setWhoAmI() | 951 | void KABCore::setWhoAmI() |
952 | { | 952 | { |
953 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 953 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
954 | 954 | ||
955 | if ( addrList.count() > 1 ) { | 955 | if ( addrList.count() > 1 ) { |
956 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 956 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
957 | return; | 957 | return; |
958 | } | 958 | } |
959 | 959 | ||
960 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 960 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
961 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 961 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
962 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 962 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
963 | } | 963 | } |
964 | 964 | ||
965 | void KABCore::setCategories() | 965 | void KABCore::setCategories() |
966 | { | 966 | { |
967 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 967 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
968 | if ( !dlg.exec() ) | 968 | if ( !dlg.exec() ) |
969 | return; | 969 | return; |
970 | 970 | ||
971 | bool merge = false; | 971 | bool merge = false; |
972 | QString msg = i18n( "Merge with existing categories?" ); | 972 | QString msg = i18n( "Merge with existing categories?" ); |
973 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 973 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
974 | merge = true; | 974 | merge = true; |
975 | 975 | ||
976 | QStringList categories = dlg.selectedCategories(); | 976 | QStringList categories = dlg.selectedCategories(); |
977 | 977 | ||
978 | QStringList uids = mViewManager->selectedUids(); | 978 | QStringList uids = mViewManager->selectedUids(); |
979 | QStringList::Iterator it; | 979 | QStringList::Iterator it; |
980 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 980 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
981 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 981 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
982 | if ( !addr.isEmpty() ) { | 982 | if ( !addr.isEmpty() ) { |
983 | if ( !merge ) | 983 | if ( !merge ) |
984 | addr.setCategories( categories ); | 984 | addr.setCategories( categories ); |
985 | else { | 985 | else { |
986 | QStringList addrCategories = addr.categories(); | 986 | QStringList addrCategories = addr.categories(); |
987 | QStringList::Iterator catIt; | 987 | QStringList::Iterator catIt; |
988 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 988 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
989 | if ( !addrCategories.contains( *catIt ) ) | 989 | if ( !addrCategories.contains( *catIt ) ) |
990 | addrCategories.append( *catIt ); | 990 | addrCategories.append( *catIt ); |
991 | } | 991 | } |
992 | addr.setCategories( addrCategories ); | 992 | addr.setCategories( addrCategories ); |
993 | } | 993 | } |
994 | 994 | ||
995 | mAddressBook->insertAddressee( addr ); | 995 | mAddressBook->insertAddressee( addr ); |
996 | } | 996 | } |
997 | } | 997 | } |
998 | 998 | ||
999 | if ( uids.count() > 0 ) | 999 | if ( uids.count() > 0 ) |
1000 | setModified( true ); | 1000 | setModified( true ); |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 1003 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
1004 | { | 1004 | { |
1005 | mIncSearchWidget->setFields( fields ); | 1005 | mIncSearchWidget->setFields( fields ); |
1006 | } | 1006 | } |
1007 | 1007 | ||
1008 | void KABCore::incrementalSearch( const QString& text ) | 1008 | void KABCore::incrementalSearch( const QString& text ) |
1009 | { | 1009 | { |
1010 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1010 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | void KABCore::setModified() | 1013 | void KABCore::setModified() |
1014 | { | 1014 | { |
1015 | setModified( true ); | 1015 | setModified( true ); |
1016 | } | 1016 | } |
1017 | 1017 | ||
1018 | void KABCore::setModifiedWOrefresh() | 1018 | void KABCore::setModifiedWOrefresh() |
1019 | { | 1019 | { |
1020 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1020 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1021 | mModified = true; | 1021 | mModified = true; |
1022 | mActionSave->setEnabled( mModified ); | 1022 | mActionSave->setEnabled( mModified ); |
1023 | #ifdef DESKTOP_VERSION | 1023 | #ifdef DESKTOP_VERSION |
1024 | mDetails->refreshView(); | 1024 | mDetails->refreshView(); |
1025 | #endif | 1025 | #endif |
1026 | 1026 | ||
1027 | } | 1027 | } |
1028 | void KABCore::setModified( bool modified ) | 1028 | void KABCore::setModified( bool modified ) |
1029 | { | 1029 | { |
1030 | mModified = modified; | 1030 | mModified = modified; |
1031 | mActionSave->setEnabled( mModified ); | 1031 | mActionSave->setEnabled( mModified ); |
1032 | 1032 | ||
1033 | if ( modified ) | 1033 | if ( modified ) |
1034 | mJumpButtonBar->recreateButtons(); | 1034 | mJumpButtonBar->recreateButtons(); |
1035 | 1035 | ||
1036 | mViewManager->refreshView(); | 1036 | mViewManager->refreshView(); |
1037 | mDetails->refreshView(); | 1037 | mDetails->refreshView(); |
1038 | 1038 | ||
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | bool KABCore::modified() const | 1041 | bool KABCore::modified() const |
1042 | { | 1042 | { |
1043 | return mModified; | 1043 | return mModified; |
1044 | } | 1044 | } |
1045 | 1045 | ||
1046 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1046 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1047 | { | 1047 | { |
1048 | 1048 | ||
1049 | Command *command = 0; | 1049 | Command *command = 0; |
1050 | QString uid; | 1050 | QString uid; |
1051 | 1051 | ||
1052 | // check if it exists already | 1052 | // check if it exists already |
1053 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1053 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1054 | if ( origAddr.isEmpty() ) | 1054 | if ( origAddr.isEmpty() ) |
1055 | command = new PwNewCommand( mAddressBook, addr ); | 1055 | command = new PwNewCommand( mAddressBook, addr ); |
1056 | else { | 1056 | else { |
1057 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1057 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1058 | uid = addr.uid(); | 1058 | uid = addr.uid(); |
1059 | } | 1059 | } |
1060 | 1060 | ||
1061 | UndoStack::instance()->push( command ); | 1061 | UndoStack::instance()->push( command ); |
1062 | RedoStack::instance()->clear(); | 1062 | RedoStack::instance()->clear(); |
1063 | 1063 | ||
1064 | setModified( true ); | 1064 | setModified( true ); |
1065 | } | 1065 | } |
1066 | 1066 | ||
1067 | void KABCore::newContact() | 1067 | void KABCore::newContact() |
1068 | { | 1068 | { |
1069 | 1069 | ||
1070 | 1070 | ||
1071 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1071 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1072 | 1072 | ||
1073 | QPtrList<KRES::Resource> kresResources; | 1073 | QPtrList<KRES::Resource> kresResources; |
1074 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1074 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1075 | KABC::Resource *resource; | 1075 | KABC::Resource *resource; |
1076 | while ( ( resource = it.current() ) != 0 ) { | 1076 | while ( ( resource = it.current() ) != 0 ) { |
1077 | ++it; | 1077 | ++it; |
1078 | if ( !resource->readOnly() ) { | 1078 | if ( !resource->readOnly() ) { |
1079 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1079 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1080 | if ( res ) | 1080 | if ( res ) |
1081 | kresResources.append( res ); | 1081 | kresResources.append( res ); |
1082 | } | 1082 | } |
1083 | } | 1083 | } |
1084 | 1084 | ||
1085 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1085 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1086 | resource = static_cast<KABC::Resource*>( res ); | 1086 | resource = static_cast<KABC::Resource*>( res ); |
1087 | 1087 | ||
1088 | if ( resource ) { | 1088 | if ( resource ) { |
1089 | KABC::Addressee addr; | 1089 | KABC::Addressee addr; |
1090 | addr.setResource( resource ); | 1090 | addr.setResource( resource ); |
1091 | mEditorDialog->setAddressee( addr ); | 1091 | mEditorDialog->setAddressee( addr ); |
1092 | KApplication::execDialog ( mEditorDialog ); | 1092 | KApplication::execDialog ( mEditorDialog ); |
1093 | 1093 | ||
1094 | } else | 1094 | } else |
1095 | return; | 1095 | return; |
1096 | 1096 | ||
1097 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1097 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1098 | 1098 | ||
1099 | 1099 | ||
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | void KABCore::addEmail( QString aStr ) | 1102 | void KABCore::addEmail( QString aStr ) |
1103 | { | 1103 | { |
1104 | #ifndef KAB_EMBEDDED | 1104 | #ifndef KAB_EMBEDDED |
1105 | QString fullName, email; | 1105 | QString fullName, email; |
1106 | 1106 | ||
1107 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1107 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1108 | 1108 | ||
1109 | // Try to lookup the addressee matching the email address | 1109 | // Try to lookup the addressee matching the email address |
1110 | bool found = false; | 1110 | bool found = false; |
1111 | QStringList emailList; | 1111 | QStringList emailList; |
1112 | KABC::AddressBook::Iterator it; | 1112 | KABC::AddressBook::Iterator it; |
1113 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1113 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1114 | emailList = (*it).emails(); | 1114 | emailList = (*it).emails(); |
1115 | if ( emailList.contains( email ) > 0 ) { | 1115 | if ( emailList.contains( email ) > 0 ) { |
1116 | found = true; | 1116 | found = true; |
1117 | (*it).setNameFromString( fullName ); | 1117 | (*it).setNameFromString( fullName ); |
1118 | editContact( (*it).uid() ); | 1118 | editContact( (*it).uid() ); |
1119 | } | 1119 | } |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | if ( !found ) { | 1122 | if ( !found ) { |
1123 | KABC::Addressee addr; | 1123 | KABC::Addressee addr; |
1124 | addr.setNameFromString( fullName ); | 1124 | addr.setNameFromString( fullName ); |
1125 | addr.insertEmail( email, true ); | 1125 | addr.insertEmail( email, true ); |
1126 | 1126 | ||
1127 | mAddressBook->insertAddressee( addr ); | 1127 | mAddressBook->insertAddressee( addr ); |
1128 | mViewManager->refreshView( addr.uid() ); | 1128 | mViewManager->refreshView( addr.uid() ); |
1129 | editContact( addr.uid() ); | 1129 | editContact( addr.uid() ); |
1130 | } | 1130 | } |
1131 | #else //KAB_EMBEDDED | 1131 | #else //KAB_EMBEDDED |
1132 | qDebug("KABCore::addEmail finsih method"); | 1132 | qDebug("KABCore::addEmail finsih method"); |
1133 | #endif //KAB_EMBEDDED | 1133 | #endif //KAB_EMBEDDED |
1134 | } | 1134 | } |
1135 | 1135 | ||
1136 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1136 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1137 | { | 1137 | { |
1138 | mXXPortManager->importVCard( url, showPreview ); | 1138 | mXXPortManager->importVCard( url, showPreview ); |
1139 | } | 1139 | } |
1140 | void KABCore::importFromOL() | 1140 | void KABCore::importFromOL() |
1141 | { | 1141 | { |
1142 | #ifdef _WIN32_ | 1142 | #ifdef _WIN32_ |
1143 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1143 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1144 | idgl->exec(); | 1144 | idgl->exec(); |
1145 | KABC::Addressee::List list = idgl->getAddressList(); | 1145 | KABC::Addressee::List list = idgl->getAddressList(); |
1146 | if ( list.count() > 0 ) { | 1146 | if ( list.count() > 0 ) { |
1147 | KABC::Addressee::List listNew; | 1147 | KABC::Addressee::List listNew; |
1148 | KABC::Addressee::List listExisting; | 1148 | KABC::Addressee::List listExisting; |
1149 | KABC::Addressee::List::Iterator it; | 1149 | KABC::Addressee::List::Iterator it; |
1150 | KABC::AddressBook::Iterator iter; | 1150 | KABC::AddressBook::Iterator iter; |
1151 | for ( it = list.begin(); it != list.end(); ++it ) { | 1151 | for ( it = list.begin(); it != list.end(); ++it ) { |
1152 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1152 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1153 | listNew.append( (*it) ); | 1153 | listNew.append( (*it) ); |
1154 | else | 1154 | else |
1155 | listExisting.append( (*it) ); | 1155 | listExisting.append( (*it) ); |
1156 | } | 1156 | } |
1157 | if ( listExisting.count() > 0 ) | 1157 | if ( listExisting.count() > 0 ) |
1158 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1158 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1159 | if ( listNew.count() > 0 ) { | 1159 | if ( listNew.count() > 0 ) { |
1160 | pasteWithNewUid = false; | 1160 | pasteWithNewUid = false; |
1161 | pasteContacts( listNew ); | 1161 | pasteContacts( listNew ); |
1162 | pasteWithNewUid = true; | 1162 | pasteWithNewUid = true; |
1163 | } | 1163 | } |
1164 | } | 1164 | } |
1165 | delete idgl; | 1165 | delete idgl; |
1166 | #endif | 1166 | #endif |
1167 | } | 1167 | } |
1168 | 1168 | ||
1169 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1169 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1170 | { | 1170 | { |
1171 | mXXPortManager->importVCard( vCard, showPreview ); | 1171 | mXXPortManager->importVCard( vCard, showPreview ); |
1172 | } | 1172 | } |
1173 | 1173 | ||
1174 | //US added a second method without defaultparameter | 1174 | //US added a second method without defaultparameter |
1175 | void KABCore::editContact2() { | 1175 | void KABCore::editContact2() { |
1176 | editContact( QString::null ); | 1176 | editContact( QString::null ); |
1177 | } | 1177 | } |
1178 | 1178 | ||
1179 | void KABCore::editContact( const QString &uid ) | 1179 | void KABCore::editContact( const QString &uid ) |
1180 | { | 1180 | { |
1181 | 1181 | ||
1182 | if ( mExtensionManager->isQuickEditVisible() ) | 1182 | if ( mExtensionManager->isQuickEditVisible() ) |
1183 | return; | 1183 | return; |
1184 | 1184 | ||
1185 | // First, locate the contact entry | 1185 | // First, locate the contact entry |
1186 | QString localUID = uid; | 1186 | QString localUID = uid; |
1187 | if ( localUID.isNull() ) { | 1187 | if ( localUID.isNull() ) { |
1188 | QStringList uidList = mViewManager->selectedUids(); | 1188 | QStringList uidList = mViewManager->selectedUids(); |
1189 | if ( uidList.count() > 0 ) | 1189 | if ( uidList.count() > 0 ) |
1190 | localUID = *( uidList.at( 0 ) ); | 1190 | localUID = *( uidList.at( 0 ) ); |
1191 | } | 1191 | } |
1192 | 1192 | ||
1193 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1193 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1194 | if ( !addr.isEmpty() ) { | 1194 | if ( !addr.isEmpty() ) { |
1195 | mEditorDialog->setAddressee( addr ); | 1195 | mEditorDialog->setAddressee( addr ); |
1196 | KApplication::execDialog ( mEditorDialog ); | 1196 | KApplication::execDialog ( mEditorDialog ); |
1197 | } | 1197 | } |
1198 | } | 1198 | } |
1199 | 1199 | ||
1200 | /** | 1200 | /** |
1201 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1201 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1202 | the method will try to find a selected addressee in the view. | 1202 | the method will try to find a selected addressee in the view. |
1203 | */ | 1203 | */ |
1204 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1204 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1205 | { | 1205 | { |
1206 | if ( mMultipleViewsAtOnce ) | 1206 | if ( mMultipleViewsAtOnce ) |
1207 | { | 1207 | { |
1208 | editContact( uid ); | 1208 | editContact( uid ); |
1209 | } | 1209 | } |
1210 | else | 1210 | else |
1211 | { | 1211 | { |
1212 | setDetailsVisible( true ); | 1212 | setDetailsVisible( true ); |
1213 | mActionDetails->setChecked(true); | 1213 | mActionDetails->setChecked(true); |
1214 | } | 1214 | } |
1215 | 1215 | ||
1216 | } | 1216 | } |
1217 | 1217 | ||
1218 | void KABCore::save() | 1218 | void KABCore::save() |
1219 | { | 1219 | { |
1220 | if (syncManager->blockSave()) | 1220 | if (syncManager->blockSave()) |
1221 | return; | 1221 | return; |
1222 | if ( !mModified ) | 1222 | if ( !mModified ) |
1223 | return; | 1223 | return; |
1224 | 1224 | ||
1225 | syncManager->setBlockSave(true); | 1225 | syncManager->setBlockSave(true); |
1226 | QString text = i18n( "There was an error while attempting to save\n the " | 1226 | QString text = i18n( "There was an error while attempting to save\n the " |
1227 | "address book. Please check that some \nother application is " | 1227 | "address book. Please check that some \nother application is " |
1228 | "not using it. " ); | 1228 | "not using it. " ); |
1229 | statusMessage(i18n("Saving addressbook ... ")); | 1229 | statusMessage(i18n("Saving addressbook ... ")); |
1230 | #ifndef KAB_EMBEDDED | 1230 | #ifndef KAB_EMBEDDED |
1231 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1231 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1232 | if ( !b || !b->save() ) { | 1232 | if ( !b || !b->save() ) { |
1233 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1233 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1234 | } | 1234 | } |
1235 | #else //KAB_EMBEDDED | 1235 | #else //KAB_EMBEDDED |
1236 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1236 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1237 | if ( !b || !b->save() ) { | 1237 | if ( !b || !b->save() ) { |
1238 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1238 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1239 | } | 1239 | } |
1240 | #endif //KAB_EMBEDDED | 1240 | #endif //KAB_EMBEDDED |
1241 | 1241 | ||
1242 | statusMessage(i18n("Addressbook saved!")); | 1242 | statusMessage(i18n("Addressbook saved!")); |
1243 | setModified( false ); | 1243 | setModified( false ); |
1244 | syncManager->setBlockSave(false); | 1244 | syncManager->setBlockSave(false); |
1245 | } | 1245 | } |
1246 | 1246 | ||
1247 | void KABCore::statusMessage(QString mess , int time ) | 1247 | void KABCore::statusMessage(QString mess , int time ) |
1248 | { | 1248 | { |
1249 | //topLevelWidget()->setCaption( mess ); | 1249 | //topLevelWidget()->setCaption( mess ); |
1250 | // pending setting timer to revome message | 1250 | // pending setting timer to revome message |
1251 | } | 1251 | } |
1252 | void KABCore::undo() | 1252 | void KABCore::undo() |
1253 | { | 1253 | { |
1254 | UndoStack::instance()->undo(); | 1254 | UndoStack::instance()->undo(); |
1255 | 1255 | ||
1256 | // Refresh the view | 1256 | // Refresh the view |
1257 | mViewManager->refreshView(); | 1257 | mViewManager->refreshView(); |
1258 | } | 1258 | } |
1259 | 1259 | ||
1260 | void KABCore::redo() | 1260 | void KABCore::redo() |
1261 | { | 1261 | { |
1262 | RedoStack::instance()->redo(); | 1262 | RedoStack::instance()->redo(); |
1263 | 1263 | ||
1264 | // Refresh the view | 1264 | // Refresh the view |
1265 | mViewManager->refreshView(); | 1265 | mViewManager->refreshView(); |
1266 | } | 1266 | } |
1267 | 1267 | ||
1268 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1268 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1269 | { | 1269 | { |
1270 | if (mMultipleViewsAtOnce) | 1270 | if (mMultipleViewsAtOnce) |
1271 | { | 1271 | { |
1272 | if ( visible ) | 1272 | if ( visible ) |
1273 | mJumpButtonBar->show(); | 1273 | mJumpButtonBar->show(); |
1274 | else | 1274 | else |
1275 | mJumpButtonBar->hide(); | 1275 | mJumpButtonBar->hide(); |
1276 | } | 1276 | } |
1277 | else | 1277 | else |
1278 | { | 1278 | { |
1279 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1279 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1280 | if (mViewManager->isVisible()) | 1280 | if (mViewManager->isVisible()) |
1281 | { | 1281 | { |
1282 | if ( visible ) | 1282 | if ( visible ) |
1283 | mJumpButtonBar->show(); | 1283 | mJumpButtonBar->show(); |
1284 | else | 1284 | else |
1285 | mJumpButtonBar->hide(); | 1285 | mJumpButtonBar->hide(); |
1286 | } | 1286 | } |
1287 | else | 1287 | else |
1288 | { | 1288 | { |
1289 | mJumpButtonBar->hide(); | 1289 | mJumpButtonBar->hide(); |
1290 | } | 1290 | } |
1291 | } | 1291 | } |
1292 | } | 1292 | } |
1293 | 1293 | ||
1294 | 1294 | ||
1295 | void KABCore::setDetailsToState() | 1295 | void KABCore::setDetailsToState() |
1296 | { | 1296 | { |
1297 | setDetailsVisible( mActionDetails->isChecked() ); | 1297 | setDetailsVisible( mActionDetails->isChecked() ); |
1298 | } | 1298 | } |
1299 | 1299 | ||
1300 | 1300 | ||
1301 | 1301 | ||
1302 | void KABCore::setDetailsVisible( bool visible ) | 1302 | void KABCore::setDetailsVisible( bool visible ) |
1303 | { | 1303 | { |
1304 | if (visible && mDetails->isHidden()) | 1304 | if (visible && mDetails->isHidden()) |
1305 | { | 1305 | { |
1306 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1306 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1307 | if ( addrList.count() > 0 ) | 1307 | if ( addrList.count() > 0 ) |
1308 | mDetails->setAddressee( addrList[ 0 ] ); | 1308 | mDetails->setAddressee( addrList[ 0 ] ); |
1309 | } | 1309 | } |
1310 | 1310 | ||
1311 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1311 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1312 | // the listview and the detailview. We do that by changing the splitbar size. | 1312 | // the listview and the detailview. We do that by changing the splitbar size. |
1313 | if (mMultipleViewsAtOnce) | 1313 | if (mMultipleViewsAtOnce) |
1314 | { | 1314 | { |
1315 | if ( visible ) | 1315 | if ( visible ) |
1316 | mDetails->show(); | 1316 | mDetails->show(); |
1317 | else | 1317 | else |
1318 | mDetails->hide(); | 1318 | mDetails->hide(); |
1319 | } | 1319 | } |
1320 | else | 1320 | else |
1321 | { | 1321 | { |
1322 | if ( visible ) { | 1322 | if ( visible ) { |
1323 | mViewManager->hide(); | 1323 | mViewManager->hide(); |
1324 | mDetails->show(); | 1324 | mDetails->show(); |
1325 | } | 1325 | } |
1326 | else { | 1326 | else { |
1327 | mViewManager->show(); | 1327 | mViewManager->show(); |
1328 | mDetails->hide(); | 1328 | mDetails->hide(); |
1329 | } | 1329 | } |
1330 | setJumpButtonBarVisible( !visible ); | 1330 | setJumpButtonBarVisible( !visible ); |
1331 | } | 1331 | } |
1332 | 1332 | ||
1333 | } | 1333 | } |
1334 | 1334 | ||
1335 | void KABCore::extensionChanged( int id ) | 1335 | void KABCore::extensionChanged( int id ) |
1336 | { | 1336 | { |
1337 | //change the details view only for non desktop systems | 1337 | //change the details view only for non desktop systems |
1338 | #ifndef DESKTOP_VERSION | 1338 | #ifndef DESKTOP_VERSION |
1339 | 1339 | ||
1340 | if (id == 0) | 1340 | if (id == 0) |
1341 | { | 1341 | { |
1342 | //the user disabled the extension. | 1342 | //the user disabled the extension. |
1343 | 1343 | ||
1344 | if (mMultipleViewsAtOnce) | 1344 | if (mMultipleViewsAtOnce) |
1345 | { // enable detailsview again | 1345 | { // enable detailsview again |
1346 | setDetailsVisible( true ); | 1346 | setDetailsVisible( true ); |
1347 | mActionDetails->setChecked( true ); | 1347 | mActionDetails->setChecked( true ); |
1348 | } | 1348 | } |
1349 | else | 1349 | else |
1350 | { //go back to the listview | 1350 | { //go back to the listview |
1351 | setDetailsVisible( false ); | 1351 | setDetailsVisible( false ); |
1352 | mActionDetails->setChecked( false ); | 1352 | mActionDetails->setChecked( false ); |
1353 | mActionDetails->setEnabled(true); | 1353 | mActionDetails->setEnabled(true); |
1354 | } | 1354 | } |
1355 | 1355 | ||
1356 | } | 1356 | } |
1357 | else | 1357 | else |
1358 | { | 1358 | { |
1359 | //the user enabled the extension. | 1359 | //the user enabled the extension. |
1360 | setDetailsVisible( false ); | 1360 | setDetailsVisible( false ); |
1361 | mActionDetails->setChecked( false ); | 1361 | mActionDetails->setChecked( false ); |
1362 | 1362 | ||
1363 | if (!mMultipleViewsAtOnce) | 1363 | if (!mMultipleViewsAtOnce) |
1364 | { | 1364 | { |
1365 | mActionDetails->setEnabled(false); | 1365 | mActionDetails->setEnabled(false); |
1366 | } | 1366 | } |
1367 | 1367 | ||
1368 | mExtensionManager->setSelectionChanged(); | 1368 | mExtensionManager->setSelectionChanged(); |
1369 | 1369 | ||
1370 | } | 1370 | } |
1371 | 1371 | ||
1372 | #endif// DESKTOP_VERSION | 1372 | #endif// DESKTOP_VERSION |
1373 | 1373 | ||
1374 | } | 1374 | } |
1375 | 1375 | ||
1376 | 1376 | ||
1377 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1377 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1378 | { | 1378 | { |
1379 | 1379 | ||
1380 | if ( list.count() != 0 ) { | 1380 | if ( list.count() != 0 ) { |
1381 | KABC::Addressee::List::ConstIterator it; | 1381 | KABC::Addressee::List::ConstIterator it; |
1382 | for ( it = list.begin(); it != list.end(); ++it ) | 1382 | for ( it = list.begin(); it != list.end(); ++it ) |
1383 | mAddressBook->insertAddressee( *it ); | 1383 | mAddressBook->insertAddressee( *it ); |
1384 | if ( list.count() > 1 ) | 1384 | if ( list.count() > 1 ) |
1385 | setModified(); | 1385 | setModified(); |
1386 | else | 1386 | else |
1387 | setModifiedWOrefresh(); | 1387 | setModifiedWOrefresh(); |
1388 | } | 1388 | } |
1389 | if ( list.count() == 0 ) | 1389 | if ( list.count() == 0 ) |
1390 | mViewManager->refreshView(); | 1390 | mViewManager->refreshView(); |
1391 | else | 1391 | else |
1392 | mViewManager->refreshView( list[ 0 ].uid() ); | 1392 | mViewManager->refreshView( list[ 0 ].uid() ); |
1393 | 1393 | ||
1394 | 1394 | ||
1395 | 1395 | ||
1396 | } | 1396 | } |
1397 | 1397 | ||
1398 | QString KABCore::getNameByPhone( const QString &phone ) | 1398 | QString KABCore::getNameByPhone( const QString &phone ) |
1399 | { | 1399 | { |
1400 | #ifndef KAB_EMBEDDED | 1400 | #ifndef KAB_EMBEDDED |
1401 | QRegExp r( "[/*/-/ ]" ); | 1401 | QRegExp r( "[/*/-/ ]" ); |
1402 | QString localPhone( phone ); | 1402 | QString localPhone( phone ); |
1403 | 1403 | ||
1404 | bool found = false; | 1404 | bool found = false; |
1405 | QString ownerName = ""; | 1405 | QString ownerName = ""; |
1406 | KABC::AddressBook::Iterator iter; | 1406 | KABC::AddressBook::Iterator iter; |
1407 | KABC::PhoneNumber::List::Iterator phoneIter; | 1407 | KABC::PhoneNumber::List::Iterator phoneIter; |
1408 | KABC::PhoneNumber::List phoneList; | 1408 | KABC::PhoneNumber::List phoneList; |
1409 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1409 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1410 | phoneList = (*iter).phoneNumbers(); | 1410 | phoneList = (*iter).phoneNumbers(); |
1411 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1411 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1412 | ++phoneIter) { | 1412 | ++phoneIter) { |
1413 | // Get rid of separator chars so just the numbers are compared. | 1413 | // Get rid of separator chars so just the numbers are compared. |
1414 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1414 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1415 | ownerName = (*iter).formattedName(); | 1415 | ownerName = (*iter).formattedName(); |
1416 | found = true; | 1416 | found = true; |
1417 | } | 1417 | } |
1418 | } | 1418 | } |
1419 | } | 1419 | } |
1420 | 1420 | ||
1421 | return ownerName; | 1421 | return ownerName; |
1422 | #else //KAB_EMBEDDED | 1422 | #else //KAB_EMBEDDED |
1423 | qDebug("KABCore::getNameByPhone finsih method"); | 1423 | qDebug("KABCore::getNameByPhone finsih method"); |
1424 | return ""; | 1424 | return ""; |
1425 | #endif //KAB_EMBEDDED | 1425 | #endif //KAB_EMBEDDED |
1426 | 1426 | ||
1427 | } | 1427 | } |
1428 | 1428 | ||
1429 | void KABCore::openConfigDialog() | 1429 | void KABCore::openConfigDialog() |
1430 | { | 1430 | { |
1431 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1431 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1432 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1432 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1433 | ConfigureDialog->addModule(kabcfg ); | 1433 | ConfigureDialog->addModule(kabcfg ); |
1434 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1434 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1435 | ConfigureDialog->addModule(kdelibcfg ); | 1435 | ConfigureDialog->addModule(kdelibcfg ); |
1436 | 1436 | ||
1437 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1437 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1438 | this, SLOT( configurationChanged() ) ); | 1438 | this, SLOT( configurationChanged() ) ); |
1439 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1439 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1440 | this, SLOT( configurationChanged() ) ); | 1440 | this, SLOT( configurationChanged() ) ); |
1441 | saveSettings(); | 1441 | saveSettings(); |
1442 | #ifndef DESKTOP_VERSION | 1442 | #ifndef DESKTOP_VERSION |
1443 | ConfigureDialog->showMaximized(); | 1443 | ConfigureDialog->showMaximized(); |
1444 | #endif | 1444 | #endif |
1445 | if ( ConfigureDialog->exec() ) | 1445 | if ( ConfigureDialog->exec() ) |
1446 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1446 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1447 | delete ConfigureDialog; | 1447 | delete ConfigureDialog; |
1448 | } | 1448 | } |
1449 | 1449 | ||
1450 | void KABCore::openLDAPDialog() | 1450 | void KABCore::openLDAPDialog() |
1451 | { | 1451 | { |
1452 | #ifndef KAB_EMBEDDED | 1452 | #ifndef KAB_EMBEDDED |
1453 | if ( !mLdapSearchDialog ) { | 1453 | if ( !mLdapSearchDialog ) { |
1454 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1454 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1455 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1455 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1456 | SLOT( refreshView() ) ); | 1456 | SLOT( refreshView() ) ); |
1457 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1457 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1458 | SLOT( setModified() ) ); | 1458 | SLOT( setModified() ) ); |
1459 | } else | 1459 | } else |
1460 | mLdapSearchDialog->restoreSettings(); | 1460 | mLdapSearchDialog->restoreSettings(); |
1461 | 1461 | ||
1462 | if ( mLdapSearchDialog->isOK() ) | 1462 | if ( mLdapSearchDialog->isOK() ) |
1463 | mLdapSearchDialog->exec(); | 1463 | mLdapSearchDialog->exec(); |
1464 | #else //KAB_EMBEDDED | 1464 | #else //KAB_EMBEDDED |
1465 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1465 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1466 | #endif //KAB_EMBEDDED | 1466 | #endif //KAB_EMBEDDED |
1467 | } | 1467 | } |
1468 | 1468 | ||
1469 | void KABCore::print() | 1469 | void KABCore::print() |
1470 | { | 1470 | { |
1471 | #ifndef KAB_EMBEDDED | 1471 | #ifndef KAB_EMBEDDED |
1472 | KPrinter printer; | 1472 | KPrinter printer; |
1473 | if ( !printer.setup( this ) ) | 1473 | if ( !printer.setup( this ) ) |
1474 | return; | 1474 | return; |
1475 | 1475 | ||
1476 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1476 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1477 | mViewManager->selectedUids(), this ); | 1477 | mViewManager->selectedUids(), this ); |
1478 | 1478 | ||
1479 | wizard.exec(); | 1479 | wizard.exec(); |
1480 | #else //KAB_EMBEDDED | 1480 | #else //KAB_EMBEDDED |
1481 | qDebug("KABCore::print() finsih method"); | 1481 | qDebug("KABCore::print() finsih method"); |
1482 | #endif //KAB_EMBEDDED | 1482 | #endif //KAB_EMBEDDED |
1483 | 1483 | ||
1484 | } | 1484 | } |
1485 | 1485 | ||
1486 | 1486 | ||
1487 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1487 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1488 | { | 1488 | { |
1489 | if ( mGUIClient ) | 1489 | if ( mGUIClient ) |
1490 | mGUIClient->insertChildClient( client ); | 1490 | mGUIClient->insertChildClient( client ); |
1491 | else | 1491 | else |
1492 | KMessageBox::error( this, "no KXMLGUICLient"); | 1492 | KMessageBox::error( this, "no KXMLGUICLient"); |
1493 | } | 1493 | } |
1494 | 1494 | ||
1495 | 1495 | ||
1496 | void KABCore::configurationChanged() | 1496 | void KABCore::configurationChanged() |
1497 | { | 1497 | { |
1498 | mExtensionManager->reconfigure(); | 1498 | mExtensionManager->reconfigure(); |
1499 | } | 1499 | } |
1500 | 1500 | ||
1501 | void KABCore::addressBookChanged() | 1501 | void KABCore::addressBookChanged() |
1502 | { | 1502 | { |
1503 | /*US | 1503 | /*US |
1504 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1504 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1505 | while ( it.current() ) { | 1505 | while ( it.current() ) { |
1506 | if ( it.current()->dirty() ) { | 1506 | if ( it.current()->dirty() ) { |
1507 | QString text = i18n( "Data has been changed externally. Unsaved " | 1507 | QString text = i18n( "Data has been changed externally. Unsaved " |
1508 | "changes will be lost." ); | 1508 | "changes will be lost." ); |
1509 | KMessageBox::information( this, text ); | 1509 | KMessageBox::information( this, text ); |
1510 | } | 1510 | } |
1511 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1511 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1512 | ++it; | 1512 | ++it; |
1513 | } | 1513 | } |
1514 | */ | 1514 | */ |
1515 | if (mEditorDialog) | 1515 | if (mEditorDialog) |
1516 | { | 1516 | { |
1517 | if (mEditorDialog->dirty()) | 1517 | if (mEditorDialog->dirty()) |
1518 | { | 1518 | { |
1519 | QString text = i18n( "Data has been changed externally. Unsaved " | 1519 | QString text = i18n( "Data has been changed externally. Unsaved " |
1520 | "changes will be lost." ); | 1520 | "changes will be lost." ); |
1521 | KMessageBox::information( this, text ); | 1521 | KMessageBox::information( this, text ); |
1522 | } | 1522 | } |
1523 | QString currentuid = mEditorDialog->addressee().uid(); | 1523 | QString currentuid = mEditorDialog->addressee().uid(); |
1524 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1524 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1525 | } | 1525 | } |
1526 | mViewManager->refreshView(); | 1526 | mViewManager->refreshView(); |
1527 | // mDetails->refreshView(); | 1527 | // mDetails->refreshView(); |
1528 | 1528 | ||
1529 | 1529 | ||
1530 | } | 1530 | } |
1531 | 1531 | ||
1532 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1532 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1533 | const char *name ) | 1533 | const char *name ) |
1534 | { | 1534 | { |
1535 | 1535 | ||
1536 | if ( mEditorDialog == 0 ) { | 1536 | if ( mEditorDialog == 0 ) { |
1537 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1537 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1538 | name ? name : "editorDialog" ); | 1538 | name ? name : "editorDialog" ); |
1539 | 1539 | ||
1540 | 1540 | ||
1541 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1541 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1542 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1542 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1543 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1543 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1544 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1544 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1545 | } | 1545 | } |
1546 | 1546 | ||
1547 | return mEditorDialog; | 1547 | return mEditorDialog; |
1548 | } | 1548 | } |
1549 | 1549 | ||
1550 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1550 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1551 | { | 1551 | { |
1552 | //mEditorDict.remove( uid ); | 1552 | //mEditorDict.remove( uid ); |
1553 | } | 1553 | } |
1554 | 1554 | ||
1555 | void KABCore::initGUI() | 1555 | void KABCore::initGUI() |
1556 | { | 1556 | { |
1557 | #ifndef KAB_EMBEDDED | 1557 | #ifndef KAB_EMBEDDED |
1558 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1558 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1559 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1559 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1560 | 1560 | ||
1561 | mExtensionBarSplitter = new QSplitter( this ); | 1561 | mExtensionBarSplitter = new QSplitter( this ); |
1562 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1562 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1563 | 1563 | ||
1564 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1564 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1565 | 1565 | ||
1566 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1566 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1567 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1567 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1568 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1568 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1569 | SLOT( incrementalSearch( const QString& ) ) ); | 1569 | SLOT( incrementalSearch( const QString& ) ) ); |
1570 | 1570 | ||
1571 | mViewManager = new ViewManager( this, viewSpace ); | 1571 | mViewManager = new ViewManager( this, viewSpace ); |
1572 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1572 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1573 | 1573 | ||
1574 | mDetails = new ViewContainer( mDetailsSplitter ); | 1574 | mDetails = new ViewContainer( mDetailsSplitter ); |
1575 | 1575 | ||
1576 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1576 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1577 | 1577 | ||
1578 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1578 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1579 | 1579 | ||
1580 | topLayout->addWidget( mExtensionBarSplitter ); | 1580 | topLayout->addWidget( mExtensionBarSplitter ); |
1581 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1581 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1582 | topLayout->addWidget( mJumpButtonBar ); | 1582 | topLayout->addWidget( mJumpButtonBar ); |
1583 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1583 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1584 | 1584 | ||
1585 | mXXPortManager = new XXPortManager( this, this ); | 1585 | mXXPortManager = new XXPortManager( this, this ); |
1586 | 1586 | ||
1587 | #else //KAB_EMBEDDED | 1587 | #else //KAB_EMBEDDED |
1588 | //US initialize viewMenu before settingup viewmanager. | 1588 | //US initialize viewMenu before settingup viewmanager. |
1589 | // Viewmanager needs this menu to plugin submenues. | 1589 | // Viewmanager needs this menu to plugin submenues. |
1590 | viewMenu = new QPopupMenu( this ); | 1590 | viewMenu = new QPopupMenu( this ); |
1591 | settingsMenu = new QPopupMenu( this ); | 1591 | settingsMenu = new QPopupMenu( this ); |
1592 | //filterMenu = new QPopupMenu( this ); | 1592 | //filterMenu = new QPopupMenu( this ); |
1593 | ImportMenu = new QPopupMenu( this ); | 1593 | ImportMenu = new QPopupMenu( this ); |
1594 | ExportMenu = new QPopupMenu( this ); | 1594 | ExportMenu = new QPopupMenu( this ); |
1595 | syncMenu = new QPopupMenu( this ); | 1595 | syncMenu = new QPopupMenu( this ); |
1596 | changeMenu= new QPopupMenu( this ); | 1596 | changeMenu= new QPopupMenu( this ); |
1597 | 1597 | ||
1598 | //US since we have no splitter for the embedded system, setup | 1598 | //US since we have no splitter for the embedded system, setup |
1599 | // a layout with two frames. One left and one right. | 1599 | // a layout with two frames. One left and one right. |
1600 | 1600 | ||
1601 | QBoxLayout *topLayout; | 1601 | QBoxLayout *topLayout; |
1602 | 1602 | ||
1603 | // = new QHBoxLayout( this ); | 1603 | // = new QHBoxLayout( this ); |
1604 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1604 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1605 | 1605 | ||
1606 | // QWidget *mainBox = new QWidget( this ); | 1606 | // QWidget *mainBox = new QWidget( this ); |
1607 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1607 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1608 | 1608 | ||
1609 | #ifdef DESKTOP_VERSION | 1609 | #ifdef DESKTOP_VERSION |
1610 | topLayout = new QHBoxLayout( this ); | 1610 | topLayout = new QHBoxLayout( this ); |
1611 | 1611 | ||
1612 | 1612 | ||
1613 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1613 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1614 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1614 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1615 | 1615 | ||
1616 | topLayout->addWidget(mMiniSplitter ); | 1616 | topLayout->addWidget(mMiniSplitter ); |
1617 | 1617 | ||
1618 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1618 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1619 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1619 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1620 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1620 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1621 | mDetails = new ViewContainer( mMiniSplitter ); | 1621 | mDetails = new ViewContainer( mMiniSplitter ); |
1622 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1622 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1623 | #else | 1623 | #else |
1624 | if ( QApplication::desktop()->width() > 480 ) { | 1624 | if ( QApplication::desktop()->width() > 480 ) { |
1625 | topLayout = new QHBoxLayout( this ); | 1625 | topLayout = new QHBoxLayout( this ); |
1626 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1626 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1627 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1627 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1628 | } else { | 1628 | } else { |
1629 | 1629 | ||
1630 | topLayout = new QHBoxLayout( this ); | 1630 | topLayout = new QHBoxLayout( this ); |
1631 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1631 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1632 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1632 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1633 | } | 1633 | } |
1634 | 1634 | ||
1635 | topLayout->addWidget(mMiniSplitter ); | 1635 | topLayout->addWidget(mMiniSplitter ); |
1636 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1636 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1637 | mDetails = new ViewContainer( mMiniSplitter ); | 1637 | mDetails = new ViewContainer( mMiniSplitter ); |
1638 | 1638 | ||
1639 | 1639 | ||
1640 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1640 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1641 | #endif | 1641 | #endif |
1642 | //eh->hide(); | 1642 | //eh->hide(); |
1643 | // topLayout->addWidget(mExtensionManager ); | 1643 | // topLayout->addWidget(mExtensionManager ); |
1644 | 1644 | ||
1645 | 1645 | ||
1646 | /*US | 1646 | /*US |
1647 | #ifndef KAB_NOSPLITTER | 1647 | #ifndef KAB_NOSPLITTER |
1648 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1648 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1649 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1649 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1650 | topLayout->setSpacing( 10 ); | 1650 | topLayout->setSpacing( 10 ); |
1651 | 1651 | ||
1652 | mDetailsSplitter = new QSplitter( this ); | 1652 | mDetailsSplitter = new QSplitter( this ); |
1653 | 1653 | ||
1654 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1654 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1655 | 1655 | ||
1656 | mViewManager = new ViewManager( this, viewSpace ); | 1656 | mViewManager = new ViewManager( this, viewSpace ); |
1657 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1657 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1658 | 1658 | ||
1659 | mDetails = new ViewContainer( mDetailsSplitter ); | 1659 | mDetails = new ViewContainer( mDetailsSplitter ); |
1660 | 1660 | ||
1661 | topLayout->addWidget( mDetailsSplitter ); | 1661 | topLayout->addWidget( mDetailsSplitter ); |
1662 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1662 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1663 | #else //KAB_NOSPLITTER | 1663 | #else //KAB_NOSPLITTER |
1664 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1664 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1665 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1665 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1666 | topLayout->setSpacing( 10 ); | 1666 | topLayout->setSpacing( 10 ); |
1667 | 1667 | ||
1668 | // mDetailsSplitter = new QSplitter( this ); | 1668 | // mDetailsSplitter = new QSplitter( this ); |
1669 | 1669 | ||
1670 | QVBox *viewSpace = new QVBox( this ); | 1670 | QVBox *viewSpace = new QVBox( this ); |
1671 | 1671 | ||
1672 | mViewManager = new ViewManager( this, viewSpace ); | 1672 | mViewManager = new ViewManager( this, viewSpace ); |
1673 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1673 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1674 | 1674 | ||
1675 | mDetails = new ViewContainer( this ); | 1675 | mDetails = new ViewContainer( this ); |
1676 | 1676 | ||
1677 | topLayout->addWidget( viewSpace ); | 1677 | topLayout->addWidget( viewSpace ); |
1678 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1678 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1679 | topLayout->addWidget( mDetails ); | 1679 | topLayout->addWidget( mDetails ); |
1680 | #endif //KAB_NOSPLITTER | 1680 | #endif //KAB_NOSPLITTER |
1681 | */ | 1681 | */ |
1682 | 1682 | ||
1683 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1683 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1684 | syncManager->setBlockSave(false); | 1684 | syncManager->setBlockSave(false); |
1685 | 1685 | ||
1686 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1686 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1687 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1687 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1688 | syncManager->setDefaultFileName( sentSyncFile()); | 1688 | syncManager->setDefaultFileName( sentSyncFile()); |
1689 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1689 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1690 | 1690 | ||
1691 | #endif //KAB_EMBEDDED | 1691 | #endif //KAB_EMBEDDED |
1692 | initActions(); | 1692 | initActions(); |
1693 | 1693 | ||
1694 | #ifdef KAB_EMBEDDED | 1694 | #ifdef KAB_EMBEDDED |
1695 | addActionsManually(); | 1695 | addActionsManually(); |
1696 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1696 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1697 | mXXPortManager = new XXPortManager( this, this ); | 1697 | mXXPortManager = new XXPortManager( this, this ); |
1698 | 1698 | ||
1699 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1699 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1700 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1700 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1701 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1701 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1702 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1702 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1703 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1703 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1704 | // mIncSearchWidget->hide(); | 1704 | // mIncSearchWidget->hide(); |
1705 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1705 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1706 | SLOT( incrementalSearch( const QString& ) ) ); | 1706 | SLOT( incrementalSearch( const QString& ) ) ); |
1707 | 1707 | ||
1708 | 1708 | ||
1709 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1709 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1710 | 1710 | ||
1711 | topLayout->addWidget( mJumpButtonBar ); | 1711 | topLayout->addWidget( mJumpButtonBar ); |
1712 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1712 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1713 | 1713 | ||
1714 | // mMainWindow->getIconToolBar()->raise(); | 1714 | // mMainWindow->getIconToolBar()->raise(); |
1715 | 1715 | ||
1716 | #endif //KAB_EMBEDDED | 1716 | #endif //KAB_EMBEDDED |
1717 | 1717 | ||
1718 | } | 1718 | } |
1719 | void KABCore::initActions() | 1719 | void KABCore::initActions() |
1720 | { | 1720 | { |
1721 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1721 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1722 | 1722 | ||
1723 | #ifndef KAB_EMBEDDED | 1723 | #ifndef KAB_EMBEDDED |
1724 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1724 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1725 | SLOT( clipboardDataChanged() ) ); | 1725 | SLOT( clipboardDataChanged() ) ); |
1726 | #endif //KAB_EMBEDDED | 1726 | #endif //KAB_EMBEDDED |
1727 | 1727 | ||
1728 | // file menu | 1728 | // file menu |
1729 | if ( mIsPart ) { | 1729 | if ( mIsPart ) { |
1730 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1730 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1731 | SLOT( sendMail() ), actionCollection(), | 1731 | SLOT( sendMail() ), actionCollection(), |
1732 | "kaddressbook_mail" ); | 1732 | "kaddressbook_mail" ); |
1733 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1733 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1734 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1734 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1735 | 1735 | ||
1736 | } else { | 1736 | } else { |
1737 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1737 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1738 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1738 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1739 | } | 1739 | } |
1740 | 1740 | ||
1741 | 1741 | ||
1742 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1742 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1743 | SLOT( save() ), actionCollection(), "file_sync" ); | 1743 | SLOT( save() ), actionCollection(), "file_sync" ); |
1744 | 1744 | ||
1745 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1745 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1746 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1746 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1747 | 1747 | ||
1748 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1748 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1749 | this, SLOT( mailVCard() ), | 1749 | this, SLOT( mailVCard() ), |
1750 | actionCollection(), "file_mail_vcard"); | 1750 | actionCollection(), "file_mail_vcard"); |
1751 | 1751 | ||
1752 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, | 1752 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, |
1753 | SLOT( export2phone() ), actionCollection(), | 1753 | SLOT( export2phone() ), actionCollection(), |
1754 | "kaddressbook_ex2phone" ); | 1754 | "kaddressbook_ex2phone" ); |
1755 | 1755 | ||
1756 | mActionBeamVCard = 0; | 1756 | mActionBeamVCard = 0; |
1757 | mActionBeam = 0; | 1757 | mActionBeam = 0; |
1758 | 1758 | ||
1759 | #ifndef DESKTOP_VERSION | 1759 | #ifndef DESKTOP_VERSION |
1760 | if ( Ir::supported() ) { | 1760 | if ( Ir::supported() ) { |
1761 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1761 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1762 | SLOT( beamVCard() ), actionCollection(), | 1762 | SLOT( beamVCard() ), actionCollection(), |
1763 | "kaddressbook_beam_vcard" ); | 1763 | "kaddressbook_beam_vcard" ); |
1764 | 1764 | ||
1765 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1765 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1766 | SLOT( beamMySelf() ), actionCollection(), | 1766 | SLOT( beamMySelf() ), actionCollection(), |
1767 | "kaddressbook_beam_myself" ); | 1767 | "kaddressbook_beam_myself" ); |
1768 | } | 1768 | } |
1769 | #endif | 1769 | #endif |
1770 | 1770 | ||
1771 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1771 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1772 | this, SLOT( editContact2() ), | 1772 | this, SLOT( editContact2() ), |
1773 | actionCollection(), "file_properties" ); | 1773 | actionCollection(), "file_properties" ); |
1774 | 1774 | ||
1775 | #ifdef KAB_EMBEDDED | 1775 | #ifdef KAB_EMBEDDED |
1776 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1776 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1777 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1777 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1778 | mMainWindow, SLOT( exit() ), | 1778 | mMainWindow, SLOT( exit() ), |
1779 | actionCollection(), "quit" ); | 1779 | actionCollection(), "quit" ); |
1780 | #endif //KAB_EMBEDDED | 1780 | #endif //KAB_EMBEDDED |
1781 | 1781 | ||
1782 | // edit menu | 1782 | // edit menu |
1783 | if ( mIsPart ) { | 1783 | if ( mIsPart ) { |
1784 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1784 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1785 | SLOT( copyContacts() ), actionCollection(), | 1785 | SLOT( copyContacts() ), actionCollection(), |
1786 | "kaddressbook_copy" ); | 1786 | "kaddressbook_copy" ); |
1787 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1787 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1788 | SLOT( cutContacts() ), actionCollection(), | 1788 | SLOT( cutContacts() ), actionCollection(), |
1789 | "kaddressbook_cut" ); | 1789 | "kaddressbook_cut" ); |
1790 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1790 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1791 | SLOT( pasteContacts() ), actionCollection(), | 1791 | SLOT( pasteContacts() ), actionCollection(), |
1792 | "kaddressbook_paste" ); | 1792 | "kaddressbook_paste" ); |
1793 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1793 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1794 | SLOT( selectAllContacts() ), actionCollection(), | 1794 | SLOT( selectAllContacts() ), actionCollection(), |
1795 | "kaddressbook_select_all" ); | 1795 | "kaddressbook_select_all" ); |
1796 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1796 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1797 | SLOT( undo() ), actionCollection(), | 1797 | SLOT( undo() ), actionCollection(), |
1798 | "kaddressbook_undo" ); | 1798 | "kaddressbook_undo" ); |
1799 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1799 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1800 | this, SLOT( redo() ), actionCollection(), | 1800 | this, SLOT( redo() ), actionCollection(), |
1801 | "kaddressbook_redo" ); | 1801 | "kaddressbook_redo" ); |
1802 | } else { | 1802 | } else { |
1803 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1803 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1804 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1804 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1805 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1805 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1806 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1806 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1807 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1807 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1808 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1808 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1809 | } | 1809 | } |
1810 | 1810 | ||
1811 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1811 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1812 | Key_Delete, this, SLOT( deleteContacts() ), | 1812 | Key_Delete, this, SLOT( deleteContacts() ), |
1813 | actionCollection(), "edit_delete" ); | 1813 | actionCollection(), "edit_delete" ); |
1814 | 1814 | ||
1815 | mActionUndo->setEnabled( false ); | 1815 | mActionUndo->setEnabled( false ); |
1816 | mActionRedo->setEnabled( false ); | 1816 | mActionRedo->setEnabled( false ); |
1817 | 1817 | ||
1818 | // settings menu | 1818 | // settings menu |
1819 | #ifdef KAB_EMBEDDED | 1819 | #ifdef KAB_EMBEDDED |
1820 | //US special menuentry to configure the addressbook resources. On KDE | 1820 | //US special menuentry to configure the addressbook resources. On KDE |
1821 | // you do that through the control center !!! | 1821 | // you do that through the control center !!! |
1822 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1822 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1823 | SLOT( configureResources() ), actionCollection(), | 1823 | SLOT( configureResources() ), actionCollection(), |
1824 | "kaddressbook_configure_resources" ); | 1824 | "kaddressbook_configure_resources" ); |
1825 | #endif //KAB_EMBEDDED | 1825 | #endif //KAB_EMBEDDED |
1826 | 1826 | ||
1827 | if ( mIsPart ) { | 1827 | if ( mIsPart ) { |
1828 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1828 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1829 | SLOT( openConfigDialog() ), actionCollection(), | 1829 | SLOT( openConfigDialog() ), actionCollection(), |
1830 | "kaddressbook_configure" ); | 1830 | "kaddressbook_configure" ); |
1831 | 1831 | ||
1832 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1832 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1833 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1833 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1834 | "kaddressbook_configure_shortcuts" ); | 1834 | "kaddressbook_configure_shortcuts" ); |
1835 | #ifdef KAB_EMBEDDED | 1835 | #ifdef KAB_EMBEDDED |
1836 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1836 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1837 | mActionConfigureToolbars->setEnabled( false ); | 1837 | mActionConfigureToolbars->setEnabled( false ); |
1838 | #endif //KAB_EMBEDDED | 1838 | #endif //KAB_EMBEDDED |
1839 | 1839 | ||
1840 | } else { | 1840 | } else { |
1841 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1841 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1842 | 1842 | ||
1843 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1843 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1844 | } | 1844 | } |
1845 | 1845 | ||
1846 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1846 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1847 | actionCollection(), "options_show_jump_bar" ); | 1847 | actionCollection(), "options_show_jump_bar" ); |
1848 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1848 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1849 | 1849 | ||
1850 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1850 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1851 | actionCollection(), "options_show_details" ); | 1851 | actionCollection(), "options_show_details" ); |
1852 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1852 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1853 | 1853 | ||
1854 | // misc | 1854 | // misc |
1855 | // only enable LDAP lookup if we can handle the protocol | 1855 | // only enable LDAP lookup if we can handle the protocol |
1856 | #ifndef KAB_EMBEDDED | 1856 | #ifndef KAB_EMBEDDED |
1857 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1857 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1858 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1858 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1859 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1859 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1860 | "ldap_lookup" ); | 1860 | "ldap_lookup" ); |
1861 | } | 1861 | } |
1862 | #else //KAB_EMBEDDED | 1862 | #else //KAB_EMBEDDED |
1863 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1863 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1864 | #endif //KAB_EMBEDDED | 1864 | #endif //KAB_EMBEDDED |
1865 | 1865 | ||
1866 | 1866 | ||
1867 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1867 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1868 | SLOT( setWhoAmI() ), actionCollection(), | 1868 | SLOT( setWhoAmI() ), actionCollection(), |
1869 | "set_personal" ); | 1869 | "set_personal" ); |
1870 | 1870 | ||
1871 | 1871 | ||
1872 | 1872 | ||
1873 | 1873 | ||
1874 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1874 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1875 | SLOT( setCategories() ), actionCollection(), | 1875 | SLOT( setCategories() ), actionCollection(), |
1876 | "edit_set_categories" ); | 1876 | "edit_set_categories" ); |
1877 | 1877 | ||
1878 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1878 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1879 | SLOT( removeVoice() ), actionCollection(), | 1879 | SLOT( removeVoice() ), actionCollection(), |
1880 | "remove_voice" ); | 1880 | "remove_voice" ); |
1881 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1881 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1882 | SLOT( importFromOL() ), actionCollection(), | 1882 | SLOT( importFromOL() ), actionCollection(), |
1883 | "import_OL" ); | 1883 | "import_OL" ); |
1884 | #ifdef KAB_EMBEDDED | 1884 | #ifdef KAB_EMBEDDED |
1885 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1885 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1886 | this, SLOT( showLicence() ), actionCollection(), | 1886 | this, SLOT( showLicence() ), actionCollection(), |
1887 | "licence_about_data" ); | 1887 | "licence_about_data" ); |
1888 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1888 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1889 | this, SLOT( faq() ), actionCollection(), | 1889 | this, SLOT( faq() ), actionCollection(), |
1890 | "faq_about_data" ); | 1890 | "faq_about_data" ); |
1891 | 1891 | ||
1892 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1892 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1893 | this, SLOT( createAboutData() ), actionCollection(), | 1893 | this, SLOT( createAboutData() ), actionCollection(), |
1894 | "kaddressbook_about_data" ); | 1894 | "kaddressbook_about_data" ); |
1895 | #endif //KAB_EMBEDDED | 1895 | #endif //KAB_EMBEDDED |
1896 | 1896 | ||
1897 | clipboardDataChanged(); | 1897 | clipboardDataChanged(); |
1898 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1898 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1899 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1899 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1900 | } | 1900 | } |
1901 | 1901 | ||
1902 | //US we need this function, to plug all actions into the correct menues. | 1902 | //US we need this function, to plug all actions into the correct menues. |
1903 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1903 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1904 | void KABCore::addActionsManually() | 1904 | void KABCore::addActionsManually() |
1905 | { | 1905 | { |
1906 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1906 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1907 | 1907 | ||
1908 | #ifdef KAB_EMBEDDED | 1908 | #ifdef KAB_EMBEDDED |
1909 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1909 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1910 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1910 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1911 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1911 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1912 | 1912 | ||
1913 | KToolBar* tb = mMainWindow->toolBar(); | 1913 | KToolBar* tb = mMainWindow->toolBar(); |
1914 | 1914 | ||
1915 | #ifdef DESKTOP_VERSION | 1915 | #ifdef DESKTOP_VERSION |
1916 | QMenuBar* mb = mMainWindow->menuBar(); | 1916 | QMenuBar* mb = mMainWindow->menuBar(); |
1917 | 1917 | ||
1918 | //US setup menubar. | 1918 | //US setup menubar. |
1919 | //Disable the following block if you do not want to have a menubar. | 1919 | //Disable the following block if you do not want to have a menubar. |
1920 | mb->insertItem( "&File", fileMenu ); | 1920 | mb->insertItem( "&File", fileMenu ); |
1921 | mb->insertItem( "&Edit", editMenu ); | 1921 | mb->insertItem( "&Edit", editMenu ); |
1922 | mb->insertItem( "&View", viewMenu ); | 1922 | mb->insertItem( "&View", viewMenu ); |
1923 | mb->insertItem( "&Settings", settingsMenu ); | 1923 | mb->insertItem( "&Settings", settingsMenu ); |
1924 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1924 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1925 | mb->insertItem( "&Change selected", changeMenu ); | 1925 | mb->insertItem( "&Change selected", changeMenu ); |
1926 | mb->insertItem( "&Help", helpMenu ); | 1926 | mb->insertItem( "&Help", helpMenu ); |
1927 | mIncSearchWidget = new IncSearchWidget( tb ); | 1927 | mIncSearchWidget = new IncSearchWidget( tb ); |
1928 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1928 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1929 | 1929 | ||
1930 | #else | 1930 | #else |
1931 | //US setup toolbar | 1931 | //US setup toolbar |
1932 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1932 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1933 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1933 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1934 | menuBarTB->insertItem( "ME", popupBarTB); | 1934 | menuBarTB->insertItem( "ME", popupBarTB); |
1935 | tb->insertWidget(-1, 0, menuBarTB); | 1935 | tb->insertWidget(-1, 0, menuBarTB); |
1936 | mIncSearchWidget = new IncSearchWidget( tb ); | 1936 | mIncSearchWidget = new IncSearchWidget( tb ); |
1937 | 1937 | ||
1938 | tb->enableMoving(false); | 1938 | tb->enableMoving(false); |
1939 | popupBarTB->insertItem( "&File", fileMenu ); | 1939 | popupBarTB->insertItem( "&File", fileMenu ); |
1940 | popupBarTB->insertItem( "&Edit", editMenu ); | 1940 | popupBarTB->insertItem( "&Edit", editMenu ); |
1941 | popupBarTB->insertItem( "&View", viewMenu ); | 1941 | popupBarTB->insertItem( "&View", viewMenu ); |
1942 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1942 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1943 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1943 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1944 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1944 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1945 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1945 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1946 | popupBarTB->insertItem( "&Help", helpMenu ); | 1946 | popupBarTB->insertItem( "&Help", helpMenu ); |
1947 | if (QApplication::desktop()->width() > 320 ) { | 1947 | if (QApplication::desktop()->width() > 320 ) { |
1948 | // mViewManager->getFilterAction()->plug ( tb); | 1948 | // mViewManager->getFilterAction()->plug ( tb); |
1949 | } | 1949 | } |
1950 | #endif | 1950 | #endif |
1951 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1951 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1952 | 1952 | ||
1953 | 1953 | ||
1954 | 1954 | ||
1955 | //US Now connect the actions with the menue entries. | 1955 | //US Now connect the actions with the menue entries. |
1956 | mActionPrint->plug( fileMenu ); | 1956 | mActionPrint->plug( fileMenu ); |
1957 | mActionMail->plug( fileMenu ); | 1957 | mActionMail->plug( fileMenu ); |
1958 | fileMenu->insertSeparator(); | 1958 | fileMenu->insertSeparator(); |
1959 | 1959 | ||
1960 | mActionNewContact->plug( fileMenu ); | 1960 | mActionNewContact->plug( fileMenu ); |
1961 | mActionNewContact->plug( tb ); | 1961 | mActionNewContact->plug( tb ); |
1962 | 1962 | ||
1963 | mActionEditAddressee->plug( fileMenu ); | 1963 | mActionEditAddressee->plug( fileMenu ); |
1964 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1964 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1965 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1965 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1966 | mActionEditAddressee->plug( tb ); | 1966 | mActionEditAddressee->plug( tb ); |
1967 | 1967 | ||
1968 | fileMenu->insertSeparator(); | 1968 | fileMenu->insertSeparator(); |
1969 | mActionSave->plug( fileMenu ); | 1969 | mActionSave->plug( fileMenu ); |
1970 | fileMenu->insertItem( "&Import", ImportMenu ); | 1970 | fileMenu->insertItem( "&Import", ImportMenu ); |
1971 | fileMenu->insertItem( "&Export", ExportMenu ); | 1971 | fileMenu->insertItem( "&Export", ExportMenu ); |
1972 | fileMenu->insertSeparator(); | 1972 | fileMenu->insertSeparator(); |
1973 | mActionMailVCard->plug( fileMenu ); | 1973 | mActionMailVCard->plug( fileMenu ); |
1974 | #ifndef DESKTOP_VERSION | 1974 | #ifndef DESKTOP_VERSION |
1975 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1975 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1976 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1976 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1977 | #endif | 1977 | #endif |
1978 | fileMenu->insertSeparator(); | 1978 | fileMenu->insertSeparator(); |
1979 | mActionQuit->plug( fileMenu ); | 1979 | mActionQuit->plug( fileMenu ); |
1980 | #ifdef _WIN32_ | 1980 | #ifdef _WIN32_ |
1981 | mActionImportOL->plug( ImportMenu ); | 1981 | mActionImportOL->plug( ImportMenu ); |
1982 | #endif | 1982 | #endif |
1983 | // edit menu | 1983 | // edit menu |
1984 | mActionUndo->plug( editMenu ); | 1984 | mActionUndo->plug( editMenu ); |
1985 | mActionRedo->plug( editMenu ); | 1985 | mActionRedo->plug( editMenu ); |
1986 | editMenu->insertSeparator(); | 1986 | editMenu->insertSeparator(); |
1987 | mActionCut->plug( editMenu ); | 1987 | mActionCut->plug( editMenu ); |
1988 | mActionCopy->plug( editMenu ); | 1988 | mActionCopy->plug( editMenu ); |
1989 | mActionPaste->plug( editMenu ); | 1989 | mActionPaste->plug( editMenu ); |
1990 | mActionDelete->plug( editMenu ); | 1990 | mActionDelete->plug( editMenu ); |
1991 | editMenu->insertSeparator(); | 1991 | editMenu->insertSeparator(); |
1992 | mActionSelectAll->plug( editMenu ); | 1992 | mActionSelectAll->plug( editMenu ); |
1993 | 1993 | ||
1994 | mActionRemoveVoice->plug( changeMenu ); | 1994 | mActionRemoveVoice->plug( changeMenu ); |
1995 | // settings menu | 1995 | // settings menu |
1996 | //US special menuentry to configure the addressbook resources. On KDE | 1996 | //US special menuentry to configure the addressbook resources. On KDE |
1997 | // you do that through the control center !!! | 1997 | // you do that through the control center !!! |
1998 | mActionConfigResources->plug( settingsMenu ); | 1998 | mActionConfigResources->plug( settingsMenu ); |
1999 | settingsMenu->insertSeparator(); | 1999 | settingsMenu->insertSeparator(); |
2000 | 2000 | ||
2001 | mActionConfigKAddressbook->plug( settingsMenu ); | 2001 | mActionConfigKAddressbook->plug( settingsMenu ); |
2002 | 2002 | ||
2003 | if ( mIsPart ) { | 2003 | if ( mIsPart ) { |
2004 | mActionConfigShortcuts->plug( settingsMenu ); | 2004 | mActionConfigShortcuts->plug( settingsMenu ); |
2005 | mActionConfigureToolbars->plug( settingsMenu ); | 2005 | mActionConfigureToolbars->plug( settingsMenu ); |
2006 | 2006 | ||
2007 | } else { | 2007 | } else { |
2008 | mActionKeyBindings->plug( settingsMenu ); | 2008 | mActionKeyBindings->plug( settingsMenu ); |
2009 | } | 2009 | } |
2010 | 2010 | ||
2011 | settingsMenu->insertSeparator(); | 2011 | settingsMenu->insertSeparator(); |
2012 | 2012 | ||
2013 | mActionJumpBar->plug( settingsMenu ); | 2013 | mActionJumpBar->plug( settingsMenu ); |
2014 | mActionDetails->plug( settingsMenu ); | 2014 | mActionDetails->plug( settingsMenu ); |
2015 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2015 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2016 | mActionDetails->plug( tb ); | 2016 | mActionDetails->plug( tb ); |
2017 | settingsMenu->insertSeparator(); | 2017 | settingsMenu->insertSeparator(); |
2018 | 2018 | ||
2019 | mActionWhoAmI->plug( settingsMenu ); | 2019 | mActionWhoAmI->plug( settingsMenu ); |
2020 | mActionCategories->plug( settingsMenu ); | 2020 | mActionCategories->plug( settingsMenu ); |
2021 | 2021 | ||
2022 | mActionLicence->plug( helpMenu ); | 2022 | mActionLicence->plug( helpMenu ); |
2023 | mActionFaq->plug( helpMenu ); | 2023 | mActionFaq->plug( helpMenu ); |
2024 | mActionAboutKAddressbook->plug( helpMenu ); | 2024 | mActionAboutKAddressbook->plug( helpMenu ); |
2025 | 2025 | ||
2026 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2026 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2027 | 2027 | ||
2028 | mActionSave->plug( tb ); | 2028 | mActionSave->plug( tb ); |
2029 | mViewManager->getFilterAction()->plug ( tb); | 2029 | mViewManager->getFilterAction()->plug ( tb); |
2030 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 2030 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
2031 | mActionUndo->plug( tb ); | 2031 | mActionUndo->plug( tb ); |
2032 | mActionDelete->plug( tb ); | 2032 | mActionDelete->plug( tb ); |
2033 | mActionRedo->plug( tb ); | 2033 | mActionRedo->plug( tb ); |
2034 | } | 2034 | } |
2035 | } | 2035 | } |
2036 | //mActionQuit->plug ( tb ); | 2036 | //mActionQuit->plug ( tb ); |
2037 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2037 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2038 | 2038 | ||
2039 | //US link the searchwidget first to this. | 2039 | //US link the searchwidget first to this. |
2040 | // The real linkage to the toolbar happens later. | 2040 | // The real linkage to the toolbar happens later. |
2041 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2041 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2042 | //US tb->insertItem( mIncSearchWidget ); | 2042 | //US tb->insertItem( mIncSearchWidget ); |
2043 | /*US | 2043 | /*US |
2044 | mIncSearchWidget = new IncSearchWidget( tb ); | 2044 | mIncSearchWidget = new IncSearchWidget( tb ); |
2045 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2045 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2046 | SLOT( incrementalSearch( const QString& ) ) ); | 2046 | SLOT( incrementalSearch( const QString& ) ) ); |
2047 | 2047 | ||
2048 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2048 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2049 | 2049 | ||
2050 | //US topLayout->addWidget( mJumpButtonBar ); | 2050 | //US topLayout->addWidget( mJumpButtonBar ); |
2051 | this->layout()->add( mJumpButtonBar ); | 2051 | this->layout()->add( mJumpButtonBar ); |
2052 | */ | 2052 | */ |
2053 | 2053 | ||
2054 | #endif //KAB_EMBEDDED | 2054 | #endif //KAB_EMBEDDED |
2055 | 2055 | ||
2056 | mActionExport2phone->plug( ExportMenu ); | 2056 | mActionExport2phone->plug( ExportMenu ); |
2057 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2057 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2058 | syncManager->fillSyncMenu(); | 2058 | syncManager->fillSyncMenu(); |
2059 | 2059 | ||
2060 | } | 2060 | } |
2061 | void KABCore::showLicence() | 2061 | void KABCore::showLicence() |
2062 | { | 2062 | { |
2063 | KApplication::showLicence(); | 2063 | KApplication::showLicence(); |
2064 | } | 2064 | } |
2065 | void KABCore::removeVoice() | 2065 | void KABCore::removeVoice() |
2066 | { | 2066 | { |
2067 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) | 2067 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) |
2068 | return; | 2068 | return; |
2069 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 2069 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
2070 | KABC::Addressee::List::Iterator it; | 2070 | KABC::Addressee::List::Iterator it; |
2071 | for ( it = list.begin(); it != list.end(); ++it ) { | 2071 | for ( it = list.begin(); it != list.end(); ++it ) { |
2072 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); | 2072 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); |
2073 | PhoneNumber::List::Iterator phoneIt; | 2073 | PhoneNumber::List::Iterator phoneIt; |
2074 | bool found = false; | 2074 | bool found = false; |
2075 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { | 2075 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { |
2076 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 2076 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
2077 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 2077 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
2078 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 2078 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
2079 | (*it).insertPhoneNumber( (*phoneIt) ); | 2079 | (*it).insertPhoneNumber( (*phoneIt) ); |
2080 | found = true; | 2080 | found = true; |
2081 | } | 2081 | } |
2082 | } | 2082 | } |
2083 | 2083 | ||
2084 | } | 2084 | } |
2085 | if ( found ) | 2085 | if ( found ) |
2086 | contactModified((*it) ); | 2086 | contactModified((*it) ); |
2087 | } | 2087 | } |
2088 | } | 2088 | } |
2089 | 2089 | ||
2090 | 2090 | ||
2091 | 2091 | ||
2092 | void KABCore::clipboardDataChanged() | 2092 | void KABCore::clipboardDataChanged() |
2093 | { | 2093 | { |
2094 | 2094 | ||
2095 | if ( mReadWrite ) | 2095 | if ( mReadWrite ) |
2096 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2096 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2097 | 2097 | ||
2098 | } | 2098 | } |
2099 | 2099 | ||
2100 | void KABCore::updateActionMenu() | 2100 | void KABCore::updateActionMenu() |
2101 | { | 2101 | { |
2102 | UndoStack *undo = UndoStack::instance(); | 2102 | UndoStack *undo = UndoStack::instance(); |
2103 | RedoStack *redo = RedoStack::instance(); | 2103 | RedoStack *redo = RedoStack::instance(); |
2104 | 2104 | ||
2105 | if ( undo->isEmpty() ) | 2105 | if ( undo->isEmpty() ) |
2106 | mActionUndo->setText( i18n( "Undo" ) ); | 2106 | mActionUndo->setText( i18n( "Undo" ) ); |
2107 | else | 2107 | else |
2108 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2108 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2109 | 2109 | ||
2110 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2110 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2111 | 2111 | ||
2112 | if ( !redo->top() ) | 2112 | if ( !redo->top() ) |
2113 | mActionRedo->setText( i18n( "Redo" ) ); | 2113 | mActionRedo->setText( i18n( "Redo" ) ); |
2114 | else | 2114 | else |
2115 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2115 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2116 | 2116 | ||
2117 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2117 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2118 | } | 2118 | } |
2119 | 2119 | ||
2120 | void KABCore::configureKeyBindings() | 2120 | void KABCore::configureKeyBindings() |
2121 | { | 2121 | { |
2122 | #ifndef KAB_EMBEDDED | 2122 | #ifndef KAB_EMBEDDED |
2123 | KKeyDialog::configure( actionCollection(), true ); | 2123 | KKeyDialog::configure( actionCollection(), true ); |
2124 | #else //KAB_EMBEDDED | 2124 | #else //KAB_EMBEDDED |
2125 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2125 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2126 | #endif //KAB_EMBEDDED | 2126 | #endif //KAB_EMBEDDED |
2127 | } | 2127 | } |
2128 | 2128 | ||
2129 | #ifdef KAB_EMBEDDED | 2129 | #ifdef KAB_EMBEDDED |
2130 | void KABCore::configureResources() | 2130 | void KABCore::configureResources() |
2131 | { | 2131 | { |
2132 | KRES::KCMKResources dlg( this, "" , 0 ); | 2132 | KRES::KCMKResources dlg( this, "" , 0 ); |
2133 | 2133 | ||
2134 | if ( !dlg.exec() ) | 2134 | if ( !dlg.exec() ) |
2135 | return; | 2135 | return; |
2136 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2136 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2137 | } | 2137 | } |
2138 | #endif //KAB_EMBEDDED | 2138 | #endif //KAB_EMBEDDED |
2139 | 2139 | ||
2140 | 2140 | ||
2141 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2141 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2142 | * for the attendees list of an event. | 2142 | * for the attendees list of an event. |
2143 | */ | 2143 | */ |
2144 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2144 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2145 | { | 2145 | { |
2146 | QStringList nameList; | 2146 | QStringList nameList; |
2147 | QStringList emailList; | 2147 | QStringList emailList; |
2148 | QStringList uidList; | 2148 | QStringList uidList; |
2149 | 2149 | ||
2150 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2150 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2151 | uint i=0; | 2151 | uint i=0; |
2152 | for (i=0; i < list.count(); i++) | 2152 | for (i=0; i < list.count(); i++) |
2153 | { | 2153 | { |
2154 | nameList.append(list[i].realName()); | 2154 | nameList.append(list[i].realName()); |
2155 | emailList.append(list[i].preferredEmail()); | 2155 | emailList.append(list[i].preferredEmail()); |
2156 | uidList.append(list[i].uid()); | 2156 | uidList.append(list[i].uid()); |
2157 | } | 2157 | } |
2158 | 2158 | ||
2159 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2159 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2160 | 2160 | ||
2161 | } | 2161 | } |
2162 | 2162 | ||
2163 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2163 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2164 | * to put them into the calendar. | 2164 | * to put them into the calendar. |
2165 | */ | 2165 | */ |
2166 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2166 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2167 | { | 2167 | { |
2168 | // qDebug("KABCore::requestForBirthdayList"); | 2168 | // qDebug("KABCore::requestForBirthdayList"); |
2169 | QStringList birthdayList; | 2169 | QStringList birthdayList; |
2170 | QStringList anniversaryList; | 2170 | QStringList anniversaryList; |
2171 | QStringList realNameList; | 2171 | QStringList realNameList; |
2172 | QStringList preferredEmailList; | 2172 | QStringList preferredEmailList; |
2173 | QStringList assembledNameList; | 2173 | QStringList assembledNameList; |
2174 | QStringList uidList; | 2174 | QStringList uidList; |
2175 | 2175 | ||
2176 | KABC::AddressBook::Iterator it; | 2176 | KABC::AddressBook::Iterator it; |
2177 | 2177 | ||
2178 | int count = 0; | 2178 | int count = 0; |
2179 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2179 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2180 | ++count; | 2180 | ++count; |
2181 | } | 2181 | } |
2182 | QProgressBar bar(count,0 ); | 2182 | QProgressBar bar(count,0 ); |
2183 | int w = 300; | 2183 | int w = 300; |
2184 | if ( QApplication::desktop()->width() < 320 ) | 2184 | if ( QApplication::desktop()->width() < 320 ) |
2185 | w = 220; | 2185 | w = 220; |
2186 | int h = bar.sizeHint().height() ; | 2186 | int h = bar.sizeHint().height() ; |
2187 | int dw = QApplication::desktop()->width(); | 2187 | int dw = QApplication::desktop()->width(); |
2188 | int dh = QApplication::desktop()->height(); | 2188 | int dh = QApplication::desktop()->height(); |
2189 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2189 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2190 | bar.show(); | 2190 | bar.show(); |
2191 | bar.setCaption (i18n("collecting birthdays - close to abort!") ); | 2191 | bar.setCaption (i18n("collecting birthdays - close to abort!") ); |
2192 | qApp->processEvents(); | 2192 | qApp->processEvents(); |
2193 | 2193 | ||
2194 | QDate bday; | 2194 | QDate bday; |
2195 | QString anni; | 2195 | QString anni; |
2196 | QString formattedbday; | 2196 | QString formattedbday; |
2197 | 2197 | ||
2198 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2198 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2199 | { | 2199 | { |
2200 | if ( ! bar.isVisible() ) | 2200 | if ( ! bar.isVisible() ) |
2201 | return; | 2201 | return; |
2202 | bar.setProgress( count++ ); | 2202 | bar.setProgress( count++ ); |
2203 | qApp->processEvents(); | 2203 | qApp->processEvents(); |
2204 | bday = (*it).birthday().date(); | 2204 | bday = (*it).birthday().date(); |
2205 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2205 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2206 | 2206 | ||
2207 | if ( bday.isValid() || !anni.isEmpty()) | 2207 | if ( bday.isValid() || !anni.isEmpty()) |
2208 | { | 2208 | { |
2209 | if (bday.isValid()) | 2209 | if (bday.isValid()) |
2210 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2210 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2211 | else | 2211 | else |
2212 | formattedbday = "NOTVALID"; | 2212 | formattedbday = "NOTVALID"; |
2213 | if (anni.isEmpty()) | 2213 | if (anni.isEmpty()) |
2214 | anni = "INVALID"; | 2214 | anni = "INVALID"; |
2215 | 2215 | ||
2216 | birthdayList.append(formattedbday); | 2216 | birthdayList.append(formattedbday); |
2217 | anniversaryList.append(anni); //should be ISODate | 2217 | anniversaryList.append(anni); //should be ISODate |
2218 | realNameList.append((*it).realName()); | 2218 | realNameList.append((*it).realName()); |
2219 | preferredEmailList.append((*it).preferredEmail()); | 2219 | preferredEmailList.append((*it).preferredEmail()); |
2220 | assembledNameList.append((*it).assembledName()); | 2220 | assembledNameList.append((*it).assembledName()); |
2221 | uidList.append((*it).uid()); | 2221 | uidList.append((*it).uid()); |
2222 | 2222 | ||
2223 | qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); | 2223 | qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); |
2224 | } | 2224 | } |
2225 | } | 2225 | } |
2226 | 2226 | ||
2227 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2227 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2228 | 2228 | ||
2229 | } | 2229 | } |
2230 | 2230 | ||
2231 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2231 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2232 | */ | 2232 | */ |
2233 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2233 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2234 | { | 2234 | { |
2235 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2235 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2236 | 2236 | ||
2237 | QString foundUid = QString::null; | 2237 | QString foundUid = QString::null; |
2238 | if ( ! uid.isEmpty() ) { | 2238 | if ( ! uid.isEmpty() ) { |
2239 | Addressee adrr = mAddressBook->findByUid( uid ); | 2239 | Addressee adrr = mAddressBook->findByUid( uid ); |
2240 | if ( !adrr.isEmpty() ) { | 2240 | if ( !adrr.isEmpty() ) { |
2241 | foundUid = uid; | 2241 | foundUid = uid; |
2242 | } | 2242 | } |
2243 | if ( email == "sendbacklist" ) { | 2243 | if ( email == "sendbacklist" ) { |
2244 | //qDebug("ssssssssssssssssssssssend "); | 2244 | //qDebug("ssssssssssssssssssssssend "); |
2245 | QStringList nameList; | 2245 | QStringList nameList; |
2246 | QStringList emailList; | 2246 | QStringList emailList; |
2247 | QStringList uidList; | 2247 | QStringList uidList; |
2248 | nameList.append(adrr.realName()); | 2248 | nameList.append(adrr.realName()); |
2249 | emailList = adrr.emails(); | 2249 | emailList = adrr.emails(); |
2250 | uidList.append( adrr.preferredEmail()); | 2250 | uidList.append( adrr.preferredEmail()); |
2251 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2251 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2252 | return; | 2252 | return; |
2253 | } | 2253 | } |
2254 | 2254 | ||
2255 | } | 2255 | } |
2256 | 2256 | ||
2257 | if ( email == "sendbacklist" ) | 2257 | if ( email == "sendbacklist" ) |
2258 | return; | 2258 | return; |
2259 | if (foundUid.isEmpty()) | 2259 | if (foundUid.isEmpty()) |
2260 | { | 2260 | { |
2261 | //find the uid of the person first | 2261 | //find the uid of the person first |
2262 | Addressee::List namelist; | 2262 | Addressee::List namelist; |
2263 | Addressee::List emaillist; | 2263 | Addressee::List emaillist; |
2264 | 2264 | ||
2265 | if (!name.isEmpty()) | 2265 | if (!name.isEmpty()) |
2266 | namelist = mAddressBook->findByName( name ); | 2266 | namelist = mAddressBook->findByName( name ); |
2267 | 2267 | ||
2268 | if (!email.isEmpty()) | 2268 | if (!email.isEmpty()) |
2269 | emaillist = mAddressBook->findByEmail( email ); | 2269 | emaillist = mAddressBook->findByEmail( email ); |
2270 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2270 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2271 | //check if we have a match in Namelist and Emaillist | 2271 | //check if we have a match in Namelist and Emaillist |
2272 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2272 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2273 | foundUid = emaillist[0].uid(); | 2273 | foundUid = emaillist[0].uid(); |
2274 | } | 2274 | } |
2275 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2275 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2276 | foundUid = namelist[0].uid(); | 2276 | foundUid = namelist[0].uid(); |
2277 | else | 2277 | else |
2278 | { | 2278 | { |
2279 | for (int i = 0; i < namelist.count(); i++) | 2279 | for (int i = 0; i < namelist.count(); i++) |
2280 | { | 2280 | { |
2281 | for (int j = 0; j < emaillist.count(); j++) | 2281 | for (int j = 0; j < emaillist.count(); j++) |
2282 | { | 2282 | { |
2283 | if (namelist[i] == emaillist[j]) | 2283 | if (namelist[i] == emaillist[j]) |
2284 | { | 2284 | { |
2285 | foundUid = namelist[i].uid(); | 2285 | foundUid = namelist[i].uid(); |
2286 | } | 2286 | } |
2287 | } | 2287 | } |
2288 | } | 2288 | } |
2289 | } | 2289 | } |
2290 | } | 2290 | } |
2291 | else | 2291 | else |
2292 | { | 2292 | { |
2293 | foundUid = uid; | 2293 | foundUid = uid; |
2294 | } | 2294 | } |
2295 | 2295 | ||
2296 | if (!foundUid.isEmpty()) | 2296 | if (!foundUid.isEmpty()) |
2297 | { | 2297 | { |
2298 | 2298 | ||
2299 | // raise Ka/Pi if it is in the background | 2299 | // raise Ka/Pi if it is in the background |
2300 | #ifndef DESKTOP_VERSION | 2300 | #ifndef DESKTOP_VERSION |
2301 | #ifndef KORG_NODCOP | 2301 | #ifndef KORG_NODCOP |
2302 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2302 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2303 | #endif | 2303 | #endif |
2304 | #endif | 2304 | #endif |
2305 | 2305 | ||
2306 | mMainWindow->showMaximized(); | 2306 | mMainWindow->showMaximized(); |
2307 | mMainWindow-> raise(); | 2307 | mMainWindow-> raise(); |
2308 | 2308 | ||
2309 | mViewManager->setSelected( "", false); | 2309 | mViewManager->setSelected( "", false); |
2310 | mViewManager->refreshView( "" ); | 2310 | mViewManager->refreshView( "" ); |
2311 | mViewManager->setSelected( foundUid, true ); | 2311 | mViewManager->setSelected( foundUid, true ); |
2312 | mViewManager->refreshView( foundUid ); | 2312 | mViewManager->refreshView( foundUid ); |
2313 | 2313 | ||
2314 | if ( !mMultipleViewsAtOnce ) | 2314 | if ( !mMultipleViewsAtOnce ) |
2315 | { | 2315 | { |
2316 | setDetailsVisible( true ); | 2316 | setDetailsVisible( true ); |
2317 | mActionDetails->setChecked(true); | 2317 | mActionDetails->setChecked(true); |
2318 | } | 2318 | } |
2319 | } | 2319 | } |
2320 | } | 2320 | } |
2321 | 2321 | ||
2322 | 2322 | ||
2323 | void KABCore::faq() | 2323 | void KABCore::faq() |
2324 | { | 2324 | { |
2325 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2325 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2326 | } | 2326 | } |
2327 | 2327 | ||
2328 | #include <libkcal/syncdefines.h> | 2328 | #include <libkcal/syncdefines.h> |
2329 | 2329 | ||
2330 | KABC::Addressee KABCore::getLastSyncAddressee() | 2330 | KABC::Addressee KABCore::getLastSyncAddressee() |
2331 | { | 2331 | { |
2332 | Addressee lse; | 2332 | Addressee lse; |
2333 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2333 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2334 | 2334 | ||
2335 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2335 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2336 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2336 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2337 | if (lse.isEmpty()) { | 2337 | if (lse.isEmpty()) { |
2338 | qDebug("Creating new last-syncAddressee "); | 2338 | qDebug("Creating new last-syncAddressee "); |
2339 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2339 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2340 | QString sum = ""; | 2340 | QString sum = ""; |
2341 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2341 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2342 | sum = "E: "; | 2342 | sum = "E: "; |
2343 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2343 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2344 | lse.setRevision( mLastAddressbookSync ); | 2344 | lse.setRevision( mLastAddressbookSync ); |
2345 | lse.setCategories( i18n("SyncEvent") ); | 2345 | lse.setCategories( i18n("SyncEvent") ); |
2346 | mAddressBook->insertAddressee( lse ); | 2346 | mAddressBook->insertAddressee( lse ); |
2347 | } | 2347 | } |
2348 | return lse; | 2348 | return lse; |
2349 | } | 2349 | } |
2350 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2350 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2351 | { | 2351 | { |
2352 | 2352 | ||
2353 | //void setZaurusId(int id); | 2353 | //void setZaurusId(int id); |
2354 | // int zaurusId() const; | 2354 | // int zaurusId() const; |
2355 | // void setZaurusUid(int id); | 2355 | // void setZaurusUid(int id); |
2356 | // int zaurusUid() const; | 2356 | // int zaurusUid() const; |
2357 | // void setZaurusStat(int id); | 2357 | // void setZaurusStat(int id); |
2358 | // int zaurusStat() const; | 2358 | // int zaurusStat() const; |
2359 | // 0 equal | 2359 | // 0 equal |
2360 | // 1 take local | 2360 | // 1 take local |
2361 | // 2 take remote | 2361 | // 2 take remote |
2362 | // 3 cancel | 2362 | // 3 cancel |
2363 | QDateTime lastSync = mLastAddressbookSync; | 2363 | QDateTime lastSync = mLastAddressbookSync; |
2364 | QDateTime localMod = local->revision(); | 2364 | QDateTime localMod = local->revision(); |
2365 | QDateTime remoteMod = remote->revision(); | 2365 | QDateTime remoteMod = remote->revision(); |
2366 | 2366 | ||
2367 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2367 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2368 | 2368 | ||
2369 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2369 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2370 | bool remCh, locCh; | 2370 | bool remCh, locCh; |
2371 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2371 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2372 | 2372 | ||
2373 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2373 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2374 | locCh = ( localMod > mLastAddressbookSync ); | 2374 | locCh = ( localMod > mLastAddressbookSync ); |
2375 | if ( !remCh && ! locCh ) { | 2375 | if ( !remCh && ! locCh ) { |
2376 | //qDebug("both not changed "); | 2376 | //qDebug("both not changed "); |
2377 | lastSync = localMod.addDays(1); | 2377 | lastSync = localMod.addDays(1); |
2378 | if ( mode <= SYNC_PREF_ASK ) | 2378 | if ( mode <= SYNC_PREF_ASK ) |
2379 | return 0; | 2379 | return 0; |
2380 | } else { | 2380 | } else { |
2381 | if ( locCh ) { | 2381 | if ( locCh ) { |
2382 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2382 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2383 | lastSync = localMod.addDays( -1 ); | 2383 | lastSync = localMod.addDays( -1 ); |
2384 | if ( !remCh ) | 2384 | if ( !remCh ) |
2385 | remoteMod =( lastSync.addDays( -1 ) ); | 2385 | remoteMod =( lastSync.addDays( -1 ) ); |
2386 | } else { | 2386 | } else { |
2387 | //qDebug(" not loc changed "); | 2387 | //qDebug(" not loc changed "); |
2388 | lastSync = localMod.addDays( 1 ); | 2388 | lastSync = localMod.addDays( 1 ); |
2389 | if ( remCh ) | 2389 | if ( remCh ) |
2390 | remoteMod =( lastSync.addDays( 1 ) ); | 2390 | remoteMod =( lastSync.addDays( 1 ) ); |
2391 | 2391 | ||
2392 | } | 2392 | } |
2393 | } | 2393 | } |
2394 | full = true; | 2394 | full = true; |
2395 | if ( mode < SYNC_PREF_ASK ) | 2395 | if ( mode < SYNC_PREF_ASK ) |
2396 | mode = SYNC_PREF_ASK; | 2396 | mode = SYNC_PREF_ASK; |
2397 | } else { | 2397 | } else { |
2398 | if ( localMod == remoteMod ) | 2398 | if ( localMod == remoteMod ) |
2399 | return 0; | 2399 | return 0; |
2400 | 2400 | ||
2401 | } | 2401 | } |
2402 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2402 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2403 | 2403 | ||
2404 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 2404 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
2405 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2405 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2406 | //full = true; //debug only | 2406 | //full = true; //debug only |
2407 | if ( full ) { | 2407 | if ( full ) { |
2408 | bool equ = ( (*local) == (*remote) ); | 2408 | bool equ = ( (*local) == (*remote) ); |
2409 | if ( equ ) { | 2409 | if ( equ ) { |
2410 | //qDebug("equal "); | 2410 | //qDebug("equal "); |
2411 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2411 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2412 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2412 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2413 | } | 2413 | } |
2414 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2414 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2415 | return 0; | 2415 | return 0; |
2416 | 2416 | ||
2417 | }//else //debug only | 2417 | }//else //debug only |
2418 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2418 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2419 | } | 2419 | } |
2420 | int result; | 2420 | int result; |
2421 | bool localIsNew; | 2421 | bool localIsNew; |
2422 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 2422 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
2423 | 2423 | ||
2424 | if ( full && mode < SYNC_PREF_NEWEST ) | 2424 | if ( full && mode < SYNC_PREF_NEWEST ) |
2425 | mode = SYNC_PREF_ASK; | 2425 | mode = SYNC_PREF_ASK; |
2426 | 2426 | ||
2427 | switch( mode ) { | 2427 | switch( mode ) { |
2428 | case SYNC_PREF_LOCAL: | 2428 | case SYNC_PREF_LOCAL: |
2429 | if ( lastSync > remoteMod ) | 2429 | if ( lastSync > remoteMod ) |
2430 | return 1; | 2430 | return 1; |
2431 | if ( lastSync > localMod ) | 2431 | if ( lastSync > localMod ) |
2432 | return 2; | 2432 | return 2; |
2433 | return 1; | 2433 | return 1; |
2434 | break; | 2434 | break; |
2435 | case SYNC_PREF_REMOTE: | 2435 | case SYNC_PREF_REMOTE: |
2436 | if ( lastSync > remoteMod ) | 2436 | if ( lastSync > remoteMod ) |
2437 | return 1; | 2437 | return 1; |
2438 | if ( lastSync > localMod ) | 2438 | if ( lastSync > localMod ) |
2439 | return 2; | 2439 | return 2; |
2440 | return 2; | 2440 | return 2; |
2441 | break; | 2441 | break; |
2442 | case SYNC_PREF_NEWEST: | 2442 | case SYNC_PREF_NEWEST: |
2443 | if ( localMod > remoteMod ) | 2443 | if ( localMod > remoteMod ) |
2444 | return 1; | 2444 | return 1; |
2445 | else | 2445 | else |
2446 | return 2; | 2446 | return 2; |
2447 | break; | 2447 | break; |
2448 | case SYNC_PREF_ASK: | 2448 | case SYNC_PREF_ASK: |
2449 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2449 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2450 | if ( lastSync > remoteMod ) | 2450 | if ( lastSync > remoteMod ) |
2451 | return 1; | 2451 | return 1; |
2452 | if ( lastSync > localMod ) | 2452 | if ( lastSync > localMod ) |
2453 | return 2; | 2453 | return 2; |
2454 | localIsNew = localMod >= remoteMod; | 2454 | localIsNew = localMod >= remoteMod; |
2455 | //qDebug("conflict! ************************************** "); | 2455 | //qDebug("conflict! ************************************** "); |
2456 | { | 2456 | { |
2457 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2457 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2458 | result = acd.executeD(localIsNew); | 2458 | result = acd.executeD(localIsNew); |
2459 | return result; | 2459 | return result; |
2460 | } | 2460 | } |
2461 | break; | 2461 | break; |
2462 | case SYNC_PREF_FORCE_LOCAL: | 2462 | case SYNC_PREF_FORCE_LOCAL: |
2463 | return 1; | 2463 | return 1; |
2464 | break; | 2464 | break; |
2465 | case SYNC_PREF_FORCE_REMOTE: | 2465 | case SYNC_PREF_FORCE_REMOTE: |
2466 | return 2; | 2466 | return 2; |
2467 | break; | 2467 | break; |
2468 | 2468 | ||
2469 | default: | 2469 | default: |
2470 | // SYNC_PREF_TAKE_BOTH not implemented | 2470 | // SYNC_PREF_TAKE_BOTH not implemented |
2471 | break; | 2471 | break; |
2472 | } | 2472 | } |
2473 | return 0; | 2473 | return 0; |
2474 | } | 2474 | } |
2475 | 2475 | ||
2476 | 2476 | ||
2477 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2477 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2478 | { | 2478 | { |
2479 | bool syncOK = true; | 2479 | bool syncOK = true; |
2480 | int addedAddressee = 0; | 2480 | int addedAddressee = 0; |
2481 | int addedAddresseeR = 0; | 2481 | int addedAddresseeR = 0; |
2482 | int deletedAddresseeR = 0; | 2482 | int deletedAddresseeR = 0; |
2483 | int deletedAddresseeL = 0; | 2483 | int deletedAddresseeL = 0; |
2484 | int changedLocal = 0; | 2484 | int changedLocal = 0; |
2485 | int changedRemote = 0; | 2485 | int changedRemote = 0; |
2486 | 2486 | ||
2487 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2487 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2488 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2488 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2489 | 2489 | ||
2490 | //QPtrList<Addressee> el = local->rawAddressees(); | 2490 | //QPtrList<Addressee> el = local->rawAddressees(); |
2491 | Addressee addresseeR; | 2491 | Addressee addresseeR; |
2492 | QString uid; | 2492 | QString uid; |
2493 | int take; | 2493 | int take; |
2494 | Addressee addresseeL; | 2494 | Addressee addresseeL; |
2495 | Addressee addresseeRSync; | 2495 | Addressee addresseeRSync; |
2496 | Addressee addresseeLSync; | 2496 | Addressee addresseeLSync; |
2497 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2497 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2498 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2498 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2499 | bool fullDateRange = false; | 2499 | bool fullDateRange = false; |
2500 | local->resetTempSyncStat(); | 2500 | local->resetTempSyncStat(); |
2501 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2501 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2502 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2502 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2503 | addresseeLSync = getLastSyncAddressee(); | 2503 | addresseeLSync = getLastSyncAddressee(); |
2504 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2504 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2505 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2505 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2506 | if ( !addresseeR.isEmpty() ) { | 2506 | if ( !addresseeR.isEmpty() ) { |
2507 | addresseeRSync = addresseeR; | 2507 | addresseeRSync = addresseeR; |
2508 | remote->removeAddressee(addresseeR ); | 2508 | remote->removeAddressee(addresseeR ); |
2509 | 2509 | ||
2510 | } else { | 2510 | } else { |
2511 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2511 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2512 | addresseeRSync = addresseeLSync ; | 2512 | addresseeRSync = addresseeLSync ; |
2513 | } else { | 2513 | } else { |
2514 | qDebug("FULLDATE 1"); | 2514 | qDebug("FULLDATE 1"); |
2515 | fullDateRange = true; | 2515 | fullDateRange = true; |
2516 | Addressee newAdd; | 2516 | Addressee newAdd; |
2517 | addresseeRSync = newAdd; | 2517 | addresseeRSync = newAdd; |
2518 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2518 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2519 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2519 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2520 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2520 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2521 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2521 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2522 | } | 2522 | } |
2523 | } | 2523 | } |
2524 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2524 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2525 | qDebug("FULLDATE 2"); | 2525 | qDebug("FULLDATE 2"); |
2526 | fullDateRange = true; | 2526 | fullDateRange = true; |
2527 | } | 2527 | } |
2528 | if ( ! fullDateRange ) { | 2528 | if ( ! fullDateRange ) { |
2529 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2529 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2530 | 2530 | ||
2531 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2531 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2532 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2532 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2533 | fullDateRange = true; | 2533 | fullDateRange = true; |
2534 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2534 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2535 | } | 2535 | } |
2536 | } | 2536 | } |
2537 | // fullDateRange = true; // debug only! | 2537 | // fullDateRange = true; // debug only! |
2538 | if ( fullDateRange ) | 2538 | if ( fullDateRange ) |
2539 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2539 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2540 | else | 2540 | else |
2541 | mLastAddressbookSync = addresseeLSync.revision(); | 2541 | mLastAddressbookSync = addresseeLSync.revision(); |
2542 | // for resyncing if own file has changed | 2542 | // for resyncing if own file has changed |
2543 | // PENDING fixme later when implemented | 2543 | // PENDING fixme later when implemented |
2544 | #if 0 | 2544 | #if 0 |
2545 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2545 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2546 | mLastAddressbookSync = loadedFileVersion; | 2546 | mLastAddressbookSync = loadedFileVersion; |
2547 | qDebug("setting mLastAddressbookSync "); | 2547 | qDebug("setting mLastAddressbookSync "); |
2548 | } | 2548 | } |
2549 | #endif | 2549 | #endif |
2550 | 2550 | ||
2551 | //qDebug("*************************** "); | 2551 | //qDebug("*************************** "); |
2552 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2552 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2553 | QStringList er = remote->uidList(); | 2553 | QStringList er = remote->uidList(); |
2554 | Addressee inR ;//= er.first(); | 2554 | Addressee inR ;//= er.first(); |
2555 | Addressee inL; | 2555 | Addressee inL; |
2556 | 2556 | ||
2557 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2557 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2558 | 2558 | ||
2559 | int modulo = (er.count()/10)+1; | 2559 | int modulo = (er.count()/10)+1; |
2560 | int incCounter = 0; | 2560 | int incCounter = 0; |
2561 | while ( incCounter < er.count()) { | 2561 | while ( incCounter < er.count()) { |
2562 | if (syncManager->isProgressBarCanceled()) | 2562 | if (syncManager->isProgressBarCanceled()) |
2563 | return false; | 2563 | return false; |
2564 | if ( incCounter % modulo == 0 ) | 2564 | if ( incCounter % modulo == 0 ) |
2565 | syncManager->showProgressBar(incCounter); | 2565 | syncManager->showProgressBar(incCounter); |
2566 | 2566 | ||
2567 | uid = er[ incCounter ]; | 2567 | uid = er[ incCounter ]; |
2568 | bool skipIncidence = false; | 2568 | bool skipIncidence = false; |
2569 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2569 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2570 | skipIncidence = true; | 2570 | skipIncidence = true; |
2571 | QString idS,OidS; | 2571 | QString idS,OidS; |
2572 | qApp->processEvents(); | 2572 | qApp->processEvents(); |
2573 | if ( !skipIncidence ) { | 2573 | if ( !skipIncidence ) { |
2574 | inL = local->findByUid( uid ); | 2574 | inL = local->findByUid( uid ); |
2575 | inR = remote->findByUid( uid ); | 2575 | inR = remote->findByUid( uid ); |
2576 | //inL.setResource( 0 ); | 2576 | //inL.setResource( 0 ); |
2577 | //inR.setResource( 0 ); | 2577 | //inR.setResource( 0 ); |
2578 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2578 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2579 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2579 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2580 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2580 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2581 | if ( take == 3 ) | 2581 | if ( take == 3 ) |
2582 | return false; | 2582 | return false; |
2583 | if ( take == 1 ) {// take local | 2583 | if ( take == 1 ) {// take local |
2584 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2584 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2585 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2585 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2586 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2586 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2587 | local->insertAddressee( inL, false ); | 2587 | local->insertAddressee( inL, false ); |
2588 | idS = inR.externalUID(); | 2588 | idS = inR.externalUID(); |
2589 | OidS = inR.originalExternalUID(); | 2589 | OidS = inR.originalExternalUID(); |
2590 | } | 2590 | } |
2591 | else | 2591 | else |
2592 | idS = inR.IDStr(); | 2592 | idS = inR.IDStr(); |
2593 | remote->removeAddressee( inR ); | 2593 | remote->removeAddressee( inR ); |
2594 | inR = inL; | 2594 | inR = inL; |
2595 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2595 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2596 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2596 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2597 | inR.setOriginalExternalUID( OidS ); | 2597 | inR.setOriginalExternalUID( OidS ); |
2598 | inR.setExternalUID( idS ); | 2598 | inR.setExternalUID( idS ); |
2599 | } else { | 2599 | } else { |
2600 | inR.setIDStr( idS ); | 2600 | inR.setIDStr( idS ); |
2601 | } | 2601 | } |
2602 | inR.setResource( 0 ); | 2602 | inR.setResource( 0 ); |
2603 | remote->insertAddressee( inR , false); | 2603 | remote->insertAddressee( inR , false); |
2604 | ++changedRemote; | 2604 | ++changedRemote; |
2605 | } else { // take == 2 take remote | 2605 | } else { // take == 2 take remote |
2606 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2606 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2607 | if ( inR.revision().date().year() < 2004 ) | 2607 | if ( inR.revision().date().year() < 2004 ) |
2608 | inR.setRevision( modifiedCalendar ); | 2608 | inR.setRevision( modifiedCalendar ); |
2609 | } | 2609 | } |
2610 | idS = inL.IDStr(); | 2610 | idS = inL.IDStr(); |
2611 | local->removeAddressee( inL ); | 2611 | local->removeAddressee( inL ); |
2612 | inL = inR; | 2612 | inL = inR; |
2613 | inL.setIDStr( idS ); | 2613 | inL.setIDStr( idS ); |
2614 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2614 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2615 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2615 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2616 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2616 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2617 | } | 2617 | } |
2618 | inL.setResource( 0 ); | 2618 | inL.setResource( 0 ); |
2619 | local->insertAddressee( inL , false ); | 2619 | local->insertAddressee( inL , false ); |
2620 | ++changedLocal; | 2620 | ++changedLocal; |
2621 | } | 2621 | } |
2622 | } | 2622 | } |
2623 | } else { // no conflict | 2623 | } else { // no conflict |
2624 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2624 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2625 | QString des = addresseeLSync.note(); | 2625 | QString des = addresseeLSync.note(); |
2626 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2626 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2627 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2627 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2628 | remote->insertAddressee( inR, false ); | 2628 | remote->insertAddressee( inR, false ); |
2629 | ++deletedAddresseeR; | 2629 | ++deletedAddresseeR; |
2630 | } else { | 2630 | } else { |
2631 | inR.setRevision( modifiedCalendar ); | 2631 | inR.setRevision( modifiedCalendar ); |
2632 | remote->insertAddressee( inR, false ); | 2632 | remote->insertAddressee( inR, false ); |
2633 | inL = inR; | 2633 | inL = inR; |
2634 | inL.setResource( 0 ); | 2634 | inL.setResource( 0 ); |
2635 | local->insertAddressee( inL , false); | 2635 | local->insertAddressee( inL , false); |
2636 | ++addedAddressee; | 2636 | ++addedAddressee; |
2637 | } | 2637 | } |
2638 | } else { | 2638 | } else { |
2639 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2639 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2640 | inR.setRevision( modifiedCalendar ); | 2640 | inR.setRevision( modifiedCalendar ); |
2641 | remote->insertAddressee( inR, false ); | 2641 | remote->insertAddressee( inR, false ); |
2642 | inR.setResource( 0 ); | 2642 | inR.setResource( 0 ); |
2643 | local->insertAddressee( inR, false ); | 2643 | local->insertAddressee( inR, false ); |
2644 | ++addedAddressee; | 2644 | ++addedAddressee; |
2645 | } else { | 2645 | } else { |
2646 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2646 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2647 | remote->removeAddressee( inR ); | 2647 | remote->removeAddressee( inR ); |
2648 | ++deletedAddresseeR; | 2648 | ++deletedAddresseeR; |
2649 | } | 2649 | } |
2650 | } | 2650 | } |
2651 | } | 2651 | } |
2652 | } | 2652 | } |
2653 | ++incCounter; | 2653 | ++incCounter; |
2654 | } | 2654 | } |
2655 | er.clear(); | 2655 | er.clear(); |
2656 | QStringList el = local->uidList(); | 2656 | QStringList el = local->uidList(); |
2657 | modulo = (el.count()/10)+1; | 2657 | modulo = (el.count()/10)+1; |
2658 | 2658 | ||
2659 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2659 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2660 | incCounter = 0; | 2660 | incCounter = 0; |
2661 | while ( incCounter < el.count()) { | 2661 | while ( incCounter < el.count()) { |
2662 | qApp->processEvents(); | 2662 | qApp->processEvents(); |
2663 | if (syncManager->isProgressBarCanceled()) | 2663 | if (syncManager->isProgressBarCanceled()) |
2664 | return false; | 2664 | return false; |
2665 | if ( incCounter % modulo == 0 ) | 2665 | if ( incCounter % modulo == 0 ) |
2666 | syncManager->showProgressBar(incCounter); | 2666 | syncManager->showProgressBar(incCounter); |
2667 | uid = el[ incCounter ]; | 2667 | uid = el[ incCounter ]; |
2668 | bool skipIncidence = false; | 2668 | bool skipIncidence = false; |
2669 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2669 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2670 | skipIncidence = true; | 2670 | skipIncidence = true; |
2671 | if ( !skipIncidence ) { | 2671 | if ( !skipIncidence ) { |
2672 | inL = local->findByUid( uid ); | 2672 | inL = local->findByUid( uid ); |
2673 | inR = remote->findByUid( uid ); | 2673 | inR = remote->findByUid( uid ); |
2674 | if ( inR.isEmpty() ) { | 2674 | if ( inR.isEmpty() ) { |
2675 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2675 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2676 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2676 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2677 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2677 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2678 | local->removeAddressee( inL ); | 2678 | local->removeAddressee( inL ); |
2679 | ++deletedAddresseeL; | 2679 | ++deletedAddresseeL; |
2680 | } else { | 2680 | } else { |
2681 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2681 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2682 | inL.removeID(mCurrentSyncDevice ); | 2682 | inL.removeID(mCurrentSyncDevice ); |
2683 | ++addedAddresseeR; | 2683 | ++addedAddresseeR; |
2684 | inL.setRevision( modifiedCalendar ); | 2684 | inL.setRevision( modifiedCalendar ); |
2685 | local->insertAddressee( inL, false ); | 2685 | local->insertAddressee( inL, false ); |
2686 | inR = inL; | 2686 | inR = inL; |
2687 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2687 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2688 | inR.setResource( 0 ); | 2688 | inR.setResource( 0 ); |
2689 | remote->insertAddressee( inR, false ); | 2689 | remote->insertAddressee( inR, false ); |
2690 | } | 2690 | } |
2691 | } | 2691 | } |
2692 | } else { | 2692 | } else { |
2693 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2693 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2694 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2694 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2695 | local->removeAddressee( inL ); | 2695 | local->removeAddressee( inL ); |
2696 | ++deletedAddresseeL; | 2696 | ++deletedAddresseeL; |
2697 | } else { | 2697 | } else { |
2698 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2698 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2699 | ++addedAddresseeR; | 2699 | ++addedAddresseeR; |
2700 | inL.setRevision( modifiedCalendar ); | 2700 | inL.setRevision( modifiedCalendar ); |
2701 | local->insertAddressee( inL, false ); | 2701 | local->insertAddressee( inL, false ); |
2702 | inR = inL; | 2702 | inR = inL; |
2703 | inR.setResource( 0 ); | 2703 | inR.setResource( 0 ); |
2704 | remote->insertAddressee( inR, false ); | 2704 | remote->insertAddressee( inR, false ); |
2705 | } | 2705 | } |
2706 | } | 2706 | } |
2707 | } | 2707 | } |
2708 | } | 2708 | } |
2709 | } | 2709 | } |
2710 | ++incCounter; | 2710 | ++incCounter; |
2711 | } | 2711 | } |
2712 | el.clear(); | 2712 | el.clear(); |
2713 | syncManager->hideProgressBar(); | 2713 | syncManager->hideProgressBar(); |
2714 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2714 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2715 | // get rid of micro seconds | 2715 | // get rid of micro seconds |
2716 | QTime t = mLastAddressbookSync.time(); | 2716 | QTime t = mLastAddressbookSync.time(); |
2717 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2717 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2718 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2718 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2719 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2719 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2720 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2720 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2721 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2721 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2722 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2722 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2723 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2723 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2724 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2724 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2725 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2725 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2726 | addresseeRSync.setNote( "" ) ; | 2726 | addresseeRSync.setNote( "" ) ; |
2727 | addresseeLSync.setNote( "" ); | 2727 | addresseeLSync.setNote( "" ); |
2728 | 2728 | ||
2729 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2729 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2730 | remote->insertAddressee( addresseeRSync, false ); | 2730 | remote->insertAddressee( addresseeRSync, false ); |
2731 | local->insertAddressee( addresseeLSync, false ); | 2731 | local->insertAddressee( addresseeLSync, false ); |
2732 | QString mes; | 2732 | QString mes; |
2733 | 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 ); | 2733 | 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 ); |
2734 | if ( syncManager->mShowSyncSummary ) { | 2734 | if ( syncManager->mShowSyncSummary ) { |
2735 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2735 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2736 | } | 2736 | } |
2737 | qDebug( mes ); | 2737 | qDebug( mes ); |
2738 | return syncOK; | 2738 | return syncOK; |
2739 | } | 2739 | } |
2740 | 2740 | ||
2741 | 2741 | ||
2742 | //this is a overwritten callbackmethods from the syncinterface | 2742 | //this is a overwritten callbackmethods from the syncinterface |
2743 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2743 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2744 | { | 2744 | { |
2745 | 2745 | ||
2746 | //pending prepare addresseeview for output | 2746 | //pending prepare addresseeview for output |
2747 | //pending detect, if remote file has REV field. if not switch to external sync | 2747 | //pending detect, if remote file has REV field. if not switch to external sync |
2748 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2748 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2749 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2749 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2750 | 2750 | ||
2751 | AddressBook abLocal(filename,"syncContact"); | 2751 | AddressBook abLocal(filename,"syncContact"); |
2752 | bool syncOK = false; | 2752 | bool syncOK = false; |
2753 | if ( abLocal.load() ) { | 2753 | if ( abLocal.load() ) { |
2754 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2754 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2755 | bool external = false; | 2755 | bool external = false; |
2756 | bool isXML = false; | 2756 | bool isXML = false; |
2757 | if ( filename.right(4) == ".xml") { | 2757 | if ( filename.right(4) == ".xml") { |
2758 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2758 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2759 | isXML = true; | 2759 | isXML = true; |
2760 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2760 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2761 | } else { | 2761 | } else { |
2762 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2762 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2763 | if ( ! lse.isEmpty() ) { | 2763 | if ( ! lse.isEmpty() ) { |
2764 | if ( lse.familyName().left(4) == "!E: " ) | 2764 | if ( lse.familyName().left(4) == "!E: " ) |
2765 | external = true; | 2765 | external = true; |
2766 | } else { | 2766 | } else { |
2767 | bool found = false; | 2767 | bool found = false; |
2768 | AddressBook::Iterator it; | 2768 | AddressBook::Iterator it; |
2769 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2769 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2770 | if ( (*it).revision().date().year() > 2003 ) { | 2770 | if ( (*it).revision().date().year() > 2003 ) { |
2771 | found = true; | 2771 | found = true; |
2772 | break; | 2772 | break; |
2773 | } | 2773 | } |
2774 | } | 2774 | } |
2775 | external = ! found; | 2775 | external = ! found; |
2776 | } | 2776 | } |
2777 | 2777 | ||
2778 | if ( external ) { | 2778 | if ( external ) { |
2779 | qDebug("Setting vcf mode to external "); | 2779 | qDebug("Setting vcf mode to external "); |
2780 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2780 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2781 | AddressBook::Iterator it; | 2781 | AddressBook::Iterator it; |
2782 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2782 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2783 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2783 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2784 | (*it).computeCsum( mCurrentSyncDevice ); | 2784 | (*it).computeCsum( mCurrentSyncDevice ); |
2785 | } | 2785 | } |
2786 | } | 2786 | } |
2787 | } | 2787 | } |
2788 | //AddressBook::Iterator it; | 2788 | //AddressBook::Iterator it; |
2789 | //QStringList vcards; | 2789 | //QStringList vcards; |
2790 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2790 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2791 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2791 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2792 | //} | 2792 | //} |
2793 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2793 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2794 | if ( syncOK ) { | 2794 | if ( syncOK ) { |
2795 | if ( syncManager->mWriteBackFile ) | 2795 | if ( syncManager->mWriteBackFile ) |
2796 | { | 2796 | { |
2797 | if ( external ) | 2797 | if ( external ) |
2798 | abLocal.removeSyncAddressees( !isXML); | 2798 | abLocal.removeSyncAddressees( !isXML); |
2799 | qDebug("Saving remote AB "); | 2799 | qDebug("Saving remote AB "); |
2800 | abLocal.saveAB(); | 2800 | abLocal.saveAB(); |
2801 | if ( isXML ) { | 2801 | if ( isXML ) { |
2802 | // afterwrite processing | 2802 | // afterwrite processing |
2803 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2803 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2804 | } | 2804 | } |
2805 | } | 2805 | } |
2806 | } | 2806 | } |
2807 | setModified(); | 2807 | setModified(); |
2808 | 2808 | ||
2809 | } | 2809 | } |
2810 | if ( syncOK ) | 2810 | if ( syncOK ) |
2811 | mViewManager->refreshView(); | 2811 | mViewManager->refreshView(); |
2812 | return syncOK; | 2812 | return syncOK; |
2813 | #if 0 | 2813 | #if 0 |
2814 | 2814 | ||
2815 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2815 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2816 | getEventViewerDialog()->setSyncMode( true ); | 2816 | getEventViewerDialog()->setSyncMode( true ); |
2817 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2817 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2818 | getEventViewerDialog()->setSyncMode( false ); | 2818 | getEventViewerDialog()->setSyncMode( false ); |
2819 | if ( syncOK ) { | 2819 | if ( syncOK ) { |
2820 | if ( KOPrefs::instance()->mWriteBackFile ) | 2820 | if ( KOPrefs::instance()->mWriteBackFile ) |
2821 | { | 2821 | { |
2822 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2822 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2823 | storage->save(); | 2823 | storage->save(); |
2824 | } | 2824 | } |
2825 | } | 2825 | } |
2826 | setModified(); | 2826 | setModified(); |
2827 | } | 2827 | } |
2828 | 2828 | ||
2829 | #endif | 2829 | #endif |
2830 | } | 2830 | } |
2831 | 2831 | ||
2832 | 2832 | ||
2833 | //this is a overwritten callbackmethods from the syncinterface | 2833 | //this is a overwritten callbackmethods from the syncinterface |
2834 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2834 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2835 | { | 2835 | { |
2836 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2836 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2837 | 2837 | ||
2838 | AddressBook abLocal( resource,"syncContact"); | 2838 | AddressBook abLocal( resource,"syncContact"); |
2839 | bool syncOK = false; | 2839 | bool syncOK = false; |
2840 | if ( abLocal.load() ) { | 2840 | if ( abLocal.load() ) { |
2841 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2841 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2842 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2842 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2843 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2843 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2844 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2844 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2845 | if ( syncOK ) { | 2845 | if ( syncOK ) { |
2846 | if ( syncManager->mWriteBackFile ) { | 2846 | if ( syncManager->mWriteBackFile ) { |
2847 | abLocal.saveAB(); | 2847 | abLocal.saveAB(); |
2848 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2848 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2849 | } | 2849 | } |
2850 | } | 2850 | } |
2851 | setModified(); | 2851 | setModified(); |
2852 | } | 2852 | } |
2853 | if ( syncOK ) | 2853 | if ( syncOK ) |
2854 | mViewManager->refreshView(); | 2854 | mViewManager->refreshView(); |
2855 | return syncOK; | 2855 | return syncOK; |
2856 | 2856 | ||
2857 | } | 2857 | } |
2858 | 2858 | ||
2859 | void KABCore::getFile( bool success ) | 2859 | void KABCore::getFile( bool success ) |
2860 | { | 2860 | { |
2861 | qDebug("KABCore::getFile "); | ||
2862 | QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); | 2861 | QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); |
2863 | if ( ! success ) { | 2862 | if ( ! success ) { |
2864 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2863 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2865 | return; | 2864 | return; |
2866 | } | 2865 | } |
2867 | mAddressBook->importFromFile( sentSyncFile() ); | 2866 | mAddressBook->importFromFile( sentSyncFile() ); |
2868 | topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); | 2867 | topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); |
2868 | mViewManager->refreshView(); | ||
2869 | } | 2869 | } |
2870 | void KABCore::syncFileRequest() | 2870 | void KABCore::syncFileRequest() |
2871 | { | 2871 | { |
2872 | mAddressBook->export2File( sentSyncFile() ); | 2872 | mAddressBook->export2File( sentSyncFile() ); |
2873 | } | 2873 | } |
2874 | QString KABCore::sentSyncFile() | 2874 | QString KABCore::sentSyncFile() |
2875 | { | 2875 | { |
2876 | #ifdef _WIN32_ | 2876 | #ifdef _WIN32_ |
2877 | return locateLocal( "tmp", "copysyncab.vcf" ); | 2877 | return locateLocal( "tmp", "copysyncab.vcf" ); |
2878 | #else | 2878 | #else |
2879 | return QString( "/tmp/copysyncab.vcf" ); | 2879 | return QString( "/tmp/copysyncab.vcf" ); |
2880 | #endif | 2880 | #endif |
2881 | } | 2881 | } |
2882 | 2882 | ||
2883 | void KABCore::setCaptionBack() | 2883 | void KABCore::setCaptionBack() |
2884 | { | 2884 | { |
2885 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 2885 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
2886 | } | 2886 | } |
2887 | 2887 | ||
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index aad48d9..32400af 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h | |||
@@ -1,227 +1,227 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | $Id$ | 20 | $Id$ |
21 | */ | 21 | */ |
22 | #ifndef _KSYNCMANAGER_H | 22 | #ifndef _KSYNCMANAGER_H |
23 | #define _KSYNCMANAGER_H | 23 | #define _KSYNCMANAGER_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qsocket.h> | 27 | #include <qsocket.h> |
28 | #include <qdatetime.h> | 28 | #include <qdatetime.h> |
29 | #include <qserversocket.h> | 29 | #include <qserversocket.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | 32 | ||
33 | class QPopupMenu; | 33 | class QPopupMenu; |
34 | class KSyncProfile; | 34 | class KSyncProfile; |
35 | class KPimPrefs; | 35 | class KPimPrefs; |
36 | class QWidget; | 36 | class QWidget; |
37 | class KSyncManager; | 37 | class KSyncManager; |
38 | class KSyncInterface; | 38 | class KSyncInterface; |
39 | class QProgressBar; | 39 | class QProgressBar; |
40 | 40 | ||
41 | 41 | ||
42 | class KServerSocket : public QServerSocket | 42 | class KServerSocket : public QServerSocket |
43 | { | 43 | { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | 45 | ||
46 | public: | 46 | public: |
47 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); | 47 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); |
48 | 48 | ||
49 | void newConnection ( int socket ) ; | 49 | void newConnection ( int socket ) ; |
50 | void setFileName( QString fn ) {mFileName = fn;}; | 50 | void setFileName( QString fn ) {mFileName = fn;}; |
51 | 51 | ||
52 | signals: | 52 | signals: |
53 | void file_received( bool ); | 53 | void file_received( bool ); |
54 | void request_file(); | 54 | void request_file(); |
55 | void saveFile(); | 55 | void saveFile(); |
56 | void endConnect(); | 56 | void endConnect(); |
57 | private slots: | 57 | private slots: |
58 | void discardClient(); | 58 | void discardClient(); |
59 | void readClient(); | 59 | void readClient(); |
60 | void readBackFileFromSocket(); | 60 | void readBackFileFromSocket(); |
61 | private : | 61 | private : |
62 | bool blockRC; | 62 | bool blockRC; |
63 | void send_file(); | 63 | void send_file(); |
64 | void get_file(); | 64 | void get_file(); |
65 | void end_connect(); | 65 | void end_connect(); |
66 | QDialog* mSyncActionDialog; | 66 | QDialog* mSyncActionDialog; |
67 | QSocket* mSocket; | 67 | QSocket* mSocket; |
68 | QString mPassWord; | 68 | QString mPassWord; |
69 | QString mFileName; | 69 | QString mFileName; |
70 | QTime piTime; | 70 | QTime piTime; |
71 | QString piFileString; | 71 | QString piFileString; |
72 | }; | 72 | }; |
73 | 73 | ||
74 | class KCommandSocket : public QObject | 74 | class KCommandSocket : public QObject |
75 | { | 75 | { |
76 | Q_OBJECT | 76 | Q_OBJECT |
77 | public: | 77 | public: |
78 | enum state { successR, errorR, successW, errorW, quiet }; | 78 | enum state { successR, errorR, successW, errorW, quiet }; |
79 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); | 79 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); |
80 | void readFile( QString ); | 80 | void readFile( QString ); |
81 | void writeFile( QString ); | 81 | void writeFile( QString ); |
82 | void sendStop(); | 82 | void sendStop(); |
83 | 83 | ||
84 | 84 | ||
85 | signals: | 85 | signals: |
86 | void commandFinished( KCommandSocket*, int ); | 86 | void commandFinished( KCommandSocket*, int ); |
87 | private slots: | 87 | private slots: |
88 | void startReadFileFromSocket(); | 88 | void startReadFileFromSocket(); |
89 | void readFileFromSocket(); | 89 | void readFileFromSocket(); |
90 | void deleteSocket(); | 90 | void deleteSocket(); |
91 | void writeFileToSocket(); | 91 | void writeFileToSocket(); |
92 | private : | 92 | private : |
93 | QSocket* mSocket; | 93 | QSocket* mSocket; |
94 | QString mPassWord; | 94 | QString mPassWord; |
95 | Q_UINT16 mPort; | 95 | Q_UINT16 mPort; |
96 | QString mHost; | 96 | QString mHost; |
97 | QString mFileName; | 97 | QString mFileName; |
98 | QTimer* mTimerSocket; | 98 | QTimer* mTimerSocket; |
99 | int mRetVal; | 99 | int mRetVal; |
100 | QTime mTime; | 100 | QTime mTime; |
101 | QString mFileString; | 101 | QString mFileString; |
102 | bool mFirst; | 102 | bool mFirst; |
103 | }; | 103 | }; |
104 | 104 | ||
105 | 105 | ||
106 | class KSyncManager : public QObject | 106 | class KSyncManager : public QObject |
107 | { | 107 | { |
108 | Q_OBJECT | 108 | Q_OBJECT |
109 | 109 | ||
110 | public: | 110 | public: |
111 | enum TargetApp { | 111 | enum TargetApp { |
112 | KOPI = 0, | 112 | KOPI = 0, |
113 | KAPI = 1, | 113 | KAPI = 1, |
114 | PWMPI = 2 }; | 114 | PWMPI = 2 }; |
115 | 115 | ||
116 | 116 | ||
117 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); | 117 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); |
118 | ~KSyncManager() ; | 118 | ~KSyncManager() ; |
119 | 119 | ||
120 | bool blockSave() { return mBlockSaveFlag; } | 120 | bool blockSave() { return mBlockSaveFlag; } |
121 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } | 121 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } |
122 | void setDefaultFileName( QString s) { mDefFileName = s ;} | 122 | void setDefaultFileName( QString s) { mDefFileName = s ;} |
123 | QString defaultFileName() { return mDefFileName ;} | 123 | QString defaultFileName() { return mDefFileName ;} |
124 | QString syncFileName(); | 124 | QString syncFileName(); |
125 | void fillSyncMenu(); | ||
126 | 125 | ||
127 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } | 126 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } |
128 | QString getCurrentSyncName() { return mCurrentSyncName; } | 127 | QString getCurrentSyncName() { return mCurrentSyncName; } |
129 | 128 | ||
130 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); | 129 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); |
131 | void hideProgressBar(); | 130 | void hideProgressBar(); |
132 | bool isProgressBarCanceled(); | 131 | bool isProgressBarCanceled(); |
133 | 132 | ||
134 | // sync stuff | 133 | // sync stuff |
135 | QString mLocalMachineName; | 134 | QString mLocalMachineName; |
136 | QStringList mExternSyncProfiles; | 135 | QStringList mExternSyncProfiles; |
137 | QStringList mSyncProfileNames; | 136 | QStringList mSyncProfileNames; |
138 | bool mAskForPreferences; | 137 | bool mAskForPreferences; |
139 | bool mShowSyncSummary; | 138 | bool mShowSyncSummary; |
140 | bool mShowSyncEvents; | 139 | bool mShowSyncEvents; |
141 | bool mShowTodoInAgenda; | 140 | bool mShowTodoInAgenda; |
142 | bool mWriteBackExistingOnly; | 141 | bool mWriteBackExistingOnly; |
143 | int mSyncAlgoPrefs; | 142 | int mSyncAlgoPrefs; |
144 | int mRingSyncAlgoPrefs; | 143 | int mRingSyncAlgoPrefs; |
145 | bool mWriteBackFile; | 144 | bool mWriteBackFile; |
146 | int mWriteBackInFuture; | 145 | int mWriteBackInFuture; |
147 | QString mPhoneDevice; | 146 | QString mPhoneDevice; |
148 | QString mPhoneConnection; | 147 | QString mPhoneConnection; |
149 | QString mPhoneModel; | 148 | QString mPhoneModel; |
150 | QString mLastSyncedLocalFile; // save! | 149 | QString mLastSyncedLocalFile; // save! |
151 | QString mPassWordPiSync; | 150 | QString mPassWordPiSync; |
152 | QString mActiveSyncPort; | 151 | QString mActiveSyncPort; |
153 | QString mActiveSyncIP ; | 152 | QString mActiveSyncIP ; |
154 | 153 | ||
155 | signals: | 154 | signals: |
156 | void save(); | 155 | void save(); |
157 | void request_file(); | 156 | void request_file(); |
158 | void getFile( bool ); | 157 | void getFile( bool ); |
159 | 158 | ||
160 | public slots: | 159 | public slots: |
160 | void fillSyncMenu(); | ||
161 | void slotSyncMenu( int ); | 161 | void slotSyncMenu( int ); |
162 | void deleteCommandSocket(KCommandSocket*s, int state); | 162 | void deleteCommandSocket(KCommandSocket*s, int state); |
163 | void readFileFromSocket(); | 163 | void readFileFromSocket(); |
164 | 164 | ||
165 | private: | 165 | private: |
166 | // LR ******************************* | 166 | // LR ******************************* |
167 | // sync stuff! | 167 | // sync stuff! |
168 | void syncPi(); | 168 | void syncPi(); |
169 | KServerSocket * mServerSocket; | 169 | KServerSocket * mServerSocket; |
170 | void enableQuick(); | 170 | void enableQuick(); |
171 | KPimPrefs* mPrefs; | 171 | KPimPrefs* mPrefs; |
172 | QString mDefFileName; | 172 | QString mDefFileName; |
173 | QString mCurrentSyncDevice; | 173 | QString mCurrentSyncDevice; |
174 | QString mCurrentSyncName; | 174 | QString mCurrentSyncName; |
175 | void quickSyncLocalFile(); | 175 | void quickSyncLocalFile(); |
176 | bool syncWithFile( QString fn , bool quick ); | 176 | bool syncWithFile( QString fn , bool quick ); |
177 | void syncLocalFile(); | 177 | void syncLocalFile(); |
178 | void syncPhone(); | 178 | void syncPhone(); |
179 | void syncSharp(); | 179 | void syncSharp(); |
180 | bool syncExternalApplication(QString); | 180 | bool syncExternalApplication(QString); |
181 | void multiSync( bool askforPrefs ); | 181 | void multiSync( bool askforPrefs ); |
182 | int mCurrentSyncProfile ; | 182 | int mCurrentSyncProfile ; |
183 | void syncRemote( KSyncProfile* prof, bool ask = true); | 183 | void syncRemote( KSyncProfile* prof, bool ask = true); |
184 | void edit_sync_options(); | 184 | void edit_sync_options(); |
185 | int ringSync(); | 185 | int ringSync(); |
186 | QString getPassword( ); | 186 | QString getPassword( ); |
187 | 187 | ||
188 | private slots: | 188 | private slots: |
189 | void confSync(); | 189 | void confSync(); |
190 | // ********************* | 190 | // ********************* |
191 | 191 | ||
192 | private: | 192 | private: |
193 | bool mBlockSaveFlag; | 193 | bool mBlockSaveFlag; |
194 | 194 | ||
195 | 195 | ||
196 | QWidget* mParent; | 196 | QWidget* mParent; |
197 | KSyncInterface* mImplementation; | 197 | KSyncInterface* mImplementation; |
198 | TargetApp mTargetApp; | 198 | TargetApp mTargetApp; |
199 | QPopupMenu* mSyncMenu; | 199 | QPopupMenu* mSyncMenu; |
200 | 200 | ||
201 | QProgressBar* bar; | 201 | QProgressBar* bar; |
202 | 202 | ||
203 | 203 | ||
204 | 204 | ||
205 | 205 | ||
206 | 206 | ||
207 | }; | 207 | }; |
208 | 208 | ||
209 | 209 | ||
210 | class KSyncInterface | 210 | class KSyncInterface |
211 | { | 211 | { |
212 | 212 | ||
213 | 213 | ||
214 | public : | 214 | public : |
215 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; | 215 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; |
216 | 216 | ||
217 | virtual bool syncExternal(KSyncManager* manager, QString resource) | 217 | virtual bool syncExternal(KSyncManager* manager, QString resource) |
218 | { | 218 | { |
219 | // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager. | 219 | // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager. |
220 | return false; | 220 | return false; |
221 | } | 221 | } |
222 | 222 | ||
223 | 223 | ||
224 | }; | 224 | }; |
225 | 225 | ||
226 | 226 | ||
227 | #endif | 227 | #endif |