author | zautrix <zautrix> | 2005-01-17 19:49:42 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-17 19:49:42 (UTC) |
commit | 522486966ecf041a6e49913b6e420d58d4284837 (patch) (unidiff) | |
tree | d15da3e6ef9ec4638eba4aaf9f14ef0c5eaecd04 | |
parent | 32479683283fc9f20d369ac9671ba0f8a33d3381 (diff) | |
download | kdepimpi-522486966ecf041a6e49913b6e420d58d4284837.zip kdepimpi-522486966ecf041a6e49913b6e420d58d4284837.tar.gz kdepimpi-522486966ecf041a6e49913b6e420d58d4284837.tar.bz2 |
const fixes
-rw-r--r-- | kabc/addressbook.cpp | 4 | ||||
-rw-r--r-- | kabc/addressbook.h | 2 | ||||
-rw-r--r-- | kabc/addressee.cpp | 10 | ||||
-rw-r--r-- | kabc/addressee.h | 10 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 33 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 2 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 5 | ||||
-rw-r--r-- | libkdepim/ksyncprefsdialog.cpp | 2 | ||||
-rw-r--r-- | microkde/kidmanager.cpp | 10 | ||||
-rw-r--r-- | microkde/kidmanager.h | 10 |
10 files changed, 55 insertions, 33 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 4de7da2..9e61261 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -1,1266 +1,1266 @@ | |||
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 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | 44 | ||
45 | #include <kglobal.h> | 45 | #include <kglobal.h> |
46 | #include <klocale.h> | 46 | #include <klocale.h> |
47 | #include <kmessagebox.h> | 47 | #include <kmessagebox.h> |
48 | #include <kdebug.h> | 48 | #include <kdebug.h> |
49 | #include <libkcal/syncdefines.h> | 49 | #include <libkcal/syncdefines.h> |
50 | #include <libkdepim/phoneaccess.h> | 50 | #include <libkdepim/phoneaccess.h> |
51 | #include "addressbook.h" | 51 | #include "addressbook.h" |
52 | #include "resource.h" | 52 | #include "resource.h" |
53 | #include "vcardconverter.h" | 53 | #include "vcardconverter.h" |
54 | #include "vcardparser/vcardtool.h" | 54 | #include "vcardparser/vcardtool.h" |
55 | 55 | ||
56 | //US #include "addressbook.moc" | 56 | //US #include "addressbook.moc" |
57 | 57 | ||
58 | using namespace KABC; | 58 | using namespace KABC; |
59 | 59 | ||
60 | struct AddressBook::AddressBookData | 60 | struct AddressBook::AddressBookData |
61 | { | 61 | { |
62 | Addressee::List mAddressees; | 62 | Addressee::List mAddressees; |
63 | Addressee::List mRemovedAddressees; | 63 | Addressee::List mRemovedAddressees; |
64 | Field::List mAllFields; | 64 | Field::List mAllFields; |
65 | KConfig *mConfig; | 65 | KConfig *mConfig; |
66 | KRES::Manager<Resource> *mManager; | 66 | KRES::Manager<Resource> *mManager; |
67 | //US ErrorHandler *mErrorHandler; | 67 | //US ErrorHandler *mErrorHandler; |
68 | }; | 68 | }; |
69 | 69 | ||
70 | struct AddressBook::Iterator::IteratorData | 70 | struct AddressBook::Iterator::IteratorData |
71 | { | 71 | { |
72 | Addressee::List::Iterator mIt; | 72 | Addressee::List::Iterator mIt; |
73 | }; | 73 | }; |
74 | 74 | ||
75 | struct AddressBook::ConstIterator::ConstIteratorData | 75 | struct AddressBook::ConstIterator::ConstIteratorData |
76 | { | 76 | { |
77 | Addressee::List::ConstIterator mIt; | 77 | Addressee::List::ConstIterator mIt; |
78 | }; | 78 | }; |
79 | 79 | ||
80 | AddressBook::Iterator::Iterator() | 80 | AddressBook::Iterator::Iterator() |
81 | { | 81 | { |
82 | d = new IteratorData; | 82 | d = new IteratorData; |
83 | } | 83 | } |
84 | 84 | ||
85 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) | 85 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) |
86 | { | 86 | { |
87 | d = new IteratorData; | 87 | d = new IteratorData; |
88 | d->mIt = i.d->mIt; | 88 | d->mIt = i.d->mIt; |
89 | } | 89 | } |
90 | 90 | ||
91 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) | 91 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) |
92 | { | 92 | { |
93 | if( this == &i ) return *this; // guard against self assignment | 93 | if( this == &i ) return *this; // guard against self assignment |
94 | delete d; // delete the old data the Iterator was completely constructed before | 94 | delete d; // delete the old data the Iterator was completely constructed before |
95 | d = new IteratorData; | 95 | d = new IteratorData; |
96 | d->mIt = i.d->mIt; | 96 | d->mIt = i.d->mIt; |
97 | return *this; | 97 | return *this; |
98 | } | 98 | } |
99 | 99 | ||
100 | AddressBook::Iterator::~Iterator() | 100 | AddressBook::Iterator::~Iterator() |
101 | { | 101 | { |
102 | delete d; | 102 | delete d; |
103 | } | 103 | } |
104 | 104 | ||
105 | const Addressee &AddressBook::Iterator::operator*() const | 105 | const Addressee &AddressBook::Iterator::operator*() const |
106 | { | 106 | { |
107 | return *(d->mIt); | 107 | return *(d->mIt); |
108 | } | 108 | } |
109 | 109 | ||
110 | Addressee &AddressBook::Iterator::operator*() | 110 | Addressee &AddressBook::Iterator::operator*() |
111 | { | 111 | { |
112 | return *(d->mIt); | 112 | return *(d->mIt); |
113 | } | 113 | } |
114 | 114 | ||
115 | Addressee *AddressBook::Iterator::operator->() | 115 | Addressee *AddressBook::Iterator::operator->() |
116 | { | 116 | { |
117 | return &(*(d->mIt)); | 117 | return &(*(d->mIt)); |
118 | } | 118 | } |
119 | 119 | ||
120 | AddressBook::Iterator &AddressBook::Iterator::operator++() | 120 | AddressBook::Iterator &AddressBook::Iterator::operator++() |
121 | { | 121 | { |
122 | (d->mIt)++; | 122 | (d->mIt)++; |
123 | return *this; | 123 | return *this; |
124 | } | 124 | } |
125 | 125 | ||
126 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) | 126 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) |
127 | { | 127 | { |
128 | (d->mIt)++; | 128 | (d->mIt)++; |
129 | return *this; | 129 | return *this; |
130 | } | 130 | } |
131 | 131 | ||
132 | AddressBook::Iterator &AddressBook::Iterator::operator--() | 132 | AddressBook::Iterator &AddressBook::Iterator::operator--() |
133 | { | 133 | { |
134 | (d->mIt)--; | 134 | (d->mIt)--; |
135 | return *this; | 135 | return *this; |
136 | } | 136 | } |
137 | 137 | ||
138 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) | 138 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) |
139 | { | 139 | { |
140 | (d->mIt)--; | 140 | (d->mIt)--; |
141 | return *this; | 141 | return *this; |
142 | } | 142 | } |
143 | 143 | ||
144 | bool AddressBook::Iterator::operator==( const Iterator &it ) | 144 | bool AddressBook::Iterator::operator==( const Iterator &it ) |
145 | { | 145 | { |
146 | return ( d->mIt == it.d->mIt ); | 146 | return ( d->mIt == it.d->mIt ); |
147 | } | 147 | } |
148 | 148 | ||
149 | bool AddressBook::Iterator::operator!=( const Iterator &it ) | 149 | bool AddressBook::Iterator::operator!=( const Iterator &it ) |
150 | { | 150 | { |
151 | return ( d->mIt != it.d->mIt ); | 151 | return ( d->mIt != it.d->mIt ); |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | AddressBook::ConstIterator::ConstIterator() | 155 | AddressBook::ConstIterator::ConstIterator() |
156 | { | 156 | { |
157 | d = new ConstIteratorData; | 157 | d = new ConstIteratorData; |
158 | } | 158 | } |
159 | 159 | ||
160 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) | 160 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) |
161 | { | 161 | { |
162 | d = new ConstIteratorData; | 162 | d = new ConstIteratorData; |
163 | d->mIt = i.d->mIt; | 163 | d->mIt = i.d->mIt; |
164 | } | 164 | } |
165 | 165 | ||
166 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) | 166 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) |
167 | { | 167 | { |
168 | if( this == &i ) return *this; // guard for self assignment | 168 | if( this == &i ) return *this; // guard for self assignment |
169 | delete d; // delete the old data because the Iterator was really constructed before | 169 | delete d; // delete the old data because the Iterator was really constructed before |
170 | d = new ConstIteratorData; | 170 | d = new ConstIteratorData; |
171 | d->mIt = i.d->mIt; | 171 | d->mIt = i.d->mIt; |
172 | return *this; | 172 | return *this; |
173 | } | 173 | } |
174 | 174 | ||
175 | AddressBook::ConstIterator::~ConstIterator() | 175 | AddressBook::ConstIterator::~ConstIterator() |
176 | { | 176 | { |
177 | delete d; | 177 | delete d; |
178 | } | 178 | } |
179 | 179 | ||
180 | const Addressee &AddressBook::ConstIterator::operator*() const | 180 | const Addressee &AddressBook::ConstIterator::operator*() const |
181 | { | 181 | { |
182 | return *(d->mIt); | 182 | return *(d->mIt); |
183 | } | 183 | } |
184 | 184 | ||
185 | const Addressee* AddressBook::ConstIterator::operator->() const | 185 | const Addressee* AddressBook::ConstIterator::operator->() const |
186 | { | 186 | { |
187 | return &(*(d->mIt)); | 187 | return &(*(d->mIt)); |
188 | } | 188 | } |
189 | 189 | ||
190 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() | 190 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() |
191 | { | 191 | { |
192 | (d->mIt)++; | 192 | (d->mIt)++; |
193 | return *this; | 193 | return *this; |
194 | } | 194 | } |
195 | 195 | ||
196 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) | 196 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) |
197 | { | 197 | { |
198 | (d->mIt)++; | 198 | (d->mIt)++; |
199 | return *this; | 199 | return *this; |
200 | } | 200 | } |
201 | 201 | ||
202 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() | 202 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() |
203 | { | 203 | { |
204 | (d->mIt)--; | 204 | (d->mIt)--; |
205 | return *this; | 205 | return *this; |
206 | } | 206 | } |
207 | 207 | ||
208 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) | 208 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) |
209 | { | 209 | { |
210 | (d->mIt)--; | 210 | (d->mIt)--; |
211 | return *this; | 211 | return *this; |
212 | } | 212 | } |
213 | 213 | ||
214 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) | 214 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) |
215 | { | 215 | { |
216 | return ( d->mIt == it.d->mIt ); | 216 | return ( d->mIt == it.d->mIt ); |
217 | } | 217 | } |
218 | 218 | ||
219 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 219 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) |
220 | { | 220 | { |
221 | return ( d->mIt != it.d->mIt ); | 221 | return ( d->mIt != it.d->mIt ); |
222 | } | 222 | } |
223 | 223 | ||
224 | 224 | ||
225 | AddressBook::AddressBook() | 225 | AddressBook::AddressBook() |
226 | { | 226 | { |
227 | init(0, "contact"); | 227 | init(0, "contact"); |
228 | } | 228 | } |
229 | 229 | ||
230 | AddressBook::AddressBook( const QString &config ) | 230 | AddressBook::AddressBook( const QString &config ) |
231 | { | 231 | { |
232 | init(config, "contact"); | 232 | init(config, "contact"); |
233 | } | 233 | } |
234 | 234 | ||
235 | AddressBook::AddressBook( const QString &config, const QString &family ) | 235 | AddressBook::AddressBook( const QString &config, const QString &family ) |
236 | { | 236 | { |
237 | init(config, family); | 237 | init(config, family); |
238 | 238 | ||
239 | } | 239 | } |
240 | 240 | ||
241 | // the default family is "contact" | 241 | // the default family is "contact" |
242 | void AddressBook::init(const QString &config, const QString &family ) | 242 | void AddressBook::init(const QString &config, const QString &family ) |
243 | { | 243 | { |
244 | blockLSEchange = false; | 244 | blockLSEchange = false; |
245 | d = new AddressBookData; | 245 | d = new AddressBookData; |
246 | QString fami = family; | 246 | QString fami = family; |
247 | if (config != 0) { | 247 | if (config != 0) { |
248 | if ( family == "syncContact" ) { | 248 | if ( family == "syncContact" ) { |
249 | qDebug("creating sync config "); | 249 | qDebug("creating sync config "); |
250 | fami = "contact"; | 250 | fami = "contact"; |
251 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); | 251 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); |
252 | con->setGroup( "General" ); | 252 | con->setGroup( "General" ); |
253 | con->writeEntry( "ResourceKeys", QString("sync") ); | 253 | con->writeEntry( "ResourceKeys", QString("sync") ); |
254 | con->writeEntry( "Standard", QString("sync") ); | 254 | con->writeEntry( "Standard", QString("sync") ); |
255 | con->setGroup( "Resource_sync" ); | 255 | con->setGroup( "Resource_sync" ); |
256 | con->writeEntry( "FileName", config ); | 256 | con->writeEntry( "FileName", config ); |
257 | con->writeEntry( "FileFormat", QString("vcard") ); | 257 | con->writeEntry( "FileFormat", QString("vcard") ); |
258 | con->writeEntry( "ResourceIdentifier", QString("sync") ); | 258 | con->writeEntry( "ResourceIdentifier", QString("sync") ); |
259 | con->writeEntry( "ResourceName", QString("sync_res") ); | 259 | con->writeEntry( "ResourceName", QString("sync_res") ); |
260 | if ( config.right(4) == ".xml" ) | 260 | if ( config.right(4) == ".xml" ) |
261 | con->writeEntry( "ResourceType", QString("qtopia") ); | 261 | con->writeEntry( "ResourceType", QString("qtopia") ); |
262 | else if ( config == "sharp" ) { | 262 | else if ( config == "sharp" ) { |
263 | con->writeEntry( "ResourceType", QString("sharp") ); | 263 | con->writeEntry( "ResourceType", QString("sharp") ); |
264 | } else { | 264 | } else { |
265 | con->writeEntry( "ResourceType", QString("file") ); | 265 | con->writeEntry( "ResourceType", QString("file") ); |
266 | } | 266 | } |
267 | //con->sync(); | 267 | //con->sync(); |
268 | d->mConfig = con; | 268 | d->mConfig = con; |
269 | } | 269 | } |
270 | else | 270 | else |
271 | d->mConfig = new KConfig( locateLocal("config", config) ); | 271 | d->mConfig = new KConfig( locateLocal("config", config) ); |
272 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 272 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
273 | } | 273 | } |
274 | else { | 274 | else { |
275 | d->mConfig = 0; | 275 | d->mConfig = 0; |
276 | // qDebug("AddressBook::init 1 config=0"); | 276 | // qDebug("AddressBook::init 1 config=0"); |
277 | } | 277 | } |
278 | 278 | ||
279 | //US d->mErrorHandler = 0; | 279 | //US d->mErrorHandler = 0; |
280 | d->mManager = new KRES::Manager<Resource>( fami ); | 280 | d->mManager = new KRES::Manager<Resource>( fami ); |
281 | d->mManager->readConfig( d->mConfig ); | 281 | d->mManager->readConfig( d->mConfig ); |
282 | if ( family == "syncContact" ) { | 282 | if ( family == "syncContact" ) { |
283 | KRES::Manager<Resource> *manager = d->mManager; | 283 | KRES::Manager<Resource> *manager = d->mManager; |
284 | KRES::Manager<Resource>::ActiveIterator it; | 284 | KRES::Manager<Resource>::ActiveIterator it; |
285 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 285 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
286 | (*it)->setAddressBook( this ); | 286 | (*it)->setAddressBook( this ); |
287 | if ( !(*it)->open() ) | 287 | if ( !(*it)->open() ) |
288 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 288 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
289 | } | 289 | } |
290 | Resource *res = standardResource(); | 290 | Resource *res = standardResource(); |
291 | if ( !res ) { | 291 | if ( !res ) { |
292 | qDebug("ERROR: no standard resource"); | 292 | qDebug("ERROR: no standard resource"); |
293 | res = manager->createResource( "file" ); | 293 | res = manager->createResource( "file" ); |
294 | if ( res ) | 294 | if ( res ) |
295 | { | 295 | { |
296 | addResource( res ); | 296 | addResource( res ); |
297 | } | 297 | } |
298 | else | 298 | else |
299 | qDebug(" No resource available!!!"); | 299 | qDebug(" No resource available!!!"); |
300 | } | 300 | } |
301 | setStandardResource( res ); | 301 | setStandardResource( res ); |
302 | manager->writeConfig(); | 302 | manager->writeConfig(); |
303 | } | 303 | } |
304 | addCustomField( i18n( "Department" ), KABC::Field::Organization, | 304 | addCustomField( i18n( "Department" ), KABC::Field::Organization, |
305 | "X-Department", "KADDRESSBOOK" ); | 305 | "X-Department", "KADDRESSBOOK" ); |
306 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 306 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
307 | "X-Profession", "KADDRESSBOOK" ); | 307 | "X-Profession", "KADDRESSBOOK" ); |
308 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 308 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
309 | "X-AssistantsName", "KADDRESSBOOK" ); | 309 | "X-AssistantsName", "KADDRESSBOOK" ); |
310 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 310 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
311 | "X-ManagersName", "KADDRESSBOOK" ); | 311 | "X-ManagersName", "KADDRESSBOOK" ); |
312 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 312 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
313 | "X-SpousesName", "KADDRESSBOOK" ); | 313 | "X-SpousesName", "KADDRESSBOOK" ); |
314 | addCustomField( i18n( "Office" ), KABC::Field::Personal, | 314 | addCustomField( i18n( "Office" ), KABC::Field::Personal, |
315 | "X-Office", "KADDRESSBOOK" ); | 315 | "X-Office", "KADDRESSBOOK" ); |
316 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 316 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
317 | "X-IMAddress", "KADDRESSBOOK" ); | 317 | "X-IMAddress", "KADDRESSBOOK" ); |
318 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 318 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
319 | "X-Anniversary", "KADDRESSBOOK" ); | 319 | "X-Anniversary", "KADDRESSBOOK" ); |
320 | 320 | ||
321 | //US added this field to become compatible with Opie/qtopia addressbook | 321 | //US added this field to become compatible with Opie/qtopia addressbook |
322 | // values can be "female" or "male" or "". An empty field represents undefined. | 322 | // values can be "female" or "male" or "". An empty field represents undefined. |
323 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 323 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
324 | "X-Gender", "KADDRESSBOOK" ); | 324 | "X-Gender", "KADDRESSBOOK" ); |
325 | addCustomField( i18n( "Children" ), KABC::Field::Personal, | 325 | addCustomField( i18n( "Children" ), KABC::Field::Personal, |
326 | "X-Children", "KADDRESSBOOK" ); | 326 | "X-Children", "KADDRESSBOOK" ); |
327 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 327 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
328 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 328 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
329 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, | 329 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, |
330 | "X-ExternalID", "KADDRESSBOOK" ); | 330 | "X-ExternalID", "KADDRESSBOOK" ); |
331 | } | 331 | } |
332 | 332 | ||
333 | AddressBook::~AddressBook() | 333 | AddressBook::~AddressBook() |
334 | { | 334 | { |
335 | delete d->mConfig; d->mConfig = 0; | 335 | delete d->mConfig; d->mConfig = 0; |
336 | delete d->mManager; d->mManager = 0; | 336 | delete d->mManager; d->mManager = 0; |
337 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 337 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
338 | delete d; d = 0; | 338 | delete d; d = 0; |
339 | } | 339 | } |
340 | 340 | ||
341 | bool AddressBook::load() | 341 | bool AddressBook::load() |
342 | { | 342 | { |
343 | 343 | ||
344 | clear(); | 344 | clear(); |
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 | qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 349 | qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
350 | ok = false; | 350 | ok = false; |
351 | } else { | 351 | } else { |
352 | qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) ); | 352 | qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) ); |
353 | } | 353 | } |
354 | // mark all addressees as unchanged | 354 | // mark all addressees as unchanged |
355 | Addressee::List::Iterator addrIt; | 355 | Addressee::List::Iterator addrIt; |
356 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { | 356 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { |
357 | (*addrIt).setChanged( false ); | 357 | (*addrIt).setChanged( false ); |
358 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); | 358 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); |
359 | if ( !id.isEmpty() ) { | 359 | if ( !id.isEmpty() ) { |
360 | //qDebug("setId aa %s ", id.latin1()); | 360 | //qDebug("setId aa %s ", id.latin1()); |
361 | (*addrIt).setIDStr(id ); | 361 | (*addrIt).setIDStr(id ); |
362 | } | 362 | } |
363 | } | 363 | } |
364 | blockLSEchange = true; | 364 | blockLSEchange = true; |
365 | return ok; | 365 | return ok; |
366 | } | 366 | } |
367 | 367 | ||
368 | bool AddressBook::save( Ticket *ticket ) | 368 | bool AddressBook::save( Ticket *ticket ) |
369 | { | 369 | { |
370 | kdDebug(5700) << "AddressBook::save()"<< endl; | 370 | kdDebug(5700) << "AddressBook::save()"<< endl; |
371 | 371 | ||
372 | if ( ticket->resource() ) { | 372 | if ( ticket->resource() ) { |
373 | deleteRemovedAddressees(); | 373 | deleteRemovedAddressees(); |
374 | return ticket->resource()->save( ticket ); | 374 | return ticket->resource()->save( ticket ); |
375 | } | 375 | } |
376 | 376 | ||
377 | return false; | 377 | return false; |
378 | } | 378 | } |
379 | // exports all Addressees, which are syncable | 379 | // exports all Addressees, which are syncable |
380 | void AddressBook::export2File( QString fileName ) | 380 | void AddressBook::export2File( QString fileName ) |
381 | { | 381 | { |
382 | 382 | ||
383 | QFile outFile( fileName ); | 383 | QFile outFile( fileName ); |
384 | if ( !outFile.open( IO_WriteOnly ) ) { | 384 | if ( !outFile.open( IO_WriteOnly ) ) { |
385 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); | 385 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); |
386 | KMessageBox::error( 0, text.arg( fileName ) ); | 386 | KMessageBox::error( 0, text.arg( fileName ) ); |
387 | return ; | 387 | return ; |
388 | } | 388 | } |
389 | QTextStream t( &outFile ); | 389 | QTextStream t( &outFile ); |
390 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 390 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
391 | Iterator it; | 391 | Iterator it; |
392 | KABC::VCardConverter::Version version; | 392 | KABC::VCardConverter::Version version; |
393 | version = KABC::VCardConverter::v3_0; | 393 | version = KABC::VCardConverter::v3_0; |
394 | for ( it = begin(); it != end(); ++it ) { | 394 | for ( it = begin(); it != end(); ++it ) { |
395 | if ( (*it).resource() && (*it).resource()->includeInSync() ) { | 395 | if ( (*it).resource() && (*it).resource()->includeInSync() ) { |
396 | if ( !(*it).IDStr().isEmpty() ) { | 396 | if ( !(*it).IDStr().isEmpty() ) { |
397 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); | 397 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); |
398 | } | 398 | } |
399 | KABC::VCardConverter converter; | 399 | KABC::VCardConverter converter; |
400 | QString vcard; | 400 | QString vcard; |
401 | //Resource *resource() const; | 401 | //Resource *resource() const; |
402 | converter.addresseeToVCard( *it, vcard, version ); | 402 | converter.addresseeToVCard( *it, vcard, version ); |
403 | t << vcard << "\r\n"; | 403 | t << vcard << "\r\n"; |
404 | } | 404 | } |
405 | } | 405 | } |
406 | t << "\r\n\r\n"; | 406 | t << "\r\n\r\n"; |
407 | outFile.close(); | 407 | outFile.close(); |
408 | } | 408 | } |
409 | // if QStringList uids is empty, all are exported | 409 | // if QStringList uids is empty, all are exported |
410 | bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) | 410 | bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) |
411 | { | 411 | { |
412 | KABC::VCardConverter converter; | 412 | KABC::VCardConverter converter; |
413 | QString datastream; | 413 | QString datastream; |
414 | Iterator it; | 414 | Iterator it; |
415 | bool all = uids.isEmpty(); | 415 | bool all = uids.isEmpty(); |
416 | for ( it = begin(); it != end(); ++it ) { | 416 | for ( it = begin(); it != end(); ++it ) { |
417 | // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 417 | // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
418 | if ( ! all ) { | 418 | if ( ! all ) { |
419 | if ( ! ( uids.contains((*it).uid() ) )) | 419 | if ( ! ( uids.contains((*it).uid() ) )) |
420 | continue; | 420 | continue; |
421 | } | 421 | } |
422 | KABC::Addressee a = ( *it ); | 422 | KABC::Addressee a = ( *it ); |
423 | if ( a.isEmpty() ) | 423 | if ( a.isEmpty() ) |
424 | continue; | 424 | continue; |
425 | if ( all && a.resource() && !a.resource()->includeInSync() ) | 425 | if ( all && a.resource() && !a.resource()->includeInSync() ) |
426 | continue; | 426 | continue; |
427 | a.simplifyEmails(); | 427 | a.simplifyEmails(); |
428 | a.simplifyPhoneNumbers(); | 428 | a.simplifyPhoneNumbers(); |
429 | a.simplifyPhoneNumberTypes(); | 429 | a.simplifyPhoneNumberTypes(); |
430 | a.simplifyAddresses(); | 430 | a.simplifyAddresses(); |
431 | 431 | ||
432 | QString vcard; | 432 | QString vcard; |
433 | QString vcardnew; | 433 | QString vcardnew; |
434 | converter.addresseeToVCard( a, vcard ); | 434 | converter.addresseeToVCard( a, vcard ); |
435 | int start = 0; | 435 | int start = 0; |
436 | int next; | 436 | int next; |
437 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 437 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
438 | int semi = vcard.find(";", next); | 438 | int semi = vcard.find(";", next); |
439 | int dopp = vcard.find(":", next); | 439 | int dopp = vcard.find(":", next); |
440 | int sep; | 440 | int sep; |
441 | if ( semi < dopp && semi >= 0 ) | 441 | if ( semi < dopp && semi >= 0 ) |
442 | sep = semi ; | 442 | sep = semi ; |
443 | else | 443 | else |
444 | sep = dopp; | 444 | sep = dopp; |
445 | vcardnew +=vcard.mid( start, next - start); | 445 | vcardnew +=vcard.mid( start, next - start); |
446 | vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); | 446 | vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); |
447 | start = sep; | 447 | start = sep; |
448 | } | 448 | } |
449 | vcardnew += vcard.mid( start,vcard.length() ); | 449 | vcardnew += vcard.mid( start,vcard.length() ); |
450 | vcard = ""; | 450 | vcard = ""; |
451 | start = 0; | 451 | start = 0; |
452 | while ( (next = vcardnew.find("ADR", start) )>= 0 ) { | 452 | while ( (next = vcardnew.find("ADR", start) )>= 0 ) { |
453 | int sep = vcardnew.find(":", next); | 453 | int sep = vcardnew.find(":", next); |
454 | vcard +=vcardnew.mid( start, next - start+3); | 454 | vcard +=vcardnew.mid( start, next - start+3); |
455 | start = sep; | 455 | start = sep; |
456 | } | 456 | } |
457 | vcard += vcardnew.mid( start,vcardnew.length() ); | 457 | vcard += vcardnew.mid( start,vcardnew.length() ); |
458 | vcard.replace ( QRegExp(";;;") , "" ); | 458 | vcard.replace ( QRegExp(";;;") , "" ); |
459 | vcard.replace ( QRegExp(";;") , "" ); | 459 | vcard.replace ( QRegExp(";;") , "" ); |
460 | datastream += vcard; | 460 | datastream += vcard; |
461 | 461 | ||
462 | } | 462 | } |
463 | 463 | ||
464 | QFile outFile(fileName); | 464 | QFile outFile(fileName); |
465 | if ( outFile.open(IO_WriteOnly) ) { | 465 | if ( outFile.open(IO_WriteOnly) ) { |
466 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 466 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
467 | QTextStream t( &outFile ); // use a text stream | 467 | QTextStream t( &outFile ); // use a text stream |
468 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 468 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
469 | t <<datastream; | 469 | t <<datastream; |
470 | t << "\r\n\r\n"; | 470 | t << "\r\n\r\n"; |
471 | outFile.close(); | 471 | outFile.close(); |
472 | 472 | ||
473 | } else { | 473 | } else { |
474 | qDebug("Error open temp file "); | 474 | qDebug("Error open temp file "); |
475 | return false; | 475 | return false; |
476 | } | 476 | } |
477 | return true; | 477 | return true; |
478 | 478 | ||
479 | } | 479 | } |
480 | int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) | 480 | int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) |
481 | { | 481 | { |
482 | 482 | ||
483 | if ( removeOld ) | 483 | if ( removeOld ) |
484 | setUntagged( true ); | 484 | setUntagged( true ); |
485 | KABC::Addressee::List list; | 485 | KABC::Addressee::List list; |
486 | QFile file( fileName ); | 486 | QFile file( fileName ); |
487 | file.open( IO_ReadOnly ); | 487 | file.open( IO_ReadOnly ); |
488 | QByteArray rawData = file.readAll(); | 488 | QByteArray rawData = file.readAll(); |
489 | file.close(); | 489 | file.close(); |
490 | QString data; | 490 | QString data; |
491 | if ( replaceLabel ) { | 491 | if ( replaceLabel ) { |
492 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); | 492 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); |
493 | data.replace ( QRegExp("LABEL") , "ADR" ); | 493 | data.replace ( QRegExp("LABEL") , "ADR" ); |
494 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); | 494 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); |
495 | } else | 495 | } else |
496 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 496 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
497 | KABC::VCardTool tool; | 497 | KABC::VCardTool tool; |
498 | list = tool.parseVCards( data ); | 498 | list = tool.parseVCards( data ); |
499 | KABC::Addressee::List::Iterator it; | 499 | KABC::Addressee::List::Iterator it; |
500 | for ( it = list.begin(); it != list.end(); ++it ) { | 500 | for ( it = list.begin(); it != list.end(); ++it ) { |
501 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); | 501 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); |
502 | if ( !id.isEmpty() ) | 502 | if ( !id.isEmpty() ) |
503 | (*it).setIDStr(id ); | 503 | (*it).setIDStr(id ); |
504 | (*it).setResource( 0 ); | 504 | (*it).setResource( 0 ); |
505 | if ( replaceLabel ) | 505 | if ( replaceLabel ) |
506 | (*it).removeVoice(); | 506 | (*it).removeVoice(); |
507 | if ( removeOld ) | 507 | if ( removeOld ) |
508 | (*it).setTagged( true ); | 508 | (*it).setTagged( true ); |
509 | insertAddressee( (*it), false, true ); | 509 | insertAddressee( (*it), false, true ); |
510 | } | 510 | } |
511 | if ( removeOld ) | 511 | if ( removeOld ) |
512 | removeUntagged(); | 512 | removeUntagged(); |
513 | return list.count(); | 513 | return list.count(); |
514 | } | 514 | } |
515 | void AddressBook::setUntagged(bool setNonSyncTagged) // = false) | 515 | void AddressBook::setUntagged(bool setNonSyncTagged) // = false) |
516 | { | 516 | { |
517 | Iterator ait; | 517 | Iterator ait; |
518 | for ( ait = begin(); ait != end(); ++ait ) { | 518 | for ( ait = begin(); ait != end(); ++ait ) { |
519 | if ( setNonSyncTagged ) { | 519 | if ( setNonSyncTagged ) { |
520 | if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { | 520 | if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { |
521 | (*ait).setTagged( true ); | 521 | (*ait).setTagged( true ); |
522 | } else | 522 | } else |
523 | (*ait).setTagged( false ); | 523 | (*ait).setTagged( false ); |
524 | } else | 524 | } else |
525 | (*ait).setTagged( false ); | 525 | (*ait).setTagged( false ); |
526 | } | 526 | } |
527 | } | 527 | } |
528 | void AddressBook::removeUntagged() | 528 | void AddressBook::removeUntagged() |
529 | { | 529 | { |
530 | Iterator ait; | 530 | Iterator ait; |
531 | bool todelete = false; | 531 | bool todelete = false; |
532 | Iterator todel; | 532 | Iterator todel; |
533 | for ( ait = begin(); ait != end(); ++ait ) { | 533 | for ( ait = begin(); ait != end(); ++ait ) { |
534 | if ( todelete ) | 534 | if ( todelete ) |
535 | removeAddressee( todel ); | 535 | removeAddressee( todel ); |
536 | if (!(*ait).tagged()) { | 536 | if (!(*ait).tagged()) { |
537 | todelete = true; | 537 | todelete = true; |
538 | todel = ait; | 538 | todel = ait; |
539 | } else | 539 | } else |
540 | todelete = false; | 540 | todelete = false; |
541 | } | 541 | } |
542 | if ( todelete ) | 542 | if ( todelete ) |
543 | removeAddressee( todel ); | 543 | removeAddressee( todel ); |
544 | deleteRemovedAddressees(); | 544 | deleteRemovedAddressees(); |
545 | } | 545 | } |
546 | void AddressBook::smplifyAddressees() | 546 | void AddressBook::smplifyAddressees() |
547 | { | 547 | { |
548 | Iterator ait; | 548 | Iterator ait; |
549 | for ( ait = begin(); ait != end(); ++ait ) { | 549 | for ( ait = begin(); ait != end(); ++ait ) { |
550 | (*ait).simplifyEmails(); | 550 | (*ait).simplifyEmails(); |
551 | (*ait).simplifyPhoneNumbers(); | 551 | (*ait).simplifyPhoneNumbers(); |
552 | (*ait).simplifyPhoneNumberTypes(); | 552 | (*ait).simplifyPhoneNumberTypes(); |
553 | (*ait).simplifyAddresses(); | 553 | (*ait).simplifyAddresses(); |
554 | } | 554 | } |
555 | } | 555 | } |
556 | void AddressBook::removeSyncInfo( QString syncProfile) | 556 | void AddressBook::removeSyncInfo( QString syncProfile) |
557 | { | 557 | { |
558 | Iterator ait; | 558 | Iterator ait; |
559 | for ( ait = begin(); ait != end(); ++ait ) { | 559 | for ( ait = begin(); ait != end(); ++ait ) { |
560 | (*ait).removeID( syncProfile ); | 560 | (*ait).removeID( syncProfile ); |
561 | } | 561 | } |
562 | if ( syncProfile.isEmpty() ) { | 562 | if ( syncProfile.isEmpty() ) { |
563 | Iterator it = begin(); | 563 | Iterator it = begin(); |
564 | Iterator it2 ; | 564 | Iterator it2 ; |
565 | while ( it != end() ) { | 565 | while ( it != end() ) { |
566 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 566 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
567 | it2 = it; | 567 | it2 = it; |
568 | //qDebug("removing %s ",(*it).uid().latin1() ); | 568 | //qDebug("removing %s ",(*it).uid().latin1() ); |
569 | ++it; | 569 | ++it; |
570 | removeAddressee( it2 ); | 570 | removeAddressee( it2 ); |
571 | } else { | 571 | } else { |
572 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 572 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
573 | ++it; | 573 | ++it; |
574 | } | 574 | } |
575 | } | 575 | } |
576 | } else { | 576 | } else { |
577 | Addressee lse; | 577 | Addressee lse; |
578 | lse = findByUid( "last-syncAddressee-"+ syncProfile ); | 578 | lse = findByUid( "last-syncAddressee-"+ syncProfile ); |
579 | if ( ! lse.isEmpty() ) | 579 | if ( ! lse.isEmpty() ) |
580 | removeAddressee( lse ); | 580 | removeAddressee( lse ); |
581 | } | 581 | } |
582 | 582 | ||
583 | } | 583 | } |
584 | void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) | 584 | void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) |
585 | { | 585 | { |
586 | Iterator ait; | 586 | Iterator ait; |
587 | for ( ait = begin(); ait != end(); ++ait ) { | 587 | for ( ait = begin(); ait != end(); ++ait ) { |
588 | QString id = (*ait).IDStr(); | 588 | QString id = (*ait).IDStr(); |
589 | (*ait).setIDStr( ":"); | 589 | (*ait).setIDStr( ":"); |
590 | (*ait).setExternalUID( id ); | 590 | (*ait).setExternalUID( id ); |
591 | (*ait).setOriginalExternalUID( id ); | 591 | (*ait).setOriginalExternalUID( id ); |
592 | if ( isPreSync ) | 592 | if ( isPreSync ) |
593 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 593 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
594 | else { | 594 | else { |
595 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 595 | (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
596 | (*ait).setID( currentSyncDevice,id ); | 596 | (*ait).setID( currentSyncDevice,id ); |
597 | 597 | ||
598 | } | 598 | } |
599 | } | 599 | } |
600 | } | 600 | } |
601 | void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) | 601 | void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) |
602 | { | 602 | { |
603 | 603 | ||
604 | setUntagged(); | 604 | setUntagged(); |
605 | KABC::Addressee::List list; | 605 | KABC::Addressee::List list; |
606 | QFile file( fileName ); | 606 | QFile file( fileName ); |
607 | file.open( IO_ReadOnly ); | 607 | file.open( IO_ReadOnly ); |
608 | QByteArray rawData = file.readAll(); | 608 | QByteArray rawData = file.readAll(); |
609 | file.close(); | 609 | file.close(); |
610 | QString data; | 610 | QString data; |
611 | 611 | ||
612 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 612 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
613 | KABC::VCardTool tool; | 613 | KABC::VCardTool tool; |
614 | list = tool.parseVCards( data ); | 614 | list = tool.parseVCards( data ); |
615 | KABC::Addressee::List::Iterator it; | 615 | KABC::Addressee::List::Iterator it; |
616 | for ( it = list.begin(); it != list.end(); ++it ) { | 616 | for ( it = list.begin(); it != list.end(); ++it ) { |
617 | Iterator ait; | 617 | Iterator ait; |
618 | for ( ait = begin(); ait != end(); ++ait ) { | 618 | for ( ait = begin(); ait != end(); ++ait ) { |
619 | if ( !(*ait).tagged() ) { | 619 | if ( !(*ait).tagged() ) { |
620 | if ( (*ait).containsAdr(*it)) { | 620 | if ( (*ait).containsAdr(*it)) { |
621 | (*ait).setTagged(true); | 621 | (*ait).setTagged(true); |
622 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); | 622 | QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); |
623 | (*it).setIDStr( ":"); | 623 | (*it).setIDStr( ":"); |
624 | (*it).setID( currentSyncDevice,id ); | 624 | (*it).setID( currentSyncDevice,id ); |
625 | (*it).setExternalUID( id ); | 625 | (*it).setExternalUID( id ); |
626 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 626 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
627 | (*it).setUid( ( (*ait).uid() )); | 627 | (*it).setUid( ( (*ait).uid() )); |
628 | break; | 628 | break; |
629 | } | 629 | } |
630 | } | 630 | } |
631 | 631 | ||
632 | } | 632 | } |
633 | if ( ait == end() ) | 633 | if ( ait == end() ) |
634 | qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); | 634 | qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); |
635 | } | 635 | } |
636 | clear(); | 636 | clear(); |
637 | for ( it = list.begin(); it != list.end(); ++it ) { | 637 | for ( it = list.begin(); it != list.end(); ++it ) { |
638 | insertAddressee( (*it) ); | 638 | insertAddressee( (*it) ); |
639 | } | 639 | } |
640 | } | 640 | } |
641 | 641 | ||
642 | bool AddressBook::saveABphone( QString fileName ) | 642 | bool AddressBook::saveABphone( QString fileName ) |
643 | { | 643 | { |
644 | //smplifyAddressees(); | 644 | //smplifyAddressees(); |
645 | qDebug("saveABphone:: saving AB... "); | 645 | qDebug("saveABphone:: saving AB... "); |
646 | if ( ! export2PhoneFormat( QStringList() ,fileName ) ) | 646 | if ( ! export2PhoneFormat( QStringList() ,fileName ) ) |
647 | return false; | 647 | return false; |
648 | qDebug("saveABphone:: writing to phone... "); | 648 | qDebug("saveABphone:: writing to phone... "); |
649 | if ( !PhoneAccess::writeToPhone( fileName) ) { | 649 | if ( !PhoneAccess::writeToPhone( fileName) ) { |
650 | return false; | 650 | return false; |
651 | } | 651 | } |
652 | qDebug("saveABphone:: re-reading from phone... "); | 652 | qDebug("saveABphone:: re-reading from phone... "); |
653 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 653 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
654 | return false; | 654 | return false; |
655 | } | 655 | } |
656 | return true; | 656 | return true; |
657 | } | 657 | } |
658 | bool AddressBook::saveAB() | 658 | bool AddressBook::saveAB() |
659 | { | 659 | { |
660 | bool ok = true; | 660 | bool ok = true; |
661 | 661 | ||
662 | deleteRemovedAddressees(); | 662 | deleteRemovedAddressees(); |
663 | Iterator ait; | 663 | Iterator ait; |
664 | for ( ait = begin(); ait != end(); ++ait ) { | 664 | for ( ait = begin(); ait != end(); ++ait ) { |
665 | if ( !(*ait).IDStr().isEmpty() ) { | 665 | if ( !(*ait).IDStr().isEmpty() ) { |
666 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); | 666 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); |
667 | } | 667 | } |
668 | } | 668 | } |
669 | KRES::Manager<Resource>::ActiveIterator it; | 669 | KRES::Manager<Resource>::ActiveIterator it; |
670 | KRES::Manager<Resource> *manager = d->mManager; | 670 | KRES::Manager<Resource> *manager = d->mManager; |
671 | qDebug("SaveAB::saving..." ); | 671 | qDebug("SaveAB::saving..." ); |
672 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 672 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
673 | qDebug("SaveAB::checking resource..." ); | 673 | qDebug("SaveAB::checking resource..." ); |
674 | if ( (*it)->readOnly() ) | 674 | if ( (*it)->readOnly() ) |
675 | qDebug("resource is readonly." ); | 675 | qDebug("resource is readonly." ); |
676 | if ( (*it)->isOpen() ) | 676 | if ( (*it)->isOpen() ) |
677 | qDebug("resource is open" ); | 677 | qDebug("resource is open" ); |
678 | 678 | ||
679 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 679 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
680 | Ticket *ticket = requestSaveTicket( *it ); | 680 | Ticket *ticket = requestSaveTicket( *it ); |
681 | qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 681 | qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
682 | if ( !ticket ) { | 682 | if ( !ticket ) { |
683 | qDebug( i18n( "Unable to save to resource '%1'. It is locked." ) | 683 | qDebug( i18n( "Unable to save to resource '%1'. It is locked." ) |
684 | .arg( (*it)->resourceName() ) ); | 684 | .arg( (*it)->resourceName() ) ); |
685 | return false; | 685 | return false; |
686 | } | 686 | } |
687 | 687 | ||
688 | //if ( !save( ticket ) ) | 688 | //if ( !save( ticket ) ) |
689 | if ( ticket->resource() ) { | 689 | if ( ticket->resource() ) { |
690 | QString name = ticket->resource()->resourceName(); | 690 | QString name = ticket->resource()->resourceName(); |
691 | if ( ! ticket->resource()->save( ticket ) ) | 691 | if ( ! ticket->resource()->save( ticket ) ) |
692 | ok = false; | 692 | ok = false; |
693 | else | 693 | else |
694 | qDebug("StdAddressBook::resource saved '%s'", name.latin1() ); | 694 | qDebug("StdAddressBook::resource saved '%s'", name.latin1() ); |
695 | 695 | ||
696 | } else | 696 | } else |
697 | ok = false; | 697 | ok = false; |
698 | 698 | ||
699 | } | 699 | } |
700 | } | 700 | } |
701 | return ok; | 701 | return ok; |
702 | } | 702 | } |
703 | 703 | ||
704 | AddressBook::Iterator AddressBook::begin() | 704 | AddressBook::Iterator AddressBook::begin() |
705 | { | 705 | { |
706 | Iterator it = Iterator(); | 706 | Iterator it = Iterator(); |
707 | it.d->mIt = d->mAddressees.begin(); | 707 | it.d->mIt = d->mAddressees.begin(); |
708 | return it; | 708 | return it; |
709 | } | 709 | } |
710 | 710 | ||
711 | AddressBook::ConstIterator AddressBook::begin() const | 711 | AddressBook::ConstIterator AddressBook::begin() const |
712 | { | 712 | { |
713 | ConstIterator it = ConstIterator(); | 713 | ConstIterator it = ConstIterator(); |
714 | it.d->mIt = d->mAddressees.begin(); | 714 | it.d->mIt = d->mAddressees.begin(); |
715 | return it; | 715 | return it; |
716 | } | 716 | } |
717 | 717 | ||
718 | AddressBook::Iterator AddressBook::end() | 718 | AddressBook::Iterator AddressBook::end() |
719 | { | 719 | { |
720 | Iterator it = Iterator(); | 720 | Iterator it = Iterator(); |
721 | it.d->mIt = d->mAddressees.end(); | 721 | it.d->mIt = d->mAddressees.end(); |
722 | return it; | 722 | return it; |
723 | } | 723 | } |
724 | 724 | ||
725 | AddressBook::ConstIterator AddressBook::end() const | 725 | AddressBook::ConstIterator AddressBook::end() const |
726 | { | 726 | { |
727 | ConstIterator it = ConstIterator(); | 727 | ConstIterator it = ConstIterator(); |
728 | it.d->mIt = d->mAddressees.end(); | 728 | it.d->mIt = d->mAddressees.end(); |
729 | return it; | 729 | return it; |
730 | } | 730 | } |
731 | 731 | ||
732 | void AddressBook::clear() | 732 | void AddressBook::clear() |
733 | { | 733 | { |
734 | d->mAddressees.clear(); | 734 | d->mAddressees.clear(); |
735 | } | 735 | } |
736 | 736 | ||
737 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 737 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) |
738 | { | 738 | { |
739 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; | 739 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; |
740 | 740 | ||
741 | if ( !resource ) | 741 | if ( !resource ) |
742 | { | 742 | { |
743 | qDebug("AddressBook::requestSaveTicket no resource" ); | 743 | qDebug("AddressBook::requestSaveTicket no resource" ); |
744 | resource = standardResource(); | 744 | resource = standardResource(); |
745 | } | 745 | } |
746 | 746 | ||
747 | KRES::Manager<Resource>::ActiveIterator it; | 747 | KRES::Manager<Resource>::ActiveIterator it; |
748 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 748 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
749 | if ( (*it) == resource ) { | 749 | if ( (*it) == resource ) { |
750 | if ( (*it)->readOnly() || !(*it)->isOpen() ) | 750 | if ( (*it)->readOnly() || !(*it)->isOpen() ) |
751 | return 0; | 751 | return 0; |
752 | else | 752 | else |
753 | return (*it)->requestSaveTicket(); | 753 | return (*it)->requestSaveTicket(); |
754 | } | 754 | } |
755 | } | 755 | } |
756 | 756 | ||
757 | return 0; | 757 | return 0; |
758 | } | 758 | } |
759 | //void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); | 759 | //void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); |
760 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) | 760 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) |
761 | { | 761 | { |
762 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { | 762 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { |
763 | //qDebug("block insert "); | 763 | //qDebug("block insert "); |
764 | return; | 764 | return; |
765 | } | 765 | } |
766 | //qDebug("inserting.... %s ",a.uid().latin1() ); | 766 | //qDebug("inserting.... %s ",a.uid().latin1() ); |
767 | bool found = false; | 767 | bool found = false; |
768 | Addressee::List::Iterator it; | 768 | Addressee::List::Iterator it; |
769 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { | 769 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { |
770 | if ( a.uid() == (*it).uid() ) { | 770 | if ( a.uid() == (*it).uid() ) { |
771 | 771 | ||
772 | bool changed = false; | 772 | bool changed = false; |
773 | Addressee addr = a; | 773 | Addressee addr = a; |
774 | if ( addr != (*it) ) | 774 | if ( addr != (*it) ) |
775 | changed = true; | 775 | changed = true; |
776 | 776 | ||
777 | if ( takeResource ) { | 777 | if ( takeResource ) { |
778 | Resource * res = (*it).resource(); | 778 | Resource * res = (*it).resource(); |
779 | (*it) = a; | 779 | (*it) = a; |
780 | (*it).setResource( res ); | 780 | (*it).setResource( res ); |
781 | } else { | 781 | } else { |
782 | (*it) = a; | 782 | (*it) = a; |
783 | if ( (*it).resource() == 0 ) | 783 | if ( (*it).resource() == 0 ) |
784 | (*it).setResource( standardResource() ); | 784 | (*it).setResource( standardResource() ); |
785 | } | 785 | } |
786 | if ( changed ) { | 786 | if ( changed ) { |
787 | if ( setRev ) { | 787 | if ( setRev ) { |
788 | (*it).setRevision( QDateTime::currentDateTime() ); | 788 | (*it).setRevision( QDateTime::currentDateTime() ); |
789 | } | 789 | } |
790 | (*it).setChanged( true ); | 790 | (*it).setChanged( true ); |
791 | } | 791 | } |
792 | 792 | ||
793 | found = true; | 793 | found = true; |
794 | } else { | 794 | } else { |
795 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 795 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
796 | QString name = (*it).uid().mid( 19 ); | 796 | QString name = (*it).uid().mid( 19 ); |
797 | Addressee b = a; | 797 | Addressee b = a; |
798 | QString id = b.getID( name ); | 798 | QString id = b.getID( name ); |
799 | if ( ! id.isEmpty() ) { | 799 | if ( ! id.isEmpty() ) { |
800 | QString des = (*it).note(); | 800 | QString des = (*it).note(); |
801 | int startN; | 801 | int startN; |
802 | if( (startN = des.find( id ) ) >= 0 ) { | 802 | if( (startN = des.find( id ) ) >= 0 ) { |
803 | int endN = des.find( ",", startN+1 ); | 803 | int endN = des.find( ",", startN+1 ); |
804 | des = des.left( startN ) + des.mid( endN+1 ); | 804 | des = des.left( startN ) + des.mid( endN+1 ); |
805 | (*it).setNote( des ); | 805 | (*it).setNote( des ); |
806 | } | 806 | } |
807 | } | 807 | } |
808 | } | 808 | } |
809 | } | 809 | } |
810 | } | 810 | } |
811 | if ( found ) | 811 | if ( found ) |
812 | return; | 812 | return; |
813 | 813 | ||
814 | d->mAddressees.append( a ); | 814 | d->mAddressees.append( a ); |
815 | Addressee& addr = d->mAddressees.last(); | 815 | Addressee& addr = d->mAddressees.last(); |
816 | if ( addr.resource() == 0 ) | 816 | if ( addr.resource() == 0 ) |
817 | addr.setResource( standardResource() ); | 817 | addr.setResource( standardResource() ); |
818 | addr.setChanged( true ); | 818 | addr.setChanged( true ); |
819 | } | 819 | } |
820 | 820 | ||
821 | void AddressBook::removeAddressee( const Addressee &a ) | 821 | void AddressBook::removeAddressee( const Addressee &a ) |
822 | { | 822 | { |
823 | Iterator it; | 823 | Iterator it; |
824 | Iterator it2; | 824 | Iterator it2; |
825 | bool found = false; | 825 | bool found = false; |
826 | for ( it = begin(); it != end(); ++it ) { | 826 | for ( it = begin(); it != end(); ++it ) { |
827 | if ( a.uid() == (*it).uid() ) { | 827 | if ( a.uid() == (*it).uid() ) { |
828 | found = true; | 828 | found = true; |
829 | it2 = it; | 829 | it2 = it; |
830 | } else { | 830 | } else { |
831 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 831 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
832 | QString name = (*it).uid().mid( 19 ); | 832 | QString name = (*it).uid().mid( 19 ); |
833 | Addressee b = a; | 833 | Addressee b = a; |
834 | QString id = b.getID( name ); | 834 | QString id = b.getID( name ); |
835 | if ( ! id.isEmpty() ) { | 835 | if ( ! id.isEmpty() ) { |
836 | QString des = (*it).note(); | 836 | QString des = (*it).note(); |
837 | if( des.find( id ) < 0 ) { | 837 | if( des.find( id ) < 0 ) { |
838 | des += id + ","; | 838 | des += id + ","; |
839 | (*it).setNote( des ); | 839 | (*it).setNote( des ); |
840 | } | 840 | } |
841 | } | 841 | } |
842 | } | 842 | } |
843 | 843 | ||
844 | } | 844 | } |
845 | } | 845 | } |
846 | 846 | ||
847 | if ( found ) | 847 | if ( found ) |
848 | removeAddressee( it2 ); | 848 | removeAddressee( it2 ); |
849 | 849 | ||
850 | } | 850 | } |
851 | 851 | ||
852 | void AddressBook::removeSyncAddressees( bool removeDeleted ) | 852 | void AddressBook::removeSyncAddressees( bool removeDeleted ) |
853 | { | 853 | { |
854 | Iterator it = begin(); | 854 | Iterator it = begin(); |
855 | Iterator it2 ; | 855 | Iterator it2 ; |
856 | QDateTime dt ( QDate( 2003,1,1) ); | 856 | QDateTime dt ( QDate( 2003,1,1) ); |
857 | while ( it != end() ) { | 857 | while ( it != end() ) { |
858 | (*it).setRevision( dt ); | 858 | (*it).setRevision( dt ); |
859 | if (( *it).IDStr() != "changed" ) { | 859 | if (( *it).IDStr() != "changed" ) { |
860 | // "changed" is used for tagging changed addressees when syncing with KDE or OL | 860 | // "changed" is used for tagging changed addressees when syncing with KDE or OL |
861 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 861 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
862 | (*it).setIDStr(":"); | 862 | (*it).setIDStr(":"); |
863 | } | 863 | } |
864 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { | 864 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { |
865 | it2 = it; | 865 | it2 = it; |
866 | //qDebug("removing %s ",(*it).uid().latin1() ); | 866 | //qDebug("removing %s ",(*it).uid().latin1() ); |
867 | ++it; | 867 | ++it; |
868 | removeAddressee( it2 ); | 868 | removeAddressee( it2 ); |
869 | } else { | 869 | } else { |
870 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 870 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
871 | if ( removeDeleted ) { | 871 | if ( removeDeleted ) { |
872 | // we have no postprocessing in the resource, we have to do it here | 872 | // we have no postprocessing in the resource, we have to do it here |
873 | // we have to compute csum for all, because it could be the first sync | 873 | // we have to compute csum for all, because it could be the first sync |
874 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 874 | (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
875 | } | 875 | } |
876 | ++it; | 876 | ++it; |
877 | } | 877 | } |
878 | } | 878 | } |
879 | deleteRemovedAddressees(); | 879 | deleteRemovedAddressees(); |
880 | } | 880 | } |
881 | 881 | ||
882 | void AddressBook::removeAddressee( const Iterator &it ) | 882 | void AddressBook::removeAddressee( const Iterator &it ) |
883 | { | 883 | { |
884 | d->mRemovedAddressees.append( (*it) ); | 884 | d->mRemovedAddressees.append( (*it) ); |
885 | d->mAddressees.remove( it.d->mIt ); | 885 | d->mAddressees.remove( it.d->mIt ); |
886 | } | 886 | } |
887 | 887 | ||
888 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 888 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
889 | { | 889 | { |
890 | Iterator it; | 890 | Iterator it; |
891 | for ( it = begin(); it != end(); ++it ) { | 891 | for ( it = begin(); it != end(); ++it ) { |
892 | if ( a.uid() == (*it).uid() ) { | 892 | if ( a.uid() == (*it).uid() ) { |
893 | return it; | 893 | return it; |
894 | } | 894 | } |
895 | } | 895 | } |
896 | return end(); | 896 | return end(); |
897 | } | 897 | } |
898 | 898 | ||
899 | Addressee AddressBook::findByUid( const QString &uid ) | 899 | Addressee AddressBook::findByUid( const QString &uid ) |
900 | { | 900 | { |
901 | Iterator it; | 901 | Iterator it; |
902 | for ( it = begin(); it != end(); ++it ) { | 902 | for ( it = begin(); it != end(); ++it ) { |
903 | if ( uid == (*it).uid() ) { | 903 | if ( uid == (*it).uid() ) { |
904 | return *it; | 904 | return *it; |
905 | } | 905 | } |
906 | } | 906 | } |
907 | return Addressee(); | 907 | return Addressee(); |
908 | } | 908 | } |
909 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) | 909 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) |
910 | { | 910 | { |
911 | //qDebug("AddressBook::preExternSync "); | 911 | //qDebug("AddressBook::preExternSync "); |
912 | AddressBook::Iterator it; | 912 | AddressBook::Iterator it; |
913 | for ( it = begin(); it != end(); ++it ) { | 913 | for ( it = begin(); it != end(); ++it ) { |
914 | (*it).setID( csd, (*it).externalUID() ); | 914 | (*it).setID( csd, (*it).externalUID() ); |
915 | (*it).computeCsum( csd ); | 915 | (*it).computeCsum( csd ); |
916 | } | 916 | } |
917 | mergeAB( aBook ,csd, isSubset ); | 917 | mergeAB( aBook ,csd, isSubset ); |
918 | } | 918 | } |
919 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) | 919 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) |
920 | { | 920 | { |
921 | //qDebug("AddressBook::postExternSync "); | 921 | //qDebug("AddressBook::postExternSync "); |
922 | AddressBook::Iterator it; | 922 | AddressBook::Iterator it; |
923 | int foundEmpty = 0; | 923 | int foundEmpty = 0; |
924 | for ( it = begin(); it != end(); ++it ) { | 924 | for ( it = begin(); it != end(); ++it ) { |
925 | //qDebug("check uid %s ", (*it).uid().latin1() ); | 925 | //qDebug("check uid %s ", (*it).uid().latin1() ); |
926 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || | 926 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || |
927 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM || | 927 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM || |
928 | (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) { | 928 | (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) { |
929 | Addressee ad = aBook->findByUid( ( (*it).uid() )); | 929 | Addressee ad = aBook->findByUid( ( (*it).uid() )); |
930 | if ( ad.isEmpty() ) { | 930 | if ( ad.isEmpty() ) { |
931 | ++foundEmpty; | 931 | ++foundEmpty; |
932 | //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1()); | 932 | //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1()); |
933 | //qDebug("-- formatted name %s ",(*it).formattedName().latin1() ); | 933 | //qDebug("-- formatted name %s ",(*it).formattedName().latin1() ); |
934 | } else { | 934 | } else { |
935 | (*it).setIDStr(":"); | 935 | (*it).setIDStr(":"); |
936 | if ( setID ) { | 936 | if ( setID ) { |
937 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) | 937 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) |
938 | ad.setID( csd, (*it).externalUID() ); | 938 | ad.setID( csd, (*it).externalUID() ); |
939 | } else | 939 | } else |
940 | ad.setID( csd, (*it).uid() ); | 940 | ad.setID( csd, (*it).uid() ); |
941 | (*it).computeCsum( csd ); | 941 | (*it).computeCsum( csd ); |
942 | ad.setCsum( csd, (*it).getCsum( csd ) ); | 942 | ad.setCsum( csd, (*it).getCsum( csd ) ); |
943 | //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() ); | 943 | //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() ); |
944 | aBook->insertAddressee( ad , false); | 944 | aBook->insertAddressee( ad , false); |
945 | } | 945 | } |
946 | } | 946 | } |
947 | } | 947 | } |
948 | if ( foundEmpty ) { | 948 | if ( foundEmpty ) { |
949 | qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty ); | 949 | qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty ); |
950 | } | 950 | } |
951 | 951 | ||
952 | } | 952 | } |
953 | 953 | ||
954 | bool AddressBook::containsExternalUid( const QString& uid ) | 954 | bool AddressBook::containsExternalUid( const QString& uid ) |
955 | { | 955 | { |
956 | Iterator it; | 956 | Iterator it; |
957 | for ( it = begin(); it != end(); ++it ) { | 957 | for ( it = begin(); it != end(); ++it ) { |
958 | if ( uid == (*it).externalUID( ) ) | 958 | if ( uid == (*it).externalUID( ) ) |
959 | return true; | 959 | return true; |
960 | } | 960 | } |
961 | return false; | 961 | return false; |
962 | } | 962 | } |
963 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) | 963 | const Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) const |
964 | { | 964 | { |
965 | Iterator it; | 965 | ConstIterator it; |
966 | for ( it = begin(); it != end(); ++it ) { | 966 | for ( it = begin(); it != end(); ++it ) { |
967 | if ( uid == (*it).getID( profile ) ) | 967 | if ( uid == (*it).getID( profile ) ) |
968 | return (*it); | 968 | return (*it); |
969 | } | 969 | } |
970 | return Addressee(); | 970 | return Addressee(); |
971 | } | 971 | } |
972 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) | 972 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) |
973 | { | 973 | { |
974 | Iterator it; | 974 | Iterator it; |
975 | Addressee ad; | 975 | Addressee ad; |
976 | for ( it = begin(); it != end(); ++it ) { | 976 | for ( it = begin(); it != end(); ++it ) { |
977 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); | 977 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); |
978 | if ( !ad.isEmpty() ) { | 978 | if ( !ad.isEmpty() ) { |
979 | (*it).mergeContact( ad ,isSubset); | 979 | (*it).mergeContact( ad ,isSubset); |
980 | } | 980 | } |
981 | } | 981 | } |
982 | #if 0 | 982 | #if 0 |
983 | // test only | 983 | // test only |
984 | for ( it = begin(); it != end(); ++it ) { | 984 | for ( it = begin(); it != end(); ++it ) { |
985 | 985 | ||
986 | qDebug("uid %s ", (*it).uid().latin1()); | 986 | qDebug("uid %s ", (*it).uid().latin1()); |
987 | } | 987 | } |
988 | #endif | 988 | #endif |
989 | } | 989 | } |
990 | 990 | ||
991 | #if 0 | 991 | #if 0 |
992 | Addressee::List AddressBook::getExternLastSyncAddressees() | 992 | Addressee::List AddressBook::getExternLastSyncAddressees() |
993 | { | 993 | { |
994 | Addressee::List results; | 994 | Addressee::List results; |
995 | 995 | ||
996 | Iterator it; | 996 | Iterator it; |
997 | for ( it = begin(); it != end(); ++it ) { | 997 | for ( it = begin(); it != end(); ++it ) { |
998 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { | 998 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { |
999 | if ( (*it).familyName().left(4) == "!E: " ) | 999 | if ( (*it).familyName().left(4) == "!E: " ) |
1000 | results.append( *it ); | 1000 | results.append( *it ); |
1001 | } | 1001 | } |
1002 | } | 1002 | } |
1003 | 1003 | ||
1004 | return results; | 1004 | return results; |
1005 | } | 1005 | } |
1006 | #endif | 1006 | #endif |
1007 | void AddressBook::resetTempSyncStat() | 1007 | void AddressBook::resetTempSyncStat() |
1008 | { | 1008 | { |
1009 | Iterator it; | 1009 | Iterator it; |
1010 | for ( it = begin(); it != end(); ++it ) { | 1010 | for ( it = begin(); it != end(); ++it ) { |
1011 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); | 1011 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); |
1012 | } | 1012 | } |
1013 | 1013 | ||
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | QStringList AddressBook:: uidList() | 1016 | QStringList AddressBook:: uidList() |
1017 | { | 1017 | { |
1018 | QStringList results; | 1018 | QStringList results; |
1019 | Iterator it; | 1019 | Iterator it; |
1020 | for ( it = begin(); it != end(); ++it ) { | 1020 | for ( it = begin(); it != end(); ++it ) { |
1021 | results.append( (*it).uid() ); | 1021 | results.append( (*it).uid() ); |
1022 | } | 1022 | } |
1023 | return results; | 1023 | return results; |
1024 | } | 1024 | } |
1025 | 1025 | ||
1026 | 1026 | ||
1027 | Addressee::List AddressBook::allAddressees() | 1027 | Addressee::List AddressBook::allAddressees() |
1028 | { | 1028 | { |
1029 | return d->mAddressees; | 1029 | return d->mAddressees; |
1030 | 1030 | ||
1031 | } | 1031 | } |
1032 | 1032 | ||
1033 | Addressee::List AddressBook::findByName( const QString &name ) | 1033 | Addressee::List AddressBook::findByName( const QString &name ) |
1034 | { | 1034 | { |
1035 | Addressee::List results; | 1035 | Addressee::List results; |
1036 | 1036 | ||
1037 | Iterator it; | 1037 | Iterator it; |
1038 | for ( it = begin(); it != end(); ++it ) { | 1038 | for ( it = begin(); it != end(); ++it ) { |
1039 | if ( name == (*it).realName() ) { | 1039 | if ( name == (*it).realName() ) { |
1040 | results.append( *it ); | 1040 | results.append( *it ); |
1041 | } | 1041 | } |
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | return results; | 1044 | return results; |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | Addressee::List AddressBook::findByEmail( const QString &email ) | 1047 | Addressee::List AddressBook::findByEmail( const QString &email ) |
1048 | { | 1048 | { |
1049 | Addressee::List results; | 1049 | Addressee::List results; |
1050 | QStringList mailList; | 1050 | QStringList mailList; |
1051 | 1051 | ||
1052 | Iterator it; | 1052 | Iterator it; |
1053 | for ( it = begin(); it != end(); ++it ) { | 1053 | for ( it = begin(); it != end(); ++it ) { |
1054 | mailList = (*it).emails(); | 1054 | mailList = (*it).emails(); |
1055 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { | 1055 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { |
1056 | if ( email == (*ite) ) { | 1056 | if ( email == (*ite) ) { |
1057 | results.append( *it ); | 1057 | results.append( *it ); |
1058 | } | 1058 | } |
1059 | } | 1059 | } |
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | return results; | 1062 | return results; |
1063 | } | 1063 | } |
1064 | 1064 | ||
1065 | Addressee::List AddressBook::findByCategory( const QString &category ) | 1065 | Addressee::List AddressBook::findByCategory( const QString &category ) |
1066 | { | 1066 | { |
1067 | Addressee::List results; | 1067 | Addressee::List results; |
1068 | 1068 | ||
1069 | Iterator it; | 1069 | Iterator it; |
1070 | for ( it = begin(); it != end(); ++it ) { | 1070 | for ( it = begin(); it != end(); ++it ) { |
1071 | if ( (*it).hasCategory( category) ) { | 1071 | if ( (*it).hasCategory( category) ) { |
1072 | results.append( *it ); | 1072 | results.append( *it ); |
1073 | } | 1073 | } |
1074 | } | 1074 | } |
1075 | 1075 | ||
1076 | return results; | 1076 | return results; |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | void AddressBook::dump() const | 1079 | void AddressBook::dump() const |
1080 | { | 1080 | { |
1081 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; | 1081 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; |
1082 | 1082 | ||
1083 | ConstIterator it; | 1083 | ConstIterator it; |
1084 | for( it = begin(); it != end(); ++it ) { | 1084 | for( it = begin(); it != end(); ++it ) { |
1085 | (*it).dump(); | 1085 | (*it).dump(); |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; | 1088 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; |
1089 | } | 1089 | } |
1090 | 1090 | ||
1091 | QString AddressBook::identifier() | 1091 | QString AddressBook::identifier() |
1092 | { | 1092 | { |
1093 | QStringList identifier; | 1093 | QStringList identifier; |
1094 | 1094 | ||
1095 | 1095 | ||
1096 | KRES::Manager<Resource>::ActiveIterator it; | 1096 | KRES::Manager<Resource>::ActiveIterator it; |
1097 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 1097 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
1098 | if ( !(*it)->identifier().isEmpty() ) | 1098 | if ( !(*it)->identifier().isEmpty() ) |
1099 | identifier.append( (*it)->identifier() ); | 1099 | identifier.append( (*it)->identifier() ); |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | return identifier.join( ":" ); | 1102 | return identifier.join( ":" ); |
1103 | } | 1103 | } |
1104 | 1104 | ||
1105 | Field::List AddressBook::fields( int category ) | 1105 | Field::List AddressBook::fields( int category ) |
1106 | { | 1106 | { |
1107 | if ( d->mAllFields.isEmpty() ) { | 1107 | if ( d->mAllFields.isEmpty() ) { |
1108 | d->mAllFields = Field::allFields(); | 1108 | d->mAllFields = Field::allFields(); |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | if ( category == Field::All ) return d->mAllFields; | 1111 | if ( category == Field::All ) return d->mAllFields; |
1112 | 1112 | ||
1113 | Field::List result; | 1113 | Field::List result; |
1114 | Field::List::ConstIterator it; | 1114 | Field::List::ConstIterator it; |
1115 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { | 1115 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { |
1116 | if ( (*it)->category() & category ) result.append( *it ); | 1116 | if ( (*it)->category() & category ) result.append( *it ); |
1117 | } | 1117 | } |
1118 | 1118 | ||
1119 | return result; | 1119 | return result; |
1120 | } | 1120 | } |
1121 | 1121 | ||
1122 | bool AddressBook::addCustomField( const QString &label, int category, | 1122 | bool AddressBook::addCustomField( const QString &label, int category, |
1123 | const QString &key, const QString &app ) | 1123 | const QString &key, const QString &app ) |
1124 | { | 1124 | { |
1125 | if ( d->mAllFields.isEmpty() ) { | 1125 | if ( d->mAllFields.isEmpty() ) { |
1126 | d->mAllFields = Field::allFields(); | 1126 | d->mAllFields = Field::allFields(); |
1127 | } | 1127 | } |
1128 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; | 1128 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; |
1129 | QString a = app.isNull() ? KGlobal::getAppName() : app; | 1129 | QString a = app.isNull() ? KGlobal::getAppName() : app; |
1130 | 1130 | ||
1131 | QString k = key.isNull() ? label : key; | 1131 | QString k = key.isNull() ? label : key; |
1132 | 1132 | ||
1133 | Field *field = Field::createCustomField( label, category, k, a ); | 1133 | Field *field = Field::createCustomField( label, category, k, a ); |
1134 | 1134 | ||
1135 | if ( !field ) return false; | 1135 | if ( !field ) return false; |
1136 | 1136 | ||
1137 | d->mAllFields.append( field ); | 1137 | d->mAllFields.append( field ); |
1138 | 1138 | ||
1139 | return true; | 1139 | return true; |
1140 | } | 1140 | } |
1141 | 1141 | ||
1142 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) | 1142 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) |
1143 | { | 1143 | { |
1144 | if (!ab.d) return s; | 1144 | if (!ab.d) return s; |
1145 | 1145 | ||
1146 | return s << ab.d->mAddressees; | 1146 | return s << ab.d->mAddressees; |
1147 | } | 1147 | } |
1148 | 1148 | ||
1149 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) | 1149 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) |
1150 | { | 1150 | { |
1151 | if (!ab.d) return s; | 1151 | if (!ab.d) return s; |
1152 | 1152 | ||
1153 | s >> ab.d->mAddressees; | 1153 | s >> ab.d->mAddressees; |
1154 | 1154 | ||
1155 | return s; | 1155 | return s; |
1156 | } | 1156 | } |
1157 | 1157 | ||
1158 | bool AddressBook::addResource( Resource *resource ) | 1158 | bool AddressBook::addResource( Resource *resource ) |
1159 | { | 1159 | { |
1160 | if ( !resource->open() ) { | 1160 | if ( !resource->open() ) { |
1161 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; | 1161 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; |
1162 | return false; | 1162 | return false; |
1163 | } | 1163 | } |
1164 | 1164 | ||
1165 | resource->setAddressBook( this ); | 1165 | resource->setAddressBook( this ); |
1166 | 1166 | ||
1167 | d->mManager->add( resource ); | 1167 | d->mManager->add( resource ); |
1168 | return true; | 1168 | return true; |
1169 | } | 1169 | } |
1170 | void AddressBook::removeResources() | 1170 | void AddressBook::removeResources() |
1171 | { | 1171 | { |
1172 | //remove all possible resources. This should cleanup the configfile. | 1172 | //remove all possible resources. This should cleanup the configfile. |
1173 | QPtrList<KABC::Resource> mResources = resources(); | 1173 | QPtrList<KABC::Resource> mResources = resources(); |
1174 | 1174 | ||
1175 | QPtrListIterator<KABC::Resource> it(mResources); | 1175 | QPtrListIterator<KABC::Resource> it(mResources); |
1176 | for ( ; it.current(); ++it ) { | 1176 | for ( ; it.current(); ++it ) { |
1177 | KABC::Resource *res = it.current(); | 1177 | KABC::Resource *res = it.current(); |
1178 | removeResource(res); | 1178 | removeResource(res); |
1179 | } | 1179 | } |
1180 | } | 1180 | } |
1181 | 1181 | ||
1182 | bool AddressBook::removeResource( Resource *resource ) | 1182 | bool AddressBook::removeResource( Resource *resource ) |
1183 | { | 1183 | { |
1184 | resource->close(); | 1184 | resource->close(); |
1185 | 1185 | ||
1186 | if ( resource == standardResource() ) | 1186 | if ( resource == standardResource() ) |
1187 | d->mManager->setStandardResource( 0 ); | 1187 | d->mManager->setStandardResource( 0 ); |
1188 | 1188 | ||
1189 | resource->setAddressBook( 0 ); | 1189 | resource->setAddressBook( 0 ); |
1190 | 1190 | ||
1191 | d->mManager->remove( resource ); | 1191 | d->mManager->remove( resource ); |
1192 | return true; | 1192 | return true; |
1193 | } | 1193 | } |
1194 | 1194 | ||
1195 | QPtrList<Resource> AddressBook::resources() | 1195 | QPtrList<Resource> AddressBook::resources() |
1196 | { | 1196 | { |
1197 | QPtrList<Resource> list; | 1197 | QPtrList<Resource> list; |
1198 | 1198 | ||
1199 | // qDebug("AddressBook::resources() 1"); | 1199 | // qDebug("AddressBook::resources() 1"); |
1200 | 1200 | ||
1201 | KRES::Manager<Resource>::ActiveIterator it; | 1201 | KRES::Manager<Resource>::ActiveIterator it; |
1202 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 1202 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
1203 | list.append( *it ); | 1203 | list.append( *it ); |
1204 | 1204 | ||
1205 | return list; | 1205 | return list; |
1206 | } | 1206 | } |
1207 | 1207 | ||
1208 | /*US | 1208 | /*US |
1209 | void AddressBook::setErrorHandler( ErrorHandler *handler ) | 1209 | void AddressBook::setErrorHandler( ErrorHandler *handler ) |
1210 | { | 1210 | { |
1211 | delete d->mErrorHandler; | 1211 | delete d->mErrorHandler; |
1212 | d->mErrorHandler = handler; | 1212 | d->mErrorHandler = handler; |
1213 | } | 1213 | } |
1214 | */ | 1214 | */ |
1215 | 1215 | ||
1216 | void AddressBook::error( const QString& msg ) | 1216 | void AddressBook::error( const QString& msg ) |
1217 | { | 1217 | { |
1218 | /*US | 1218 | /*US |
1219 | if ( !d->mErrorHandler ) // create default error handler | 1219 | if ( !d->mErrorHandler ) // create default error handler |
1220 | d->mErrorHandler = new ConsoleErrorHandler; | 1220 | d->mErrorHandler = new ConsoleErrorHandler; |
1221 | 1221 | ||
1222 | if ( d->mErrorHandler ) | 1222 | if ( d->mErrorHandler ) |
1223 | d->mErrorHandler->error( msg ); | 1223 | d->mErrorHandler->error( msg ); |
1224 | else | 1224 | else |
1225 | kdError(5700) << "no error handler defined" << endl; | 1225 | kdError(5700) << "no error handler defined" << endl; |
1226 | */ | 1226 | */ |
1227 | kdDebug(5700) << "msg" << endl; | 1227 | kdDebug(5700) << "msg" << endl; |
1228 | qDebug(msg); | 1228 | qDebug(msg); |
1229 | } | 1229 | } |
1230 | 1230 | ||
1231 | void AddressBook::deleteRemovedAddressees() | 1231 | void AddressBook::deleteRemovedAddressees() |
1232 | { | 1232 | { |
1233 | Addressee::List::Iterator it; | 1233 | Addressee::List::Iterator it; |
1234 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { | 1234 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { |
1235 | Resource *resource = (*it).resource(); | 1235 | Resource *resource = (*it).resource(); |
1236 | if ( resource && !resource->readOnly() && resource->isOpen() ) | 1236 | if ( resource && !resource->readOnly() && resource->isOpen() ) |
1237 | resource->removeAddressee( *it ); | 1237 | resource->removeAddressee( *it ); |
1238 | } | 1238 | } |
1239 | 1239 | ||
1240 | d->mRemovedAddressees.clear(); | 1240 | d->mRemovedAddressees.clear(); |
1241 | } | 1241 | } |
1242 | 1242 | ||
1243 | void AddressBook::setStandardResource( Resource *resource ) | 1243 | void AddressBook::setStandardResource( Resource *resource ) |
1244 | { | 1244 | { |
1245 | // qDebug("AddressBook::setStandardResource 1"); | 1245 | // qDebug("AddressBook::setStandardResource 1"); |
1246 | d->mManager->setStandardResource( resource ); | 1246 | d->mManager->setStandardResource( resource ); |
1247 | } | 1247 | } |
1248 | 1248 | ||
1249 | Resource *AddressBook::standardResource() | 1249 | Resource *AddressBook::standardResource() |
1250 | { | 1250 | { |
1251 | return d->mManager->standardResource(); | 1251 | return d->mManager->standardResource(); |
1252 | } | 1252 | } |
1253 | 1253 | ||
1254 | KRES::Manager<Resource> *AddressBook::resourceManager() | 1254 | KRES::Manager<Resource> *AddressBook::resourceManager() |
1255 | { | 1255 | { |
1256 | return d->mManager; | 1256 | return d->mManager; |
1257 | } | 1257 | } |
1258 | 1258 | ||
1259 | void AddressBook::cleanUp() | 1259 | void AddressBook::cleanUp() |
1260 | { | 1260 | { |
1261 | KRES::Manager<Resource>::ActiveIterator it; | 1261 | KRES::Manager<Resource>::ActiveIterator it; |
1262 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 1262 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
1263 | if ( !(*it)->readOnly() && (*it)->isOpen() ) | 1263 | if ( !(*it)->readOnly() && (*it)->isOpen() ) |
1264 | (*it)->cleanUp(); | 1264 | (*it)->cleanUp(); |
1265 | } | 1265 | } |
1266 | } | 1266 | } |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 2351add..18c03b5 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -1,350 +1,350 @@ | |||
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 | #ifndef KABC_ADDRESSBOOK_H | 28 | #ifndef KABC_ADDRESSBOOK_H |
29 | #define KABC_ADDRESSBOOK_H | 29 | #define KABC_ADDRESSBOOK_H |
30 | 30 | ||
31 | #include <qobject.h> | 31 | #include <qobject.h> |
32 | 32 | ||
33 | #include <kresources/manager.h> | 33 | #include <kresources/manager.h> |
34 | #include <qptrlist.h> | 34 | #include <qptrlist.h> |
35 | 35 | ||
36 | #include "addressee.h" | 36 | #include "addressee.h" |
37 | #include "field.h" | 37 | #include "field.h" |
38 | 38 | ||
39 | namespace KABC { | 39 | namespace KABC { |
40 | 40 | ||
41 | class ErrorHandler; | 41 | class ErrorHandler; |
42 | class Resource; | 42 | class Resource; |
43 | class Ticket; | 43 | class Ticket; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | @short Address Book | 46 | @short Address Book |
47 | 47 | ||
48 | This class provides access to a collection of address book entries. | 48 | This class provides access to a collection of address book entries. |
49 | */ | 49 | */ |
50 | class AddressBook : public QObject | 50 | class AddressBook : public QObject |
51 | { | 51 | { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | friend QDataStream &operator<<( QDataStream &, const AddressBook & ); | 54 | friend QDataStream &operator<<( QDataStream &, const AddressBook & ); |
55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); | 55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); |
56 | friend class StdAddressBook; | 56 | friend class StdAddressBook; |
57 | 57 | ||
58 | public: | 58 | public: |
59 | /** | 59 | /** |
60 | @short Address Book Iterator | 60 | @short Address Book Iterator |
61 | 61 | ||
62 | This class provides an iterator for address book entries. | 62 | This class provides an iterator for address book entries. |
63 | */ | 63 | */ |
64 | class Iterator | 64 | class Iterator |
65 | { | 65 | { |
66 | public: | 66 | public: |
67 | Iterator(); | 67 | Iterator(); |
68 | Iterator( const Iterator & ); | 68 | Iterator( const Iterator & ); |
69 | ~Iterator(); | 69 | ~Iterator(); |
70 | 70 | ||
71 | Iterator &operator=( const Iterator & ); | 71 | Iterator &operator=( const Iterator & ); |
72 | const Addressee &operator*() const; | 72 | const Addressee &operator*() const; |
73 | Addressee &operator*(); | 73 | Addressee &operator*(); |
74 | Addressee* operator->(); | 74 | Addressee* operator->(); |
75 | Iterator &operator++(); | 75 | Iterator &operator++(); |
76 | Iterator &operator++(int); | 76 | Iterator &operator++(int); |
77 | Iterator &operator--(); | 77 | Iterator &operator--(); |
78 | Iterator &operator--(int); | 78 | Iterator &operator--(int); |
79 | bool operator==( const Iterator &it ); | 79 | bool operator==( const Iterator &it ); |
80 | bool operator!=( const Iterator &it ); | 80 | bool operator!=( const Iterator &it ); |
81 | 81 | ||
82 | struct IteratorData; | 82 | struct IteratorData; |
83 | IteratorData *d; | 83 | IteratorData *d; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | /** | 86 | /** |
87 | @short Address Book Const Iterator | 87 | @short Address Book Const Iterator |
88 | 88 | ||
89 | This class provides a const iterator for address book entries. | 89 | This class provides a const iterator for address book entries. |
90 | */ | 90 | */ |
91 | class ConstIterator | 91 | class ConstIterator |
92 | { | 92 | { |
93 | public: | 93 | public: |
94 | ConstIterator(); | 94 | ConstIterator(); |
95 | ConstIterator( const ConstIterator & ); | 95 | ConstIterator( const ConstIterator & ); |
96 | ~ConstIterator(); | 96 | ~ConstIterator(); |
97 | 97 | ||
98 | ConstIterator &operator=( const ConstIterator & ); | 98 | ConstIterator &operator=( const ConstIterator & ); |
99 | const Addressee &operator*() const; | 99 | const Addressee &operator*() const; |
100 | const Addressee* operator->() const; | 100 | const Addressee* operator->() const; |
101 | ConstIterator &operator++(); | 101 | ConstIterator &operator++(); |
102 | ConstIterator &operator++(int); | 102 | ConstIterator &operator++(int); |
103 | ConstIterator &operator--(); | 103 | ConstIterator &operator--(); |
104 | ConstIterator &operator--(int); | 104 | ConstIterator &operator--(int); |
105 | bool operator==( const ConstIterator &it ); | 105 | bool operator==( const ConstIterator &it ); |
106 | bool operator!=( const ConstIterator &it ); | 106 | bool operator!=( const ConstIterator &it ); |
107 | 107 | ||
108 | struct ConstIteratorData; | 108 | struct ConstIteratorData; |
109 | ConstIteratorData *d; | 109 | ConstIteratorData *d; |
110 | }; | 110 | }; |
111 | 111 | ||
112 | /** | 112 | /** |
113 | Constructs a address book object. | 113 | Constructs a address book object. |
114 | 114 | ||
115 | @param format File format class. | 115 | @param format File format class. |
116 | */ | 116 | */ |
117 | AddressBook(); | 117 | AddressBook(); |
118 | AddressBook( const QString &config ); | 118 | AddressBook( const QString &config ); |
119 | AddressBook( const QString &config, const QString &family ); | 119 | AddressBook( const QString &config, const QString &family ); |
120 | virtual ~AddressBook(); | 120 | virtual ~AddressBook(); |
121 | 121 | ||
122 | /** | 122 | /** |
123 | Requests a ticket for saving the addressbook. Calling this function locks | 123 | Requests a ticket for saving the addressbook. Calling this function locks |
124 | the addressbook for all other processes. If the address book is already | 124 | the addressbook for all other processes. If the address book is already |
125 | locked the function returns 0. You need the returned @ref Ticket object | 125 | locked the function returns 0. You need the returned @ref Ticket object |
126 | for calling the @ref save() function. | 126 | for calling the @ref save() function. |
127 | 127 | ||
128 | @see save() | 128 | @see save() |
129 | */ | 129 | */ |
130 | Ticket *requestSaveTicket( Resource *resource=0 ); | 130 | Ticket *requestSaveTicket( Resource *resource=0 ); |
131 | 131 | ||
132 | /** | 132 | /** |
133 | Load address book from file. | 133 | Load address book from file. |
134 | */ | 134 | */ |
135 | bool load(); | 135 | bool load(); |
136 | 136 | ||
137 | /** | 137 | /** |
138 | Save address book. The address book is saved to the file, the Ticket | 138 | Save address book. The address book is saved to the file, the Ticket |
139 | object has been requested for by @ref requestSaveTicket(). | 139 | object has been requested for by @ref requestSaveTicket(). |
140 | 140 | ||
141 | @param ticket a ticket object returned by @ref requestSaveTicket() | 141 | @param ticket a ticket object returned by @ref requestSaveTicket() |
142 | */ | 142 | */ |
143 | bool save( Ticket *ticket ); | 143 | bool save( Ticket *ticket ); |
144 | bool saveAB( ); | 144 | bool saveAB( ); |
145 | bool saveABphone( QString fileName ); | 145 | bool saveABphone( QString fileName ); |
146 | void smplifyAddressees(); | 146 | void smplifyAddressees(); |
147 | void removeSyncInfo( QString syncProfile); | 147 | void removeSyncInfo( QString syncProfile); |
148 | void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); | 148 | void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); |
149 | void export2File( QString fileName ); | 149 | void export2File( QString fileName ); |
150 | bool export2PhoneFormat( QStringList uids ,QString fileName ); | 150 | bool export2PhoneFormat( QStringList uids ,QString fileName ); |
151 | int importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); | 151 | int importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); |
152 | void setUntagged( bool setNonSyncTagged = false ); | 152 | void setUntagged( bool setNonSyncTagged = false ); |
153 | void removeUntagged(); | 153 | void removeUntagged(); |
154 | void findNewExtIds( QString fileName, QString currentSyncDevice ); | 154 | void findNewExtIds( QString fileName, QString currentSyncDevice ); |
155 | /** | 155 | /** |
156 | Returns a iterator for first entry of address book. | 156 | Returns a iterator for first entry of address book. |
157 | */ | 157 | */ |
158 | Iterator begin(); | 158 | Iterator begin(); |
159 | 159 | ||
160 | /** | 160 | /** |
161 | Returns a const iterator for first entry of address book. | 161 | Returns a const iterator for first entry of address book. |
162 | */ | 162 | */ |
163 | ConstIterator begin() const; | 163 | ConstIterator begin() const; |
164 | 164 | ||
165 | /** | 165 | /** |
166 | Returns a iterator for first entry of address book. | 166 | Returns a iterator for first entry of address book. |
167 | */ | 167 | */ |
168 | Iterator end(); | 168 | Iterator end(); |
169 | 169 | ||
170 | /** | 170 | /** |
171 | Returns a const iterator for first entry of address book. | 171 | Returns a const iterator for first entry of address book. |
172 | */ | 172 | */ |
173 | ConstIterator end() const; | 173 | ConstIterator end() const; |
174 | 174 | ||
175 | /** | 175 | /** |
176 | Removes all entries from address book. | 176 | Removes all entries from address book. |
177 | */ | 177 | */ |
178 | void clear(); | 178 | void clear(); |
179 | 179 | ||
180 | /** | 180 | /** |
181 | Insert an Addressee object into address book. If an object with the same | 181 | Insert an Addressee object into address book. If an object with the same |
182 | unique id already exists in the address book it it replaced by the new | 182 | unique id already exists in the address book it it replaced by the new |
183 | one. If not the new object is appended to the address book. | 183 | one. If not the new object is appended to the address book. |
184 | */ | 184 | */ |
185 | void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); | 185 | void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); |
186 | 186 | ||
187 | /** | 187 | /** |
188 | Removes entry from the address book. | 188 | Removes entry from the address book. |
189 | */ | 189 | */ |
190 | void removeAddressee( const Addressee & ); | 190 | void removeAddressee( const Addressee & ); |
191 | 191 | ||
192 | /** | 192 | /** |
193 | This is like @ref removeAddressee() just above, with the difference that | 193 | This is like @ref removeAddressee() just above, with the difference that |
194 | the first element is a iterator, returned by @ref begin(). | 194 | the first element is a iterator, returned by @ref begin(). |
195 | */ | 195 | */ |
196 | void removeAddressee( const Iterator & ); | 196 | void removeAddressee( const Iterator & ); |
197 | 197 | ||
198 | /** | 198 | /** |
199 | Find the specified entry in address book. Returns end(), if the entry | 199 | Find the specified entry in address book. Returns end(), if the entry |
200 | couldn't be found. | 200 | couldn't be found. |
201 | */ | 201 | */ |
202 | Iterator find( const Addressee & ); | 202 | Iterator find( const Addressee & ); |
203 | 203 | ||
204 | /** | 204 | /** |
205 | Find the entry specified by an unique id. Returns an empty Addressee | 205 | Find the entry specified by an unique id. Returns an empty Addressee |
206 | object, if the address book does not contain an entry with this id. | 206 | object, if the address book does not contain an entry with this id. |
207 | */ | 207 | */ |
208 | Addressee findByUid( const QString & ); | 208 | Addressee findByUid( const QString & ); |
209 | 209 | ||
210 | 210 | ||
211 | /** | 211 | /** |
212 | Returns a list of all addressees in the address book. This list can | 212 | Returns a list of all addressees in the address book. This list can |
213 | be sorted with @ref KABC::AddresseeList for example. | 213 | be sorted with @ref KABC::AddresseeList for example. |
214 | */ | 214 | */ |
215 | Addressee::List allAddressees(); | 215 | Addressee::List allAddressees(); |
216 | 216 | ||
217 | /** | 217 | /** |
218 | Find all entries with the specified name in the address book. Returns | 218 | Find all entries with the specified name in the address book. Returns |
219 | an empty list, if no entries could be found. | 219 | an empty list, if no entries could be found. |
220 | */ | 220 | */ |
221 | Addressee::List findByName( const QString & ); | 221 | Addressee::List findByName( const QString & ); |
222 | 222 | ||
223 | /** | 223 | /** |
224 | Find all entries with the specified email address in the address book. | 224 | Find all entries with the specified email address in the address book. |
225 | Returns an empty list, if no entries could be found. | 225 | Returns an empty list, if no entries could be found. |
226 | */ | 226 | */ |
227 | Addressee::List findByEmail( const QString & ); | 227 | Addressee::List findByEmail( const QString & ); |
228 | 228 | ||
229 | /** | 229 | /** |
230 | Find all entries wich have the specified category in the address book. | 230 | Find all entries wich have the specified category in the address book. |
231 | Returns an empty list, if no entries could be found. | 231 | Returns an empty list, if no entries could be found. |
232 | */ | 232 | */ |
233 | Addressee::List findByCategory( const QString & ); | 233 | Addressee::List findByCategory( const QString & ); |
234 | 234 | ||
235 | /** | 235 | /** |
236 | Return a string identifying this addressbook. | 236 | Return a string identifying this addressbook. |
237 | */ | 237 | */ |
238 | virtual QString identifier(); | 238 | virtual QString identifier(); |
239 | 239 | ||
240 | /** | 240 | /** |
241 | Used for debug output. | 241 | Used for debug output. |
242 | */ | 242 | */ |
243 | void dump() const; | 243 | void dump() const; |
244 | 244 | ||
245 | void emitAddressBookLocked() { emit addressBookLocked( this ); } | 245 | void emitAddressBookLocked() { emit addressBookLocked( this ); } |
246 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } | 246 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } |
247 | void emitAddressBookChanged() { emit addressBookChanged( this ); } | 247 | void emitAddressBookChanged() { emit addressBookChanged( this ); } |
248 | 248 | ||
249 | /** | 249 | /** |
250 | Return list of all Fields known to the address book which are associated | 250 | Return list of all Fields known to the address book which are associated |
251 | with the given field category. | 251 | with the given field category. |
252 | */ | 252 | */ |
253 | Field::List fields( int category = Field::All ); | 253 | Field::List fields( int category = Field::All ); |
254 | 254 | ||
255 | /** | 255 | /** |
256 | Add custom field to address book. | 256 | Add custom field to address book. |
257 | 257 | ||
258 | @param label User visible label of the field. | 258 | @param label User visible label of the field. |
259 | @param category Ored list of field categories. | 259 | @param category Ored list of field categories. |
260 | @param key Identifier used as key for reading and writing the field. | 260 | @param key Identifier used as key for reading and writing the field. |
261 | @param app String used as application key for reading and writing | 261 | @param app String used as application key for reading and writing |
262 | the field. | 262 | the field. |
263 | */ | 263 | */ |
264 | bool addCustomField( const QString &label, int category = Field::All, | 264 | bool addCustomField( const QString &label, int category = Field::All, |
265 | const QString &key = QString::null, | 265 | const QString &key = QString::null, |
266 | const QString &app = QString::null ); | 266 | const QString &app = QString::null ); |
267 | 267 | ||
268 | 268 | ||
269 | /** | 269 | /** |
270 | Add address book resource. | 270 | Add address book resource. |
271 | */ | 271 | */ |
272 | bool addResource( Resource * ); | 272 | bool addResource( Resource * ); |
273 | 273 | ||
274 | /** | 274 | /** |
275 | Remove address book resource. | 275 | Remove address book resource. |
276 | */ | 276 | */ |
277 | void removeResources(); | 277 | void removeResources(); |
278 | bool removeResource( Resource * ); | 278 | bool removeResource( Resource * ); |
279 | 279 | ||
280 | /** | 280 | /** |
281 | Return pointer list of all resources. | 281 | Return pointer list of all resources. |
282 | */ | 282 | */ |
283 | QPtrList<Resource> resources(); | 283 | QPtrList<Resource> resources(); |
284 | 284 | ||
285 | /** | 285 | /** |
286 | Set the @p ErrorHandler, that is used by @ref error() to | 286 | Set the @p ErrorHandler, that is used by @ref error() to |
287 | provide gui-independend error messages. | 287 | provide gui-independend error messages. |
288 | */ | 288 | */ |
289 | void setErrorHandler( ErrorHandler * ); | 289 | void setErrorHandler( ErrorHandler * ); |
290 | 290 | ||
291 | /** | 291 | /** |
292 | Shows gui independend error messages. | 292 | Shows gui independend error messages. |
293 | */ | 293 | */ |
294 | void error( const QString& ); | 294 | void error( const QString& ); |
295 | 295 | ||
296 | /** | 296 | /** |
297 | Query all resources to clean up their lock files | 297 | Query all resources to clean up their lock files |
298 | */ | 298 | */ |
299 | void cleanUp(); | 299 | void cleanUp(); |
300 | 300 | ||
301 | // sync stuff | 301 | // sync stuff |
302 | //Addressee::List getExternLastSyncAddressees(); | 302 | //Addressee::List getExternLastSyncAddressees(); |
303 | void resetTempSyncStat(); | 303 | void resetTempSyncStat(); |
304 | QStringList uidList(); | 304 | QStringList uidList(); |
305 | void removeSyncAddressees( bool removeDeleted = false ); | 305 | void removeSyncAddressees( bool removeDeleted = false ); |
306 | void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); | 306 | void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); |
307 | Addressee findByExternUid( const QString& uid , const QString& profile ); | 307 | const Addressee findByExternUid( const QString& uid , const QString& profile ) const; |
308 | bool containsExternalUid( const QString& uid ); | 308 | bool containsExternalUid( const QString& uid ); |
309 | 309 | ||
310 | void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); | 310 | void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); |
311 | void postExternSync( AddressBook* aBook, const QString& csd , bool setID ); | 311 | void postExternSync( AddressBook* aBook, const QString& csd , bool setID ); |
312 | signals: | 312 | signals: |
313 | /** | 313 | /** |
314 | Emitted, when the address book has changed on disk. | 314 | Emitted, when the address book has changed on disk. |
315 | */ | 315 | */ |
316 | void addressBookChanged( AddressBook * ); | 316 | void addressBookChanged( AddressBook * ); |
317 | 317 | ||
318 | /** | 318 | /** |
319 | Emitted, when the address book has been locked for writing. | 319 | Emitted, when the address book has been locked for writing. |
320 | */ | 320 | */ |
321 | void addressBookLocked( AddressBook * ); | 321 | void addressBookLocked( AddressBook * ); |
322 | 322 | ||
323 | /** | 323 | /** |
324 | Emitted, when the address book has been unlocked. | 324 | Emitted, when the address book has been unlocked. |
325 | */ | 325 | */ |
326 | void addressBookUnlocked( AddressBook * ); | 326 | void addressBookUnlocked( AddressBook * ); |
327 | 327 | ||
328 | protected: | 328 | protected: |
329 | void deleteRemovedAddressees(); | 329 | void deleteRemovedAddressees(); |
330 | void setStandardResource( Resource * ); | 330 | void setStandardResource( Resource * ); |
331 | Resource *standardResource(); | 331 | Resource *standardResource(); |
332 | KRES::Manager<Resource> *resourceManager(); | 332 | KRES::Manager<Resource> *resourceManager(); |
333 | 333 | ||
334 | void init(const QString &config, const QString &family); | 334 | void init(const QString &config, const QString &family); |
335 | 335 | ||
336 | private: | 336 | private: |
337 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 | 337 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 |
338 | 338 | ||
339 | 339 | ||
340 | struct AddressBookData; | 340 | struct AddressBookData; |
341 | AddressBookData *d; | 341 | AddressBookData *d; |
342 | bool blockLSEchange; | 342 | bool blockLSEchange; |
343 | }; | 343 | }; |
344 | 344 | ||
345 | QDataStream &operator<<( QDataStream &, const AddressBook & ); | 345 | QDataStream &operator<<( QDataStream &, const AddressBook & ); |
346 | QDataStream &operator>>( QDataStream &, AddressBook & ); | 346 | QDataStream &operator>>( QDataStream &, AddressBook & ); |
347 | 347 | ||
348 | } | 348 | } |
349 | 349 | ||
350 | #endif | 350 | #endif |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index d60cd6b..3b238f5 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,2141 +1,2141 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | 30 | ||
31 | #include <ksharedptr.h> | 31 | #include <ksharedptr.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kidmanager.h> | 35 | #include <kidmanager.h> |
36 | //US | 36 | //US |
37 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | 38 | #include <libkcal/syncdefines.h> |
39 | 39 | ||
40 | //US #include "resource.h" | 40 | //US #include "resource.h" |
41 | #include "addressee.h" | 41 | #include "addressee.h" |
42 | 42 | ||
43 | using namespace KABC; | 43 | using namespace KABC; |
44 | 44 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
46 | static bool matchBinaryPatternA( int value, int pattern ); | 46 | static bool matchBinaryPatternA( int value, int pattern ); |
47 | static bool matchBinaryPatternP( int value, int pattern ); | 47 | static bool matchBinaryPatternP( int value, int pattern ); |
48 | 48 | ||
49 | struct Addressee::AddresseeData : public KShared | 49 | struct Addressee::AddresseeData : public KShared |
50 | { | 50 | { |
51 | QString uid; | 51 | QString uid; |
52 | QString name; | 52 | QString name; |
53 | QString formattedName; | 53 | QString formattedName; |
54 | QString familyName; | 54 | QString familyName; |
55 | QString givenName; | 55 | QString givenName; |
56 | QString additionalName; | 56 | QString additionalName; |
57 | QString prefix; | 57 | QString prefix; |
58 | QString suffix; | 58 | QString suffix; |
59 | QString nickName; | 59 | QString nickName; |
60 | QDateTime birthday; | 60 | QDateTime birthday; |
61 | QString mailer; | 61 | QString mailer; |
62 | TimeZone timeZone; | 62 | TimeZone timeZone; |
63 | Geo geo; | 63 | Geo geo; |
64 | QString title; | 64 | QString title; |
65 | QString role; | 65 | QString role; |
66 | QString organization; | 66 | QString organization; |
67 | QString note; | 67 | QString note; |
68 | QString productId; | 68 | QString productId; |
69 | QDateTime revision; | 69 | QDateTime revision; |
70 | QString sortString; | 70 | QString sortString; |
71 | QString externalUID; | 71 | QString externalUID; |
72 | QString originalExternalUID; | 72 | QString originalExternalUID; |
73 | KURL url; | 73 | KURL url; |
74 | Secrecy secrecy; | 74 | Secrecy secrecy; |
75 | Picture logo; | 75 | Picture logo; |
76 | Picture photo; | 76 | Picture photo; |
77 | Sound sound; | 77 | Sound sound; |
78 | Agent agent; | 78 | Agent agent; |
79 | QString mExternalId; | 79 | QString mExternalId; |
80 | PhoneNumber::List phoneNumbers; | 80 | PhoneNumber::List phoneNumbers; |
81 | Address::List addresses; | 81 | Address::List addresses; |
82 | Key::List keys; | 82 | Key::List keys; |
83 | QStringList emails; | 83 | QStringList emails; |
84 | QStringList categories; | 84 | QStringList categories; |
85 | QStringList custom; | 85 | QStringList custom; |
86 | int mTempSyncStat; | 86 | int mTempSyncStat; |
87 | Resource *resource; | 87 | Resource *resource; |
88 | 88 | ||
89 | bool empty :1; | 89 | bool empty :1; |
90 | bool changed :1; | 90 | bool changed :1; |
91 | bool tagged :1; | 91 | bool tagged :1; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | Addressee::Addressee() | 94 | Addressee::Addressee() |
95 | { | 95 | { |
96 | mData = new AddresseeData; | 96 | mData = new AddresseeData; |
97 | mData->empty = true; | 97 | mData->empty = true; |
98 | mData->changed = false; | 98 | mData->changed = false; |
99 | mData->resource = 0; | 99 | mData->resource = 0; |
100 | mData->mExternalId = ":"; | 100 | mData->mExternalId = ":"; |
101 | mData->revision = QDateTime ( QDate( 2003,1,1)); | 101 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
103 | } | 103 | } |
104 | 104 | ||
105 | Addressee::~Addressee() | 105 | Addressee::~Addressee() |
106 | { | 106 | { |
107 | } | 107 | } |
108 | 108 | ||
109 | Addressee::Addressee( const Addressee &a ) | 109 | Addressee::Addressee( const Addressee &a ) |
110 | { | 110 | { |
111 | mData = a.mData; | 111 | mData = a.mData; |
112 | } | 112 | } |
113 | 113 | ||
114 | Addressee &Addressee::operator=( const Addressee &a ) | 114 | Addressee &Addressee::operator=( const Addressee &a ) |
115 | { | 115 | { |
116 | mData = a.mData; | 116 | mData = a.mData; |
117 | return (*this); | 117 | return (*this); |
118 | } | 118 | } |
119 | 119 | ||
120 | Addressee Addressee::copy() | 120 | Addressee Addressee::copy() |
121 | { | 121 | { |
122 | Addressee a; | 122 | Addressee a; |
123 | *(a.mData) = *mData; | 123 | *(a.mData) = *mData; |
124 | return a; | 124 | return a; |
125 | } | 125 | } |
126 | 126 | ||
127 | void Addressee::detach() | 127 | void Addressee::detach() |
128 | { | 128 | { |
129 | if ( mData.count() == 1 ) return; | 129 | if ( mData.count() == 1 ) return; |
130 | *this = copy(); | 130 | *this = copy(); |
131 | } | 131 | } |
132 | 132 | ||
133 | bool Addressee::operator==( const Addressee &a ) const | 133 | bool Addressee::operator==( const Addressee &a ) const |
134 | { | 134 | { |
135 | if ( uid() != a.uid() ) return false; | 135 | if ( uid() != a.uid() ) return false; |
136 | if ( mData->name != a.mData->name ) return false; | 136 | if ( mData->name != a.mData->name ) return false; |
137 | if ( mData->formattedName != a.mData->formattedName ) return false; | 137 | if ( mData->formattedName != a.mData->formattedName ) return false; |
138 | if ( mData->familyName != a.mData->familyName ) return false; | 138 | if ( mData->familyName != a.mData->familyName ) return false; |
139 | if ( mData->givenName != a.mData->givenName ) return false; | 139 | if ( mData->givenName != a.mData->givenName ) return false; |
140 | if ( mData->additionalName != a.mData->additionalName ) return false; | 140 | if ( mData->additionalName != a.mData->additionalName ) return false; |
141 | if ( mData->prefix != a.mData->prefix ) return false; | 141 | if ( mData->prefix != a.mData->prefix ) return false; |
142 | if ( mData->suffix != a.mData->suffix ) return false; | 142 | if ( mData->suffix != a.mData->suffix ) return false; |
143 | if ( mData->nickName != a.mData->nickName ) return false; | 143 | if ( mData->nickName != a.mData->nickName ) return false; |
144 | if ( mData->birthday != a.mData->birthday ) return false; | 144 | if ( mData->birthday != a.mData->birthday ) return false; |
145 | if ( mData->mailer != a.mData->mailer ) return false; | 145 | if ( mData->mailer != a.mData->mailer ) return false; |
146 | if ( mData->timeZone != a.mData->timeZone ) return false; | 146 | if ( mData->timeZone != a.mData->timeZone ) return false; |
147 | if ( mData->geo != a.mData->geo ) return false; | 147 | if ( mData->geo != a.mData->geo ) return false; |
148 | if ( mData->title != a.mData->title ) return false; | 148 | if ( mData->title != a.mData->title ) return false; |
149 | if ( mData->role != a.mData->role ) return false; | 149 | if ( mData->role != a.mData->role ) return false; |
150 | if ( mData->organization != a.mData->organization ) return false; | 150 | if ( mData->organization != a.mData->organization ) return false; |
151 | if ( mData->note != a.mData->note ) return false; | 151 | if ( mData->note != a.mData->note ) return false; |
152 | if ( mData->productId != a.mData->productId ) return false; | 152 | if ( mData->productId != a.mData->productId ) return false; |
153 | //if ( mData->revision != a.mData->revision ) return false; | 153 | //if ( mData->revision != a.mData->revision ) return false; |
154 | if ( mData->sortString != a.mData->sortString ) return false; | 154 | if ( mData->sortString != a.mData->sortString ) return false; |
155 | if ( mData->secrecy != a.mData->secrecy ) return false; | 155 | if ( mData->secrecy != a.mData->secrecy ) return false; |
156 | if ( mData->logo != a.mData->logo ) return false; | 156 | if ( mData->logo != a.mData->logo ) return false; |
157 | if ( mData->photo != a.mData->photo ) return false; | 157 | if ( mData->photo != a.mData->photo ) return false; |
158 | if ( mData->sound != a.mData->sound ) return false; | 158 | if ( mData->sound != a.mData->sound ) return false; |
159 | if ( mData->agent != a.mData->agent ) return false; | 159 | if ( mData->agent != a.mData->agent ) return false; |
160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
161 | ( mData->url != a.mData->url ) ) return false; | 161 | ( mData->url != a.mData->url ) ) return false; |
162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
163 | if ( mData->addresses != a.mData->addresses ) return false; | 163 | if ( mData->addresses != a.mData->addresses ) return false; |
164 | if ( mData->keys != a.mData->keys ) return false; | 164 | if ( mData->keys != a.mData->keys ) return false; |
165 | if ( mData->emails != a.mData->emails ) return false; | 165 | if ( mData->emails != a.mData->emails ) return false; |
166 | if ( mData->categories != a.mData->categories ) return false; | 166 | if ( mData->categories != a.mData->categories ) return false; |
167 | if ( mData->custom != a.mData->custom ) return false; | 167 | if ( mData->custom != a.mData->custom ) return false; |
168 | 168 | ||
169 | return true; | 169 | return true; |
170 | } | 170 | } |
171 | 171 | ||
172 | bool Addressee::operator!=( const Addressee &a ) const | 172 | bool Addressee::operator!=( const Addressee &a ) const |
173 | { | 173 | { |
174 | return !( a == *this ); | 174 | return !( a == *this ); |
175 | } | 175 | } |
176 | 176 | ||
177 | bool Addressee::isEmpty() const | 177 | bool Addressee::isEmpty() const |
178 | { | 178 | { |
179 | return mData->empty; | 179 | return mData->empty; |
180 | } | 180 | } |
181 | ulong Addressee::getCsum4List( const QStringList & attList) | 181 | ulong Addressee::getCsum4List( const QStringList & attList) |
182 | { | 182 | { |
183 | int max = attList.count(); | 183 | int max = attList.count(); |
184 | ulong cSum = 0; | 184 | ulong cSum = 0; |
185 | int j,k,i; | 185 | int j,k,i; |
186 | int add; | 186 | int add; |
187 | for ( i = 0; i < max ; ++i ) { | 187 | for ( i = 0; i < max ; ++i ) { |
188 | QString s = attList[i]; | 188 | QString s = attList[i]; |
189 | if ( ! s.isEmpty() ){ | 189 | if ( ! s.isEmpty() ){ |
190 | j = s.length(); | 190 | j = s.length(); |
191 | for ( k = 0; k < j; ++k ) { | 191 | for ( k = 0; k < j; ++k ) { |
192 | int mul = k +1; | 192 | int mul = k +1; |
193 | add = s[k].unicode (); | 193 | add = s[k].unicode (); |
194 | if ( k < 16 ) | 194 | if ( k < 16 ) |
195 | mul = mul * mul; | 195 | mul = mul * mul; |
196 | int ii = i+1; | 196 | int ii = i+1; |
197 | add = add * mul *ii*ii*ii; | 197 | add = add * mul *ii*ii*ii; |
198 | cSum += add; | 198 | cSum += add; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | } | 202 | } |
203 | //QString dump = attList.join(","); | 203 | //QString dump = attList.join(","); |
204 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 204 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
205 | 205 | ||
206 | return cSum; | 206 | return cSum; |
207 | 207 | ||
208 | } | 208 | } |
209 | void Addressee::computeCsum(const QString &dev) | 209 | void Addressee::computeCsum(const QString &dev) |
210 | { | 210 | { |
211 | QStringList l; | 211 | QStringList l; |
212 | //if ( !mData->name.isEmpty() ) l.append(mData->name); | 212 | //if ( !mData->name.isEmpty() ) l.append(mData->name); |
213 | //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 213 | //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
216 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); | 216 | if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); |
217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
231 | // if ( !mData->logo.isEmpty() ) l.append( ); | 231 | // if ( !mData->logo.isEmpty() ) l.append( ); |
232 | //if ( !mData->photo.isEmpty() ) l.append( ); | 232 | //if ( !mData->photo.isEmpty() ) l.append( ); |
233 | //if ( !mData->sound.isEmpty() ) l.append( ); | 233 | //if ( !mData->sound.isEmpty() ) l.append( ); |
234 | //if ( !mData->agent.isEmpty() ) l.append( ); | 234 | //if ( !mData->agent.isEmpty() ) l.append( ); |
235 | if ( mData->url.isValid() ) | 235 | if ( mData->url.isValid() ) |
236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); |
237 | KABC::PhoneNumber::List phoneNumbers; | 237 | KABC::PhoneNumber::List phoneNumbers; |
238 | KABC::PhoneNumber::List::Iterator phoneIter; | 238 | KABC::PhoneNumber::List::Iterator phoneIter; |
239 | 239 | ||
240 | QStringList t; | 240 | QStringList t; |
241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
242 | ++phoneIter ) | 242 | ++phoneIter ) |
243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
244 | t.sort(); | 244 | t.sort(); |
245 | uint iii; | 245 | uint iii; |
246 | for ( iii = 0; iii < t.count(); ++iii) | 246 | for ( iii = 0; iii < t.count(); ++iii) |
247 | l.append( t[iii] ); | 247 | l.append( t[iii] ); |
248 | t = mData->emails; | 248 | t = mData->emails; |
249 | t.sort(); | 249 | t.sort(); |
250 | for ( iii = 0; iii < t.count(); ++iii) | 250 | for ( iii = 0; iii < t.count(); ++iii) |
251 | l.append( t[iii] ); | 251 | l.append( t[iii] ); |
252 | t = mData->categories; | 252 | t = mData->categories; |
253 | t.sort(); | 253 | t.sort(); |
254 | for ( iii = 0; iii < t.count(); ++iii) | 254 | for ( iii = 0; iii < t.count(); ++iii) |
255 | l.append( t[iii] ); | 255 | l.append( t[iii] ); |
256 | t = mData->custom; | 256 | t = mData->custom; |
257 | t.sort(); | 257 | t.sort(); |
258 | for ( iii = 0; iii < t.count(); ++iii) | 258 | for ( iii = 0; iii < t.count(); ++iii) |
259 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { | 259 | if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { |
260 | int find = t[iii].find (':')+1; | 260 | int find = t[iii].find (':')+1; |
261 | //qDebug("lennnn %d %d ", find, t[iii].length()); | 261 | //qDebug("lennnn %d %d ", find, t[iii].length()); |
262 | if ( find < t[iii].length()) | 262 | if ( find < t[iii].length()) |
263 | l.append( t[iii] ); | 263 | l.append( t[iii] ); |
264 | 264 | ||
265 | } | 265 | } |
266 | KABC::Address::List::Iterator addressIter; | 266 | KABC::Address::List::Iterator addressIter; |
267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
268 | ++addressIter ) { | 268 | ++addressIter ) { |
269 | t = (*addressIter).asList(); | 269 | t = (*addressIter).asList(); |
270 | t.sort(); | 270 | t.sort(); |
271 | for ( iii = 0; iii < t.count(); ++iii) | 271 | for ( iii = 0; iii < t.count(); ++iii) |
272 | l.append( t[iii] ); | 272 | l.append( t[iii] ); |
273 | } | 273 | } |
274 | uint cs = getCsum4List(l); | 274 | uint cs = getCsum4List(l); |
275 | 275 | ||
276 | #if 0 | 276 | #if 0 |
277 | for ( iii = 0; iii < l.count(); ++iii) | 277 | for ( iii = 0; iii < l.count(); ++iii) |
278 | qDebug("%d***%s***",iii,l[iii].latin1()); | 278 | qDebug("%d***%s***",iii,l[iii].latin1()); |
279 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 279 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
280 | #endif | 280 | #endif |
281 | 281 | ||
282 | setCsum( dev, QString::number (cs )); | 282 | setCsum( dev, QString::number (cs )); |
283 | } | 283 | } |
284 | 284 | ||
285 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 285 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
286 | { | 286 | { |
287 | 287 | ||
288 | detach(); | 288 | detach(); |
289 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 289 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
290 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 290 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
291 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 291 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
292 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 292 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
293 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 293 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
294 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 294 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
295 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 295 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
296 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 296 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
297 | if ( !mData->birthday.isValid() ) | 297 | if ( !mData->birthday.isValid() ) |
298 | if ( ad.mData->birthday.isValid()) | 298 | if ( ad.mData->birthday.isValid()) |
299 | mData->birthday = ad.mData->birthday; | 299 | mData->birthday = ad.mData->birthday; |
300 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 300 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
301 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 301 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
302 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 302 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
303 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 303 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
304 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 304 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
305 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 305 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
306 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 306 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
307 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 307 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
308 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 308 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
309 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 309 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
310 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 310 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
311 | QStringList t; | 311 | QStringList t; |
312 | QStringList tAD; | 312 | QStringList tAD; |
313 | uint iii; | 313 | uint iii; |
314 | 314 | ||
315 | // ********** phone numbers | 315 | // ********** phone numbers |
316 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 316 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
317 | PhoneNumber::List::Iterator phoneItAD; | 317 | PhoneNumber::List::Iterator phoneItAD; |
318 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 318 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
319 | bool found = false; | 319 | bool found = false; |
320 | PhoneNumber::List::Iterator it; | 320 | PhoneNumber::List::Iterator it; |
321 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 321 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
322 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 322 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
323 | found = true; | 323 | found = true; |
324 | (*it).setType( ( *phoneItAD ).type() ); | 324 | (*it).setType( ( *phoneItAD ).type() ); |
325 | (*it).setNumber( ( *phoneItAD ).number() ); | 325 | (*it).setNumber( ( *phoneItAD ).number() ); |
326 | break; | 326 | break; |
327 | } | 327 | } |
328 | } | 328 | } |
329 | // if ( isSubSet && ! found ) | 329 | // if ( isSubSet && ! found ) |
330 | if ( ! found ) // LR try this one... | 330 | if ( ! found ) // LR try this one... |
331 | mData->phoneNumbers.append( *phoneItAD ); | 331 | mData->phoneNumbers.append( *phoneItAD ); |
332 | } | 332 | } |
333 | if ( isSubSet ) { | 333 | if ( isSubSet ) { |
334 | // ************* emails; | 334 | // ************* emails; |
335 | t = mData->emails; | 335 | t = mData->emails; |
336 | tAD = ad.mData->emails; | 336 | tAD = ad.mData->emails; |
337 | for ( iii = 0; iii < tAD.count(); ++iii) | 337 | for ( iii = 0; iii < tAD.count(); ++iii) |
338 | if ( !t.contains(tAD[iii] ) ) | 338 | if ( !t.contains(tAD[iii] ) ) |
339 | mData->emails.append( tAD[iii] ); | 339 | mData->emails.append( tAD[iii] ); |
340 | } | 340 | } |
341 | 341 | ||
342 | // ************* categories; | 342 | // ************* categories; |
343 | t = mData->categories; | 343 | t = mData->categories; |
344 | tAD = ad.mData->categories; | 344 | tAD = ad.mData->categories; |
345 | for ( iii = 0; iii < tAD.count(); ++iii) | 345 | for ( iii = 0; iii < tAD.count(); ++iii) |
346 | if ( !t.contains(tAD[iii] ) ) | 346 | if ( !t.contains(tAD[iii] ) ) |
347 | mData->categories.append( tAD[iii] ); | 347 | mData->categories.append( tAD[iii] ); |
348 | QStringList::ConstIterator it; | 348 | QStringList::ConstIterator it; |
349 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { | 349 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { |
350 | QString qualifiedName = (*it).left( (*it).find( ":" )); | 350 | QString qualifiedName = (*it).left( (*it).find( ":" )); |
351 | bool found = false; | 351 | bool found = false; |
352 | QStringList::ConstIterator itL; | 352 | QStringList::ConstIterator itL; |
353 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { | 353 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { |
354 | if ( (*itL).startsWith( qualifiedName ) ) { | 354 | if ( (*itL).startsWith( qualifiedName ) ) { |
355 | found = true; | 355 | found = true; |
356 | break; | 356 | break; |
357 | } | 357 | } |
358 | } | 358 | } |
359 | if ( ! found ) { | 359 | if ( ! found ) { |
360 | mData->custom.append( *it ); | 360 | mData->custom.append( *it ); |
361 | } | 361 | } |
362 | } | 362 | } |
363 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; | 363 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; |
364 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; | 364 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; |
365 | if ( !mData->sound.isIntern() ) { | 365 | if ( !mData->sound.isIntern() ) { |
366 | if ( mData->sound.url().isEmpty() ) { | 366 | if ( mData->sound.url().isEmpty() ) { |
367 | mData->sound = ad.mData->sound; | 367 | mData->sound = ad.mData->sound; |
368 | } | 368 | } |
369 | } | 369 | } |
370 | if ( !mData->agent.isIntern() ) { | 370 | if ( !mData->agent.isIntern() ) { |
371 | if ( mData->agent.url().isEmpty() ) { | 371 | if ( mData->agent.url().isEmpty() ) { |
372 | mData->agent = ad.mData->agent; | 372 | mData->agent = ad.mData->agent; |
373 | } | 373 | } |
374 | } | 374 | } |
375 | { | 375 | { |
376 | Key::List::Iterator itA; | 376 | Key::List::Iterator itA; |
377 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | 377 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { |
378 | bool found = false; | 378 | bool found = false; |
379 | Key::List::Iterator it; | 379 | Key::List::Iterator it; |
380 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 380 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
381 | if ( (*it) == (*itA)) { | 381 | if ( (*it) == (*itA)) { |
382 | found = true; | 382 | found = true; |
383 | break; | 383 | break; |
384 | 384 | ||
385 | } | 385 | } |
386 | } | 386 | } |
387 | if ( ! found ) { | 387 | if ( ! found ) { |
388 | mData->keys.append( *itA ); | 388 | mData->keys.append( *itA ); |
389 | } | 389 | } |
390 | } | 390 | } |
391 | } | 391 | } |
392 | KABC::Address::List::Iterator addressIterA; | 392 | KABC::Address::List::Iterator addressIterA; |
393 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { | 393 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { |
394 | bool found = false; | 394 | bool found = false; |
395 | KABC::Address::List::Iterator addressIter; | 395 | KABC::Address::List::Iterator addressIter; |
396 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 396 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
397 | ++addressIter ) { | 397 | ++addressIter ) { |
398 | if ( (*addressIter) == (*addressIterA)) { | 398 | if ( (*addressIter) == (*addressIterA)) { |
399 | found = true; | 399 | found = true; |
400 | (*addressIter).setType( (*addressIterA).type() ); | 400 | (*addressIter).setType( (*addressIterA).type() ); |
401 | break; | 401 | break; |
402 | } | 402 | } |
403 | 403 | ||
404 | } | 404 | } |
405 | if ( isSubSet && ! found ) { | 405 | if ( isSubSet && ! found ) { |
406 | mData->addresses.append( *addressIterA ); | 406 | mData->addresses.append( *addressIterA ); |
407 | } | 407 | } |
408 | } | 408 | } |
409 | //qDebug("merge contact %s ", ad.uid().latin1()); | 409 | //qDebug("merge contact %s ", ad.uid().latin1()); |
410 | setUid( ad.uid() ); | 410 | setUid( ad.uid() ); |
411 | setRevision( ad.revision() ); | 411 | setRevision( ad.revision() ); |
412 | } | 412 | } |
413 | 413 | ||
414 | bool Addressee::removeVoice() | 414 | bool Addressee::removeVoice() |
415 | { | 415 | { |
416 | PhoneNumber::List phoneN = phoneNumbers(); | 416 | PhoneNumber::List phoneN = phoneNumbers(); |
417 | PhoneNumber::List::Iterator phoneIt; | 417 | PhoneNumber::List::Iterator phoneIt; |
418 | bool found = false; | 418 | bool found = false; |
419 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 419 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
420 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 420 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
421 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 421 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
422 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 422 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
423 | insertPhoneNumber( (*phoneIt) ); | 423 | insertPhoneNumber( (*phoneIt) ); |
424 | found = true; | 424 | found = true; |
425 | } | 425 | } |
426 | } | 426 | } |
427 | 427 | ||
428 | } | 428 | } |
429 | return found; | 429 | return found; |
430 | } | 430 | } |
431 | 431 | ||
432 | bool Addressee::containsAdr(const Addressee& ad ) | 432 | bool Addressee::containsAdr(const Addressee& ad ) |
433 | { | 433 | { |
434 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; | 434 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; |
435 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; | 435 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; |
436 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; | 436 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; |
437 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; | 437 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; |
438 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; | 438 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; |
439 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; | 439 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; |
440 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; | 440 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; |
441 | 441 | ||
442 | // compare phone numbers | 442 | // compare phone numbers |
443 | PhoneNumber::List phoneN = ad.phoneNumbers(); | 443 | PhoneNumber::List phoneN = ad.phoneNumbers(); |
444 | PhoneNumber::List::Iterator phoneIt; | 444 | PhoneNumber::List::Iterator phoneIt; |
445 | bool found = false; | 445 | bool found = false; |
446 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 446 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
447 | bool found = false; | 447 | bool found = false; |
448 | PhoneNumber::List phoneL = ad.phoneNumbers(); | 448 | PhoneNumber::List phoneL = ad.phoneNumbers(); |
449 | PhoneNumber::List::Iterator phoneItL; | 449 | PhoneNumber::List::Iterator phoneItL; |
450 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { | 450 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { |
451 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { | 451 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { |
452 | found = true; | 452 | found = true; |
453 | break; | 453 | break; |
454 | } | 454 | } |
455 | } | 455 | } |
456 | if ( ! found ) | 456 | if ( ! found ) |
457 | return false; | 457 | return false; |
458 | } | 458 | } |
459 | return true; | 459 | return true; |
460 | 460 | ||
461 | } | 461 | } |
462 | void Addressee::simplifyAddresses() | 462 | void Addressee::simplifyAddresses() |
463 | { | 463 | { |
464 | 464 | ||
465 | 465 | ||
466 | Address::List list; | 466 | Address::List list; |
467 | Address::List::Iterator it; | 467 | Address::List::Iterator it; |
468 | Address::List::Iterator it2; | 468 | Address::List::Iterator it2; |
469 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 469 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
470 | it2 = it; | 470 | it2 = it; |
471 | ++it2; | 471 | ++it2; |
472 | for( ; it2 != mData->addresses.end(); ++it2 ) { | 472 | for( ; it2 != mData->addresses.end(); ++it2 ) { |
473 | if ( (*it) == (*it2) ) { | 473 | if ( (*it) == (*it2) ) { |
474 | list.append( *it ); | 474 | list.append( *it ); |
475 | break; | 475 | break; |
476 | } | 476 | } |
477 | } | 477 | } |
478 | } | 478 | } |
479 | for( it = list.begin(); it != list.end(); ++it ) { | 479 | for( it = list.begin(); it != list.end(); ++it ) { |
480 | removeAddress( (*it) ); | 480 | removeAddress( (*it) ); |
481 | } | 481 | } |
482 | 482 | ||
483 | list.clear(); | 483 | list.clear(); |
484 | int max = 2; | 484 | int max = 2; |
485 | if ( mData->url.isValid() ) | 485 | if ( mData->url.isValid() ) |
486 | max = 1; | 486 | max = 1; |
487 | if ( mData->addresses.count() <= max ) return ; | 487 | if ( mData->addresses.count() <= max ) return ; |
488 | int count = 0; | 488 | int count = 0; |
489 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 489 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
490 | if ( count >= max ) | 490 | if ( count >= max ) |
491 | list.append( *it ); | 491 | list.append( *it ); |
492 | ++count; | 492 | ++count; |
493 | } | 493 | } |
494 | for( it = list.begin(); it != list.end(); ++it ) { | 494 | for( it = list.begin(); it != list.end(); ++it ) { |
495 | removeAddress( (*it) ); | 495 | removeAddress( (*it) ); |
496 | } | 496 | } |
497 | } | 497 | } |
498 | 498 | ||
499 | // removes all emails but the first | 499 | // removes all emails but the first |
500 | // needed by phone sync | 500 | // needed by phone sync |
501 | void Addressee::simplifyEmails() | 501 | void Addressee::simplifyEmails() |
502 | { | 502 | { |
503 | if ( mData->emails.count() == 0 ) return ; | 503 | if ( mData->emails.count() == 0 ) return ; |
504 | QString email = mData->emails.first(); | 504 | QString email = mData->emails.first(); |
505 | detach(); | 505 | detach(); |
506 | mData->emails.clear(); | 506 | mData->emails.clear(); |
507 | mData->emails.append( email ); | 507 | mData->emails.append( email ); |
508 | } | 508 | } |
509 | 509 | ||
510 | void Addressee::simplifyPhoneNumbers() | 510 | void Addressee::simplifyPhoneNumbers() |
511 | { | 511 | { |
512 | int max = 4; | 512 | int max = 4; |
513 | int inList = mData->phoneNumbers.count(); | 513 | int inList = mData->phoneNumbers.count(); |
514 | KABC::PhoneNumber::List removeNumbers; | 514 | KABC::PhoneNumber::List removeNumbers; |
515 | KABC::PhoneNumber::List::Iterator phoneIter; | 515 | KABC::PhoneNumber::List::Iterator phoneIter; |
516 | if ( inList > max ) { | 516 | if ( inList > max ) { |
517 | // delete non-preferred numbers | 517 | // delete non-preferred numbers |
518 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 518 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
519 | ++phoneIter ) { | 519 | ++phoneIter ) { |
520 | if ( inList > max ) { | 520 | if ( inList > max ) { |
521 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { | 521 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { |
522 | removeNumbers.append( ( *phoneIter ) ); | 522 | removeNumbers.append( ( *phoneIter ) ); |
523 | --inList; | 523 | --inList; |
524 | } | 524 | } |
525 | } else | 525 | } else |
526 | break; | 526 | break; |
527 | } | 527 | } |
528 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 528 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
529 | ++phoneIter ) { | 529 | ++phoneIter ) { |
530 | removePhoneNumber(( *phoneIter )); | 530 | removePhoneNumber(( *phoneIter )); |
531 | } | 531 | } |
532 | // delete preferred numbers | 532 | // delete preferred numbers |
533 | if ( inList > max ) { | 533 | if ( inList > max ) { |
534 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 534 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
535 | ++phoneIter ) { | 535 | ++phoneIter ) { |
536 | if ( inList > max ) { | 536 | if ( inList > max ) { |
537 | removeNumbers.append( ( *phoneIter ) ); | 537 | removeNumbers.append( ( *phoneIter ) ); |
538 | --inList; | 538 | --inList; |
539 | } else | 539 | } else |
540 | break; | 540 | break; |
541 | } | 541 | } |
542 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 542 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
543 | ++phoneIter ) { | 543 | ++phoneIter ) { |
544 | removePhoneNumber(( *phoneIter )); | 544 | removePhoneNumber(( *phoneIter )); |
545 | } | 545 | } |
546 | } | 546 | } |
547 | } | 547 | } |
548 | // remove non-numeric characters | 548 | // remove non-numeric characters |
549 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 549 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
550 | ++phoneIter ) { | 550 | ++phoneIter ) { |
551 | if ( ! ( *phoneIter ).simplifyNumber() ) | 551 | if ( ! ( *phoneIter ).simplifyNumber() ) |
552 | removeNumbers.append( ( *phoneIter ) ); | 552 | removeNumbers.append( ( *phoneIter ) ); |
553 | } | 553 | } |
554 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 554 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
555 | ++phoneIter ) { | 555 | ++phoneIter ) { |
556 | removePhoneNumber(( *phoneIter )); | 556 | removePhoneNumber(( *phoneIter )); |
557 | } | 557 | } |
558 | } | 558 | } |
559 | void Addressee::simplifyPhoneNumberTypes() | 559 | void Addressee::simplifyPhoneNumberTypes() |
560 | { | 560 | { |
561 | KABC::PhoneNumber::List::Iterator phoneIter; | 561 | KABC::PhoneNumber::List::Iterator phoneIter; |
562 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 562 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
563 | ++phoneIter ) | 563 | ++phoneIter ) |
564 | ( *phoneIter ).simplifyType(); | 564 | ( *phoneIter ).simplifyType(); |
565 | } | 565 | } |
566 | void Addressee::removeID(const QString &prof) | 566 | void Addressee::removeID(const QString &prof) |
567 | { | 567 | { |
568 | detach(); | 568 | detach(); |
569 | if ( prof.isEmpty() ) | 569 | if ( prof.isEmpty() ) |
570 | mData->mExternalId = ":"; | 570 | mData->mExternalId = ":"; |
571 | else | 571 | else |
572 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 572 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
573 | 573 | ||
574 | } | 574 | } |
575 | void Addressee::setID( const QString & prof , const QString & id ) | 575 | void Addressee::setID( const QString & prof , const QString & id ) |
576 | { | 576 | { |
577 | detach(); | 577 | detach(); |
578 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 578 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
579 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 579 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
580 | } | 580 | } |
581 | void Addressee::setTempSyncStat( int id ) | 581 | void Addressee::setTempSyncStat( int id ) |
582 | { | 582 | { |
583 | if ( mData->mTempSyncStat == id ) return; | 583 | if ( mData->mTempSyncStat == id ) return; |
584 | detach(); | 584 | detach(); |
585 | mData->mTempSyncStat = id; | 585 | mData->mTempSyncStat = id; |
586 | } | 586 | } |
587 | int Addressee::tempSyncStat() const | 587 | int Addressee::tempSyncStat() const |
588 | { | 588 | { |
589 | return mData->mTempSyncStat; | 589 | return mData->mTempSyncStat; |
590 | } | 590 | } |
591 | 591 | ||
592 | QString Addressee::getID( const QString & prof) | 592 | const QString Addressee::getID( const QString & prof) const |
593 | { | 593 | { |
594 | return KIdManager::getId ( mData->mExternalId, prof ); | 594 | return KIdManager::getId ( mData->mExternalId, prof ); |
595 | } | 595 | } |
596 | 596 | ||
597 | void Addressee::setCsum( const QString & prof , const QString & id ) | 597 | void Addressee::setCsum( const QString & prof , const QString & id ) |
598 | { | 598 | { |
599 | detach(); | 599 | detach(); |
600 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 600 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
601 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 601 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
602 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 602 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
603 | } | 603 | } |
604 | 604 | ||
605 | QString Addressee::getCsum( const QString & prof) | 605 | const QString Addressee::getCsum( const QString & prof) const |
606 | { | 606 | { |
607 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 607 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
608 | } | 608 | } |
609 | 609 | ||
610 | void Addressee::setIDStr( const QString & s ) | 610 | void Addressee::setIDStr( const QString & s ) |
611 | { | 611 | { |
612 | detach(); | 612 | detach(); |
613 | mData->mExternalId = s; | 613 | mData->mExternalId = s; |
614 | } | 614 | } |
615 | 615 | ||
616 | QString Addressee::IDStr() const | 616 | const QString Addressee::IDStr() const |
617 | { | 617 | { |
618 | return mData->mExternalId; | 618 | return mData->mExternalId; |
619 | } | 619 | } |
620 | 620 | ||
621 | void Addressee::setExternalUID( const QString &id ) | 621 | void Addressee::setExternalUID( const QString &id ) |
622 | { | 622 | { |
623 | if ( id == mData->externalUID ) return; | 623 | if ( id == mData->externalUID ) return; |
624 | detach(); | 624 | detach(); |
625 | mData->empty = false; | 625 | mData->empty = false; |
626 | mData->externalUID = id; | 626 | mData->externalUID = id; |
627 | } | 627 | } |
628 | 628 | ||
629 | QString Addressee::externalUID() const | 629 | const QString Addressee::externalUID() const |
630 | { | 630 | { |
631 | return mData->externalUID; | 631 | return mData->externalUID; |
632 | } | 632 | } |
633 | void Addressee::setOriginalExternalUID( const QString &id ) | 633 | void Addressee::setOriginalExternalUID( const QString &id ) |
634 | { | 634 | { |
635 | if ( id == mData->originalExternalUID ) return; | 635 | if ( id == mData->originalExternalUID ) return; |
636 | detach(); | 636 | detach(); |
637 | mData->empty = false; | 637 | mData->empty = false; |
638 | //qDebug("*******Set orig uid %s ", id.latin1()); | 638 | //qDebug("*******Set orig uid %s ", id.latin1()); |
639 | mData->originalExternalUID = id; | 639 | mData->originalExternalUID = id; |
640 | } | 640 | } |
641 | 641 | ||
642 | QString Addressee::originalExternalUID() const | 642 | QString Addressee::originalExternalUID() const |
643 | { | 643 | { |
644 | return mData->originalExternalUID; | 644 | return mData->originalExternalUID; |
645 | } | 645 | } |
646 | 646 | ||
647 | void Addressee::setUid( const QString &id ) | 647 | void Addressee::setUid( const QString &id ) |
648 | { | 648 | { |
649 | if ( id == mData->uid ) return; | 649 | if ( id == mData->uid ) return; |
650 | detach(); | 650 | detach(); |
651 | //qDebug("****setuid %s ", id.latin1()); | 651 | //qDebug("****setuid %s ", id.latin1()); |
652 | mData->empty = false; | 652 | mData->empty = false; |
653 | mData->uid = id; | 653 | mData->uid = id; |
654 | } | 654 | } |
655 | 655 | ||
656 | QString Addressee::uid() const | 656 | const QString Addressee::uid() const |
657 | { | 657 | { |
658 | if ( mData->uid.isEmpty() ) | 658 | if ( mData->uid.isEmpty() ) |
659 | mData->uid = KApplication::randomString( 10 ); | 659 | mData->uid = KApplication::randomString( 10 ); |
660 | 660 | ||
661 | return mData->uid; | 661 | return mData->uid; |
662 | } | 662 | } |
663 | 663 | ||
664 | QString Addressee::uidLabel() | 664 | QString Addressee::uidLabel() |
665 | { | 665 | { |
666 | return i18n("Unique Identifier"); | 666 | return i18n("Unique Identifier"); |
667 | } | 667 | } |
668 | 668 | ||
669 | void Addressee::setName( const QString &name ) | 669 | void Addressee::setName( const QString &name ) |
670 | { | 670 | { |
671 | if ( name == mData->name ) return; | 671 | if ( name == mData->name ) return; |
672 | detach(); | 672 | detach(); |
673 | mData->empty = false; | 673 | mData->empty = false; |
674 | mData->name = name; | 674 | mData->name = name; |
675 | } | 675 | } |
676 | 676 | ||
677 | QString Addressee::name() const | 677 | QString Addressee::name() const |
678 | { | 678 | { |
679 | return mData->name; | 679 | return mData->name; |
680 | } | 680 | } |
681 | 681 | ||
682 | QString Addressee::nameLabel() | 682 | QString Addressee::nameLabel() |
683 | { | 683 | { |
684 | return i18n("Name"); | 684 | return i18n("Name"); |
685 | } | 685 | } |
686 | 686 | ||
687 | 687 | ||
688 | void Addressee::setFormattedName( const QString &formattedName ) | 688 | void Addressee::setFormattedName( const QString &formattedName ) |
689 | { | 689 | { |
690 | if ( formattedName == mData->formattedName ) return; | 690 | if ( formattedName == mData->formattedName ) return; |
691 | detach(); | 691 | detach(); |
692 | mData->empty = false; | 692 | mData->empty = false; |
693 | mData->formattedName = formattedName; | 693 | mData->formattedName = formattedName; |
694 | } | 694 | } |
695 | 695 | ||
696 | QString Addressee::formattedName() const | 696 | QString Addressee::formattedName() const |
697 | { | 697 | { |
698 | return mData->formattedName; | 698 | return mData->formattedName; |
699 | } | 699 | } |
700 | 700 | ||
701 | QString Addressee::formattedNameLabel() | 701 | QString Addressee::formattedNameLabel() |
702 | { | 702 | { |
703 | return i18n("Formatted Name"); | 703 | return i18n("Formatted Name"); |
704 | } | 704 | } |
705 | 705 | ||
706 | 706 | ||
707 | void Addressee::setFamilyName( const QString &familyName ) | 707 | void Addressee::setFamilyName( const QString &familyName ) |
708 | { | 708 | { |
709 | if ( familyName == mData->familyName ) return; | 709 | if ( familyName == mData->familyName ) return; |
710 | detach(); | 710 | detach(); |
711 | mData->empty = false; | 711 | mData->empty = false; |
712 | mData->familyName = familyName; | 712 | mData->familyName = familyName; |
713 | } | 713 | } |
714 | 714 | ||
715 | QString Addressee::familyName() const | 715 | QString Addressee::familyName() const |
716 | { | 716 | { |
717 | return mData->familyName; | 717 | return mData->familyName; |
718 | } | 718 | } |
719 | 719 | ||
720 | QString Addressee::familyNameLabel() | 720 | QString Addressee::familyNameLabel() |
721 | { | 721 | { |
722 | return i18n("Family Name"); | 722 | return i18n("Family Name"); |
723 | } | 723 | } |
724 | 724 | ||
725 | 725 | ||
726 | void Addressee::setGivenName( const QString &givenName ) | 726 | void Addressee::setGivenName( const QString &givenName ) |
727 | { | 727 | { |
728 | if ( givenName == mData->givenName ) return; | 728 | if ( givenName == mData->givenName ) return; |
729 | detach(); | 729 | detach(); |
730 | mData->empty = false; | 730 | mData->empty = false; |
731 | mData->givenName = givenName; | 731 | mData->givenName = givenName; |
732 | } | 732 | } |
733 | 733 | ||
734 | QString Addressee::givenName() const | 734 | QString Addressee::givenName() const |
735 | { | 735 | { |
736 | return mData->givenName; | 736 | return mData->givenName; |
737 | } | 737 | } |
738 | 738 | ||
739 | QString Addressee::givenNameLabel() | 739 | QString Addressee::givenNameLabel() |
740 | { | 740 | { |
741 | return i18n("Given Name"); | 741 | return i18n("Given Name"); |
742 | } | 742 | } |
743 | 743 | ||
744 | 744 | ||
745 | void Addressee::setAdditionalName( const QString &additionalName ) | 745 | void Addressee::setAdditionalName( const QString &additionalName ) |
746 | { | 746 | { |
747 | if ( additionalName == mData->additionalName ) return; | 747 | if ( additionalName == mData->additionalName ) return; |
748 | detach(); | 748 | detach(); |
749 | mData->empty = false; | 749 | mData->empty = false; |
750 | mData->additionalName = additionalName; | 750 | mData->additionalName = additionalName; |
751 | } | 751 | } |
752 | 752 | ||
753 | QString Addressee::additionalName() const | 753 | QString Addressee::additionalName() const |
754 | { | 754 | { |
755 | return mData->additionalName; | 755 | return mData->additionalName; |
756 | } | 756 | } |
757 | 757 | ||
758 | QString Addressee::additionalNameLabel() | 758 | QString Addressee::additionalNameLabel() |
759 | { | 759 | { |
760 | return i18n("Additional Names"); | 760 | return i18n("Additional Names"); |
761 | } | 761 | } |
762 | 762 | ||
763 | 763 | ||
764 | void Addressee::setPrefix( const QString &prefix ) | 764 | void Addressee::setPrefix( const QString &prefix ) |
765 | { | 765 | { |
766 | if ( prefix == mData->prefix ) return; | 766 | if ( prefix == mData->prefix ) return; |
767 | detach(); | 767 | detach(); |
768 | mData->empty = false; | 768 | mData->empty = false; |
769 | mData->prefix = prefix; | 769 | mData->prefix = prefix; |
770 | } | 770 | } |
771 | 771 | ||
772 | QString Addressee::prefix() const | 772 | QString Addressee::prefix() const |
773 | { | 773 | { |
774 | return mData->prefix; | 774 | return mData->prefix; |
775 | } | 775 | } |
776 | 776 | ||
777 | QString Addressee::prefixLabel() | 777 | QString Addressee::prefixLabel() |
778 | { | 778 | { |
779 | return i18n("Honorific Prefixes"); | 779 | return i18n("Honorific Prefixes"); |
780 | } | 780 | } |
781 | 781 | ||
782 | 782 | ||
783 | void Addressee::setSuffix( const QString &suffix ) | 783 | void Addressee::setSuffix( const QString &suffix ) |
784 | { | 784 | { |
785 | if ( suffix == mData->suffix ) return; | 785 | if ( suffix == mData->suffix ) return; |
786 | detach(); | 786 | detach(); |
787 | mData->empty = false; | 787 | mData->empty = false; |
788 | mData->suffix = suffix; | 788 | mData->suffix = suffix; |
789 | } | 789 | } |
790 | 790 | ||
791 | QString Addressee::suffix() const | 791 | QString Addressee::suffix() const |
792 | { | 792 | { |
793 | return mData->suffix; | 793 | return mData->suffix; |
794 | } | 794 | } |
795 | 795 | ||
796 | QString Addressee::suffixLabel() | 796 | QString Addressee::suffixLabel() |
797 | { | 797 | { |
798 | return i18n("Honorific Suffixes"); | 798 | return i18n("Honorific Suffixes"); |
799 | } | 799 | } |
800 | 800 | ||
801 | 801 | ||
802 | void Addressee::setNickName( const QString &nickName ) | 802 | void Addressee::setNickName( const QString &nickName ) |
803 | { | 803 | { |
804 | if ( nickName == mData->nickName ) return; | 804 | if ( nickName == mData->nickName ) return; |
805 | detach(); | 805 | detach(); |
806 | mData->empty = false; | 806 | mData->empty = false; |
807 | mData->nickName = nickName; | 807 | mData->nickName = nickName; |
808 | } | 808 | } |
809 | 809 | ||
810 | QString Addressee::nickName() const | 810 | QString Addressee::nickName() const |
811 | { | 811 | { |
812 | return mData->nickName; | 812 | return mData->nickName; |
813 | } | 813 | } |
814 | 814 | ||
815 | QString Addressee::nickNameLabel() | 815 | QString Addressee::nickNameLabel() |
816 | { | 816 | { |
817 | return i18n("Nick Name"); | 817 | return i18n("Nick Name"); |
818 | } | 818 | } |
819 | 819 | ||
820 | 820 | ||
821 | void Addressee::setBirthday( const QDateTime &birthday ) | 821 | void Addressee::setBirthday( const QDateTime &birthday ) |
822 | { | 822 | { |
823 | if ( birthday == mData->birthday ) return; | 823 | if ( birthday == mData->birthday ) return; |
824 | detach(); | 824 | detach(); |
825 | mData->empty = false; | 825 | mData->empty = false; |
826 | mData->birthday = birthday; | 826 | mData->birthday = birthday; |
827 | } | 827 | } |
828 | 828 | ||
829 | QDateTime Addressee::birthday() const | 829 | QDateTime Addressee::birthday() const |
830 | { | 830 | { |
831 | return mData->birthday; | 831 | return mData->birthday; |
832 | } | 832 | } |
833 | 833 | ||
834 | QString Addressee::birthdayLabel() | 834 | QString Addressee::birthdayLabel() |
835 | { | 835 | { |
836 | return i18n("Birthday"); | 836 | return i18n("Birthday"); |
837 | } | 837 | } |
838 | 838 | ||
839 | 839 | ||
840 | QString Addressee::homeAddressStreetLabel() | 840 | QString Addressee::homeAddressStreetLabel() |
841 | { | 841 | { |
842 | return i18n("Home Address Street"); | 842 | return i18n("Home Address Street"); |
843 | } | 843 | } |
844 | 844 | ||
845 | 845 | ||
846 | QString Addressee::homeAddressLocalityLabel() | 846 | QString Addressee::homeAddressLocalityLabel() |
847 | { | 847 | { |
848 | return i18n("Home Address Locality"); | 848 | return i18n("Home Address Locality"); |
849 | } | 849 | } |
850 | 850 | ||
851 | 851 | ||
852 | QString Addressee::homeAddressRegionLabel() | 852 | QString Addressee::homeAddressRegionLabel() |
853 | { | 853 | { |
854 | return i18n("Home Address Region"); | 854 | return i18n("Home Address Region"); |
855 | } | 855 | } |
856 | 856 | ||
857 | 857 | ||
858 | QString Addressee::homeAddressPostalCodeLabel() | 858 | QString Addressee::homeAddressPostalCodeLabel() |
859 | { | 859 | { |
860 | return i18n("Home Address Postal Code"); | 860 | return i18n("Home Address Postal Code"); |
861 | } | 861 | } |
862 | 862 | ||
863 | 863 | ||
864 | QString Addressee::homeAddressCountryLabel() | 864 | QString Addressee::homeAddressCountryLabel() |
865 | { | 865 | { |
866 | return i18n("Home Address Country"); | 866 | return i18n("Home Address Country"); |
867 | } | 867 | } |
868 | 868 | ||
869 | 869 | ||
870 | QString Addressee::homeAddressLabelLabel() | 870 | QString Addressee::homeAddressLabelLabel() |
871 | { | 871 | { |
872 | return i18n("Home Address Label"); | 872 | return i18n("Home Address Label"); |
873 | } | 873 | } |
874 | 874 | ||
875 | 875 | ||
876 | QString Addressee::businessAddressStreetLabel() | 876 | QString Addressee::businessAddressStreetLabel() |
877 | { | 877 | { |
878 | return i18n("Business Address Street"); | 878 | return i18n("Business Address Street"); |
879 | } | 879 | } |
880 | 880 | ||
881 | 881 | ||
882 | QString Addressee::businessAddressLocalityLabel() | 882 | QString Addressee::businessAddressLocalityLabel() |
883 | { | 883 | { |
884 | return i18n("Business Address Locality"); | 884 | return i18n("Business Address Locality"); |
885 | } | 885 | } |
886 | 886 | ||
887 | 887 | ||
888 | QString Addressee::businessAddressRegionLabel() | 888 | QString Addressee::businessAddressRegionLabel() |
889 | { | 889 | { |
890 | return i18n("Business Address Region"); | 890 | return i18n("Business Address Region"); |
891 | } | 891 | } |
892 | 892 | ||
893 | 893 | ||
894 | QString Addressee::businessAddressPostalCodeLabel() | 894 | QString Addressee::businessAddressPostalCodeLabel() |
895 | { | 895 | { |
896 | return i18n("Business Address Postal Code"); | 896 | return i18n("Business Address Postal Code"); |
897 | } | 897 | } |
898 | 898 | ||
899 | 899 | ||
900 | QString Addressee::businessAddressCountryLabel() | 900 | QString Addressee::businessAddressCountryLabel() |
901 | { | 901 | { |
902 | return i18n("Business Address Country"); | 902 | return i18n("Business Address Country"); |
903 | } | 903 | } |
904 | 904 | ||
905 | 905 | ||
906 | QString Addressee::businessAddressLabelLabel() | 906 | QString Addressee::businessAddressLabelLabel() |
907 | { | 907 | { |
908 | return i18n("Business Address Label"); | 908 | return i18n("Business Address Label"); |
909 | } | 909 | } |
910 | 910 | ||
911 | 911 | ||
912 | QString Addressee::homePhoneLabel() | 912 | QString Addressee::homePhoneLabel() |
913 | { | 913 | { |
914 | return i18n("Home Phone"); | 914 | return i18n("Home Phone"); |
915 | } | 915 | } |
916 | 916 | ||
917 | 917 | ||
918 | QString Addressee::businessPhoneLabel() | 918 | QString Addressee::businessPhoneLabel() |
919 | { | 919 | { |
920 | return i18n("Business Phone"); | 920 | return i18n("Business Phone"); |
921 | } | 921 | } |
922 | 922 | ||
923 | 923 | ||
924 | QString Addressee::mobilePhoneLabel() | 924 | QString Addressee::mobilePhoneLabel() |
925 | { | 925 | { |
926 | return i18n("Mobile Phone"); | 926 | return i18n("Mobile Phone"); |
927 | } | 927 | } |
928 | 928 | ||
929 | 929 | ||
930 | QString Addressee::homeFaxLabel() | 930 | QString Addressee::homeFaxLabel() |
931 | { | 931 | { |
932 | return i18n("Home Fax"); | 932 | return i18n("Home Fax"); |
933 | } | 933 | } |
934 | 934 | ||
935 | 935 | ||
936 | QString Addressee::businessFaxLabel() | 936 | QString Addressee::businessFaxLabel() |
937 | { | 937 | { |
938 | return i18n("Business Fax"); | 938 | return i18n("Business Fax"); |
939 | } | 939 | } |
940 | 940 | ||
941 | 941 | ||
942 | QString Addressee::carPhoneLabel() | 942 | QString Addressee::carPhoneLabel() |
943 | { | 943 | { |
944 | return i18n("Car Phone"); | 944 | return i18n("Car Phone"); |
945 | } | 945 | } |
946 | 946 | ||
947 | 947 | ||
948 | QString Addressee::isdnLabel() | 948 | QString Addressee::isdnLabel() |
949 | { | 949 | { |
950 | return i18n("ISDN"); | 950 | return i18n("ISDN"); |
951 | } | 951 | } |
952 | 952 | ||
953 | 953 | ||
954 | QString Addressee::pagerLabel() | 954 | QString Addressee::pagerLabel() |
955 | { | 955 | { |
956 | return i18n("Pager"); | 956 | return i18n("Pager"); |
957 | } | 957 | } |
958 | 958 | ||
959 | QString Addressee::sipLabel() | 959 | QString Addressee::sipLabel() |
960 | { | 960 | { |
961 | return i18n("SIP"); | 961 | return i18n("SIP"); |
962 | } | 962 | } |
963 | 963 | ||
964 | QString Addressee::emailLabel() | 964 | QString Addressee::emailLabel() |
965 | { | 965 | { |
966 | return i18n("Email Address"); | 966 | return i18n("Email Address"); |
967 | } | 967 | } |
968 | 968 | ||
969 | 969 | ||
970 | void Addressee::setMailer( const QString &mailer ) | 970 | void Addressee::setMailer( const QString &mailer ) |
971 | { | 971 | { |
972 | if ( mailer == mData->mailer ) return; | 972 | if ( mailer == mData->mailer ) return; |
973 | detach(); | 973 | detach(); |
974 | mData->empty = false; | 974 | mData->empty = false; |
975 | mData->mailer = mailer; | 975 | mData->mailer = mailer; |
976 | } | 976 | } |
977 | 977 | ||
978 | QString Addressee::mailer() const | 978 | QString Addressee::mailer() const |
979 | { | 979 | { |
980 | return mData->mailer; | 980 | return mData->mailer; |
981 | } | 981 | } |
982 | 982 | ||
983 | QString Addressee::mailerLabel() | 983 | QString Addressee::mailerLabel() |
984 | { | 984 | { |
985 | return i18n("Mail Client"); | 985 | return i18n("Mail Client"); |
986 | } | 986 | } |
987 | 987 | ||
988 | 988 | ||
989 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 989 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
990 | { | 990 | { |
991 | if ( timeZone == mData->timeZone ) return; | 991 | if ( timeZone == mData->timeZone ) return; |
992 | detach(); | 992 | detach(); |
993 | mData->empty = false; | 993 | mData->empty = false; |
994 | mData->timeZone = timeZone; | 994 | mData->timeZone = timeZone; |
995 | } | 995 | } |
996 | 996 | ||
997 | TimeZone Addressee::timeZone() const | 997 | TimeZone Addressee::timeZone() const |
998 | { | 998 | { |
999 | return mData->timeZone; | 999 | return mData->timeZone; |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | QString Addressee::timeZoneLabel() | 1002 | QString Addressee::timeZoneLabel() |
1003 | { | 1003 | { |
1004 | return i18n("Time Zone"); | 1004 | return i18n("Time Zone"); |
1005 | } | 1005 | } |
1006 | 1006 | ||
1007 | 1007 | ||
1008 | void Addressee::setGeo( const Geo &geo ) | 1008 | void Addressee::setGeo( const Geo &geo ) |
1009 | { | 1009 | { |
1010 | if ( geo == mData->geo ) return; | 1010 | if ( geo == mData->geo ) return; |
1011 | detach(); | 1011 | detach(); |
1012 | mData->empty = false; | 1012 | mData->empty = false; |
1013 | mData->geo = geo; | 1013 | mData->geo = geo; |
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | Geo Addressee::geo() const | 1016 | Geo Addressee::geo() const |
1017 | { | 1017 | { |
1018 | return mData->geo; | 1018 | return mData->geo; |
1019 | } | 1019 | } |
1020 | 1020 | ||
1021 | QString Addressee::geoLabel() | 1021 | QString Addressee::geoLabel() |
1022 | { | 1022 | { |
1023 | return i18n("Geographic Position"); | 1023 | return i18n("Geographic Position"); |
1024 | } | 1024 | } |
1025 | 1025 | ||
1026 | 1026 | ||
1027 | void Addressee::setTitle( const QString &title ) | 1027 | void Addressee::setTitle( const QString &title ) |
1028 | { | 1028 | { |
1029 | if ( title == mData->title ) return; | 1029 | if ( title == mData->title ) return; |
1030 | detach(); | 1030 | detach(); |
1031 | mData->empty = false; | 1031 | mData->empty = false; |
1032 | mData->title = title; | 1032 | mData->title = title; |
1033 | } | 1033 | } |
1034 | 1034 | ||
1035 | QString Addressee::title() const | 1035 | QString Addressee::title() const |
1036 | { | 1036 | { |
1037 | return mData->title; | 1037 | return mData->title; |
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | QString Addressee::titleLabel() | 1040 | QString Addressee::titleLabel() |
1041 | { | 1041 | { |
1042 | return i18n("Title"); | 1042 | return i18n("Title"); |
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | 1045 | ||
1046 | void Addressee::setRole( const QString &role ) | 1046 | void Addressee::setRole( const QString &role ) |
1047 | { | 1047 | { |
1048 | if ( role == mData->role ) return; | 1048 | if ( role == mData->role ) return; |
1049 | detach(); | 1049 | detach(); |
1050 | mData->empty = false; | 1050 | mData->empty = false; |
1051 | mData->role = role; | 1051 | mData->role = role; |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | QString Addressee::role() const | 1054 | QString Addressee::role() const |
1055 | { | 1055 | { |
1056 | return mData->role; | 1056 | return mData->role; |
1057 | } | 1057 | } |
1058 | 1058 | ||
1059 | QString Addressee::roleLabel() | 1059 | QString Addressee::roleLabel() |
1060 | { | 1060 | { |
1061 | return i18n("Role"); | 1061 | return i18n("Role"); |
1062 | } | 1062 | } |
1063 | 1063 | ||
1064 | 1064 | ||
1065 | void Addressee::setOrganization( const QString &organization ) | 1065 | void Addressee::setOrganization( const QString &organization ) |
1066 | { | 1066 | { |
1067 | if ( organization == mData->organization ) return; | 1067 | if ( organization == mData->organization ) return; |
1068 | detach(); | 1068 | detach(); |
1069 | mData->empty = false; | 1069 | mData->empty = false; |
1070 | mData->organization = organization; | 1070 | mData->organization = organization; |
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | QString Addressee::organization() const | 1073 | QString Addressee::organization() const |
1074 | { | 1074 | { |
1075 | return mData->organization; | 1075 | return mData->organization; |
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | QString Addressee::organizationLabel() | 1078 | QString Addressee::organizationLabel() |
1079 | { | 1079 | { |
1080 | return i18n("Organization"); | 1080 | return i18n("Organization"); |
1081 | } | 1081 | } |
1082 | 1082 | ||
1083 | 1083 | ||
1084 | void Addressee::setNote( const QString ¬e ) | 1084 | void Addressee::setNote( const QString ¬e ) |
1085 | { | 1085 | { |
1086 | if ( note == mData->note ) return; | 1086 | if ( note == mData->note ) return; |
1087 | detach(); | 1087 | detach(); |
1088 | mData->empty = false; | 1088 | mData->empty = false; |
1089 | mData->note = note; | 1089 | mData->note = note; |
1090 | } | 1090 | } |
1091 | 1091 | ||
1092 | QString Addressee::note() const | 1092 | QString Addressee::note() const |
1093 | { | 1093 | { |
1094 | return mData->note; | 1094 | return mData->note; |
1095 | } | 1095 | } |
1096 | 1096 | ||
1097 | QString Addressee::noteLabel() | 1097 | QString Addressee::noteLabel() |
1098 | { | 1098 | { |
1099 | return i18n("Note"); | 1099 | return i18n("Note"); |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | 1102 | ||
1103 | void Addressee::setProductId( const QString &productId ) | 1103 | void Addressee::setProductId( const QString &productId ) |
1104 | { | 1104 | { |
1105 | if ( productId == mData->productId ) return; | 1105 | if ( productId == mData->productId ) return; |
1106 | detach(); | 1106 | detach(); |
1107 | mData->empty = false; | 1107 | mData->empty = false; |
1108 | mData->productId = productId; | 1108 | mData->productId = productId; |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | QString Addressee::productId() const | 1111 | QString Addressee::productId() const |
1112 | { | 1112 | { |
1113 | return mData->productId; | 1113 | return mData->productId; |
1114 | } | 1114 | } |
1115 | 1115 | ||
1116 | QString Addressee::productIdLabel() | 1116 | QString Addressee::productIdLabel() |
1117 | { | 1117 | { |
1118 | return i18n("Product Identifier"); | 1118 | return i18n("Product Identifier"); |
1119 | } | 1119 | } |
1120 | 1120 | ||
1121 | 1121 | ||
1122 | void Addressee::setRevision( const QDateTime &revision ) | 1122 | void Addressee::setRevision( const QDateTime &revision ) |
1123 | { | 1123 | { |
1124 | if ( revision == mData->revision ) return; | 1124 | if ( revision == mData->revision ) return; |
1125 | detach(); | 1125 | detach(); |
1126 | mData->empty = false; | 1126 | mData->empty = false; |
1127 | mData->revision = QDateTime( revision.date(), | 1127 | mData->revision = QDateTime( revision.date(), |
1128 | QTime (revision.time().hour(), | 1128 | QTime (revision.time().hour(), |
1129 | revision.time().minute(), | 1129 | revision.time().minute(), |
1130 | revision.time().second())); | 1130 | revision.time().second())); |
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | QDateTime Addressee::revision() const | 1133 | QDateTime Addressee::revision() const |
1134 | { | 1134 | { |
1135 | return mData->revision; | 1135 | return mData->revision; |
1136 | } | 1136 | } |
1137 | 1137 | ||
1138 | QString Addressee::revisionLabel() | 1138 | QString Addressee::revisionLabel() |
1139 | { | 1139 | { |
1140 | return i18n("Revision Date"); | 1140 | return i18n("Revision Date"); |
1141 | } | 1141 | } |
1142 | 1142 | ||
1143 | 1143 | ||
1144 | void Addressee::setSortString( const QString &sortString ) | 1144 | void Addressee::setSortString( const QString &sortString ) |
1145 | { | 1145 | { |
1146 | if ( sortString == mData->sortString ) return; | 1146 | if ( sortString == mData->sortString ) return; |
1147 | detach(); | 1147 | detach(); |
1148 | mData->empty = false; | 1148 | mData->empty = false; |
1149 | mData->sortString = sortString; | 1149 | mData->sortString = sortString; |
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | QString Addressee::sortString() const | 1152 | QString Addressee::sortString() const |
1153 | { | 1153 | { |
1154 | return mData->sortString; | 1154 | return mData->sortString; |
1155 | } | 1155 | } |
1156 | 1156 | ||
1157 | QString Addressee::sortStringLabel() | 1157 | QString Addressee::sortStringLabel() |
1158 | { | 1158 | { |
1159 | return i18n("Sort String"); | 1159 | return i18n("Sort String"); |
1160 | } | 1160 | } |
1161 | 1161 | ||
1162 | 1162 | ||
1163 | void Addressee::setUrl( const KURL &url ) | 1163 | void Addressee::setUrl( const KURL &url ) |
1164 | { | 1164 | { |
1165 | if ( url == mData->url ) return; | 1165 | if ( url == mData->url ) return; |
1166 | detach(); | 1166 | detach(); |
1167 | mData->empty = false; | 1167 | mData->empty = false; |
1168 | mData->url = url; | 1168 | mData->url = url; |
1169 | } | 1169 | } |
1170 | 1170 | ||
1171 | KURL Addressee::url() const | 1171 | KURL Addressee::url() const |
1172 | { | 1172 | { |
1173 | return mData->url; | 1173 | return mData->url; |
1174 | } | 1174 | } |
1175 | 1175 | ||
1176 | QString Addressee::urlLabel() | 1176 | QString Addressee::urlLabel() |
1177 | { | 1177 | { |
1178 | return i18n("URL"); | 1178 | return i18n("URL"); |
1179 | } | 1179 | } |
1180 | 1180 | ||
1181 | 1181 | ||
1182 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 1182 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
1183 | { | 1183 | { |
1184 | if ( secrecy == mData->secrecy ) return; | 1184 | if ( secrecy == mData->secrecy ) return; |
1185 | detach(); | 1185 | detach(); |
1186 | mData->empty = false; | 1186 | mData->empty = false; |
1187 | mData->secrecy = secrecy; | 1187 | mData->secrecy = secrecy; |
1188 | } | 1188 | } |
1189 | 1189 | ||
1190 | Secrecy Addressee::secrecy() const | 1190 | Secrecy Addressee::secrecy() const |
1191 | { | 1191 | { |
1192 | return mData->secrecy; | 1192 | return mData->secrecy; |
1193 | } | 1193 | } |
1194 | 1194 | ||
1195 | QString Addressee::secrecyLabel() | 1195 | QString Addressee::secrecyLabel() |
1196 | { | 1196 | { |
1197 | return i18n("Security Class"); | 1197 | return i18n("Security Class"); |
1198 | } | 1198 | } |
1199 | 1199 | ||
1200 | 1200 | ||
1201 | void Addressee::setLogo( const Picture &logo ) | 1201 | void Addressee::setLogo( const Picture &logo ) |
1202 | { | 1202 | { |
1203 | if ( logo == mData->logo ) return; | 1203 | if ( logo == mData->logo ) return; |
1204 | detach(); | 1204 | detach(); |
1205 | mData->empty = false; | 1205 | mData->empty = false; |
1206 | mData->logo = logo; | 1206 | mData->logo = logo; |
1207 | } | 1207 | } |
1208 | 1208 | ||
1209 | Picture Addressee::logo() const | 1209 | Picture Addressee::logo() const |
1210 | { | 1210 | { |
1211 | return mData->logo; | 1211 | return mData->logo; |
1212 | } | 1212 | } |
1213 | 1213 | ||
1214 | QString Addressee::logoLabel() | 1214 | QString Addressee::logoLabel() |
1215 | { | 1215 | { |
1216 | return i18n("Logo"); | 1216 | return i18n("Logo"); |
1217 | } | 1217 | } |
1218 | 1218 | ||
1219 | 1219 | ||
1220 | void Addressee::setPhoto( const Picture &photo ) | 1220 | void Addressee::setPhoto( const Picture &photo ) |
1221 | { | 1221 | { |
1222 | if ( photo == mData->photo ) return; | 1222 | if ( photo == mData->photo ) return; |
1223 | detach(); | 1223 | detach(); |
1224 | mData->empty = false; | 1224 | mData->empty = false; |
1225 | mData->photo = photo; | 1225 | mData->photo = photo; |
1226 | } | 1226 | } |
1227 | 1227 | ||
1228 | Picture Addressee::photo() const | 1228 | Picture Addressee::photo() const |
1229 | { | 1229 | { |
1230 | return mData->photo; | 1230 | return mData->photo; |
1231 | } | 1231 | } |
1232 | 1232 | ||
1233 | QString Addressee::photoLabel() | 1233 | QString Addressee::photoLabel() |
1234 | { | 1234 | { |
1235 | return i18n("Photo"); | 1235 | return i18n("Photo"); |
1236 | } | 1236 | } |
1237 | 1237 | ||
1238 | 1238 | ||
1239 | void Addressee::setSound( const Sound &sound ) | 1239 | void Addressee::setSound( const Sound &sound ) |
1240 | { | 1240 | { |
1241 | if ( sound == mData->sound ) return; | 1241 | if ( sound == mData->sound ) return; |
1242 | detach(); | 1242 | detach(); |
1243 | mData->empty = false; | 1243 | mData->empty = false; |
1244 | mData->sound = sound; | 1244 | mData->sound = sound; |
1245 | } | 1245 | } |
1246 | 1246 | ||
1247 | Sound Addressee::sound() const | 1247 | Sound Addressee::sound() const |
1248 | { | 1248 | { |
1249 | return mData->sound; | 1249 | return mData->sound; |
1250 | } | 1250 | } |
1251 | 1251 | ||
1252 | QString Addressee::soundLabel() | 1252 | QString Addressee::soundLabel() |
1253 | { | 1253 | { |
1254 | return i18n("Sound"); | 1254 | return i18n("Sound"); |
1255 | } | 1255 | } |
1256 | 1256 | ||
1257 | 1257 | ||
1258 | void Addressee::setAgent( const Agent &agent ) | 1258 | void Addressee::setAgent( const Agent &agent ) |
1259 | { | 1259 | { |
1260 | if ( agent == mData->agent ) return; | 1260 | if ( agent == mData->agent ) return; |
1261 | detach(); | 1261 | detach(); |
1262 | mData->empty = false; | 1262 | mData->empty = false; |
1263 | mData->agent = agent; | 1263 | mData->agent = agent; |
1264 | } | 1264 | } |
1265 | 1265 | ||
1266 | Agent Addressee::agent() const | 1266 | Agent Addressee::agent() const |
1267 | { | 1267 | { |
1268 | return mData->agent; | 1268 | return mData->agent; |
1269 | } | 1269 | } |
1270 | 1270 | ||
1271 | QString Addressee::agentLabel() | 1271 | QString Addressee::agentLabel() |
1272 | { | 1272 | { |
1273 | return i18n("Agent"); | 1273 | return i18n("Agent"); |
1274 | } | 1274 | } |
1275 | 1275 | ||
1276 | 1276 | ||
1277 | 1277 | ||
1278 | void Addressee::setNameFromString( const QString &str ) | 1278 | void Addressee::setNameFromString( const QString &str ) |
1279 | { | 1279 | { |
1280 | setFormattedName( str ); | 1280 | setFormattedName( str ); |
1281 | setName( str ); | 1281 | setName( str ); |
1282 | 1282 | ||
1283 | static bool first = true; | 1283 | static bool first = true; |
1284 | static QStringList titles; | 1284 | static QStringList titles; |
1285 | static QStringList suffixes; | 1285 | static QStringList suffixes; |
1286 | static QStringList prefixes; | 1286 | static QStringList prefixes; |
1287 | 1287 | ||
1288 | if ( first ) { | 1288 | if ( first ) { |
1289 | first = false; | 1289 | first = false; |
1290 | titles += i18n( "Dr." ); | 1290 | titles += i18n( "Dr." ); |
1291 | titles += i18n( "Miss" ); | 1291 | titles += i18n( "Miss" ); |
1292 | titles += i18n( "Mr." ); | 1292 | titles += i18n( "Mr." ); |
1293 | titles += i18n( "Mrs." ); | 1293 | titles += i18n( "Mrs." ); |
1294 | titles += i18n( "Ms." ); | 1294 | titles += i18n( "Ms." ); |
1295 | titles += i18n( "Prof." ); | 1295 | titles += i18n( "Prof." ); |
1296 | 1296 | ||
1297 | suffixes += i18n( "I" ); | 1297 | suffixes += i18n( "I" ); |
1298 | suffixes += i18n( "II" ); | 1298 | suffixes += i18n( "II" ); |
1299 | suffixes += i18n( "III" ); | 1299 | suffixes += i18n( "III" ); |
1300 | suffixes += i18n( "Jr." ); | 1300 | suffixes += i18n( "Jr." ); |
1301 | suffixes += i18n( "Sr." ); | 1301 | suffixes += i18n( "Sr." ); |
1302 | 1302 | ||
1303 | prefixes += "van"; | 1303 | prefixes += "van"; |
1304 | prefixes += "von"; | 1304 | prefixes += "von"; |
1305 | prefixes += "de"; | 1305 | prefixes += "de"; |
1306 | 1306 | ||
1307 | KConfig config( locateLocal( "config", "kabcrc") ); | 1307 | KConfig config( locateLocal( "config", "kabcrc") ); |
1308 | config.setGroup( "General" ); | 1308 | config.setGroup( "General" ); |
1309 | titles += config.readListEntry( "Prefixes" ); | 1309 | titles += config.readListEntry( "Prefixes" ); |
1310 | titles.remove( "" ); | 1310 | titles.remove( "" ); |
1311 | prefixes += config.readListEntry( "Inclusions" ); | 1311 | prefixes += config.readListEntry( "Inclusions" ); |
1312 | prefixes.remove( "" ); | 1312 | prefixes.remove( "" ); |
1313 | suffixes += config.readListEntry( "Suffixes" ); | 1313 | suffixes += config.readListEntry( "Suffixes" ); |
1314 | suffixes.remove( "" ); | 1314 | suffixes.remove( "" ); |
1315 | } | 1315 | } |
1316 | 1316 | ||
1317 | // clear all name parts | 1317 | // clear all name parts |
1318 | setPrefix( "" ); | 1318 | setPrefix( "" ); |
1319 | setGivenName( "" ); | 1319 | setGivenName( "" ); |
1320 | setAdditionalName( "" ); | 1320 | setAdditionalName( "" ); |
1321 | setFamilyName( "" ); | 1321 | setFamilyName( "" ); |
1322 | setSuffix( "" ); | 1322 | setSuffix( "" ); |
1323 | 1323 | ||
1324 | if ( str.isEmpty() ) | 1324 | if ( str.isEmpty() ) |
1325 | return; | 1325 | return; |
1326 | 1326 | ||
1327 | int i = str.find(','); | 1327 | int i = str.find(','); |
1328 | if( i < 0 ) { | 1328 | if( i < 0 ) { |
1329 | QStringList parts = QStringList::split( " ", str ); | 1329 | QStringList parts = QStringList::split( " ", str ); |
1330 | int leftOffset = 0; | 1330 | int leftOffset = 0; |
1331 | int rightOffset = parts.count() - 1; | 1331 | int rightOffset = parts.count() - 1; |
1332 | 1332 | ||
1333 | QString suffix; | 1333 | QString suffix; |
1334 | while ( rightOffset >= 0 ) { | 1334 | while ( rightOffset >= 0 ) { |
1335 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1335 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1336 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1336 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1337 | rightOffset--; | 1337 | rightOffset--; |
1338 | } else | 1338 | } else |
1339 | break; | 1339 | break; |
1340 | } | 1340 | } |
1341 | setSuffix( suffix ); | 1341 | setSuffix( suffix ); |
1342 | 1342 | ||
1343 | if ( rightOffset < 0 ) | 1343 | if ( rightOffset < 0 ) |
1344 | return; | 1344 | return; |
1345 | 1345 | ||
1346 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1346 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1347 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1347 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1348 | rightOffset--; | 1348 | rightOffset--; |
1349 | } else | 1349 | } else |
1350 | setFamilyName( parts[ rightOffset ] ); | 1350 | setFamilyName( parts[ rightOffset ] ); |
1351 | 1351 | ||
1352 | QString prefix; | 1352 | QString prefix; |
1353 | while ( leftOffset < rightOffset ) { | 1353 | while ( leftOffset < rightOffset ) { |
1354 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1354 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1355 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1355 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1356 | leftOffset++; | 1356 | leftOffset++; |
1357 | } else | 1357 | } else |
1358 | break; | 1358 | break; |
1359 | } | 1359 | } |
1360 | setPrefix( prefix ); | 1360 | setPrefix( prefix ); |
1361 | 1361 | ||
1362 | if ( leftOffset < rightOffset ) { | 1362 | if ( leftOffset < rightOffset ) { |
1363 | setGivenName( parts[ leftOffset ] ); | 1363 | setGivenName( parts[ leftOffset ] ); |
1364 | leftOffset++; | 1364 | leftOffset++; |
1365 | } | 1365 | } |
1366 | 1366 | ||
1367 | QString additionalName; | 1367 | QString additionalName; |
1368 | while ( leftOffset < rightOffset ) { | 1368 | while ( leftOffset < rightOffset ) { |
1369 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1369 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1370 | leftOffset++; | 1370 | leftOffset++; |
1371 | } | 1371 | } |
1372 | setAdditionalName( additionalName ); | 1372 | setAdditionalName( additionalName ); |
1373 | } else { | 1373 | } else { |
1374 | QString part1 = str.left( i ); | 1374 | QString part1 = str.left( i ); |
1375 | QString part2 = str.mid( i + 1 ); | 1375 | QString part2 = str.mid( i + 1 ); |
1376 | 1376 | ||
1377 | QStringList parts = QStringList::split( " ", part1 ); | 1377 | QStringList parts = QStringList::split( " ", part1 ); |
1378 | int leftOffset = 0; | 1378 | int leftOffset = 0; |
1379 | int rightOffset = parts.count() - 1; | 1379 | int rightOffset = parts.count() - 1; |
1380 | 1380 | ||
1381 | QString suffix; | 1381 | QString suffix; |
1382 | while ( rightOffset >= 0 ) { | 1382 | while ( rightOffset >= 0 ) { |
1383 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1383 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1384 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1384 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1385 | rightOffset--; | 1385 | rightOffset--; |
1386 | } else | 1386 | } else |
1387 | break; | 1387 | break; |
1388 | } | 1388 | } |
1389 | setSuffix( suffix ); | 1389 | setSuffix( suffix ); |
1390 | 1390 | ||
1391 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1391 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1392 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1392 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1393 | rightOffset--; | 1393 | rightOffset--; |
1394 | } else | 1394 | } else |
1395 | setFamilyName( parts[ rightOffset ] ); | 1395 | setFamilyName( parts[ rightOffset ] ); |
1396 | 1396 | ||
1397 | QString prefix; | 1397 | QString prefix; |
1398 | while ( leftOffset < rightOffset ) { | 1398 | while ( leftOffset < rightOffset ) { |
1399 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1399 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1400 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1400 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1401 | leftOffset++; | 1401 | leftOffset++; |
1402 | } else | 1402 | } else |
1403 | break; | 1403 | break; |
1404 | } | 1404 | } |
1405 | 1405 | ||
1406 | parts = QStringList::split( " ", part2 ); | 1406 | parts = QStringList::split( " ", part2 ); |
1407 | 1407 | ||
1408 | leftOffset = 0; | 1408 | leftOffset = 0; |
1409 | rightOffset = parts.count(); | 1409 | rightOffset = parts.count(); |
1410 | 1410 | ||
1411 | while ( leftOffset < rightOffset ) { | 1411 | while ( leftOffset < rightOffset ) { |
1412 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1412 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1413 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1413 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1414 | leftOffset++; | 1414 | leftOffset++; |
1415 | } else | 1415 | } else |
1416 | break; | 1416 | break; |
1417 | } | 1417 | } |
1418 | setPrefix( prefix ); | 1418 | setPrefix( prefix ); |
1419 | 1419 | ||
1420 | if ( leftOffset < rightOffset ) { | 1420 | if ( leftOffset < rightOffset ) { |
1421 | setGivenName( parts[ leftOffset ] ); | 1421 | setGivenName( parts[ leftOffset ] ); |
1422 | leftOffset++; | 1422 | leftOffset++; |
1423 | } | 1423 | } |
1424 | 1424 | ||
1425 | QString additionalName; | 1425 | QString additionalName; |
1426 | while ( leftOffset < rightOffset ) { | 1426 | while ( leftOffset < rightOffset ) { |
1427 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1427 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1428 | leftOffset++; | 1428 | leftOffset++; |
1429 | } | 1429 | } |
1430 | setAdditionalName( additionalName ); | 1430 | setAdditionalName( additionalName ); |
1431 | } | 1431 | } |
1432 | } | 1432 | } |
1433 | 1433 | ||
1434 | QString Addressee::realName() const | 1434 | QString Addressee::realName() const |
1435 | { | 1435 | { |
1436 | if ( !formattedName().isEmpty() ) | 1436 | if ( !formattedName().isEmpty() ) |
1437 | return formattedName(); | 1437 | return formattedName(); |
1438 | 1438 | ||
1439 | QString n = assembledName(); | 1439 | QString n = assembledName(); |
1440 | 1440 | ||
1441 | if ( n.isEmpty() ) | 1441 | if ( n.isEmpty() ) |
1442 | n = name(); | 1442 | n = name(); |
1443 | 1443 | ||
1444 | return n; | 1444 | return n; |
1445 | } | 1445 | } |
1446 | 1446 | ||
1447 | QString Addressee::assembledName() const | 1447 | QString Addressee::assembledName() const |
1448 | { | 1448 | { |
1449 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1449 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
1450 | familyName() + " " + suffix(); | 1450 | familyName() + " " + suffix(); |
1451 | 1451 | ||
1452 | return name.simplifyWhiteSpace(); | 1452 | return name.simplifyWhiteSpace(); |
1453 | } | 1453 | } |
1454 | 1454 | ||
1455 | QString Addressee::fullEmail( const QString &email ) const | 1455 | QString Addressee::fullEmail( const QString &email ) const |
1456 | { | 1456 | { |
1457 | QString e; | 1457 | QString e; |
1458 | if ( email.isNull() ) { | 1458 | if ( email.isNull() ) { |
1459 | e = preferredEmail(); | 1459 | e = preferredEmail(); |
1460 | } else { | 1460 | } else { |
1461 | e = email; | 1461 | e = email; |
1462 | } | 1462 | } |
1463 | if ( e.isEmpty() ) return QString::null; | 1463 | if ( e.isEmpty() ) return QString::null; |
1464 | 1464 | ||
1465 | QString text; | 1465 | QString text; |
1466 | if ( realName().isEmpty() ) | 1466 | if ( realName().isEmpty() ) |
1467 | text = e; | 1467 | text = e; |
1468 | else | 1468 | else |
1469 | text = assembledName() + " <" + e + ">"; | 1469 | text = assembledName() + " <" + e + ">"; |
1470 | 1470 | ||
1471 | return text; | 1471 | return text; |
1472 | } | 1472 | } |
1473 | 1473 | ||
1474 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1474 | void Addressee::insertEmail( const QString &email, bool preferred ) |
1475 | { | 1475 | { |
1476 | detach(); | 1476 | detach(); |
1477 | 1477 | ||
1478 | QStringList::Iterator it = mData->emails.find( email ); | 1478 | QStringList::Iterator it = mData->emails.find( email ); |
1479 | 1479 | ||
1480 | if ( it != mData->emails.end() ) { | 1480 | if ( it != mData->emails.end() ) { |
1481 | if ( !preferred || it == mData->emails.begin() ) return; | 1481 | if ( !preferred || it == mData->emails.begin() ) return; |
1482 | mData->emails.remove( it ); | 1482 | mData->emails.remove( it ); |
1483 | mData->emails.prepend( email ); | 1483 | mData->emails.prepend( email ); |
1484 | } else { | 1484 | } else { |
1485 | if ( preferred ) { | 1485 | if ( preferred ) { |
1486 | mData->emails.prepend( email ); | 1486 | mData->emails.prepend( email ); |
1487 | } else { | 1487 | } else { |
1488 | mData->emails.append( email ); | 1488 | mData->emails.append( email ); |
1489 | } | 1489 | } |
1490 | } | 1490 | } |
1491 | } | 1491 | } |
1492 | 1492 | ||
1493 | void Addressee::removeEmail( const QString &email ) | 1493 | void Addressee::removeEmail( const QString &email ) |
1494 | { | 1494 | { |
1495 | detach(); | 1495 | detach(); |
1496 | 1496 | ||
1497 | QStringList::Iterator it = mData->emails.find( email ); | 1497 | QStringList::Iterator it = mData->emails.find( email ); |
1498 | if ( it == mData->emails.end() ) return; | 1498 | if ( it == mData->emails.end() ) return; |
1499 | 1499 | ||
1500 | mData->emails.remove( it ); | 1500 | mData->emails.remove( it ); |
1501 | } | 1501 | } |
1502 | 1502 | ||
1503 | QString Addressee::preferredEmail() const | 1503 | QString Addressee::preferredEmail() const |
1504 | { | 1504 | { |
1505 | if ( mData->emails.count() == 0 ) return QString::null; | 1505 | if ( mData->emails.count() == 0 ) return QString::null; |
1506 | else return mData->emails.first(); | 1506 | else return mData->emails.first(); |
1507 | } | 1507 | } |
1508 | 1508 | ||
1509 | QStringList Addressee::emails() const | 1509 | QStringList Addressee::emails() const |
1510 | { | 1510 | { |
1511 | return mData->emails; | 1511 | return mData->emails; |
1512 | } | 1512 | } |
1513 | void Addressee::setEmails( const QStringList& emails ) { | 1513 | void Addressee::setEmails( const QStringList& emails ) { |
1514 | detach(); | 1514 | detach(); |
1515 | mData->emails = emails; | 1515 | mData->emails = emails; |
1516 | } | 1516 | } |
1517 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1517 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1518 | { | 1518 | { |
1519 | detach(); | 1519 | detach(); |
1520 | mData->empty = false; | 1520 | mData->empty = false; |
1521 | 1521 | ||
1522 | PhoneNumber::List::Iterator it; | 1522 | PhoneNumber::List::Iterator it; |
1523 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1523 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1524 | if ( (*it).id() == phoneNumber.id() ) { | 1524 | if ( (*it).id() == phoneNumber.id() ) { |
1525 | *it = phoneNumber; | 1525 | *it = phoneNumber; |
1526 | return; | 1526 | return; |
1527 | } | 1527 | } |
1528 | } | 1528 | } |
1529 | mData->phoneNumbers.append( phoneNumber ); | 1529 | mData->phoneNumbers.append( phoneNumber ); |
1530 | } | 1530 | } |
1531 | 1531 | ||
1532 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1532 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1533 | { | 1533 | { |
1534 | detach(); | 1534 | detach(); |
1535 | 1535 | ||
1536 | PhoneNumber::List::Iterator it; | 1536 | PhoneNumber::List::Iterator it; |
1537 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1537 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1538 | if ( (*it).id() == phoneNumber.id() ) { | 1538 | if ( (*it).id() == phoneNumber.id() ) { |
1539 | mData->phoneNumbers.remove( it ); | 1539 | mData->phoneNumbers.remove( it ); |
1540 | return; | 1540 | return; |
1541 | } | 1541 | } |
1542 | } | 1542 | } |
1543 | } | 1543 | } |
1544 | 1544 | ||
1545 | PhoneNumber Addressee::phoneNumber( int type ) const | 1545 | PhoneNumber Addressee::phoneNumber( int type ) const |
1546 | { | 1546 | { |
1547 | PhoneNumber phoneNumber( "", type ); | 1547 | PhoneNumber phoneNumber( "", type ); |
1548 | PhoneNumber::List::ConstIterator it; | 1548 | PhoneNumber::List::ConstIterator it; |
1549 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1549 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1550 | if ( matchBinaryPatternP( (*it).type(), type ) ) { | 1550 | if ( matchBinaryPatternP( (*it).type(), type ) ) { |
1551 | if ( (*it).type() & PhoneNumber::Pref ) | 1551 | if ( (*it).type() & PhoneNumber::Pref ) |
1552 | return (*it); | 1552 | return (*it); |
1553 | else if ( phoneNumber.number().isEmpty() ) | 1553 | else if ( phoneNumber.number().isEmpty() ) |
1554 | phoneNumber = (*it); | 1554 | phoneNumber = (*it); |
1555 | } | 1555 | } |
1556 | } | 1556 | } |
1557 | 1557 | ||
1558 | return phoneNumber; | 1558 | return phoneNumber; |
1559 | } | 1559 | } |
1560 | 1560 | ||
1561 | PhoneNumber::List Addressee::phoneNumbers() const | 1561 | PhoneNumber::List Addressee::phoneNumbers() const |
1562 | { | 1562 | { |
1563 | return mData->phoneNumbers; | 1563 | return mData->phoneNumbers; |
1564 | } | 1564 | } |
1565 | 1565 | ||
1566 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1566 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1567 | { | 1567 | { |
1568 | PhoneNumber::List list; | 1568 | PhoneNumber::List list; |
1569 | 1569 | ||
1570 | PhoneNumber::List::ConstIterator it; | 1570 | PhoneNumber::List::ConstIterator it; |
1571 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1571 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1572 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1572 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1573 | list.append( *it ); | 1573 | list.append( *it ); |
1574 | } | 1574 | } |
1575 | } | 1575 | } |
1576 | return list; | 1576 | return list; |
1577 | } | 1577 | } |
1578 | 1578 | ||
1579 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1579 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1580 | { | 1580 | { |
1581 | PhoneNumber::List::ConstIterator it; | 1581 | PhoneNumber::List::ConstIterator it; |
1582 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1582 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1583 | if ( (*it).id() == id ) { | 1583 | if ( (*it).id() == id ) { |
1584 | return *it; | 1584 | return *it; |
1585 | } | 1585 | } |
1586 | } | 1586 | } |
1587 | return PhoneNumber(); | 1587 | return PhoneNumber(); |
1588 | } | 1588 | } |
1589 | 1589 | ||
1590 | void Addressee::insertKey( const Key &key ) | 1590 | void Addressee::insertKey( const Key &key ) |
1591 | { | 1591 | { |
1592 | detach(); | 1592 | detach(); |
1593 | mData->empty = false; | 1593 | mData->empty = false; |
1594 | 1594 | ||
1595 | Key::List::Iterator it; | 1595 | Key::List::Iterator it; |
1596 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1596 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1597 | if ( (*it).id() == key.id() ) { | 1597 | if ( (*it).id() == key.id() ) { |
1598 | *it = key; | 1598 | *it = key; |
1599 | return; | 1599 | return; |
1600 | } | 1600 | } |
1601 | } | 1601 | } |
1602 | mData->keys.append( key ); | 1602 | mData->keys.append( key ); |
1603 | } | 1603 | } |
1604 | 1604 | ||
1605 | void Addressee::removeKey( const Key &key ) | 1605 | void Addressee::removeKey( const Key &key ) |
1606 | { | 1606 | { |
1607 | detach(); | 1607 | detach(); |
1608 | 1608 | ||
1609 | Key::List::Iterator it; | 1609 | Key::List::Iterator it; |
1610 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1610 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1611 | if ( (*it).id() == key.id() ) { | 1611 | if ( (*it).id() == key.id() ) { |
1612 | mData->keys.remove( key ); | 1612 | mData->keys.remove( key ); |
1613 | return; | 1613 | return; |
1614 | } | 1614 | } |
1615 | } | 1615 | } |
1616 | } | 1616 | } |
1617 | 1617 | ||
1618 | Key Addressee::key( int type, QString customTypeString ) const | 1618 | Key Addressee::key( int type, QString customTypeString ) const |
1619 | { | 1619 | { |
1620 | Key::List::ConstIterator it; | 1620 | Key::List::ConstIterator it; |
1621 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1621 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1622 | if ( (*it).type() == type ) { | 1622 | if ( (*it).type() == type ) { |
1623 | if ( type == Key::Custom ) { | 1623 | if ( type == Key::Custom ) { |
1624 | if ( customTypeString.isEmpty() ) { | 1624 | if ( customTypeString.isEmpty() ) { |
1625 | return *it; | 1625 | return *it; |
1626 | } else { | 1626 | } else { |
1627 | if ( (*it).customTypeString() == customTypeString ) | 1627 | if ( (*it).customTypeString() == customTypeString ) |
1628 | return (*it); | 1628 | return (*it); |
1629 | } | 1629 | } |
1630 | } else { | 1630 | } else { |
1631 | return *it; | 1631 | return *it; |
1632 | } | 1632 | } |
1633 | } | 1633 | } |
1634 | } | 1634 | } |
1635 | return Key( QString(), type ); | 1635 | return Key( QString(), type ); |
1636 | } | 1636 | } |
1637 | void Addressee::setKeys( const Key::List& list ) { | 1637 | void Addressee::setKeys( const Key::List& list ) { |
1638 | detach(); | 1638 | detach(); |
1639 | mData->keys = list; | 1639 | mData->keys = list; |
1640 | } | 1640 | } |
1641 | 1641 | ||
1642 | Key::List Addressee::keys() const | 1642 | Key::List Addressee::keys() const |
1643 | { | 1643 | { |
1644 | return mData->keys; | 1644 | return mData->keys; |
1645 | } | 1645 | } |
1646 | 1646 | ||
1647 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1647 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1648 | { | 1648 | { |
1649 | Key::List list; | 1649 | Key::List list; |
1650 | 1650 | ||
1651 | Key::List::ConstIterator it; | 1651 | Key::List::ConstIterator it; |
1652 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1652 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1653 | if ( (*it).type() == type ) { | 1653 | if ( (*it).type() == type ) { |
1654 | if ( type == Key::Custom ) { | 1654 | if ( type == Key::Custom ) { |
1655 | if ( customTypeString.isEmpty() ) { | 1655 | if ( customTypeString.isEmpty() ) { |
1656 | list.append(*it); | 1656 | list.append(*it); |
1657 | } else { | 1657 | } else { |
1658 | if ( (*it).customTypeString() == customTypeString ) | 1658 | if ( (*it).customTypeString() == customTypeString ) |
1659 | list.append(*it); | 1659 | list.append(*it); |
1660 | } | 1660 | } |
1661 | } else { | 1661 | } else { |
1662 | list.append(*it); | 1662 | list.append(*it); |
1663 | } | 1663 | } |
1664 | } | 1664 | } |
1665 | } | 1665 | } |
1666 | return list; | 1666 | return list; |
1667 | } | 1667 | } |
1668 | 1668 | ||
1669 | Key Addressee::findKey( const QString &id ) const | 1669 | Key Addressee::findKey( const QString &id ) const |
1670 | { | 1670 | { |
1671 | Key::List::ConstIterator it; | 1671 | Key::List::ConstIterator it; |
1672 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1672 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1673 | if ( (*it).id() == id ) { | 1673 | if ( (*it).id() == id ) { |
1674 | return *it; | 1674 | return *it; |
1675 | } | 1675 | } |
1676 | } | 1676 | } |
1677 | return Key(); | 1677 | return Key(); |
1678 | } | 1678 | } |
1679 | 1679 | ||
1680 | QString Addressee::asString() const | 1680 | QString Addressee::asString() const |
1681 | { | 1681 | { |
1682 | return "Smith, agent Smith..."; | 1682 | return "Smith, agent Smith..."; |
1683 | } | 1683 | } |
1684 | 1684 | ||
1685 | void Addressee::dump() const | 1685 | void Addressee::dump() const |
1686 | { | 1686 | { |
1687 | return; | 1687 | return; |
1688 | #if 0 | 1688 | #if 0 |
1689 | kdDebug(5700) << "Addressee {" << endl; | 1689 | kdDebug(5700) << "Addressee {" << endl; |
1690 | 1690 | ||
1691 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1691 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1692 | 1692 | ||
1693 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1693 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1694 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1694 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1695 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1695 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1696 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1696 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1697 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1697 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1698 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1698 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1699 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1699 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1700 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1700 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1701 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1701 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1702 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1702 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1703 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1703 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1704 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1704 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1705 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1705 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1706 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1706 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1707 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1707 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1708 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1708 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1709 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1709 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1710 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1710 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1711 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1711 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1712 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1712 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1713 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1713 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1714 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1714 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1715 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1715 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1716 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1716 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1717 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1717 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1718 | 1718 | ||
1719 | kdDebug(5700) << " Emails {" << endl; | 1719 | kdDebug(5700) << " Emails {" << endl; |
1720 | QStringList e = emails(); | 1720 | QStringList e = emails(); |
1721 | QStringList::ConstIterator it; | 1721 | QStringList::ConstIterator it; |
1722 | for( it = e.begin(); it != e.end(); ++it ) { | 1722 | for( it = e.begin(); it != e.end(); ++it ) { |
1723 | kdDebug(5700) << " " << (*it) << endl; | 1723 | kdDebug(5700) << " " << (*it) << endl; |
1724 | } | 1724 | } |
1725 | kdDebug(5700) << " }" << endl; | 1725 | kdDebug(5700) << " }" << endl; |
1726 | 1726 | ||
1727 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1727 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1728 | PhoneNumber::List p = phoneNumbers(); | 1728 | PhoneNumber::List p = phoneNumbers(); |
1729 | PhoneNumber::List::ConstIterator it2; | 1729 | PhoneNumber::List::ConstIterator it2; |
1730 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1730 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1731 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1731 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1732 | } | 1732 | } |
1733 | kdDebug(5700) << " }" << endl; | 1733 | kdDebug(5700) << " }" << endl; |
1734 | 1734 | ||
1735 | Address::List a = addresses(); | 1735 | Address::List a = addresses(); |
1736 | Address::List::ConstIterator it3; | 1736 | Address::List::ConstIterator it3; |
1737 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1737 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1738 | (*it3).dump(); | 1738 | (*it3).dump(); |
1739 | } | 1739 | } |
1740 | 1740 | ||
1741 | kdDebug(5700) << " Keys {" << endl; | 1741 | kdDebug(5700) << " Keys {" << endl; |
1742 | Key::List k = keys(); | 1742 | Key::List k = keys(); |
1743 | Key::List::ConstIterator it4; | 1743 | Key::List::ConstIterator it4; |
1744 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1744 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1745 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1745 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1746 | " Key: " << (*it4).textData() << | 1746 | " Key: " << (*it4).textData() << |
1747 | " CustomString: " << (*it4).customTypeString() << endl; | 1747 | " CustomString: " << (*it4).customTypeString() << endl; |
1748 | } | 1748 | } |
1749 | kdDebug(5700) << " }" << endl; | 1749 | kdDebug(5700) << " }" << endl; |
1750 | 1750 | ||
1751 | kdDebug(5700) << "}" << endl; | 1751 | kdDebug(5700) << "}" << endl; |
1752 | #endif | 1752 | #endif |
1753 | } | 1753 | } |
1754 | 1754 | ||
1755 | 1755 | ||
1756 | void Addressee::insertAddress( const Address &address ) | 1756 | void Addressee::insertAddress( const Address &address ) |
1757 | { | 1757 | { |
1758 | detach(); | 1758 | detach(); |
1759 | mData->empty = false; | 1759 | mData->empty = false; |
1760 | 1760 | ||
1761 | Address::List::Iterator it; | 1761 | Address::List::Iterator it; |
1762 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1762 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1763 | if ( (*it).id() == address.id() ) { | 1763 | if ( (*it).id() == address.id() ) { |
1764 | *it = address; | 1764 | *it = address; |
1765 | return; | 1765 | return; |
1766 | } | 1766 | } |
1767 | } | 1767 | } |
1768 | mData->addresses.append( address ); | 1768 | mData->addresses.append( address ); |
1769 | } | 1769 | } |
1770 | 1770 | ||
1771 | void Addressee::removeAddress( const Address &address ) | 1771 | void Addressee::removeAddress( const Address &address ) |
1772 | { | 1772 | { |
1773 | detach(); | 1773 | detach(); |
1774 | 1774 | ||
1775 | Address::List::Iterator it; | 1775 | Address::List::Iterator it; |
1776 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1776 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1777 | if ( (*it).id() == address.id() ) { | 1777 | if ( (*it).id() == address.id() ) { |
1778 | mData->addresses.remove( it ); | 1778 | mData->addresses.remove( it ); |
1779 | return; | 1779 | return; |
1780 | } | 1780 | } |
1781 | } | 1781 | } |
1782 | } | 1782 | } |
1783 | 1783 | ||
1784 | Address Addressee::address( int type ) const | 1784 | Address Addressee::address( int type ) const |
1785 | { | 1785 | { |
1786 | Address address( type ); | 1786 | Address address( type ); |
1787 | Address::List::ConstIterator it; | 1787 | Address::List::ConstIterator it; |
1788 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1788 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1789 | if ( matchBinaryPatternA( (*it).type(), type ) ) { | 1789 | if ( matchBinaryPatternA( (*it).type(), type ) ) { |
1790 | if ( (*it).type() & Address::Pref ) | 1790 | if ( (*it).type() & Address::Pref ) |
1791 | return (*it); | 1791 | return (*it); |
1792 | else if ( address.isEmpty() ) | 1792 | else if ( address.isEmpty() ) |
1793 | address = (*it); | 1793 | address = (*it); |
1794 | } | 1794 | } |
1795 | } | 1795 | } |
1796 | 1796 | ||
1797 | return address; | 1797 | return address; |
1798 | } | 1798 | } |
1799 | 1799 | ||
1800 | Address::List Addressee::addresses() const | 1800 | Address::List Addressee::addresses() const |
1801 | { | 1801 | { |
1802 | return mData->addresses; | 1802 | return mData->addresses; |
1803 | } | 1803 | } |
1804 | 1804 | ||
1805 | Address::List Addressee::addresses( int type ) const | 1805 | Address::List Addressee::addresses( int type ) const |
1806 | { | 1806 | { |
1807 | Address::List list; | 1807 | Address::List list; |
1808 | 1808 | ||
1809 | Address::List::ConstIterator it; | 1809 | Address::List::ConstIterator it; |
1810 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1810 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1811 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1811 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1812 | list.append( *it ); | 1812 | list.append( *it ); |
1813 | } | 1813 | } |
1814 | } | 1814 | } |
1815 | 1815 | ||
1816 | return list; | 1816 | return list; |
1817 | } | 1817 | } |
1818 | 1818 | ||
1819 | Address Addressee::findAddress( const QString &id ) const | 1819 | Address Addressee::findAddress( const QString &id ) const |
1820 | { | 1820 | { |
1821 | Address::List::ConstIterator it; | 1821 | Address::List::ConstIterator it; |
1822 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1822 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1823 | if ( (*it).id() == id ) { | 1823 | if ( (*it).id() == id ) { |
1824 | return *it; | 1824 | return *it; |
1825 | } | 1825 | } |
1826 | } | 1826 | } |
1827 | return Address(); | 1827 | return Address(); |
1828 | } | 1828 | } |
1829 | 1829 | ||
1830 | void Addressee::insertCategory( const QString &c ) | 1830 | void Addressee::insertCategory( const QString &c ) |
1831 | { | 1831 | { |
1832 | detach(); | 1832 | detach(); |
1833 | mData->empty = false; | 1833 | mData->empty = false; |
1834 | 1834 | ||
1835 | if ( mData->categories.contains( c ) ) return; | 1835 | if ( mData->categories.contains( c ) ) return; |
1836 | 1836 | ||
1837 | mData->categories.append( c ); | 1837 | mData->categories.append( c ); |
1838 | } | 1838 | } |
1839 | 1839 | ||
1840 | void Addressee::removeCategory( const QString &c ) | 1840 | void Addressee::removeCategory( const QString &c ) |
1841 | { | 1841 | { |
1842 | detach(); | 1842 | detach(); |
1843 | 1843 | ||
1844 | QStringList::Iterator it = mData->categories.find( c ); | 1844 | QStringList::Iterator it = mData->categories.find( c ); |
1845 | if ( it == mData->categories.end() ) return; | 1845 | if ( it == mData->categories.end() ) return; |
1846 | 1846 | ||
1847 | mData->categories.remove( it ); | 1847 | mData->categories.remove( it ); |
1848 | } | 1848 | } |
1849 | 1849 | ||
1850 | bool Addressee::hasCategory( const QString &c ) const | 1850 | bool Addressee::hasCategory( const QString &c ) const |
1851 | { | 1851 | { |
1852 | return ( mData->categories.contains( c ) ); | 1852 | return ( mData->categories.contains( c ) ); |
1853 | } | 1853 | } |
1854 | 1854 | ||
1855 | void Addressee::setCategories( const QStringList &c ) | 1855 | void Addressee::setCategories( const QStringList &c ) |
1856 | { | 1856 | { |
1857 | detach(); | 1857 | detach(); |
1858 | mData->empty = false; | 1858 | mData->empty = false; |
1859 | 1859 | ||
1860 | mData->categories = c; | 1860 | mData->categories = c; |
1861 | } | 1861 | } |
1862 | 1862 | ||
1863 | QStringList Addressee::categories() const | 1863 | QStringList Addressee::categories() const |
1864 | { | 1864 | { |
1865 | return mData->categories; | 1865 | return mData->categories; |
1866 | } | 1866 | } |
1867 | 1867 | ||
1868 | void Addressee::insertCustom( const QString &app, const QString &name, | 1868 | void Addressee::insertCustom( const QString &app, const QString &name, |
1869 | const QString &value ) | 1869 | const QString &value ) |
1870 | { | 1870 | { |
1871 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 1871 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
1872 | 1872 | ||
1873 | detach(); | 1873 | detach(); |
1874 | mData->empty = false; | 1874 | mData->empty = false; |
1875 | 1875 | ||
1876 | QString qualifiedName = app + "-" + name + ":"; | 1876 | QString qualifiedName = app + "-" + name + ":"; |
1877 | 1877 | ||
1878 | QStringList::Iterator it; | 1878 | QStringList::Iterator it; |
1879 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1879 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1880 | if ( (*it).startsWith( qualifiedName ) ) { | 1880 | if ( (*it).startsWith( qualifiedName ) ) { |
1881 | (*it) = qualifiedName + value; | 1881 | (*it) = qualifiedName + value; |
1882 | return; | 1882 | return; |
1883 | } | 1883 | } |
1884 | } | 1884 | } |
1885 | mData->custom.append( qualifiedName + value ); | 1885 | mData->custom.append( qualifiedName + value ); |
1886 | } | 1886 | } |
1887 | 1887 | ||
1888 | void Addressee::removeCustom( const QString &app, const QString &name) | 1888 | void Addressee::removeCustom( const QString &app, const QString &name) |
1889 | { | 1889 | { |
1890 | detach(); | 1890 | detach(); |
1891 | 1891 | ||
1892 | QString qualifiedName = app + "-" + name + ":"; | 1892 | QString qualifiedName = app + "-" + name + ":"; |
1893 | 1893 | ||
1894 | QStringList::Iterator it; | 1894 | QStringList::Iterator it; |
1895 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1895 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1896 | if ( (*it).startsWith( qualifiedName ) ) { | 1896 | if ( (*it).startsWith( qualifiedName ) ) { |
1897 | mData->custom.remove( it ); | 1897 | mData->custom.remove( it ); |
1898 | return; | 1898 | return; |
1899 | } | 1899 | } |
1900 | } | 1900 | } |
1901 | } | 1901 | } |
1902 | 1902 | ||
1903 | QString Addressee::custom( const QString &app, const QString &name ) const | 1903 | QString Addressee::custom( const QString &app, const QString &name ) const |
1904 | { | 1904 | { |
1905 | QString qualifiedName = app + "-" + name + ":"; | 1905 | QString qualifiedName = app + "-" + name + ":"; |
1906 | QString value; | 1906 | QString value; |
1907 | 1907 | ||
1908 | QStringList::ConstIterator it; | 1908 | QStringList::ConstIterator it; |
1909 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1909 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1910 | if ( (*it).startsWith( qualifiedName ) ) { | 1910 | if ( (*it).startsWith( qualifiedName ) ) { |
1911 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1911 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1912 | break; | 1912 | break; |
1913 | } | 1913 | } |
1914 | } | 1914 | } |
1915 | 1915 | ||
1916 | return value; | 1916 | return value; |
1917 | } | 1917 | } |
1918 | 1918 | ||
1919 | void Addressee::setCustoms( const QStringList &l ) | 1919 | void Addressee::setCustoms( const QStringList &l ) |
1920 | { | 1920 | { |
1921 | detach(); | 1921 | detach(); |
1922 | mData->empty = false; | 1922 | mData->empty = false; |
1923 | 1923 | ||
1924 | mData->custom = l; | 1924 | mData->custom = l; |
1925 | } | 1925 | } |
1926 | 1926 | ||
1927 | QStringList Addressee::customs() const | 1927 | QStringList Addressee::customs() const |
1928 | { | 1928 | { |
1929 | return mData->custom; | 1929 | return mData->custom; |
1930 | } | 1930 | } |
1931 | 1931 | ||
1932 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, | 1932 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |
1933 | QString &email) | 1933 | QString &email) |
1934 | { | 1934 | { |
1935 | int startPos, endPos, len; | 1935 | int startPos, endPos, len; |
1936 | QString partA, partB, result; | 1936 | QString partA, partB, result; |
1937 | char endCh = '>'; | 1937 | char endCh = '>'; |
1938 | 1938 | ||
1939 | startPos = rawEmail.find('<'); | 1939 | startPos = rawEmail.find('<'); |
1940 | if (startPos < 0) | 1940 | if (startPos < 0) |
1941 | { | 1941 | { |
1942 | startPos = rawEmail.find('('); | 1942 | startPos = rawEmail.find('('); |
1943 | endCh = ')'; | 1943 | endCh = ')'; |
1944 | } | 1944 | } |
1945 | if (startPos < 0) | 1945 | if (startPos < 0) |
1946 | { | 1946 | { |
1947 | // We couldn't find any separators, so we assume the whole string | 1947 | // We couldn't find any separators, so we assume the whole string |
1948 | // is the email address | 1948 | // is the email address |
1949 | email = rawEmail; | 1949 | email = rawEmail; |
1950 | fullName = ""; | 1950 | fullName = ""; |
1951 | } | 1951 | } |
1952 | else | 1952 | else |
1953 | { | 1953 | { |
1954 | // We have a start position, try to find an end | 1954 | // We have a start position, try to find an end |
1955 | endPos = rawEmail.find(endCh, startPos+1); | 1955 | endPos = rawEmail.find(endCh, startPos+1); |
1956 | 1956 | ||
1957 | if (endPos < 0) | 1957 | if (endPos < 0) |
1958 | { | 1958 | { |
1959 | // We couldn't find the end of the email address. We can only | 1959 | // We couldn't find the end of the email address. We can only |
1960 | // assume the entire string is the email address. | 1960 | // assume the entire string is the email address. |
1961 | email = rawEmail; | 1961 | email = rawEmail; |
1962 | fullName = ""; | 1962 | fullName = ""; |
1963 | } | 1963 | } |
1964 | else | 1964 | else |
1965 | { | 1965 | { |
1966 | // We have a start and end to the email address | 1966 | // We have a start and end to the email address |
1967 | 1967 | ||
1968 | // Grab the name part | 1968 | // Grab the name part |
1969 | fullName = rawEmail.left(startPos).stripWhiteSpace(); | 1969 | fullName = rawEmail.left(startPos).stripWhiteSpace(); |
1970 | 1970 | ||
1971 | // grab the email part | 1971 | // grab the email part |
1972 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); | 1972 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); |
1973 | 1973 | ||
1974 | // Check that we do not have any extra characters on the end of the | 1974 | // Check that we do not have any extra characters on the end of the |
1975 | // strings | 1975 | // strings |
1976 | len = fullName.length(); | 1976 | len = fullName.length(); |
1977 | if (fullName[0]=='"' && fullName[len-1]=='"') | 1977 | if (fullName[0]=='"' && fullName[len-1]=='"') |
1978 | fullName = fullName.mid(1, len-2); | 1978 | fullName = fullName.mid(1, len-2); |
1979 | else if (fullName[0]=='<' && fullName[len-1]=='>') | 1979 | else if (fullName[0]=='<' && fullName[len-1]=='>') |
1980 | fullName = fullName.mid(1, len-2); | 1980 | fullName = fullName.mid(1, len-2); |
1981 | else if (fullName[0]=='(' && fullName[len-1]==')') | 1981 | else if (fullName[0]=='(' && fullName[len-1]==')') |
1982 | fullName = fullName.mid(1, len-2); | 1982 | fullName = fullName.mid(1, len-2); |
1983 | } | 1983 | } |
1984 | } | 1984 | } |
1985 | } | 1985 | } |
1986 | 1986 | ||
1987 | void Addressee::setResource( Resource *resource ) | 1987 | void Addressee::setResource( Resource *resource ) |
1988 | { | 1988 | { |
1989 | detach(); | 1989 | detach(); |
1990 | mData->resource = resource; | 1990 | mData->resource = resource; |
1991 | } | 1991 | } |
1992 | 1992 | ||
1993 | Resource *Addressee::resource() const | 1993 | Resource *Addressee::resource() const |
1994 | { | 1994 | { |
1995 | return mData->resource; | 1995 | return mData->resource; |
1996 | } | 1996 | } |
1997 | 1997 | ||
1998 | //US | 1998 | //US |
1999 | QString Addressee::resourceLabel() | 1999 | QString Addressee::resourceLabel() |
2000 | { | 2000 | { |
2001 | return i18n("Resource"); | 2001 | return i18n("Resource"); |
2002 | } | 2002 | } |
2003 | QString Addressee::categoryLabel() | 2003 | QString Addressee::categoryLabel() |
2004 | { | 2004 | { |
2005 | return i18n("Category"); | 2005 | return i18n("Category"); |
2006 | } | 2006 | } |
2007 | 2007 | ||
2008 | void Addressee::setChanged( bool value ) | 2008 | void Addressee::setChanged( bool value ) |
2009 | { | 2009 | { |
2010 | detach(); | 2010 | detach(); |
2011 | mData->changed = value; | 2011 | mData->changed = value; |
2012 | } | 2012 | } |
2013 | 2013 | ||
2014 | bool Addressee::changed() const | 2014 | bool Addressee::changed() const |
2015 | { | 2015 | { |
2016 | return mData->changed; | 2016 | return mData->changed; |
2017 | } | 2017 | } |
2018 | 2018 | ||
2019 | void Addressee::setTagged( bool value ) | 2019 | void Addressee::setTagged( bool value ) |
2020 | { | 2020 | { |
2021 | detach(); | 2021 | detach(); |
2022 | mData->tagged = value; | 2022 | mData->tagged = value; |
2023 | } | 2023 | } |
2024 | 2024 | ||
2025 | bool Addressee::tagged() const | 2025 | bool Addressee::tagged() const |
2026 | { | 2026 | { |
2027 | return mData->tagged; | 2027 | return mData->tagged; |
2028 | } | 2028 | } |
2029 | 2029 | ||
2030 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) | 2030 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) |
2031 | { | 2031 | { |
2032 | if (!a.mData) return s; | 2032 | if (!a.mData) return s; |
2033 | 2033 | ||
2034 | s << a.uid(); | 2034 | s << a.uid(); |
2035 | 2035 | ||
2036 | s << a.mData->name; | 2036 | s << a.mData->name; |
2037 | s << a.mData->formattedName; | 2037 | s << a.mData->formattedName; |
2038 | s << a.mData->familyName; | 2038 | s << a.mData->familyName; |
2039 | s << a.mData->givenName; | 2039 | s << a.mData->givenName; |
2040 | s << a.mData->additionalName; | 2040 | s << a.mData->additionalName; |
2041 | s << a.mData->prefix; | 2041 | s << a.mData->prefix; |
2042 | s << a.mData->suffix; | 2042 | s << a.mData->suffix; |
2043 | s << a.mData->nickName; | 2043 | s << a.mData->nickName; |
2044 | s << a.mData->birthday; | 2044 | s << a.mData->birthday; |
2045 | s << a.mData->mailer; | 2045 | s << a.mData->mailer; |
2046 | s << a.mData->timeZone; | 2046 | s << a.mData->timeZone; |
2047 | s << a.mData->geo; | 2047 | s << a.mData->geo; |
2048 | s << a.mData->title; | 2048 | s << a.mData->title; |
2049 | s << a.mData->role; | 2049 | s << a.mData->role; |
2050 | s << a.mData->organization; | 2050 | s << a.mData->organization; |
2051 | s << a.mData->note; | 2051 | s << a.mData->note; |
2052 | s << a.mData->productId; | 2052 | s << a.mData->productId; |
2053 | s << a.mData->revision; | 2053 | s << a.mData->revision; |
2054 | s << a.mData->sortString; | 2054 | s << a.mData->sortString; |
2055 | s << a.mData->url; | 2055 | s << a.mData->url; |
2056 | s << a.mData->secrecy; | 2056 | s << a.mData->secrecy; |
2057 | s << a.mData->logo; | 2057 | s << a.mData->logo; |
2058 | s << a.mData->photo; | 2058 | s << a.mData->photo; |
2059 | s << a.mData->sound; | 2059 | s << a.mData->sound; |
2060 | s << a.mData->agent; | 2060 | s << a.mData->agent; |
2061 | s << a.mData->phoneNumbers; | 2061 | s << a.mData->phoneNumbers; |
2062 | s << a.mData->addresses; | 2062 | s << a.mData->addresses; |
2063 | s << a.mData->emails; | 2063 | s << a.mData->emails; |
2064 | s << a.mData->categories; | 2064 | s << a.mData->categories; |
2065 | s << a.mData->custom; | 2065 | s << a.mData->custom; |
2066 | s << a.mData->keys; | 2066 | s << a.mData->keys; |
2067 | return s; | 2067 | return s; |
2068 | } | 2068 | } |
2069 | 2069 | ||
2070 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) | 2070 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) |
2071 | { | 2071 | { |
2072 | if (!a.mData) return s; | 2072 | if (!a.mData) return s; |
2073 | 2073 | ||
2074 | s >> a.mData->uid; | 2074 | s >> a.mData->uid; |
2075 | 2075 | ||
2076 | s >> a.mData->name; | 2076 | s >> a.mData->name; |
2077 | s >> a.mData->formattedName; | 2077 | s >> a.mData->formattedName; |
2078 | s >> a.mData->familyName; | 2078 | s >> a.mData->familyName; |
2079 | s >> a.mData->givenName; | 2079 | s >> a.mData->givenName; |
2080 | s >> a.mData->additionalName; | 2080 | s >> a.mData->additionalName; |
2081 | s >> a.mData->prefix; | 2081 | s >> a.mData->prefix; |
2082 | s >> a.mData->suffix; | 2082 | s >> a.mData->suffix; |
2083 | s >> a.mData->nickName; | 2083 | s >> a.mData->nickName; |
2084 | s >> a.mData->birthday; | 2084 | s >> a.mData->birthday; |
2085 | s >> a.mData->mailer; | 2085 | s >> a.mData->mailer; |
2086 | s >> a.mData->timeZone; | 2086 | s >> a.mData->timeZone; |
2087 | s >> a.mData->geo; | 2087 | s >> a.mData->geo; |
2088 | s >> a.mData->title; | 2088 | s >> a.mData->title; |
2089 | s >> a.mData->role; | 2089 | s >> a.mData->role; |
2090 | s >> a.mData->organization; | 2090 | s >> a.mData->organization; |
2091 | s >> a.mData->note; | 2091 | s >> a.mData->note; |
2092 | s >> a.mData->productId; | 2092 | s >> a.mData->productId; |
2093 | s >> a.mData->revision; | 2093 | s >> a.mData->revision; |
2094 | s >> a.mData->sortString; | 2094 | s >> a.mData->sortString; |
2095 | s >> a.mData->url; | 2095 | s >> a.mData->url; |
2096 | s >> a.mData->secrecy; | 2096 | s >> a.mData->secrecy; |
2097 | s >> a.mData->logo; | 2097 | s >> a.mData->logo; |
2098 | s >> a.mData->photo; | 2098 | s >> a.mData->photo; |
2099 | s >> a.mData->sound; | 2099 | s >> a.mData->sound; |
2100 | s >> a.mData->agent; | 2100 | s >> a.mData->agent; |
2101 | s >> a.mData->phoneNumbers; | 2101 | s >> a.mData->phoneNumbers; |
2102 | s >> a.mData->addresses; | 2102 | s >> a.mData->addresses; |
2103 | s >> a.mData->emails; | 2103 | s >> a.mData->emails; |
2104 | s >> a.mData->categories; | 2104 | s >> a.mData->categories; |
2105 | s >> a.mData->custom; | 2105 | s >> a.mData->custom; |
2106 | s >> a.mData->keys; | 2106 | s >> a.mData->keys; |
2107 | 2107 | ||
2108 | a.mData->empty = false; | 2108 | a.mData->empty = false; |
2109 | 2109 | ||
2110 | return s; | 2110 | return s; |
2111 | } | 2111 | } |
2112 | bool matchBinaryPattern( int value, int pattern ) | 2112 | bool matchBinaryPattern( int value, int pattern ) |
2113 | { | 2113 | { |
2114 | /** | 2114 | /** |
2115 | We want to match all telephonnumbers/addresses which have the bits in the | 2115 | We want to match all telephonnumbers/addresses which have the bits in the |
2116 | pattern set. More are allowed. | 2116 | pattern set. More are allowed. |
2117 | if pattern == 0 we have a special handling, then we want only those with | 2117 | if pattern == 0 we have a special handling, then we want only those with |
2118 | exactly no bit set. | 2118 | exactly no bit set. |
2119 | */ | 2119 | */ |
2120 | if ( pattern == 0 ) | 2120 | if ( pattern == 0 ) |
2121 | return ( value == 0 ); | 2121 | return ( value == 0 ); |
2122 | else | 2122 | else |
2123 | return ( pattern == ( pattern & value ) ); | 2123 | return ( pattern == ( pattern & value ) ); |
2124 | } | 2124 | } |
2125 | 2125 | ||
2126 | bool matchBinaryPatternP( int value, int pattern ) | 2126 | bool matchBinaryPatternP( int value, int pattern ) |
2127 | { | 2127 | { |
2128 | 2128 | ||
2129 | if ( pattern == 0 ) | 2129 | if ( pattern == 0 ) |
2130 | return ( value == 0 ); | 2130 | return ( value == 0 ); |
2131 | else | 2131 | else |
2132 | return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); | 2132 | return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); |
2133 | } | 2133 | } |
2134 | bool matchBinaryPatternA( int value, int pattern ) | 2134 | bool matchBinaryPatternA( int value, int pattern ) |
2135 | { | 2135 | { |
2136 | 2136 | ||
2137 | if ( pattern == 0 ) | 2137 | if ( pattern == 0 ) |
2138 | return ( value == 0 ); | 2138 | return ( value == 0 ); |
2139 | else | 2139 | else |
2140 | return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); | 2140 | return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); |
2141 | } | 2141 | } |
diff --git a/kabc/addressee.h b/kabc/addressee.h index 08d2f56..8051fec 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -1,853 +1,853 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef KABC_ADDRESSEE_H | 29 | #ifndef KABC_ADDRESSEE_H |
30 | #define KABC_ADDRESSEE_H | 30 | #define KABC_ADDRESSEE_H |
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qstring.h> | 33 | #include <qstring.h> |
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
36 | 36 | ||
37 | #include <ksharedptr.h> | 37 | #include <ksharedptr.h> |
38 | #include <kurl.h> | 38 | #include <kurl.h> |
39 | 39 | ||
40 | #include "address.h" | 40 | #include "address.h" |
41 | #include "agent.h" | 41 | #include "agent.h" |
42 | #include "geo.h" | 42 | #include "geo.h" |
43 | #include "key.h" | 43 | #include "key.h" |
44 | #include "phonenumber.h" | 44 | #include "phonenumber.h" |
45 | #include "picture.h" | 45 | #include "picture.h" |
46 | #include "secrecy.h" | 46 | #include "secrecy.h" |
47 | #include "sound.h" | 47 | #include "sound.h" |
48 | #include "timezone.h" | 48 | #include "timezone.h" |
49 | 49 | ||
50 | namespace KABC { | 50 | namespace KABC { |
51 | 51 | ||
52 | class Resource; | 52 | class Resource; |
53 | 53 | ||
54 | /** | 54 | /** |
55 | @short address book entry | 55 | @short address book entry |
56 | 56 | ||
57 | This class represents an entry in the address book. | 57 | This class represents an entry in the address book. |
58 | 58 | ||
59 | The data of this class is implicitly shared. You can pass this class by value. | 59 | The data of this class is implicitly shared. You can pass this class by value. |
60 | 60 | ||
61 | If you need the name of a field for presenting it to the user you should use | 61 | If you need the name of a field for presenting it to the user you should use |
62 | the functions ending in Label(). They return a translated string which can be | 62 | the functions ending in Label(). They return a translated string which can be |
63 | used as label for the corresponding field. | 63 | used as label for the corresponding field. |
64 | 64 | ||
65 | About the name fields: | 65 | About the name fields: |
66 | 66 | ||
67 | givenName() is the first name and familyName() the last name. In some | 67 | givenName() is the first name and familyName() the last name. In some |
68 | countries the family name comes first, that's the reason for the | 68 | countries the family name comes first, that's the reason for the |
69 | naming. formattedName() is the full name with the correct formatting. | 69 | naming. formattedName() is the full name with the correct formatting. |
70 | It is used as an override, when the correct formatting can't be generated | 70 | It is used as an override, when the correct formatting can't be generated |
71 | from the other name fields automatically. | 71 | from the other name fields automatically. |
72 | 72 | ||
73 | realName() returns a fully formatted name(). It uses formattedName, if set, | 73 | realName() returns a fully formatted name(). It uses formattedName, if set, |
74 | otherwise it constucts the name from the name fields. As fallback, if | 74 | otherwise it constucts the name from the name fields. As fallback, if |
75 | nothing else is set it uses name(). | 75 | nothing else is set it uses name(). |
76 | 76 | ||
77 | name() is the NAME type of RFC2426. It can be used as internal name for the | 77 | name() is the NAME type of RFC2426. It can be used as internal name for the |
78 | data enty, but shouldn't be used for displaying the data to the user. | 78 | data enty, but shouldn't be used for displaying the data to the user. |
79 | */ | 79 | */ |
80 | class Addressee | 80 | class Addressee |
81 | { | 81 | { |
82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); | 82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); |
83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); | 83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); |
84 | 84 | ||
85 | public: | 85 | public: |
86 | typedef QValueList<Addressee> List; | 86 | typedef QValueList<Addressee> List; |
87 | 87 | ||
88 | /** | 88 | /** |
89 | Construct an empty address book entry. | 89 | Construct an empty address book entry. |
90 | */ | 90 | */ |
91 | Addressee(); | 91 | Addressee(); |
92 | ~Addressee(); | 92 | ~Addressee(); |
93 | 93 | ||
94 | Addressee( const Addressee & ); | 94 | Addressee( const Addressee & ); |
95 | Addressee &operator=( const Addressee & ); | 95 | Addressee &operator=( const Addressee & ); |
96 | 96 | ||
97 | bool operator==( const Addressee & ) const; | 97 | bool operator==( const Addressee & ) const; |
98 | bool operator!=( const Addressee & ) const; | 98 | bool operator!=( const Addressee & ) const; |
99 | // sync stuff | 99 | // sync stuff |
100 | void setTempSyncStat(int id); | 100 | void setTempSyncStat(int id); |
101 | int tempSyncStat() const; | 101 | int tempSyncStat() const; |
102 | void setIDStr( const QString & ); | 102 | void setIDStr( const QString & ); |
103 | QString IDStr() const; | 103 | const QString IDStr() const; |
104 | void setID( const QString &, const QString & ); | 104 | void setID( const QString &, const QString & ); |
105 | QString getID( const QString & ); | 105 | const QString getID( const QString & ) const; |
106 | void setCsum( const QString &, const QString & ); | 106 | void setCsum( const QString &, const QString & ); |
107 | QString getCsum( const QString & ); | 107 | const QString getCsum( const QString & ) const ; |
108 | void removeID(const QString &); | 108 | void removeID(const QString &); |
109 | void computeCsum(const QString &dev); | 109 | void computeCsum(const QString &dev); |
110 | ulong getCsum4List( const QStringList & attList); | 110 | ulong getCsum4List( const QStringList & attList); |
111 | /** | 111 | /** |
112 | Return, if the address book entry is empty. | 112 | Return, if the address book entry is empty. |
113 | */ | 113 | */ |
114 | bool isEmpty() const; | 114 | bool isEmpty() const; |
115 | void setExternalUID( const QString &id ); | 115 | void setExternalUID( const QString &id ); |
116 | QString externalUID() const; | 116 | const QString externalUID() const; |
117 | void setOriginalExternalUID( const QString &id ); | 117 | void setOriginalExternalUID( const QString &id ); |
118 | QString originalExternalUID() const; | 118 | QString originalExternalUID() const; |
119 | void mergeContact( const Addressee& ad, bool isSubSet ); | 119 | void mergeContact( const Addressee& ad, bool isSubSet ); |
120 | void simplifyEmails(); | 120 | void simplifyEmails(); |
121 | void simplifyAddresses(); | 121 | void simplifyAddresses(); |
122 | void simplifyPhoneNumbers(); | 122 | void simplifyPhoneNumbers(); |
123 | void simplifyPhoneNumberTypes(); | 123 | void simplifyPhoneNumberTypes(); |
124 | bool removeVoice(); | 124 | bool removeVoice(); |
125 | bool containsAdr(const Addressee& addr ); | 125 | bool containsAdr(const Addressee& addr ); |
126 | 126 | ||
127 | /** | 127 | /** |
128 | Set unique identifier. | 128 | Set unique identifier. |
129 | */ | 129 | */ |
130 | void setUid( const QString &uid ); | 130 | void setUid( const QString &uid ); |
131 | /** | 131 | /** |
132 | Return unique identifier. | 132 | Return unique identifier. |
133 | */ | 133 | */ |
134 | QString uid() const; | 134 | const QString uid() const; |
135 | /** | 135 | /** |
136 | Return translated label for uid field. | 136 | Return translated label for uid field. |
137 | */ | 137 | */ |
138 | static QString uidLabel(); | 138 | static QString uidLabel(); |
139 | 139 | ||
140 | /** | 140 | /** |
141 | Set name. | 141 | Set name. |
142 | */ | 142 | */ |
143 | void setName( const QString &name ); | 143 | void setName( const QString &name ); |
144 | /** | 144 | /** |
145 | Return name. | 145 | Return name. |
146 | */ | 146 | */ |
147 | QString name() const; | 147 | QString name() const; |
148 | /** | 148 | /** |
149 | Return translated label for name field. | 149 | Return translated label for name field. |
150 | */ | 150 | */ |
151 | static QString nameLabel(); | 151 | static QString nameLabel(); |
152 | 152 | ||
153 | /** | 153 | /** |
154 | Set formatted name. | 154 | Set formatted name. |
155 | */ | 155 | */ |
156 | void setFormattedName( const QString &formattedName ); | 156 | void setFormattedName( const QString &formattedName ); |
157 | /** | 157 | /** |
158 | Return formatted name. | 158 | Return formatted name. |
159 | */ | 159 | */ |
160 | QString formattedName() const; | 160 | QString formattedName() const; |
161 | /** | 161 | /** |
162 | Return translated label for formattedName field. | 162 | Return translated label for formattedName field. |
163 | */ | 163 | */ |
164 | static QString formattedNameLabel(); | 164 | static QString formattedNameLabel(); |
165 | 165 | ||
166 | /** | 166 | /** |
167 | Set family name. | 167 | Set family name. |
168 | */ | 168 | */ |
169 | void setFamilyName( const QString &familyName ); | 169 | void setFamilyName( const QString &familyName ); |
170 | /** | 170 | /** |
171 | Return family name. | 171 | Return family name. |
172 | */ | 172 | */ |
173 | QString familyName() const; | 173 | QString familyName() const; |
174 | /** | 174 | /** |
175 | Return translated label for familyName field. | 175 | Return translated label for familyName field. |
176 | */ | 176 | */ |
177 | static QString familyNameLabel(); | 177 | static QString familyNameLabel(); |
178 | 178 | ||
179 | /** | 179 | /** |
180 | Set given name. | 180 | Set given name. |
181 | */ | 181 | */ |
182 | void setGivenName( const QString &givenName ); | 182 | void setGivenName( const QString &givenName ); |
183 | /** | 183 | /** |
184 | Return given name. | 184 | Return given name. |
185 | */ | 185 | */ |
186 | QString givenName() const; | 186 | QString givenName() const; |
187 | /** | 187 | /** |
188 | Return translated label for givenName field. | 188 | Return translated label for givenName field. |
189 | */ | 189 | */ |
190 | static QString givenNameLabel(); | 190 | static QString givenNameLabel(); |
191 | 191 | ||
192 | /** | 192 | /** |
193 | Set additional names. | 193 | Set additional names. |
194 | */ | 194 | */ |
195 | void setAdditionalName( const QString &additionalName ); | 195 | void setAdditionalName( const QString &additionalName ); |
196 | /** | 196 | /** |
197 | Return additional names. | 197 | Return additional names. |
198 | */ | 198 | */ |
199 | QString additionalName() const; | 199 | QString additionalName() const; |
200 | /** | 200 | /** |
201 | Return translated label for additionalName field. | 201 | Return translated label for additionalName field. |
202 | */ | 202 | */ |
203 | static QString additionalNameLabel(); | 203 | static QString additionalNameLabel(); |
204 | 204 | ||
205 | /** | 205 | /** |
206 | Set honorific prefixes. | 206 | Set honorific prefixes. |
207 | */ | 207 | */ |
208 | void setPrefix( const QString &prefix ); | 208 | void setPrefix( const QString &prefix ); |
209 | /** | 209 | /** |
210 | Return honorific prefixes. | 210 | Return honorific prefixes. |
211 | */ | 211 | */ |
212 | QString prefix() const; | 212 | QString prefix() const; |
213 | /** | 213 | /** |
214 | Return translated label for prefix field. | 214 | Return translated label for prefix field. |
215 | */ | 215 | */ |
216 | static QString prefixLabel(); | 216 | static QString prefixLabel(); |
217 | 217 | ||
218 | /** | 218 | /** |
219 | Set honorific suffixes. | 219 | Set honorific suffixes. |
220 | */ | 220 | */ |
221 | void setSuffix( const QString &suffix ); | 221 | void setSuffix( const QString &suffix ); |
222 | /** | 222 | /** |
223 | Return honorific suffixes. | 223 | Return honorific suffixes. |
224 | */ | 224 | */ |
225 | QString suffix() const; | 225 | QString suffix() const; |
226 | /** | 226 | /** |
227 | Return translated label for suffix field. | 227 | Return translated label for suffix field. |
228 | */ | 228 | */ |
229 | static QString suffixLabel(); | 229 | static QString suffixLabel(); |
230 | 230 | ||
231 | /** | 231 | /** |
232 | Set nick name. | 232 | Set nick name. |
233 | */ | 233 | */ |
234 | void setNickName( const QString &nickName ); | 234 | void setNickName( const QString &nickName ); |
235 | /** | 235 | /** |
236 | Return nick name. | 236 | Return nick name. |
237 | */ | 237 | */ |
238 | QString nickName() const; | 238 | QString nickName() const; |
239 | /** | 239 | /** |
240 | Return translated label for nickName field. | 240 | Return translated label for nickName field. |
241 | */ | 241 | */ |
242 | static QString nickNameLabel(); | 242 | static QString nickNameLabel(); |
243 | 243 | ||
244 | /** | 244 | /** |
245 | Set birthday. | 245 | Set birthday. |
246 | */ | 246 | */ |
247 | void setBirthday( const QDateTime &birthday ); | 247 | void setBirthday( const QDateTime &birthday ); |
248 | /** | 248 | /** |
249 | Return birthday. | 249 | Return birthday. |
250 | */ | 250 | */ |
251 | QDateTime birthday() const; | 251 | QDateTime birthday() const; |
252 | /** | 252 | /** |
253 | Return translated label for birthday field. | 253 | Return translated label for birthday field. |
254 | */ | 254 | */ |
255 | static QString birthdayLabel(); | 255 | static QString birthdayLabel(); |
256 | 256 | ||
257 | /** | 257 | /** |
258 | Return translated label for homeAddressStreet field. | 258 | Return translated label for homeAddressStreet field. |
259 | */ | 259 | */ |
260 | static QString homeAddressStreetLabel(); | 260 | static QString homeAddressStreetLabel(); |
261 | 261 | ||
262 | /** | 262 | /** |
263 | Return translated label for homeAddressLocality field. | 263 | Return translated label for homeAddressLocality field. |
264 | */ | 264 | */ |
265 | static QString homeAddressLocalityLabel(); | 265 | static QString homeAddressLocalityLabel(); |
266 | 266 | ||
267 | /** | 267 | /** |
268 | Return translated label for homeAddressRegion field. | 268 | Return translated label for homeAddressRegion field. |
269 | */ | 269 | */ |
270 | static QString homeAddressRegionLabel(); | 270 | static QString homeAddressRegionLabel(); |
271 | 271 | ||
272 | /** | 272 | /** |
273 | Return translated label for homeAddressPostalCode field. | 273 | Return translated label for homeAddressPostalCode field. |
274 | */ | 274 | */ |
275 | static QString homeAddressPostalCodeLabel(); | 275 | static QString homeAddressPostalCodeLabel(); |
276 | 276 | ||
277 | /** | 277 | /** |
278 | Return translated label for homeAddressCountry field. | 278 | Return translated label for homeAddressCountry field. |
279 | */ | 279 | */ |
280 | static QString homeAddressCountryLabel(); | 280 | static QString homeAddressCountryLabel(); |
281 | 281 | ||
282 | /** | 282 | /** |
283 | Return translated label for homeAddressLabel field. | 283 | Return translated label for homeAddressLabel field. |
284 | */ | 284 | */ |
285 | static QString homeAddressLabelLabel(); | 285 | static QString homeAddressLabelLabel(); |
286 | 286 | ||
287 | /** | 287 | /** |
288 | Return translated label for businessAddressStreet field. | 288 | Return translated label for businessAddressStreet field. |
289 | */ | 289 | */ |
290 | static QString businessAddressStreetLabel(); | 290 | static QString businessAddressStreetLabel(); |
291 | 291 | ||
292 | /** | 292 | /** |
293 | Return translated label for businessAddressLocality field. | 293 | Return translated label for businessAddressLocality field. |
294 | */ | 294 | */ |
295 | static QString businessAddressLocalityLabel(); | 295 | static QString businessAddressLocalityLabel(); |
296 | 296 | ||
297 | /** | 297 | /** |
298 | Return translated label for businessAddressRegion field. | 298 | Return translated label for businessAddressRegion field. |
299 | */ | 299 | */ |
300 | static QString businessAddressRegionLabel(); | 300 | static QString businessAddressRegionLabel(); |
301 | 301 | ||
302 | /** | 302 | /** |
303 | Return translated label for businessAddressPostalCode field. | 303 | Return translated label for businessAddressPostalCode field. |
304 | */ | 304 | */ |
305 | static QString businessAddressPostalCodeLabel(); | 305 | static QString businessAddressPostalCodeLabel(); |
306 | 306 | ||
307 | /** | 307 | /** |
308 | Return translated label for businessAddressCountry field. | 308 | Return translated label for businessAddressCountry field. |
309 | */ | 309 | */ |
310 | static QString businessAddressCountryLabel(); | 310 | static QString businessAddressCountryLabel(); |
311 | 311 | ||
312 | /** | 312 | /** |
313 | Return translated label for businessAddressLabel field. | 313 | Return translated label for businessAddressLabel field. |
314 | */ | 314 | */ |
315 | static QString businessAddressLabelLabel(); | 315 | static QString businessAddressLabelLabel(); |
316 | 316 | ||
317 | /** | 317 | /** |
318 | Return translated label for homePhone field. | 318 | Return translated label for homePhone field. |
319 | */ | 319 | */ |
320 | static QString homePhoneLabel(); | 320 | static QString homePhoneLabel(); |
321 | 321 | ||
322 | /** | 322 | /** |
323 | Return translated label for businessPhone field. | 323 | Return translated label for businessPhone field. |
324 | */ | 324 | */ |
325 | static QString businessPhoneLabel(); | 325 | static QString businessPhoneLabel(); |
326 | 326 | ||
327 | /** | 327 | /** |
328 | Return translated label for mobilePhone field. | 328 | Return translated label for mobilePhone field. |
329 | */ | 329 | */ |
330 | static QString mobilePhoneLabel(); | 330 | static QString mobilePhoneLabel(); |
331 | 331 | ||
332 | /** | 332 | /** |
333 | Return translated label for homeFax field. | 333 | Return translated label for homeFax field. |
334 | */ | 334 | */ |
335 | static QString homeFaxLabel(); | 335 | static QString homeFaxLabel(); |
336 | 336 | ||
337 | /** | 337 | /** |
338 | Return translated label for businessFax field. | 338 | Return translated label for businessFax field. |
339 | */ | 339 | */ |
340 | static QString businessFaxLabel(); | 340 | static QString businessFaxLabel(); |
341 | 341 | ||
342 | /** | 342 | /** |
343 | Return translated label for carPhone field. | 343 | Return translated label for carPhone field. |
344 | */ | 344 | */ |
345 | static QString carPhoneLabel(); | 345 | static QString carPhoneLabel(); |
346 | 346 | ||
347 | /** | 347 | /** |
348 | Return translated label for isdn field. | 348 | Return translated label for isdn field. |
349 | */ | 349 | */ |
350 | static QString isdnLabel(); | 350 | static QString isdnLabel(); |
351 | 351 | ||
352 | /** | 352 | /** |
353 | Return translated label for pager field. | 353 | Return translated label for pager field. |
354 | */ | 354 | */ |
355 | static QString pagerLabel(); | 355 | static QString pagerLabel(); |
356 | 356 | ||
357 | /** | 357 | /** |
358 | Return translated label for sip field. | 358 | Return translated label for sip field. |
359 | */ | 359 | */ |
360 | static QString sipLabel(); | 360 | static QString sipLabel(); |
361 | 361 | ||
362 | /** | 362 | /** |
363 | Return translated label for email field. | 363 | Return translated label for email field. |
364 | */ | 364 | */ |
365 | static QString emailLabel(); | 365 | static QString emailLabel(); |
366 | 366 | ||
367 | /** | 367 | /** |
368 | Set mail client. | 368 | Set mail client. |
369 | */ | 369 | */ |
370 | void setMailer( const QString &mailer ); | 370 | void setMailer( const QString &mailer ); |
371 | /** | 371 | /** |
372 | Return mail client. | 372 | Return mail client. |
373 | */ | 373 | */ |
374 | QString mailer() const; | 374 | QString mailer() const; |
375 | /** | 375 | /** |
376 | Return translated label for mailer field. | 376 | Return translated label for mailer field. |
377 | */ | 377 | */ |
378 | static QString mailerLabel(); | 378 | static QString mailerLabel(); |
379 | 379 | ||
380 | /** | 380 | /** |
381 | Set time zone. | 381 | Set time zone. |
382 | */ | 382 | */ |
383 | void setTimeZone( const TimeZone &timeZone ); | 383 | void setTimeZone( const TimeZone &timeZone ); |
384 | /** | 384 | /** |
385 | Return time zone. | 385 | Return time zone. |
386 | */ | 386 | */ |
387 | TimeZone timeZone() const; | 387 | TimeZone timeZone() const; |
388 | /** | 388 | /** |
389 | Return translated label for timeZone field. | 389 | Return translated label for timeZone field. |
390 | */ | 390 | */ |
391 | static QString timeZoneLabel(); | 391 | static QString timeZoneLabel(); |
392 | 392 | ||
393 | /** | 393 | /** |
394 | Set geographic position. | 394 | Set geographic position. |
395 | */ | 395 | */ |
396 | void setGeo( const Geo &geo ); | 396 | void setGeo( const Geo &geo ); |
397 | /** | 397 | /** |
398 | Return geographic position. | 398 | Return geographic position. |
399 | */ | 399 | */ |
400 | Geo geo() const; | 400 | Geo geo() const; |
401 | /** | 401 | /** |
402 | Return translated label for geo field. | 402 | Return translated label for geo field. |
403 | */ | 403 | */ |
404 | static QString geoLabel(); | 404 | static QString geoLabel(); |
405 | 405 | ||
406 | /** | 406 | /** |
407 | Set title. | 407 | Set title. |
408 | */ | 408 | */ |
409 | void setTitle( const QString &title ); | 409 | void setTitle( const QString &title ); |
410 | /** | 410 | /** |
411 | Return title. | 411 | Return title. |
412 | */ | 412 | */ |
413 | QString title() const; | 413 | QString title() const; |
414 | /** | 414 | /** |
415 | Return translated label for title field. | 415 | Return translated label for title field. |
416 | */ | 416 | */ |
417 | static QString titleLabel(); | 417 | static QString titleLabel(); |
418 | 418 | ||
419 | /** | 419 | /** |
420 | Set role. | 420 | Set role. |
421 | */ | 421 | */ |
422 | void setRole( const QString &role ); | 422 | void setRole( const QString &role ); |
423 | /** | 423 | /** |
424 | Return role. | 424 | Return role. |
425 | */ | 425 | */ |
426 | QString role() const; | 426 | QString role() const; |
427 | /** | 427 | /** |
428 | Return translated label for role field. | 428 | Return translated label for role field. |
429 | */ | 429 | */ |
430 | static QString roleLabel(); | 430 | static QString roleLabel(); |
431 | 431 | ||
432 | /** | 432 | /** |
433 | Set organization. | 433 | Set organization. |
434 | */ | 434 | */ |
435 | void setOrganization( const QString &organization ); | 435 | void setOrganization( const QString &organization ); |
436 | /** | 436 | /** |
437 | Return organization. | 437 | Return organization. |
438 | */ | 438 | */ |
439 | QString organization() const; | 439 | QString organization() const; |
440 | /** | 440 | /** |
441 | Return translated label for organization field. | 441 | Return translated label for organization field. |
442 | */ | 442 | */ |
443 | static QString organizationLabel(); | 443 | static QString organizationLabel(); |
444 | 444 | ||
445 | /** | 445 | /** |
446 | Set note. | 446 | Set note. |
447 | */ | 447 | */ |
448 | void setNote( const QString ¬e ); | 448 | void setNote( const QString ¬e ); |
449 | /** | 449 | /** |
450 | Return note. | 450 | Return note. |
451 | */ | 451 | */ |
452 | QString note() const; | 452 | QString note() const; |
453 | /** | 453 | /** |
454 | Return translated label for note field. | 454 | Return translated label for note field. |
455 | */ | 455 | */ |
456 | static QString noteLabel(); | 456 | static QString noteLabel(); |
457 | 457 | ||
458 | /** | 458 | /** |
459 | Set product identifier. | 459 | Set product identifier. |
460 | */ | 460 | */ |
461 | void setProductId( const QString &productId ); | 461 | void setProductId( const QString &productId ); |
462 | /** | 462 | /** |
463 | Return product identifier. | 463 | Return product identifier. |
464 | */ | 464 | */ |
465 | QString productId() const; | 465 | QString productId() const; |
466 | /** | 466 | /** |
467 | Return translated label for productId field. | 467 | Return translated label for productId field. |
468 | */ | 468 | */ |
469 | static QString productIdLabel(); | 469 | static QString productIdLabel(); |
470 | 470 | ||
471 | /** | 471 | /** |
472 | Set revision date. | 472 | Set revision date. |
473 | */ | 473 | */ |
474 | void setRevision( const QDateTime &revision ); | 474 | void setRevision( const QDateTime &revision ); |
475 | /** | 475 | /** |
476 | Return revision date. | 476 | Return revision date. |
477 | */ | 477 | */ |
478 | QDateTime revision() const; | 478 | QDateTime revision() const; |
479 | /** | 479 | /** |
480 | Return translated label for revision field. | 480 | Return translated label for revision field. |
481 | */ | 481 | */ |
482 | static QString revisionLabel(); | 482 | static QString revisionLabel(); |
483 | 483 | ||
484 | /** | 484 | /** |
485 | Set sort string. | 485 | Set sort string. |
486 | */ | 486 | */ |
487 | void setSortString( const QString &sortString ); | 487 | void setSortString( const QString &sortString ); |
488 | /** | 488 | /** |
489 | Return sort string. | 489 | Return sort string. |
490 | */ | 490 | */ |
491 | QString sortString() const; | 491 | QString sortString() const; |
492 | /** | 492 | /** |
493 | Return translated label for sortString field. | 493 | Return translated label for sortString field. |
494 | */ | 494 | */ |
495 | static QString sortStringLabel(); | 495 | static QString sortStringLabel(); |
496 | 496 | ||
497 | /** | 497 | /** |
498 | Set URL. | 498 | Set URL. |
499 | */ | 499 | */ |
500 | void setUrl( const KURL &url ); | 500 | void setUrl( const KURL &url ); |
501 | /** | 501 | /** |
502 | Return URL. | 502 | Return URL. |
503 | */ | 503 | */ |
504 | KURL url() const; | 504 | KURL url() const; |
505 | /** | 505 | /** |
506 | Return translated label for url field. | 506 | Return translated label for url field. |
507 | */ | 507 | */ |
508 | static QString urlLabel(); | 508 | static QString urlLabel(); |
509 | 509 | ||
510 | /** | 510 | /** |
511 | Set security class. | 511 | Set security class. |
512 | */ | 512 | */ |
513 | void setSecrecy( const Secrecy &secrecy ); | 513 | void setSecrecy( const Secrecy &secrecy ); |
514 | /** | 514 | /** |
515 | Return security class. | 515 | Return security class. |
516 | */ | 516 | */ |
517 | Secrecy secrecy() const; | 517 | Secrecy secrecy() const; |
518 | /** | 518 | /** |
519 | Return translated label for secrecy field. | 519 | Return translated label for secrecy field. |
520 | */ | 520 | */ |
521 | static QString secrecyLabel(); | 521 | static QString secrecyLabel(); |
522 | 522 | ||
523 | /** | 523 | /** |
524 | Set logo. | 524 | Set logo. |
525 | */ | 525 | */ |
526 | void setLogo( const Picture &logo ); | 526 | void setLogo( const Picture &logo ); |
527 | /** | 527 | /** |
528 | Return logo. | 528 | Return logo. |
529 | */ | 529 | */ |
530 | Picture logo() const; | 530 | Picture logo() const; |
531 | /** | 531 | /** |
532 | Return translated label for logo field. | 532 | Return translated label for logo field. |
533 | */ | 533 | */ |
534 | static QString logoLabel(); | 534 | static QString logoLabel(); |
535 | 535 | ||
536 | /** | 536 | /** |
537 | Set photo. | 537 | Set photo. |
538 | */ | 538 | */ |
539 | void setPhoto( const Picture &photo ); | 539 | void setPhoto( const Picture &photo ); |
540 | /** | 540 | /** |
541 | Return photo. | 541 | Return photo. |
542 | */ | 542 | */ |
543 | Picture photo() const; | 543 | Picture photo() const; |
544 | /** | 544 | /** |
545 | Return translated label for photo field. | 545 | Return translated label for photo field. |
546 | */ | 546 | */ |
547 | static QString photoLabel(); | 547 | static QString photoLabel(); |
548 | 548 | ||
549 | /** | 549 | /** |
550 | Set sound. | 550 | Set sound. |
551 | */ | 551 | */ |
552 | void setSound( const Sound &sound ); | 552 | void setSound( const Sound &sound ); |
553 | /** | 553 | /** |
554 | Return sound. | 554 | Return sound. |
555 | */ | 555 | */ |
556 | Sound sound() const; | 556 | Sound sound() const; |
557 | /** | 557 | /** |
558 | Return translated label for sound field. | 558 | Return translated label for sound field. |
559 | */ | 559 | */ |
560 | static QString soundLabel(); | 560 | static QString soundLabel(); |
561 | 561 | ||
562 | /** | 562 | /** |
563 | Set agent. | 563 | Set agent. |
564 | */ | 564 | */ |
565 | void setAgent( const Agent &agent ); | 565 | void setAgent( const Agent &agent ); |
566 | /** | 566 | /** |
567 | Return agent. | 567 | Return agent. |
568 | */ | 568 | */ |
569 | Agent agent() const; | 569 | Agent agent() const; |
570 | /** | 570 | /** |
571 | Return translated label for agent field. | 571 | Return translated label for agent field. |
572 | */ | 572 | */ |
573 | static QString agentLabel(); | 573 | static QString agentLabel(); |
574 | 574 | ||
575 | /** | 575 | /** |
576 | Set name fields by parsing the given string and trying to associate the | 576 | Set name fields by parsing the given string and trying to associate the |
577 | parts of the string with according fields. This function should probably | 577 | parts of the string with according fields. This function should probably |
578 | be a bit more clever. | 578 | be a bit more clever. |
579 | */ | 579 | */ |
580 | void setNameFromString( const QString & ); | 580 | void setNameFromString( const QString & ); |
581 | 581 | ||
582 | /** | 582 | /** |
583 | Return the name of the addressee. This is calculated from all the name | 583 | Return the name of the addressee. This is calculated from all the name |
584 | fields. | 584 | fields. |
585 | */ | 585 | */ |
586 | QString realName() const; | 586 | QString realName() const; |
587 | 587 | ||
588 | /** | 588 | /** |
589 | Return the name that consists of all name parts. | 589 | Return the name that consists of all name parts. |
590 | */ | 590 | */ |
591 | QString assembledName() const; | 591 | QString assembledName() const; |
592 | 592 | ||
593 | /** | 593 | /** |
594 | Return email address including real name. | 594 | Return email address including real name. |
595 | 595 | ||
596 | @param email Email address to be used to construct the full email string. | 596 | @param email Email address to be used to construct the full email string. |
597 | If this is QString::null the preferred email address is used. | 597 | If this is QString::null the preferred email address is used. |
598 | */ | 598 | */ |
599 | QString fullEmail( const QString &email=QString::null ) const; | 599 | QString fullEmail( const QString &email=QString::null ) const; |
600 | 600 | ||
601 | /** | 601 | /** |
602 | Insert an email address. If the email address already exists in this | 602 | Insert an email address. If the email address already exists in this |
603 | addressee it is not duplicated. | 603 | addressee it is not duplicated. |
604 | 604 | ||
605 | @param email Email address | 605 | @param email Email address |
606 | @param preferred Set to true, if this is the preferred email address of | 606 | @param preferred Set to true, if this is the preferred email address of |
607 | the addressee. | 607 | the addressee. |
608 | */ | 608 | */ |
609 | void insertEmail( const QString &email, bool preferred=false ); | 609 | void insertEmail( const QString &email, bool preferred=false ); |
610 | 610 | ||
611 | /** | 611 | /** |
612 | Remove email address. If the email address doesn't exist, nothing happens. | 612 | Remove email address. If the email address doesn't exist, nothing happens. |
613 | */ | 613 | */ |
614 | void removeEmail( const QString &email ); | 614 | void removeEmail( const QString &email ); |
615 | 615 | ||
616 | /** | 616 | /** |
617 | Return preferred email address. This is the first email address or the | 617 | Return preferred email address. This is the first email address or the |
618 | last one added with @ref insertEmail() with a set preferred parameter. | 618 | last one added with @ref insertEmail() with a set preferred parameter. |
619 | */ | 619 | */ |
620 | QString preferredEmail() const; | 620 | QString preferredEmail() const; |
621 | 621 | ||
622 | /** | 622 | /** |
623 | Return list of all email addresses. | 623 | Return list of all email addresses. |
624 | */ | 624 | */ |
625 | QStringList emails() const; | 625 | QStringList emails() const; |
626 | 626 | ||
627 | /** | 627 | /** |
628 | Set the emails to @param. | 628 | Set the emails to @param. |
629 | The first email address gets the preferred one! | 629 | The first email address gets the preferred one! |
630 | @param list The list of email addresses. | 630 | @param list The list of email addresses. |
631 | */ | 631 | */ |
632 | void setEmails( const QStringList& list); | 632 | void setEmails( const QStringList& list); |
633 | 633 | ||
634 | /** | 634 | /** |
635 | Insert a phone number. If a phone number with the same id already exists | 635 | Insert a phone number. If a phone number with the same id already exists |
636 | in this addressee it is not duplicated. | 636 | in this addressee it is not duplicated. |
637 | */ | 637 | */ |
638 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); | 638 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); |
639 | 639 | ||
640 | /** | 640 | /** |
641 | Remove phone number. If no phone number with the given id exists for this | 641 | Remove phone number. If no phone number with the given id exists for this |
642 | addresse nothing happens. | 642 | addresse nothing happens. |
643 | */ | 643 | */ |
644 | void removePhoneNumber( const PhoneNumber &phoneNumber ); | 644 | void removePhoneNumber( const PhoneNumber &phoneNumber ); |
645 | 645 | ||
646 | /** | 646 | /** |
647 | Return phone number, which matches the given type. | 647 | Return phone number, which matches the given type. |
648 | */ | 648 | */ |
649 | PhoneNumber phoneNumber( int type ) const; | 649 | PhoneNumber phoneNumber( int type ) const; |
650 | 650 | ||
651 | /** | 651 | /** |
652 | Return list of all phone numbers. | 652 | Return list of all phone numbers. |
653 | */ | 653 | */ |
654 | PhoneNumber::List phoneNumbers() const; | 654 | PhoneNumber::List phoneNumbers() const; |
655 | 655 | ||
656 | /** | 656 | /** |
657 | Return list of phone numbers with a special type. | 657 | Return list of phone numbers with a special type. |
658 | */ | 658 | */ |
659 | PhoneNumber::List phoneNumbers( int type ) const; | 659 | PhoneNumber::List phoneNumbers( int type ) const; |
660 | 660 | ||
661 | /** | 661 | /** |
662 | Return phone number with the given id. | 662 | Return phone number with the given id. |
663 | */ | 663 | */ |
664 | PhoneNumber findPhoneNumber( const QString &id ) const; | 664 | PhoneNumber findPhoneNumber( const QString &id ) const; |
665 | 665 | ||
666 | /** | 666 | /** |
667 | Insert a key. If a key with the same id already exists | 667 | Insert a key. If a key with the same id already exists |
668 | in this addressee it is not duplicated. | 668 | in this addressee it is not duplicated. |
669 | */ | 669 | */ |
670 | void insertKey( const Key &key ); | 670 | void insertKey( const Key &key ); |
671 | 671 | ||
672 | /** | 672 | /** |
673 | Remove a key. If no key with the given id exists for this | 673 | Remove a key. If no key with the given id exists for this |
674 | addresse nothing happens. | 674 | addresse nothing happens. |
675 | */ | 675 | */ |
676 | void removeKey( const Key &key ); | 676 | void removeKey( const Key &key ); |
677 | 677 | ||
678 | /** | 678 | /** |
679 | Return key, which matches the given type. | 679 | Return key, which matches the given type. |
680 | If @p type == Key::Custom you can specify a string | 680 | If @p type == Key::Custom you can specify a string |
681 | that should match. If you leave the string empty, the first | 681 | that should match. If you leave the string empty, the first |
682 | key with a custom value is returned. | 682 | key with a custom value is returned. |
683 | */ | 683 | */ |
684 | Key key( int type, QString customTypeString = QString::null ) const; | 684 | Key key( int type, QString customTypeString = QString::null ) const; |
685 | 685 | ||
686 | /** | 686 | /** |
687 | Return list of all keys. | 687 | Return list of all keys. |
688 | */ | 688 | */ |
689 | Key::List keys() const; | 689 | Key::List keys() const; |
690 | 690 | ||
691 | /** | 691 | /** |
692 | Set the list of keys | 692 | Set the list of keys |
693 | @param keys The keys to be set. | 693 | @param keys The keys to be set. |
694 | */ | 694 | */ |
695 | void setKeys( const Key::List& keys); | 695 | void setKeys( const Key::List& keys); |
696 | 696 | ||
697 | /** | 697 | /** |
698 | Return list of keys with a special type. | 698 | Return list of keys with a special type. |
699 | If @p type == Key::Custom you can specify a string | 699 | If @p type == Key::Custom you can specify a string |
700 | that should match. If you leave the string empty, all custom | 700 | that should match. If you leave the string empty, all custom |
701 | keys will be returned. | 701 | keys will be returned. |
702 | */ | 702 | */ |
703 | Key::List keys( int type, QString customTypeString = QString::null ) const; | 703 | Key::List keys( int type, QString customTypeString = QString::null ) const; |
704 | 704 | ||
705 | /** | 705 | /** |
706 | Return key with the given id. | 706 | Return key with the given id. |
707 | */ | 707 | */ |
708 | Key findKey( const QString &id ) const; | 708 | Key findKey( const QString &id ) const; |
709 | 709 | ||
710 | /** | 710 | /** |
711 | Insert an address. If an address with the same id already exists | 711 | Insert an address. If an address with the same id already exists |
712 | in this addressee it is not duplicated. | 712 | in this addressee it is not duplicated. |
713 | */ | 713 | */ |
714 | void insertAddress( const Address &address ); | 714 | void insertAddress( const Address &address ); |
715 | 715 | ||
716 | /** | 716 | /** |
717 | Remove address. If no address with the given id exists for this | 717 | Remove address. If no address with the given id exists for this |
718 | addresse nothing happens. | 718 | addresse nothing happens. |
719 | */ | 719 | */ |
720 | void removeAddress( const Address &address ); | 720 | void removeAddress( const Address &address ); |
721 | 721 | ||
722 | /** | 722 | /** |
723 | Return address, which matches the given type. | 723 | Return address, which matches the given type. |
724 | */ | 724 | */ |
725 | Address address( int type ) const; | 725 | Address address( int type ) const; |
726 | 726 | ||
727 | /** | 727 | /** |
728 | Return list of all addresses. | 728 | Return list of all addresses. |
729 | */ | 729 | */ |
730 | Address::List addresses() const; | 730 | Address::List addresses() const; |
731 | 731 | ||
732 | /** | 732 | /** |
733 | Return list of addresses with a special type. | 733 | Return list of addresses with a special type. |
734 | */ | 734 | */ |
735 | Address::List addresses( int type ) const; | 735 | Address::List addresses( int type ) const; |
736 | 736 | ||
737 | /** | 737 | /** |
738 | Return address with the given id. | 738 | Return address with the given id. |
739 | */ | 739 | */ |
740 | Address findAddress( const QString &id ) const; | 740 | Address findAddress( const QString &id ) const; |
741 | 741 | ||
742 | /** | 742 | /** |
743 | Insert category. If the category already exists it is not duplicated. | 743 | Insert category. If the category already exists it is not duplicated. |
744 | */ | 744 | */ |
745 | void insertCategory( const QString & ); | 745 | void insertCategory( const QString & ); |
746 | 746 | ||
747 | /** | 747 | /** |
748 | Remove category. | 748 | Remove category. |
749 | */ | 749 | */ |
750 | void removeCategory( const QString & ); | 750 | void removeCategory( const QString & ); |
751 | 751 | ||
752 | /** | 752 | /** |
753 | Return, if addressee has the given category. | 753 | Return, if addressee has the given category. |
754 | */ | 754 | */ |
755 | bool hasCategory( const QString & ) const; | 755 | bool hasCategory( const QString & ) const; |
756 | 756 | ||
757 | /** | 757 | /** |
758 | Set categories to given value. | 758 | Set categories to given value. |
759 | */ | 759 | */ |
760 | void setCategories( const QStringList & ); | 760 | void setCategories( const QStringList & ); |
761 | 761 | ||
762 | /** | 762 | /** |
763 | Return list of all set categories. | 763 | Return list of all set categories. |
764 | */ | 764 | */ |
765 | QStringList categories() const; | 765 | QStringList categories() const; |
766 | 766 | ||
767 | /** | 767 | /** |
768 | Insert custom entry. The entry is identified by the name of the inserting | 768 | Insert custom entry. The entry is identified by the name of the inserting |
769 | application and a unique name. If an entry with the given app and name | 769 | application and a unique name. If an entry with the given app and name |
770 | already exists its value is replaced with the new given value. | 770 | already exists its value is replaced with the new given value. |
771 | */ | 771 | */ |
772 | void insertCustom( const QString &app, const QString &name, | 772 | void insertCustom( const QString &app, const QString &name, |
773 | const QString &value ); | 773 | const QString &value ); |
774 | 774 | ||
775 | /** | 775 | /** |
776 | Remove custom entry. | 776 | Remove custom entry. |
777 | */ | 777 | */ |
778 | void removeCustom( const QString &app, const QString &name ); | 778 | void removeCustom( const QString &app, const QString &name ); |
779 | 779 | ||
780 | /** | 780 | /** |
781 | Return value of custom entry, identified by app and entry name. | 781 | Return value of custom entry, identified by app and entry name. |
782 | */ | 782 | */ |
783 | QString custom( const QString &app, const QString &name ) const; | 783 | QString custom( const QString &app, const QString &name ) const; |
784 | 784 | ||
785 | /** | 785 | /** |
786 | Set all custom entries. | 786 | Set all custom entries. |
787 | */ | 787 | */ |
788 | void setCustoms( const QStringList & ); | 788 | void setCustoms( const QStringList & ); |
789 | 789 | ||
790 | /** | 790 | /** |
791 | Return list of all custom entries. | 791 | Return list of all custom entries. |
792 | */ | 792 | */ |
793 | QStringList customs() const; | 793 | QStringList customs() const; |
794 | 794 | ||
795 | /** | 795 | /** |
796 | Parse full email address. The result is given back in fullName and email. | 796 | Parse full email address. The result is given back in fullName and email. |
797 | */ | 797 | */ |
798 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, | 798 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, |
799 | QString &email ); | 799 | QString &email ); |
800 | 800 | ||
801 | /** | 801 | /** |
802 | Debug output. | 802 | Debug output. |
803 | */ | 803 | */ |
804 | void dump() const; | 804 | void dump() const; |
805 | 805 | ||
806 | /** | 806 | /** |
807 | Returns string representation of the addressee. | 807 | Returns string representation of the addressee. |
808 | */ | 808 | */ |
809 | QString asString() const; | 809 | QString asString() const; |
810 | 810 | ||
811 | /** | 811 | /** |
812 | Set resource where the addressee is from. | 812 | Set resource where the addressee is from. |
813 | */ | 813 | */ |
814 | void setResource( Resource *resource ); | 814 | void setResource( Resource *resource ); |
815 | 815 | ||
816 | /** | 816 | /** |
817 | Return pointer to resource. | 817 | Return pointer to resource. |
818 | */ | 818 | */ |
819 | Resource *resource() const; | 819 | Resource *resource() const; |
820 | 820 | ||
821 | /** | 821 | /** |
822 | Return resourcelabel. | 822 | Return resourcelabel. |
823 | */ | 823 | */ |
824 | //US | 824 | //US |
825 | static QString resourceLabel(); | 825 | static QString resourceLabel(); |
826 | static QString categoryLabel(); | 826 | static QString categoryLabel(); |
827 | /** | 827 | /** |
828 | Mark addressee as changed. | 828 | Mark addressee as changed. |
829 | */ | 829 | */ |
830 | void setChanged( bool value ); | 830 | void setChanged( bool value ); |
831 | 831 | ||
832 | /** | 832 | /** |
833 | Return whether the addressee is changed. | 833 | Return whether the addressee is changed. |
834 | */ | 834 | */ |
835 | bool changed() const; | 835 | bool changed() const; |
836 | 836 | ||
837 | void setTagged( bool value ); | 837 | void setTagged( bool value ); |
838 | bool tagged() const; | 838 | bool tagged() const; |
839 | 839 | ||
840 | private: | 840 | private: |
841 | Addressee copy(); | 841 | Addressee copy(); |
842 | void detach(); | 842 | void detach(); |
843 | 843 | ||
844 | struct AddresseeData; | 844 | struct AddresseeData; |
845 | mutable KSharedPtr<AddresseeData> mData; | 845 | mutable KSharedPtr<AddresseeData> mData; |
846 | }; | 846 | }; |
847 | 847 | ||
848 | QDataStream &operator<<( QDataStream &, const Addressee & ); | 848 | QDataStream &operator<<( QDataStream &, const Addressee & ); |
849 | QDataStream &operator>>( QDataStream &, Addressee & ); | 849 | QDataStream &operator>>( QDataStream &, Addressee & ); |
850 | 850 | ||
851 | } | 851 | } |
852 | 852 | ||
853 | #endif | 853 | #endif |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index d393660..42e147f 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,3284 +1,3305 @@ | |||
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 | #include "xxportselectdialog.h" | 118 | #include "xxportselectdialog.h" |
119 | 119 | ||
120 | 120 | ||
121 | #include <kresources/selectdialog.h> | 121 | #include <kresources/selectdialog.h> |
122 | #include <kmessagebox.h> | 122 | #include <kmessagebox.h> |
123 | 123 | ||
124 | #include <picture.h> | 124 | #include <picture.h> |
125 | #include <resource.h> | 125 | #include <resource.h> |
126 | 126 | ||
127 | //US#include <qsplitter.h> | 127 | //US#include <qsplitter.h> |
128 | #include <qmap.h> | 128 | #include <qmap.h> |
129 | #include <qdir.h> | 129 | #include <qdir.h> |
130 | #include <qfile.h> | 130 | #include <qfile.h> |
131 | #include <qvbox.h> | 131 | #include <qvbox.h> |
132 | #include <qlayout.h> | 132 | #include <qlayout.h> |
133 | #include <qclipboard.h> | 133 | #include <qclipboard.h> |
134 | #include <qtextstream.h> | 134 | #include <qtextstream.h> |
135 | #include <qradiobutton.h> | 135 | #include <qradiobutton.h> |
136 | #include <qbuttongroup.h> | 136 | #include <qbuttongroup.h> |
137 | 137 | ||
138 | #include <libkdepim/categoryselectdialog.h> | 138 | #include <libkdepim/categoryselectdialog.h> |
139 | #include <libkdepim/categoryeditdialog.h> | 139 | #include <libkdepim/categoryeditdialog.h> |
140 | #include <kabc/vcardconverter.h> | 140 | #include <kabc/vcardconverter.h> |
141 | 141 | ||
142 | 142 | ||
143 | #include "addresseeutil.h" | 143 | #include "addresseeutil.h" |
144 | #include "undocmds.h" | 144 | #include "undocmds.h" |
145 | #include "addresseeeditordialog.h" | 145 | #include "addresseeeditordialog.h" |
146 | #include "viewmanager.h" | 146 | #include "viewmanager.h" |
147 | #include "details/detailsviewcontainer.h" | 147 | #include "details/detailsviewcontainer.h" |
148 | #include "kabprefs.h" | 148 | #include "kabprefs.h" |
149 | #include "xxportmanager.h" | 149 | #include "xxportmanager.h" |
150 | #include "incsearchwidget.h" | 150 | #include "incsearchwidget.h" |
151 | #include "jumpbuttonbar.h" | 151 | #include "jumpbuttonbar.h" |
152 | #include "extensionmanager.h" | 152 | #include "extensionmanager.h" |
153 | #include "addresseeconfig.h" | 153 | #include "addresseeconfig.h" |
154 | #include "nameeditdialog.h" | 154 | #include "nameeditdialog.h" |
155 | #include <kcmultidialog.h> | 155 | #include <kcmultidialog.h> |
156 | 156 | ||
157 | #ifdef _WIN32_ | 157 | #ifdef _WIN32_ |
158 | 158 | ||
159 | #include "kaimportoldialog.h" | 159 | #include "kaimportoldialog.h" |
160 | #else | 160 | #else |
161 | #include <unistd.h> | 161 | #include <unistd.h> |
162 | #endif | 162 | #endif |
163 | // sync includes | 163 | // sync includes |
164 | #include <libkdepim/ksyncprofile.h> | 164 | #include <libkdepim/ksyncprofile.h> |
165 | #include <libkdepim/ksyncprefsdialog.h> | 165 | #include <libkdepim/ksyncprefsdialog.h> |
166 | 166 | ||
167 | 167 | ||
168 | class KABCatPrefs : public QDialog | 168 | class KABCatPrefs : public QDialog |
169 | { | 169 | { |
170 | public: | 170 | public: |
171 | KABCatPrefs( QWidget *parent=0, const char *name=0 ) : | 171 | KABCatPrefs( QWidget *parent=0, const char *name=0 ) : |
172 | QDialog( parent, name, true ) | 172 | QDialog( parent, name, true ) |
173 | { | 173 | { |
174 | setCaption( i18n("Manage new Categories") ); | 174 | setCaption( i18n("Manage new Categories") ); |
175 | QVBoxLayout* lay = new QVBoxLayout( this ); | 175 | QVBoxLayout* lay = new QVBoxLayout( this ); |
176 | lay->setSpacing( 3 ); | 176 | lay->setSpacing( 3 ); |
177 | lay->setMargin( 3 ); | 177 | lay->setMargin( 3 ); |
178 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 178 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
179 | lay->addWidget( lab ); | 179 | lay->addWidget( lab ); |
180 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 180 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
181 | lay->addWidget( format ); | 181 | lay->addWidget( format ); |
182 | format->setExclusive ( true ) ; | 182 | format->setExclusive ( true ) ; |
183 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 183 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
184 | new QRadioButton(i18n("Remove from addressees"), format ); | 184 | new QRadioButton(i18n("Remove from addressees"), format ); |
185 | addCatBut->setChecked( true ); | 185 | addCatBut->setChecked( true ); |
186 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 186 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
187 | lay->addWidget( ok ); | 187 | lay->addWidget( ok ); |
188 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 188 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
189 | lay->addWidget( cancel ); | 189 | lay->addWidget( cancel ); |
190 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 190 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
191 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 191 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
192 | resize( 200, 200 ); | 192 | resize( 200, 200 ); |
193 | } | 193 | } |
194 | 194 | ||
195 | bool addCat() { return addCatBut->isChecked(); } | 195 | bool addCat() { return addCatBut->isChecked(); } |
196 | private: | 196 | private: |
197 | QRadioButton* addCatBut; | 197 | QRadioButton* addCatBut; |
198 | }; | 198 | }; |
199 | 199 | ||
200 | class KABFormatPrefs : public QDialog | 200 | class KABFormatPrefs : public QDialog |
201 | { | 201 | { |
202 | public: | 202 | public: |
203 | KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : | 203 | KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : |
204 | QDialog( parent, name, true ) | 204 | QDialog( parent, name, true ) |
205 | { | 205 | { |
206 | setCaption( i18n("Set formatted name") ); | 206 | setCaption( i18n("Set formatted name") ); |
207 | QVBoxLayout* lay = new QVBoxLayout( this ); | 207 | QVBoxLayout* lay = new QVBoxLayout( this ); |
208 | lay->setSpacing( 3 ); | 208 | lay->setSpacing( 3 ); |
209 | lay->setMargin( 3 ); | 209 | lay->setMargin( 3 ); |
210 | QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); | 210 | QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); |
211 | lay->addWidget( lab ); | 211 | lay->addWidget( lab ); |
212 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); | 212 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); |
213 | lay->addWidget( format ); | 213 | lay->addWidget( format ); |
214 | format->setExclusive ( true ) ; | 214 | format->setExclusive ( true ) ; |
215 | simple = new QRadioButton(i18n("Simple: James Bond"), format ); | 215 | simple = new QRadioButton(i18n("Simple: James Bond"), format ); |
216 | full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); | 216 | full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); |
217 | reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); | 217 | reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); |
218 | company = new QRadioButton(i18n("Organization: MI6"), format ); | 218 | company = new QRadioButton(i18n("Organization: MI6"), format ); |
219 | simple->setChecked( true ); | 219 | simple->setChecked( true ); |
220 | setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); | 220 | setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); |
221 | lay->addWidget( setCompany ); | 221 | lay->addWidget( setCompany ); |
222 | QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); | 222 | QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); |
223 | lay->addWidget( ok ); | 223 | lay->addWidget( ok ); |
224 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 224 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
225 | lay->addWidget( cancel ); | 225 | lay->addWidget( cancel ); |
226 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 226 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
227 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 227 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
228 | //resize( 200, 200 ); | 228 | //resize( 200, 200 ); |
229 | 229 | ||
230 | } | 230 | } |
231 | public: | 231 | public: |
232 | QRadioButton* simple, *full, *reverse, *company; | 232 | QRadioButton* simple, *full, *reverse, *company; |
233 | QCheckBox* setCompany; | 233 | QCheckBox* setCompany; |
234 | }; | 234 | }; |
235 | 235 | ||
236 | 236 | ||
237 | 237 | ||
238 | class KAex2phonePrefs : public QDialog | 238 | class KAex2phonePrefs : public QDialog |
239 | { | 239 | { |
240 | public: | 240 | public: |
241 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 241 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
242 | QDialog( parent, name, true ) | 242 | QDialog( parent, name, true ) |
243 | { | 243 | { |
244 | setCaption( i18n("Export to phone options") ); | 244 | setCaption( i18n("Export to phone options") ); |
245 | QVBoxLayout* lay = new QVBoxLayout( this ); | 245 | QVBoxLayout* lay = new QVBoxLayout( this ); |
246 | lay->setSpacing( 3 ); | 246 | lay->setSpacing( 3 ); |
247 | lay->setMargin( 3 ); | 247 | lay->setMargin( 3 ); |
248 | QLabel *lab; | 248 | QLabel *lab; |
249 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 249 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
250 | lab->setAlignment (AlignHCenter ); | 250 | lab->setAlignment (AlignHCenter ); |
251 | QHBox* temphb; | 251 | QHBox* temphb; |
252 | temphb = new QHBox( this ); | 252 | temphb = new QHBox( this ); |
253 | new QLabel( i18n("I/O device: "), temphb ); | 253 | new QLabel( i18n("I/O device: "), temphb ); |
254 | mPhoneDevice = new QLineEdit( temphb); | 254 | mPhoneDevice = new QLineEdit( temphb); |
255 | lay->addWidget( temphb ); | 255 | lay->addWidget( temphb ); |
256 | temphb = new QHBox( this ); | 256 | temphb = new QHBox( this ); |
257 | new QLabel( i18n("Connection: "), temphb ); | 257 | new QLabel( i18n("Connection: "), temphb ); |
258 | mPhoneConnection = new QLineEdit( temphb); | 258 | mPhoneConnection = new QLineEdit( temphb); |
259 | lay->addWidget( temphb ); | 259 | lay->addWidget( temphb ); |
260 | temphb = new QHBox( this ); | 260 | temphb = new QHBox( this ); |
261 | new QLabel( i18n("Model(opt.): "), temphb ); | 261 | new QLabel( i18n("Model(opt.): "), temphb ); |
262 | mPhoneModel = new QLineEdit( temphb); | 262 | mPhoneModel = new QLineEdit( temphb); |
263 | lay->addWidget( temphb ); | 263 | lay->addWidget( temphb ); |
264 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); | 264 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); |
265 | // lay->addWidget( mWriteToSim ); | 265 | // lay->addWidget( mWriteToSim ); |
266 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); | 266 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); |
267 | lab->setAlignment (AlignHCenter); | 267 | lab->setAlignment (AlignHCenter); |
268 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 268 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
269 | lay->addWidget( ok ); | 269 | lay->addWidget( ok ); |
270 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 270 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
271 | lay->addWidget( cancel ); | 271 | lay->addWidget( cancel ); |
272 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 272 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
273 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 273 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
274 | resize( 220, 240 ); | 274 | resize( 220, 240 ); |
275 | 275 | ||
276 | } | 276 | } |
277 | 277 | ||
278 | public: | 278 | public: |
279 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 279 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
280 | QCheckBox* mWriteToSim; | 280 | QCheckBox* mWriteToSim; |
281 | }; | 281 | }; |
282 | 282 | ||
283 | 283 | ||
284 | bool pasteWithNewUid = true; | 284 | bool pasteWithNewUid = true; |
285 | 285 | ||
286 | #ifdef KAB_EMBEDDED | 286 | #ifdef KAB_EMBEDDED |
287 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 287 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
288 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 288 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
289 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 289 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
290 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 290 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
291 | #else //KAB_EMBEDDED | 291 | #else //KAB_EMBEDDED |
292 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 292 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
293 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 293 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
294 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 294 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
295 | mReadWrite( readWrite ), mModified( false ) | 295 | mReadWrite( readWrite ), mModified( false ) |
296 | #endif //KAB_EMBEDDED | 296 | #endif //KAB_EMBEDDED |
297 | { | 297 | { |
298 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 298 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
299 | // syncManager->setBlockSave(false); | 299 | // syncManager->setBlockSave(false); |
300 | mMiniSplitter = 0; | 300 | mMiniSplitter = 0; |
301 | mExtensionBarSplitter = 0; | 301 | mExtensionBarSplitter = 0; |
302 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 302 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
303 | mAddressBook = KABC::StdAddressBook::self(); | 303 | mAddressBook = KABC::StdAddressBook::self(); |
304 | KABC::StdAddressBook::setAutomaticSave( false ); | 304 | KABC::StdAddressBook::setAutomaticSave( false ); |
305 | 305 | ||
306 | #ifndef KAB_EMBEDDED | 306 | #ifndef KAB_EMBEDDED |
307 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 307 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
308 | #endif //KAB_EMBEDDED | 308 | #endif //KAB_EMBEDDED |
309 | 309 | ||
310 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 310 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
311 | SLOT( addressBookChanged() ) ); | 311 | SLOT( addressBookChanged() ) ); |
312 | 312 | ||
313 | #if 0 | 313 | #if 0 |
314 | // LP moved to addressbook init method | 314 | // LP moved to addressbook init method |
315 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 315 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
316 | "X-Department", "KADDRESSBOOK" ); | 316 | "X-Department", "KADDRESSBOOK" ); |
317 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 317 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
318 | "X-Profession", "KADDRESSBOOK" ); | 318 | "X-Profession", "KADDRESSBOOK" ); |
319 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 319 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
320 | "X-AssistantsName", "KADDRESSBOOK" ); | 320 | "X-AssistantsName", "KADDRESSBOOK" ); |
321 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 321 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
322 | "X-ManagersName", "KADDRESSBOOK" ); | 322 | "X-ManagersName", "KADDRESSBOOK" ); |
323 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 323 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
324 | "X-SpousesName", "KADDRESSBOOK" ); | 324 | "X-SpousesName", "KADDRESSBOOK" ); |
325 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 325 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
326 | "X-Office", "KADDRESSBOOK" ); | 326 | "X-Office", "KADDRESSBOOK" ); |
327 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 327 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
328 | "X-IMAddress", "KADDRESSBOOK" ); | 328 | "X-IMAddress", "KADDRESSBOOK" ); |
329 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 329 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
330 | "X-Anniversary", "KADDRESSBOOK" ); | 330 | "X-Anniversary", "KADDRESSBOOK" ); |
331 | 331 | ||
332 | //US added this field to become compatible with Opie/qtopia addressbook | 332 | //US added this field to become compatible with Opie/qtopia addressbook |
333 | // values can be "female" or "male" or "". An empty field represents undefined. | 333 | // values can be "female" or "male" or "". An empty field represents undefined. |
334 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 334 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
335 | "X-Gender", "KADDRESSBOOK" ); | 335 | "X-Gender", "KADDRESSBOOK" ); |
336 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 336 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
337 | "X-Children", "KADDRESSBOOK" ); | 337 | "X-Children", "KADDRESSBOOK" ); |
338 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 338 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
339 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 339 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
340 | #endif | 340 | #endif |
341 | initGUI(); | 341 | initGUI(); |
342 | 342 | ||
343 | mIncSearchWidget->setFocus(); | 343 | mIncSearchWidget->setFocus(); |
344 | 344 | ||
345 | 345 | ||
346 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 346 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
347 | SLOT( setContactSelected( const QString& ) ) ); | 347 | SLOT( setContactSelected( const QString& ) ) ); |
348 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 348 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
349 | SLOT( executeContact( const QString& ) ) ); | 349 | SLOT( executeContact( const QString& ) ) ); |
350 | 350 | ||
351 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 351 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
352 | SLOT( deleteContacts( ) ) ); | 352 | SLOT( deleteContacts( ) ) ); |
353 | connect( mViewManager, SIGNAL( modified() ), | 353 | connect( mViewManager, SIGNAL( modified() ), |
354 | SLOT( setModified() ) ); | 354 | SLOT( setModified() ) ); |
355 | 355 | ||
356 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 356 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
357 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 357 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
358 | 358 | ||
359 | connect( mXXPortManager, SIGNAL( modified() ), | 359 | connect( mXXPortManager, SIGNAL( modified() ), |
360 | SLOT( setModified() ) ); | 360 | SLOT( setModified() ) ); |
361 | 361 | ||
362 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 362 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
363 | SLOT( incrementalSearch( const QString& ) ) ); | 363 | SLOT( incrementalSearch( const QString& ) ) ); |
364 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 364 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
365 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 365 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
366 | 366 | ||
367 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 367 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
368 | SLOT( sendMail( const QString& ) ) ); | 368 | SLOT( sendMail( const QString& ) ) ); |
369 | 369 | ||
370 | 370 | ||
371 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 371 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
372 | 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&))); | 372 | 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&))); |
373 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); | 373 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); |
374 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); | 374 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); |
375 | 375 | ||
376 | 376 | ||
377 | #ifndef KAB_EMBEDDED | 377 | #ifndef KAB_EMBEDDED |
378 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 378 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
379 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 379 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
380 | 380 | ||
381 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 381 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
382 | SLOT( browse( const QString& ) ) ); | 382 | SLOT( browse( const QString& ) ) ); |
383 | 383 | ||
384 | 384 | ||
385 | mAddressBookService = new KAddressBookService( this ); | 385 | mAddressBookService = new KAddressBookService( this ); |
386 | 386 | ||
387 | #endif //KAB_EMBEDDED | 387 | #endif //KAB_EMBEDDED |
388 | 388 | ||
389 | mMessageTimer = new QTimer( this ); | 389 | mMessageTimer = new QTimer( this ); |
390 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); | 390 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); |
391 | mEditorDialog = 0; | 391 | mEditorDialog = 0; |
392 | createAddresseeEditorDialog( this ); | 392 | createAddresseeEditorDialog( this ); |
393 | setModified( false ); | 393 | setModified( false ); |
394 | mBRdisabled = false; | 394 | mBRdisabled = false; |
395 | #ifndef DESKTOP_VERSION | 395 | #ifndef DESKTOP_VERSION |
396 | infrared = 0; | 396 | infrared = 0; |
397 | #endif | 397 | #endif |
398 | //toggleBeamReceive( ); | 398 | //toggleBeamReceive( ); |
399 | //mMainWindow->toolBar()->show(); | 399 | //mMainWindow->toolBar()->show(); |
400 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi | 400 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi |
401 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); | 401 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); |
402 | } | 402 | } |
403 | 403 | ||
404 | void KABCore::updateToolBar() | 404 | void KABCore::updateToolBar() |
405 | { | 405 | { |
406 | static int iii = 0; | 406 | static int iii = 0; |
407 | ++iii; | 407 | ++iii; |
408 | mMainWindow->toolBar()->repaintMe(); | 408 | mMainWindow->toolBar()->repaintMe(); |
409 | if ( iii < 3 ) | 409 | if ( iii < 3 ) |
410 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); | 410 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); |
411 | } | 411 | } |
412 | KABCore::~KABCore() | 412 | KABCore::~KABCore() |
413 | { | 413 | { |
414 | // save(); | 414 | // save(); |
415 | //saveSettings(); | 415 | //saveSettings(); |
416 | //KABPrefs::instance()->writeConfig(); | 416 | //KABPrefs::instance()->writeConfig(); |
417 | delete AddresseeConfig::instance(); | 417 | delete AddresseeConfig::instance(); |
418 | mAddressBook = 0; | 418 | mAddressBook = 0; |
419 | KABC::StdAddressBook::close(); | 419 | KABC::StdAddressBook::close(); |
420 | 420 | ||
421 | delete syncManager; | 421 | delete syncManager; |
422 | #ifndef DESKTOP_VERSION | 422 | #ifndef DESKTOP_VERSION |
423 | if ( infrared ) | 423 | if ( infrared ) |
424 | delete infrared; | 424 | delete infrared; |
425 | #endif | 425 | #endif |
426 | } | 426 | } |
427 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) | 427 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) |
428 | { | 428 | { |
429 | qDebug("KA: QCOP message received: %s ", cmsg.data() ); | 429 | qDebug("KA: QCOP message received: %s ", cmsg.data() ); |
430 | if ( cmsg == "setDocument(QString)" ) { | 430 | if ( cmsg == "setDocument(QString)" ) { |
431 | QDataStream stream( data, IO_ReadOnly ); | 431 | QDataStream stream( data, IO_ReadOnly ); |
432 | QString fileName; | 432 | QString fileName; |
433 | stream >> fileName; | 433 | stream >> fileName; |
434 | recieve( fileName ); | 434 | recieve( fileName ); |
435 | return; | 435 | return; |
436 | } | 436 | } |
437 | } | 437 | } |
438 | void KABCore::toggleBeamReceive( ) | 438 | void KABCore::toggleBeamReceive( ) |
439 | { | 439 | { |
440 | if ( mBRdisabled ) | 440 | if ( mBRdisabled ) |
441 | return; | 441 | return; |
442 | #ifndef DESKTOP_VERSION | 442 | #ifndef DESKTOP_VERSION |
443 | if ( infrared ) { | 443 | if ( infrared ) { |
444 | qDebug("AB disable BeamReceive "); | 444 | qDebug("AB disable BeamReceive "); |
445 | delete infrared; | 445 | delete infrared; |
446 | infrared = 0; | 446 | infrared = 0; |
447 | mActionBR->setChecked(false); | 447 | mActionBR->setChecked(false); |
448 | return; | 448 | return; |
449 | } | 449 | } |
450 | qDebug("AB enable BeamReceive "); | 450 | qDebug("AB enable BeamReceive "); |
451 | mActionBR->setChecked(true); | 451 | mActionBR->setChecked(true); |
452 | 452 | ||
453 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; | 453 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; |
454 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); | 454 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); |
455 | #endif | 455 | #endif |
456 | } | 456 | } |
457 | 457 | ||
458 | 458 | ||
459 | void KABCore::disableBR(bool b) | 459 | void KABCore::disableBR(bool b) |
460 | { | 460 | { |
461 | #ifndef DESKTOP_VERSION | 461 | #ifndef DESKTOP_VERSION |
462 | if ( b ) { | 462 | if ( b ) { |
463 | if ( infrared ) { | 463 | if ( infrared ) { |
464 | toggleBeamReceive( ); | 464 | toggleBeamReceive( ); |
465 | } | 465 | } |
466 | mBRdisabled = true; | 466 | mBRdisabled = true; |
467 | } else { | 467 | } else { |
468 | if ( mBRdisabled ) { | 468 | if ( mBRdisabled ) { |
469 | mBRdisabled = false; | 469 | mBRdisabled = false; |
470 | //toggleBeamReceive( ); | 470 | //toggleBeamReceive( ); |
471 | } | 471 | } |
472 | } | 472 | } |
473 | #endif | 473 | #endif |
474 | 474 | ||
475 | } | 475 | } |
476 | void KABCore::recieve( QString fn ) | 476 | void KABCore::recieve( QString fn ) |
477 | { | 477 | { |
478 | //qDebug("KABCore::recieve "); | 478 | //qDebug("KABCore::recieve "); |
479 | int count = mAddressBook->importFromFile( fn, true ); | 479 | int count = mAddressBook->importFromFile( fn, true ); |
480 | if ( count ) | 480 | if ( count ) |
481 | setModified( true ); | 481 | setModified( true ); |
482 | mViewManager->refreshView(); | 482 | mViewManager->refreshView(); |
483 | message(i18n("%1 contact(s) received!").arg( count )); | 483 | message(i18n("%1 contact(s) received!").arg( count )); |
484 | topLevelWidget()->showMaximized(); | 484 | topLevelWidget()->showMaximized(); |
485 | topLevelWidget()->raise(); | 485 | topLevelWidget()->raise(); |
486 | } | 486 | } |
487 | void KABCore::restoreSettings() | 487 | void KABCore::restoreSettings() |
488 | { | 488 | { |
489 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 489 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
490 | 490 | ||
491 | bool state; | 491 | bool state; |
492 | 492 | ||
493 | if (mMultipleViewsAtOnce) | 493 | if (mMultipleViewsAtOnce) |
494 | state = KABPrefs::instance()->mDetailsPageVisible; | 494 | state = KABPrefs::instance()->mDetailsPageVisible; |
495 | else | 495 | else |
496 | state = false; | 496 | state = false; |
497 | 497 | ||
498 | mActionDetails->setChecked( state ); | 498 | mActionDetails->setChecked( state ); |
499 | setDetailsVisible( state ); | 499 | setDetailsVisible( state ); |
500 | 500 | ||
501 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 501 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
502 | 502 | ||
503 | mActionJumpBar->setChecked( state ); | 503 | mActionJumpBar->setChecked( state ); |
504 | setJumpButtonBarVisible( state ); | 504 | setJumpButtonBarVisible( state ); |
505 | /*US | 505 | /*US |
506 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 506 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
507 | if ( splitterSize.count() == 0 ) { | 507 | if ( splitterSize.count() == 0 ) { |
508 | splitterSize.append( width() / 2 ); | 508 | splitterSize.append( width() / 2 ); |
509 | splitterSize.append( width() / 2 ); | 509 | splitterSize.append( width() / 2 ); |
510 | } | 510 | } |
511 | mMiniSplitter->setSizes( splitterSize ); | 511 | mMiniSplitter->setSizes( splitterSize ); |
512 | if ( mExtensionBarSplitter ) { | 512 | if ( mExtensionBarSplitter ) { |
513 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 513 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
514 | if ( splitterSize.count() == 0 ) { | 514 | if ( splitterSize.count() == 0 ) { |
515 | splitterSize.append( width() / 2 ); | 515 | splitterSize.append( width() / 2 ); |
516 | splitterSize.append( width() / 2 ); | 516 | splitterSize.append( width() / 2 ); |
517 | } | 517 | } |
518 | mExtensionBarSplitter->setSizes( splitterSize ); | 518 | mExtensionBarSplitter->setSizes( splitterSize ); |
519 | 519 | ||
520 | } | 520 | } |
521 | */ | 521 | */ |
522 | mViewManager->restoreSettings(); | 522 | mViewManager->restoreSettings(); |
523 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 523 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
524 | mExtensionManager->restoreSettings(); | 524 | mExtensionManager->restoreSettings(); |
525 | #ifdef DESKTOP_VERSION | 525 | #ifdef DESKTOP_VERSION |
526 | int wid = width(); | 526 | int wid = width(); |
527 | if ( wid < 10 ) | 527 | if ( wid < 10 ) |
528 | wid = 400; | 528 | wid = 400; |
529 | #else | 529 | #else |
530 | int wid = QApplication::desktop()->width(); | 530 | int wid = QApplication::desktop()->width(); |
531 | if ( wid < 640 ) | 531 | if ( wid < 640 ) |
532 | wid = QApplication::desktop()->height(); | 532 | wid = QApplication::desktop()->height(); |
533 | #endif | 533 | #endif |
534 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 534 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
535 | if ( true /*splitterSize.count() == 0*/ ) { | 535 | if ( true /*splitterSize.count() == 0*/ ) { |
536 | splitterSize.append( wid / 2 ); | 536 | splitterSize.append( wid / 2 ); |
537 | splitterSize.append( wid / 2 ); | 537 | splitterSize.append( wid / 2 ); |
538 | } | 538 | } |
539 | mMiniSplitter->setSizes( splitterSize ); | 539 | mMiniSplitter->setSizes( splitterSize ); |
540 | if ( mExtensionBarSplitter ) { | 540 | if ( mExtensionBarSplitter ) { |
541 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 541 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
542 | if ( true /*splitterSize.count() == 0*/ ) { | 542 | if ( true /*splitterSize.count() == 0*/ ) { |
543 | splitterSize.append( wid / 2 ); | 543 | splitterSize.append( wid / 2 ); |
544 | splitterSize.append( wid / 2 ); | 544 | splitterSize.append( wid / 2 ); |
545 | } | 545 | } |
546 | mExtensionBarSplitter->setSizes( splitterSize ); | 546 | mExtensionBarSplitter->setSizes( splitterSize ); |
547 | 547 | ||
548 | } | 548 | } |
549 | 549 | ||
550 | 550 | ||
551 | } | 551 | } |
552 | 552 | ||
553 | void KABCore::saveSettings() | 553 | void KABCore::saveSettings() |
554 | { | 554 | { |
555 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 555 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
556 | if ( mExtensionBarSplitter ) | 556 | if ( mExtensionBarSplitter ) |
557 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 557 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
558 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 558 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
559 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 559 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
560 | #ifndef KAB_EMBEDDED | 560 | #ifndef KAB_EMBEDDED |
561 | 561 | ||
562 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 562 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
563 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 563 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
564 | #endif //KAB_EMBEDDED | 564 | #endif //KAB_EMBEDDED |
565 | mExtensionManager->saveSettings(); | 565 | mExtensionManager->saveSettings(); |
566 | mViewManager->saveSettings(); | 566 | mViewManager->saveSettings(); |
567 | 567 | ||
568 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 568 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
569 | KABPrefs::instance()->writeConfig(); | 569 | KABPrefs::instance()->writeConfig(); |
570 | qDebug("KABCore::saveSettings() "); | 570 | qDebug("KABCore::saveSettings() "); |
571 | } | 571 | } |
572 | 572 | ||
573 | KABC::AddressBook *KABCore::addressBook() const | 573 | KABC::AddressBook *KABCore::addressBook() const |
574 | { | 574 | { |
575 | return mAddressBook; | 575 | return mAddressBook; |
576 | } | 576 | } |
577 | 577 | ||
578 | KConfig *KABCore::config() | 578 | KConfig *KABCore::config() |
579 | { | 579 | { |
580 | #ifndef KAB_EMBEDDED | 580 | #ifndef KAB_EMBEDDED |
581 | return KABPrefs::instance()->config(); | 581 | return KABPrefs::instance()->config(); |
582 | #else //KAB_EMBEDDED | 582 | #else //KAB_EMBEDDED |
583 | return KABPrefs::instance()->getConfig(); | 583 | return KABPrefs::instance()->getConfig(); |
584 | #endif //KAB_EMBEDDED | 584 | #endif //KAB_EMBEDDED |
585 | } | 585 | } |
586 | 586 | ||
587 | KActionCollection *KABCore::actionCollection() const | 587 | KActionCollection *KABCore::actionCollection() const |
588 | { | 588 | { |
589 | return mGUIClient->actionCollection(); | 589 | return mGUIClient->actionCollection(); |
590 | } | 590 | } |
591 | 591 | ||
592 | KABC::Field *KABCore::currentSearchField() const | 592 | KABC::Field *KABCore::currentSearchField() const |
593 | { | 593 | { |
594 | if (mIncSearchWidget) | 594 | if (mIncSearchWidget) |
595 | return mIncSearchWidget->currentField(); | 595 | return mIncSearchWidget->currentField(); |
596 | else | 596 | else |
597 | return 0; | 597 | return 0; |
598 | } | 598 | } |
599 | 599 | ||
600 | QStringList KABCore::selectedUIDs() const | 600 | QStringList KABCore::selectedUIDs() const |
601 | { | 601 | { |
602 | return mViewManager->selectedUids(); | 602 | return mViewManager->selectedUids(); |
603 | } | 603 | } |
604 | 604 | ||
605 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 605 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
606 | { | 606 | { |
607 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 607 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
608 | 608 | ||
609 | QPtrList<KRES::Resource> kresResources; | 609 | QPtrList<KRES::Resource> kresResources; |
610 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 610 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
611 | KABC::Resource *resource; | 611 | KABC::Resource *resource; |
612 | while ( ( resource = resIt.current() ) != 0 ) { | 612 | while ( ( resource = resIt.current() ) != 0 ) { |
613 | ++resIt; | 613 | ++resIt; |
614 | if ( !resource->readOnly() ) { | 614 | if ( !resource->readOnly() ) { |
615 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 615 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
616 | if ( res ) | 616 | if ( res ) |
617 | kresResources.append( res ); | 617 | kresResources.append( res ); |
618 | } | 618 | } |
619 | } | 619 | } |
620 | 620 | ||
621 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 621 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
622 | return static_cast<KABC::Resource*>( res ); | 622 | return static_cast<KABC::Resource*>( res ); |
623 | } | 623 | } |
624 | 624 | ||
625 | #ifndef KAB_EMBEDDED | 625 | #ifndef KAB_EMBEDDED |
626 | KAboutData *KABCore::createAboutData() | 626 | KAboutData *KABCore::createAboutData() |
627 | #else //KAB_EMBEDDED | 627 | #else //KAB_EMBEDDED |
628 | void KABCore::createAboutData() | 628 | void KABCore::createAboutData() |
629 | #endif //KAB_EMBEDDED | 629 | #endif //KAB_EMBEDDED |
630 | { | 630 | { |
631 | #ifndef KAB_EMBEDDED | 631 | #ifndef KAB_EMBEDDED |
632 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 632 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
633 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 633 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
634 | KAboutData::License_GPL_V2, | 634 | KAboutData::License_GPL_V2, |
635 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 635 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
636 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 636 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
637 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 637 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
638 | about->addAuthor( "Cornelius Schumacher", | 638 | about->addAuthor( "Cornelius Schumacher", |
639 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 639 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
640 | "schumacher@kde.org" ); | 640 | "schumacher@kde.org" ); |
641 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 641 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
642 | "mpilone@slac.com" ); | 642 | "mpilone@slac.com" ); |
643 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 643 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
644 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 644 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
645 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 645 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
646 | "michel@klaralvdalens-datakonsult.se" ); | 646 | "michel@klaralvdalens-datakonsult.se" ); |
647 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 647 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
648 | "hansen@kde.org" ); | 648 | "hansen@kde.org" ); |
649 | 649 | ||
650 | return about; | 650 | return about; |
651 | #endif //KAB_EMBEDDED | 651 | #endif //KAB_EMBEDDED |
652 | 652 | ||
653 | QString version; | 653 | QString version; |
654 | #include <../version> | 654 | #include <../version> |
655 | QMessageBox::about( this, "About KAddressbook/Pi", | 655 | QMessageBox::about( this, "About KAddressbook/Pi", |
656 | "KAddressbook/Platform-independent\n" | 656 | "KAddressbook/Platform-independent\n" |
657 | "(KA/Pi) " +version + " - " + | 657 | "(KA/Pi) " +version + " - " + |
658 | #ifdef DESKTOP_VERSION | 658 | #ifdef DESKTOP_VERSION |
659 | "Desktop Edition\n" | 659 | "Desktop Edition\n" |
660 | #else | 660 | #else |
661 | "PDA-Edition\n" | 661 | "PDA-Edition\n" |
662 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 662 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
663 | #endif | 663 | #endif |
664 | 664 | ||
665 | "(c) 2004 Ulf Schenk\n" | 665 | "(c) 2004 Ulf Schenk\n" |
666 | "(c) 2004 Lutz Rogowski\n" | 666 | "(c) 2004 Lutz Rogowski\n" |
667 | "(c) 1997-2003, The KDE PIM Team\n" | 667 | "(c) 1997-2003, The KDE PIM Team\n" |
668 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 668 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
669 | "Don Sanders Original author\n" | 669 | "Don Sanders Original author\n" |
670 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 670 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
671 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 671 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
672 | "Greg Stern DCOP interface\n" | 672 | "Greg Stern DCOP interface\n" |
673 | "Mark Westcot Contact pinning\n" | 673 | "Mark Westcot Contact pinning\n" |
674 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 674 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
675 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 675 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
676 | #ifdef _WIN32_ | 676 | #ifdef _WIN32_ |
677 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 677 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
678 | #endif | 678 | #endif |
679 | ); | 679 | ); |
680 | } | 680 | } |
681 | 681 | ||
682 | void KABCore::setContactSelected( const QString &uid ) | 682 | void KABCore::setContactSelected( const QString &uid ) |
683 | { | 683 | { |
684 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 684 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
685 | if ( !mDetails->isHidden() ) | 685 | if ( !mDetails->isHidden() ) |
686 | mDetails->setAddressee( addr ); | 686 | mDetails->setAddressee( addr ); |
687 | 687 | ||
688 | if ( !addr.isEmpty() ) { | 688 | if ( !addr.isEmpty() ) { |
689 | emit contactSelected( addr.formattedName() ); | 689 | emit contactSelected( addr.formattedName() ); |
690 | KABC::Picture pic = addr.photo(); | 690 | KABC::Picture pic = addr.photo(); |
691 | if ( pic.isIntern() ) { | 691 | if ( pic.isIntern() ) { |
692 | //US emit contactSelected( pic.data() ); | 692 | //US emit contactSelected( pic.data() ); |
693 | //US instead use: | 693 | //US instead use: |
694 | QPixmap px; | 694 | QPixmap px; |
695 | if (pic.data().isNull() != true) | 695 | if (pic.data().isNull() != true) |
696 | { | 696 | { |
697 | px.convertFromImage(pic.data()); | 697 | px.convertFromImage(pic.data()); |
698 | } | 698 | } |
699 | 699 | ||
700 | emit contactSelected( px ); | 700 | emit contactSelected( px ); |
701 | } | 701 | } |
702 | } | 702 | } |
703 | 703 | ||
704 | 704 | ||
705 | mExtensionManager->setSelectionChanged(); | 705 | mExtensionManager->setSelectionChanged(); |
706 | 706 | ||
707 | // update the actions | 707 | // update the actions |
708 | bool selected = !uid.isEmpty(); | 708 | bool selected = !uid.isEmpty(); |
709 | 709 | ||
710 | if ( mReadWrite ) { | 710 | if ( mReadWrite ) { |
711 | mActionCut->setEnabled( selected ); | 711 | mActionCut->setEnabled( selected ); |
712 | mActionPaste->setEnabled( selected ); | 712 | mActionPaste->setEnabled( selected ); |
713 | } | 713 | } |
714 | 714 | ||
715 | mActionCopy->setEnabled( selected ); | 715 | mActionCopy->setEnabled( selected ); |
716 | mActionDelete->setEnabled( selected ); | 716 | mActionDelete->setEnabled( selected ); |
717 | mActionEditAddressee->setEnabled( selected ); | 717 | mActionEditAddressee->setEnabled( selected ); |
718 | mActionMail->setEnabled( selected ); | 718 | mActionMail->setEnabled( selected ); |
719 | mActionMailVCard->setEnabled( selected ); | 719 | mActionMailVCard->setEnabled( selected ); |
720 | //if (mActionBeam) | 720 | //if (mActionBeam) |
721 | //mActionBeam->setEnabled( selected ); | 721 | //mActionBeam->setEnabled( selected ); |
722 | mActionWhoAmI->setEnabled( selected ); | 722 | mActionWhoAmI->setEnabled( selected ); |
723 | } | 723 | } |
724 | 724 | ||
725 | void KABCore::sendMail() | 725 | void KABCore::sendMail() |
726 | { | 726 | { |
727 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 727 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
728 | } | 728 | } |
729 | 729 | ||
730 | void KABCore::sendMail( const QString& emaillist ) | 730 | void KABCore::sendMail( const QString& emaillist ) |
731 | { | 731 | { |
732 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 732 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
733 | if (emaillist.contains(",") > 0) | 733 | if (emaillist.contains(",") > 0) |
734 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 734 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
735 | else | 735 | else |
736 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 736 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
737 | } | 737 | } |
738 | 738 | ||
739 | 739 | ||
740 | 740 | ||
741 | void KABCore::mailVCard() | 741 | void KABCore::mailVCard() |
742 | { | 742 | { |
743 | QStringList uids = mViewManager->selectedUids(); | 743 | QStringList uids = mViewManager->selectedUids(); |
744 | if ( !uids.isEmpty() ) | 744 | if ( !uids.isEmpty() ) |
745 | mailVCard( uids ); | 745 | mailVCard( uids ); |
746 | } | 746 | } |
747 | 747 | ||
748 | void KABCore::mailVCard( const QStringList& uids ) | 748 | void KABCore::mailVCard( const QStringList& uids ) |
749 | { | 749 | { |
750 | QStringList urls; | 750 | QStringList urls; |
751 | 751 | ||
752 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 752 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
753 | 753 | ||
754 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 754 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
755 | 755 | ||
756 | 756 | ||
757 | 757 | ||
758 | QDir().mkdir( dirName, true ); | 758 | QDir().mkdir( dirName, true ); |
759 | 759 | ||
760 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 760 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
761 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 761 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
762 | 762 | ||
763 | if ( a.isEmpty() ) | 763 | if ( a.isEmpty() ) |
764 | continue; | 764 | continue; |
765 | 765 | ||
766 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 766 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
767 | 767 | ||
768 | QString fileName = dirName + "/" + name; | 768 | QString fileName = dirName + "/" + name; |
769 | 769 | ||
770 | QFile outFile(fileName); | 770 | QFile outFile(fileName); |
771 | 771 | ||
772 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 772 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
773 | KABC::VCardConverter converter; | 773 | KABC::VCardConverter converter; |
774 | QString vcard; | 774 | QString vcard; |
775 | 775 | ||
776 | converter.addresseeToVCard( a, vcard ); | 776 | converter.addresseeToVCard( a, vcard ); |
777 | 777 | ||
778 | QTextStream t( &outFile ); // use a text stream | 778 | QTextStream t( &outFile ); // use a text stream |
779 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 779 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
780 | t << vcard; | 780 | t << vcard; |
781 | 781 | ||
782 | outFile.close(); | 782 | outFile.close(); |
783 | 783 | ||
784 | urls.append( fileName ); | 784 | urls.append( fileName ); |
785 | } | 785 | } |
786 | } | 786 | } |
787 | 787 | ||
788 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 788 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
789 | 789 | ||
790 | 790 | ||
791 | /*US | 791 | /*US |
792 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 792 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
793 | QString::null, // subject | 793 | QString::null, // subject |
794 | QString::null, // body | 794 | QString::null, // body |
795 | QString::null, | 795 | QString::null, |
796 | urls ); // attachments | 796 | urls ); // attachments |
797 | */ | 797 | */ |
798 | 798 | ||
799 | } | 799 | } |
800 | 800 | ||
801 | /** | 801 | /** |
802 | Beams the "WhoAmI contact. | 802 | Beams the "WhoAmI contact. |
803 | */ | 803 | */ |
804 | void KABCore::beamMySelf() | 804 | void KABCore::beamMySelf() |
805 | { | 805 | { |
806 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 806 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
807 | if (!a.isEmpty()) | 807 | if (!a.isEmpty()) |
808 | { | 808 | { |
809 | QStringList uids; | 809 | QStringList uids; |
810 | uids << a.uid(); | 810 | uids << a.uid(); |
811 | 811 | ||
812 | beamVCard(uids); | 812 | beamVCard(uids); |
813 | } else { | 813 | } else { |
814 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 814 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
815 | 815 | ||
816 | 816 | ||
817 | } | 817 | } |
818 | } | 818 | } |
819 | void KABCore::updateMainWindow() | 819 | void KABCore::updateMainWindow() |
820 | { | 820 | { |
821 | 821 | ||
822 | mMainWindow->showMaximized(); | 822 | mMainWindow->showMaximized(); |
823 | mMainWindow->update(); | 823 | mMainWindow->update(); |
824 | } | 824 | } |
825 | void KABCore::resizeEvent(QResizeEvent* e ) | 825 | void KABCore::resizeEvent(QResizeEvent* e ) |
826 | { | 826 | { |
827 | if ( !mMiniSplitter ) | 827 | if ( !mMiniSplitter ) |
828 | return; | 828 | return; |
829 | //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); | 829 | //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); |
830 | if ( QApplication::desktop()->width() >= 480 ) { | 830 | if ( QApplication::desktop()->width() >= 480 ) { |
831 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 | 831 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 |
832 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { | 832 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { |
833 | mMiniSplitter->setOrientation( Qt::Horizontal); | 833 | mMiniSplitter->setOrientation( Qt::Horizontal); |
834 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 834 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
835 | if ( QApplication::desktop()->width() <= 640 ) { | 835 | if ( QApplication::desktop()->width() <= 640 ) { |
836 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 836 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
837 | mViewManager->getFilterAction()->setComboWidth( 150 ); | 837 | mViewManager->getFilterAction()->setComboWidth( 150 ); |
838 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 838 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
839 | } | 839 | } |
840 | } | 840 | } |
841 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 | 841 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 |
842 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { | 842 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { |
843 | mMiniSplitter->setOrientation( Qt::Vertical ); | 843 | mMiniSplitter->setOrientation( Qt::Vertical ); |
844 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 844 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
845 | if ( QApplication::desktop()->width() <= 640 ) { | 845 | if ( QApplication::desktop()->width() <= 640 ) { |
846 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 846 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
847 | mMainWindow->showMinimized(); | 847 | mMainWindow->showMinimized(); |
848 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 848 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
849 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 849 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
850 | } | 850 | } |
851 | } | 851 | } |
852 | } | 852 | } |
853 | } | 853 | } |
854 | 854 | ||
855 | } | 855 | } |
856 | void KABCore::export2phone() | 856 | void KABCore::export2phone() |
857 | { | 857 | { |
858 | 858 | ||
859 | QStringList uids; | 859 | QStringList uids; |
860 | XXPortSelectDialog dlg( this, false, this ); | 860 | XXPortSelectDialog dlg( this, false, this ); |
861 | if ( dlg.exec() ) | 861 | if ( dlg.exec() ) |
862 | uids = dlg.uids(); | 862 | uids = dlg.uids(); |
863 | else | 863 | else |
864 | return; | 864 | return; |
865 | if ( uids.isEmpty() ) | 865 | if ( uids.isEmpty() ) |
866 | return; | 866 | return; |
867 | // qDebug("count %d ", uids.count()); | 867 | // qDebug("count %d ", uids.count()); |
868 | 868 | ||
869 | KAex2phonePrefs ex2phone; | 869 | KAex2phonePrefs ex2phone; |
870 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 870 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
871 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 871 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
872 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 872 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
873 | 873 | ||
874 | if ( !ex2phone.exec() ) { | 874 | if ( !ex2phone.exec() ) { |
875 | return; | 875 | return; |
876 | } | 876 | } |
877 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 877 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
878 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 878 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
879 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 879 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
880 | 880 | ||
881 | 881 | ||
882 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 882 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
883 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 883 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
884 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 884 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
885 | 885 | ||
886 | QString fileName = getPhoneFile(); | 886 | QString fileName = getPhoneFile(); |
887 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 887 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
888 | return; | 888 | return; |
889 | 889 | ||
890 | message(i18n("Exporting to phone...")); | 890 | message(i18n("Exporting to phone...")); |
891 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 891 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
892 | 892 | ||
893 | } | 893 | } |
894 | QString KABCore::getPhoneFile() | 894 | QString KABCore::getPhoneFile() |
895 | { | 895 | { |
896 | #ifdef DESKTOP_VERSION | 896 | #ifdef DESKTOP_VERSION |
897 | return locateLocal("tmp", "phonefile.vcf"); | 897 | return locateLocal("tmp", "phonefile.vcf"); |
898 | #else | 898 | #else |
899 | return "/tmp/phonefile.vcf"; | 899 | return "/tmp/phonefile.vcf"; |
900 | #endif | 900 | #endif |
901 | 901 | ||
902 | } | 902 | } |
903 | void KABCore::writeToPhone( ) | 903 | void KABCore::writeToPhone( ) |
904 | { | 904 | { |
905 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 905 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
906 | message(i18n("Export to phone finished!")); | 906 | message(i18n("Export to phone finished!")); |
907 | else | 907 | else |
908 | qDebug(i18n("Error exporting to phone")); | 908 | qDebug(i18n("Error exporting to phone")); |
909 | } | 909 | } |
910 | void KABCore::beamVCard() | 910 | void KABCore::beamVCard() |
911 | { | 911 | { |
912 | QStringList uids; | 912 | QStringList uids; |
913 | XXPortSelectDialog dlg( this, false, this ); | 913 | XXPortSelectDialog dlg( this, false, this ); |
914 | if ( dlg.exec() ) | 914 | if ( dlg.exec() ) |
915 | uids = dlg.uids(); | 915 | uids = dlg.uids(); |
916 | else | 916 | else |
917 | return; | 917 | return; |
918 | if ( uids.isEmpty() ) | 918 | if ( uids.isEmpty() ) |
919 | return; | 919 | return; |
920 | beamVCard( uids ); | 920 | beamVCard( uids ); |
921 | } | 921 | } |
922 | 922 | ||
923 | 923 | ||
924 | void KABCore::beamVCard(const QStringList& uids) | 924 | void KABCore::beamVCard(const QStringList& uids) |
925 | { | 925 | { |
926 | 926 | ||
927 | // LR: we should use the /tmp dir on the Zaurus, | 927 | // LR: we should use the /tmp dir on the Zaurus, |
928 | // because: /tmp = RAM, (HOME)/kdepim = flash memory | 928 | // because: /tmp = RAM, (HOME)/kdepim = flash memory |
929 | 929 | ||
930 | #ifdef DESKTOP_VERSION | 930 | #ifdef DESKTOP_VERSION |
931 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); | 931 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); |
932 | #else | 932 | #else |
933 | QString fileName = "/tmp/kapibeamfile.vcf"; | 933 | QString fileName = "/tmp/kapibeamfile.vcf"; |
934 | #endif | 934 | #endif |
935 | 935 | ||
936 | KABC::VCardConverter converter; | 936 | KABC::VCardConverter converter; |
937 | QString description; | 937 | QString description; |
938 | QString datastream; | 938 | QString datastream; |
939 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 939 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
940 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 940 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
941 | 941 | ||
942 | if ( a.isEmpty() ) | 942 | if ( a.isEmpty() ) |
943 | continue; | 943 | continue; |
944 | 944 | ||
945 | if (description.isEmpty()) | 945 | if (description.isEmpty()) |
946 | description = a.formattedName(); | 946 | description = a.formattedName(); |
947 | 947 | ||
948 | QString vcard; | 948 | QString vcard; |
949 | converter.addresseeToVCard( a, vcard ); | 949 | converter.addresseeToVCard( a, vcard ); |
950 | int start = 0; | 950 | int start = 0; |
951 | int next; | 951 | int next; |
952 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 952 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
953 | int semi = vcard.find(";", next); | 953 | int semi = vcard.find(";", next); |
954 | int dopp = vcard.find(":", next); | 954 | int dopp = vcard.find(":", next); |
955 | int sep; | 955 | int sep; |
956 | if ( semi < dopp && semi >= 0 ) | 956 | if ( semi < dopp && semi >= 0 ) |
957 | sep = semi ; | 957 | sep = semi ; |
958 | else | 958 | else |
959 | sep = dopp; | 959 | sep = dopp; |
960 | datastream +=vcard.mid( start, next - start); | 960 | datastream +=vcard.mid( start, next - start); |
961 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 961 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
962 | start = sep; | 962 | start = sep; |
963 | } | 963 | } |
964 | datastream += vcard.mid( start,vcard.length() ); | 964 | datastream += vcard.mid( start,vcard.length() ); |
965 | } | 965 | } |
966 | #ifndef DESKTOP_VERSION | 966 | #ifndef DESKTOP_VERSION |
967 | QFile outFile(fileName); | 967 | QFile outFile(fileName); |
968 | if ( outFile.open(IO_WriteOnly) ) { | 968 | if ( outFile.open(IO_WriteOnly) ) { |
969 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 969 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
970 | QTextStream t( &outFile ); // use a text stream | 970 | QTextStream t( &outFile ); // use a text stream |
971 | //t.setEncoding( QTextStream::UnicodeUTF8 ); | 971 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
972 | t.setEncoding( QTextStream::Latin1 ); | 972 | t.setEncoding( QTextStream::Latin1 ); |
973 | t <<datastream.latin1(); | 973 | t <<datastream.latin1(); |
974 | outFile.close(); | 974 | outFile.close(); |
975 | Ir *ir = new Ir( this ); | 975 | Ir *ir = new Ir( this ); |
976 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 976 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
977 | ir->send( fileName, description, "text/x-vCard" ); | 977 | ir->send( fileName, description, "text/x-vCard" ); |
978 | } else { | 978 | } else { |
979 | qDebug("Error open temp beam file "); | 979 | qDebug("Error open temp beam file "); |
980 | return; | 980 | return; |
981 | } | 981 | } |
982 | #endif | 982 | #endif |
983 | 983 | ||
984 | } | 984 | } |
985 | 985 | ||
986 | void KABCore::beamDone( Ir *ir ) | 986 | void KABCore::beamDone( Ir *ir ) |
987 | { | 987 | { |
988 | #ifndef DESKTOP_VERSION | 988 | #ifndef DESKTOP_VERSION |
989 | delete ir; | 989 | delete ir; |
990 | #endif | 990 | #endif |
991 | topLevelWidget()->raise(); | 991 | topLevelWidget()->raise(); |
992 | message( i18n("Beaming finished!") ); | 992 | message( i18n("Beaming finished!") ); |
993 | } | 993 | } |
994 | 994 | ||
995 | 995 | ||
996 | void KABCore::browse( const QString& url ) | 996 | void KABCore::browse( const QString& url ) |
997 | { | 997 | { |
998 | #ifndef KAB_EMBEDDED | 998 | #ifndef KAB_EMBEDDED |
999 | kapp->invokeBrowser( url ); | 999 | kapp->invokeBrowser( url ); |
1000 | #else //KAB_EMBEDDED | 1000 | #else //KAB_EMBEDDED |
1001 | qDebug("KABCore::browse must be fixed"); | 1001 | qDebug("KABCore::browse must be fixed"); |
1002 | #endif //KAB_EMBEDDED | 1002 | #endif //KAB_EMBEDDED |
1003 | } | 1003 | } |
1004 | 1004 | ||
1005 | void KABCore::selectAllContacts() | 1005 | void KABCore::selectAllContacts() |
1006 | { | 1006 | { |
1007 | mViewManager->setSelected( QString::null, true ); | 1007 | mViewManager->setSelected( QString::null, true ); |
1008 | } | 1008 | } |
1009 | 1009 | ||
1010 | void KABCore::deleteContacts() | 1010 | void KABCore::deleteContacts() |
1011 | { | 1011 | { |
1012 | QStringList uidList = mViewManager->selectedUids(); | 1012 | QStringList uidList = mViewManager->selectedUids(); |
1013 | deleteContacts( uidList ); | 1013 | deleteContacts( uidList ); |
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | void KABCore::deleteContacts( const QStringList &uids ) | 1016 | void KABCore::deleteContacts( const QStringList &uids ) |
1017 | { | 1017 | { |
1018 | if ( uids.count() > 0 ) { | 1018 | if ( uids.count() > 0 ) { |
1019 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 1019 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
1020 | UndoStack::instance()->push( command ); | 1020 | UndoStack::instance()->push( command ); |
1021 | RedoStack::instance()->clear(); | 1021 | RedoStack::instance()->clear(); |
1022 | 1022 | ||
1023 | // now if we deleted anything, refresh | 1023 | // now if we deleted anything, refresh |
1024 | setContactSelected( QString::null ); | 1024 | setContactSelected( QString::null ); |
1025 | setModified( true ); | 1025 | setModified( true ); |
1026 | } | 1026 | } |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | void KABCore::copyContacts() | 1029 | void KABCore::copyContacts() |
1030 | { | 1030 | { |
1031 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1031 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1032 | 1032 | ||
1033 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 1033 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
1034 | 1034 | ||
1035 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 1035 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
1036 | 1036 | ||
1037 | QClipboard *cb = QApplication::clipboard(); | 1037 | QClipboard *cb = QApplication::clipboard(); |
1038 | cb->setText( clipText ); | 1038 | cb->setText( clipText ); |
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | void KABCore::cutContacts() | 1041 | void KABCore::cutContacts() |
1042 | { | 1042 | { |
1043 | QStringList uidList = mViewManager->selectedUids(); | 1043 | QStringList uidList = mViewManager->selectedUids(); |
1044 | 1044 | ||
1045 | //US if ( uidList.size() > 0 ) { | 1045 | //US if ( uidList.size() > 0 ) { |
1046 | if ( uidList.count() > 0 ) { | 1046 | if ( uidList.count() > 0 ) { |
1047 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 1047 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
1048 | UndoStack::instance()->push( command ); | 1048 | UndoStack::instance()->push( command ); |
1049 | RedoStack::instance()->clear(); | 1049 | RedoStack::instance()->clear(); |
1050 | 1050 | ||
1051 | setModified( true ); | 1051 | setModified( true ); |
1052 | } | 1052 | } |
1053 | } | 1053 | } |
1054 | 1054 | ||
1055 | void KABCore::pasteContacts() | 1055 | void KABCore::pasteContacts() |
1056 | { | 1056 | { |
1057 | QClipboard *cb = QApplication::clipboard(); | 1057 | QClipboard *cb = QApplication::clipboard(); |
1058 | 1058 | ||
1059 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 1059 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
1060 | 1060 | ||
1061 | pasteContacts( list ); | 1061 | pasteContacts( list ); |
1062 | } | 1062 | } |
1063 | 1063 | ||
1064 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 1064 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
1065 | { | 1065 | { |
1066 | KABC::Resource *resource = requestResource( this ); | 1066 | KABC::Resource *resource = requestResource( this ); |
1067 | KABC::Addressee::List::Iterator it; | 1067 | KABC::Addressee::List::Iterator it; |
1068 | for ( it = list.begin(); it != list.end(); ++it ) | 1068 | for ( it = list.begin(); it != list.end(); ++it ) |
1069 | (*it).setResource( resource ); | 1069 | (*it).setResource( resource ); |
1070 | 1070 | ||
1071 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 1071 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
1072 | UndoStack::instance()->push( command ); | 1072 | UndoStack::instance()->push( command ); |
1073 | RedoStack::instance()->clear(); | 1073 | RedoStack::instance()->clear(); |
1074 | 1074 | ||
1075 | setModified( true ); | 1075 | setModified( true ); |
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | void KABCore::setWhoAmI() | 1078 | void KABCore::setWhoAmI() |
1079 | { | 1079 | { |
1080 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1080 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1081 | 1081 | ||
1082 | if ( addrList.count() > 1 ) { | 1082 | if ( addrList.count() > 1 ) { |
1083 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 1083 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
1084 | return; | 1084 | return; |
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 1087 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
1088 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 1088 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
1089 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 1089 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
1090 | } | 1090 | } |
1091 | void KABCore::editCategories() | 1091 | void KABCore::editCategories() |
1092 | { | 1092 | { |
1093 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); | 1093 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); |
1094 | dlg.exec(); | 1094 | dlg.exec(); |
1095 | } | 1095 | } |
1096 | void KABCore::setCategories() | 1096 | void KABCore::setCategories() |
1097 | { | 1097 | { |
1098 | 1098 | ||
1099 | QStringList uids; | 1099 | QStringList uids; |
1100 | XXPortSelectDialog dlgx( this, false, this ); | 1100 | XXPortSelectDialog dlgx( this, false, this ); |
1101 | if ( dlgx.exec() ) | 1101 | if ( dlgx.exec() ) |
1102 | uids = dlgx.uids(); | 1102 | uids = dlgx.uids(); |
1103 | else | 1103 | else |
1104 | return; | 1104 | return; |
1105 | if ( uids.isEmpty() ) | 1105 | if ( uids.isEmpty() ) |
1106 | return; | 1106 | return; |
1107 | // qDebug("count %d ", uids.count()); | 1107 | // qDebug("count %d ", uids.count()); |
1108 | 1108 | ||
1109 | 1109 | ||
1110 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 1110 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
1111 | if ( !dlg.exec() ) { | 1111 | if ( !dlg.exec() ) { |
1112 | message( i18n("Setting categories cancelled") ); | 1112 | message( i18n("Setting categories cancelled") ); |
1113 | return; | 1113 | return; |
1114 | } | 1114 | } |
1115 | bool merge = false; | 1115 | bool merge = false; |
1116 | QString msg = i18n( "Merge with existing categories?" ); | 1116 | QString msg = i18n( "Merge with existing categories?" ); |
1117 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 1117 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
1118 | merge = true; | 1118 | merge = true; |
1119 | 1119 | ||
1120 | message( i18n("Setting categories ... please wait!") ); | 1120 | message( i18n("Setting categories ... please wait!") ); |
1121 | QStringList categories = dlg.selectedCategories(); | 1121 | QStringList categories = dlg.selectedCategories(); |
1122 | 1122 | ||
1123 | //QStringList uids = mViewManager->selectedUids(); | 1123 | //QStringList uids = mViewManager->selectedUids(); |
1124 | QStringList::Iterator it; | 1124 | QStringList::Iterator it; |
1125 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 1125 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
1126 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 1126 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
1127 | if ( !addr.isEmpty() ) { | 1127 | if ( !addr.isEmpty() ) { |
1128 | if ( !merge ) | 1128 | if ( !merge ) |
1129 | addr.setCategories( categories ); | 1129 | addr.setCategories( categories ); |
1130 | else { | 1130 | else { |
1131 | QStringList addrCategories = addr.categories(); | 1131 | QStringList addrCategories = addr.categories(); |
1132 | QStringList::Iterator catIt; | 1132 | QStringList::Iterator catIt; |
1133 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 1133 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
1134 | if ( !addrCategories.contains( *catIt ) ) | 1134 | if ( !addrCategories.contains( *catIt ) ) |
1135 | addrCategories.append( *catIt ); | 1135 | addrCategories.append( *catIt ); |
1136 | } | 1136 | } |
1137 | addr.setCategories( addrCategories ); | 1137 | addr.setCategories( addrCategories ); |
1138 | } | 1138 | } |
1139 | mAddressBook->insertAddressee( addr ); | 1139 | mAddressBook->insertAddressee( addr ); |
1140 | } | 1140 | } |
1141 | } | 1141 | } |
1142 | 1142 | ||
1143 | if ( uids.count() > 0 ) | 1143 | if ( uids.count() > 0 ) |
1144 | setModified( true ); | 1144 | setModified( true ); |
1145 | message( i18n("Setting categories completed!") ); | 1145 | message( i18n("Setting categories completed!") ); |
1146 | } | 1146 | } |
1147 | 1147 | ||
1148 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 1148 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
1149 | { | 1149 | { |
1150 | mIncSearchWidget->setFields( fields ); | 1150 | mIncSearchWidget->setFields( fields ); |
1151 | } | 1151 | } |
1152 | 1152 | ||
1153 | void KABCore::incrementalSearch( const QString& text ) | 1153 | void KABCore::incrementalSearch( const QString& text ) |
1154 | { | 1154 | { |
1155 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1155 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1156 | } | 1156 | } |
1157 | 1157 | ||
1158 | void KABCore::setModified() | 1158 | void KABCore::setModified() |
1159 | { | 1159 | { |
1160 | setModified( true ); | 1160 | setModified( true ); |
1161 | } | 1161 | } |
1162 | 1162 | ||
1163 | void KABCore::setModifiedWOrefresh() | 1163 | void KABCore::setModifiedWOrefresh() |
1164 | { | 1164 | { |
1165 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1165 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1166 | mModified = true; | 1166 | mModified = true; |
1167 | mActionSave->setEnabled( mModified ); | 1167 | mActionSave->setEnabled( mModified ); |
1168 | 1168 | ||
1169 | 1169 | ||
1170 | } | 1170 | } |
1171 | void KABCore::setModified( bool modified ) | 1171 | void KABCore::setModified( bool modified ) |
1172 | { | 1172 | { |
1173 | mModified = modified; | 1173 | mModified = modified; |
1174 | mActionSave->setEnabled( mModified ); | 1174 | mActionSave->setEnabled( mModified ); |
1175 | 1175 | ||
1176 | if ( modified ) | 1176 | if ( modified ) |
1177 | mJumpButtonBar->recreateButtons(); | 1177 | mJumpButtonBar->recreateButtons(); |
1178 | 1178 | ||
1179 | mViewManager->refreshView(); | 1179 | mViewManager->refreshView(); |
1180 | 1180 | ||
1181 | } | 1181 | } |
1182 | 1182 | ||
1183 | bool KABCore::modified() const | 1183 | bool KABCore::modified() const |
1184 | { | 1184 | { |
1185 | return mModified; | 1185 | return mModified; |
1186 | } | 1186 | } |
1187 | 1187 | ||
1188 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1188 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1189 | { | 1189 | { |
1190 | addrModified( addr ); | 1190 | addrModified( addr ); |
1191 | } | 1191 | } |
1192 | 1192 | ||
1193 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) | 1193 | void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) |
1194 | { | 1194 | { |
1195 | 1195 | ||
1196 | Command *command = 0; | 1196 | Command *command = 0; |
1197 | QString uid; | 1197 | QString uid; |
1198 | 1198 | ||
1199 | // check if it exists already | 1199 | // check if it exists already |
1200 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1200 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1201 | if ( origAddr.isEmpty() ) | 1201 | if ( origAddr.isEmpty() ) |
1202 | command = new PwNewCommand( mAddressBook, addr ); | 1202 | command = new PwNewCommand( mAddressBook, addr ); |
1203 | else { | 1203 | else { |
1204 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1204 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1205 | uid = addr.uid(); | 1205 | uid = addr.uid(); |
1206 | } | 1206 | } |
1207 | 1207 | ||
1208 | UndoStack::instance()->push( command ); | 1208 | UndoStack::instance()->push( command ); |
1209 | RedoStack::instance()->clear(); | 1209 | RedoStack::instance()->clear(); |
1210 | if ( updateDetails ) | 1210 | if ( updateDetails ) |
1211 | mDetails->setAddressee( addr ); | 1211 | mDetails->setAddressee( addr ); |
1212 | setModified( true ); | 1212 | setModified( true ); |
1213 | } | 1213 | } |
1214 | 1214 | ||
1215 | void KABCore::newContact() | 1215 | void KABCore::newContact() |
1216 | { | 1216 | { |
1217 | 1217 | ||
1218 | 1218 | ||
1219 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1219 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1220 | 1220 | ||
1221 | QPtrList<KRES::Resource> kresResources; | 1221 | QPtrList<KRES::Resource> kresResources; |
1222 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1222 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1223 | KABC::Resource *resource; | 1223 | KABC::Resource *resource; |
1224 | while ( ( resource = it.current() ) != 0 ) { | 1224 | while ( ( resource = it.current() ) != 0 ) { |
1225 | ++it; | 1225 | ++it; |
1226 | if ( !resource->readOnly() ) { | 1226 | if ( !resource->readOnly() ) { |
1227 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1227 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1228 | if ( res ) | 1228 | if ( res ) |
1229 | kresResources.append( res ); | 1229 | kresResources.append( res ); |
1230 | } | 1230 | } |
1231 | } | 1231 | } |
1232 | 1232 | ||
1233 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1233 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1234 | resource = static_cast<KABC::Resource*>( res ); | 1234 | resource = static_cast<KABC::Resource*>( res ); |
1235 | 1235 | ||
1236 | if ( resource ) { | 1236 | if ( resource ) { |
1237 | KABC::Addressee addr; | 1237 | KABC::Addressee addr; |
1238 | addr.setResource( resource ); | 1238 | addr.setResource( resource ); |
1239 | mEditorDialog->setAddressee( addr ); | 1239 | mEditorDialog->setAddressee( addr ); |
1240 | KApplication::execDialog ( mEditorDialog ); | 1240 | KApplication::execDialog ( mEditorDialog ); |
1241 | 1241 | ||
1242 | } else | 1242 | } else |
1243 | return; | 1243 | return; |
1244 | 1244 | ||
1245 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1245 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1246 | 1246 | ||
1247 | 1247 | ||
1248 | } | 1248 | } |
1249 | 1249 | ||
1250 | void KABCore::addEmail( QString aStr ) | 1250 | void KABCore::addEmail( QString aStr ) |
1251 | { | 1251 | { |
1252 | #ifndef KAB_EMBEDDED | 1252 | #ifndef KAB_EMBEDDED |
1253 | QString fullName, email; | 1253 | QString fullName, email; |
1254 | 1254 | ||
1255 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1255 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1256 | 1256 | ||
1257 | // Try to lookup the addressee matching the email address | 1257 | // Try to lookup the addressee matching the email address |
1258 | bool found = false; | 1258 | bool found = false; |
1259 | QStringList emailList; | 1259 | QStringList emailList; |
1260 | KABC::AddressBook::Iterator it; | 1260 | KABC::AddressBook::Iterator it; |
1261 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1261 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1262 | emailList = (*it).emails(); | 1262 | emailList = (*it).emails(); |
1263 | if ( emailList.contains( email ) > 0 ) { | 1263 | if ( emailList.contains( email ) > 0 ) { |
1264 | found = true; | 1264 | found = true; |
1265 | (*it).setNameFromString( fullName ); | 1265 | (*it).setNameFromString( fullName ); |
1266 | editContact( (*it).uid() ); | 1266 | editContact( (*it).uid() ); |
1267 | } | 1267 | } |
1268 | } | 1268 | } |
1269 | 1269 | ||
1270 | if ( !found ) { | 1270 | if ( !found ) { |
1271 | KABC::Addressee addr; | 1271 | KABC::Addressee addr; |
1272 | addr.setNameFromString( fullName ); | 1272 | addr.setNameFromString( fullName ); |
1273 | addr.insertEmail( email, true ); | 1273 | addr.insertEmail( email, true ); |
1274 | 1274 | ||
1275 | mAddressBook->insertAddressee( addr ); | 1275 | mAddressBook->insertAddressee( addr ); |
1276 | mViewManager->refreshView( addr.uid() ); | 1276 | mViewManager->refreshView( addr.uid() ); |
1277 | editContact( addr.uid() ); | 1277 | editContact( addr.uid() ); |
1278 | } | 1278 | } |
1279 | #else //KAB_EMBEDDED | 1279 | #else //KAB_EMBEDDED |
1280 | qDebug("KABCore::addEmail finsih method"); | 1280 | qDebug("KABCore::addEmail finsih method"); |
1281 | #endif //KAB_EMBEDDED | 1281 | #endif //KAB_EMBEDDED |
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1284 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1285 | { | 1285 | { |
1286 | mXXPortManager->importVCard( url, showPreview ); | 1286 | mXXPortManager->importVCard( url, showPreview ); |
1287 | } | 1287 | } |
1288 | void KABCore::importFromOL() | 1288 | void KABCore::importFromOL() |
1289 | { | 1289 | { |
1290 | #ifdef _WIN32_ | 1290 | #ifdef _WIN32_ |
1291 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1291 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1292 | idgl->exec(); | 1292 | idgl->exec(); |
1293 | KABC::Addressee::List list = idgl->getAddressList(); | 1293 | KABC::Addressee::List list = idgl->getAddressList(); |
1294 | if ( list.count() > 0 ) { | 1294 | if ( list.count() > 0 ) { |
1295 | KABC::Addressee::List listNew; | 1295 | KABC::Addressee::List listNew; |
1296 | KABC::Addressee::List listExisting; | 1296 | KABC::Addressee::List listExisting; |
1297 | KABC::Addressee::List::Iterator it; | 1297 | KABC::Addressee::List::Iterator it; |
1298 | KABC::AddressBook::Iterator iter; | 1298 | KABC::AddressBook::Iterator iter; |
1299 | for ( it = list.begin(); it != list.end(); ++it ) { | 1299 | for ( it = list.begin(); it != list.end(); ++it ) { |
1300 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1300 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1301 | listNew.append( (*it) ); | 1301 | listNew.append( (*it) ); |
1302 | else | 1302 | else |
1303 | listExisting.append( (*it) ); | 1303 | listExisting.append( (*it) ); |
1304 | } | 1304 | } |
1305 | if ( listExisting.count() > 0 ) | 1305 | if ( listExisting.count() > 0 ) |
1306 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1306 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1307 | if ( listNew.count() > 0 ) { | 1307 | if ( listNew.count() > 0 ) { |
1308 | pasteWithNewUid = false; | 1308 | pasteWithNewUid = false; |
1309 | pasteContacts( listNew ); | 1309 | pasteContacts( listNew ); |
1310 | pasteWithNewUid = true; | 1310 | pasteWithNewUid = true; |
1311 | } | 1311 | } |
1312 | } | 1312 | } |
1313 | delete idgl; | 1313 | delete idgl; |
1314 | #endif | 1314 | #endif |
1315 | } | 1315 | } |
1316 | 1316 | ||
1317 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1317 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1318 | { | 1318 | { |
1319 | mXXPortManager->importVCard( vCard, showPreview ); | 1319 | mXXPortManager->importVCard( vCard, showPreview ); |
1320 | } | 1320 | } |
1321 | 1321 | ||
1322 | //US added a second method without defaultparameter | 1322 | //US added a second method without defaultparameter |
1323 | void KABCore::editContact2() { | 1323 | void KABCore::editContact2() { |
1324 | editContact( QString::null ); | 1324 | editContact( QString::null ); |
1325 | } | 1325 | } |
1326 | 1326 | ||
1327 | void KABCore::editContact( const QString &uid ) | 1327 | void KABCore::editContact( const QString &uid ) |
1328 | { | 1328 | { |
1329 | 1329 | ||
1330 | if ( mExtensionManager->isQuickEditVisible() ) | 1330 | if ( mExtensionManager->isQuickEditVisible() ) |
1331 | return; | 1331 | return; |
1332 | 1332 | ||
1333 | // First, locate the contact entry | 1333 | // First, locate the contact entry |
1334 | QString localUID = uid; | 1334 | QString localUID = uid; |
1335 | if ( localUID.isNull() ) { | 1335 | if ( localUID.isNull() ) { |
1336 | QStringList uidList = mViewManager->selectedUids(); | 1336 | QStringList uidList = mViewManager->selectedUids(); |
1337 | if ( uidList.count() > 0 ) | 1337 | if ( uidList.count() > 0 ) |
1338 | localUID = *( uidList.at( 0 ) ); | 1338 | localUID = *( uidList.at( 0 ) ); |
1339 | } | 1339 | } |
1340 | 1340 | ||
1341 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1341 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1342 | if ( !addr.isEmpty() ) { | 1342 | if ( !addr.isEmpty() ) { |
1343 | mEditorDialog->setAddressee( addr ); | 1343 | mEditorDialog->setAddressee( addr ); |
1344 | KApplication::execDialog ( mEditorDialog ); | 1344 | KApplication::execDialog ( mEditorDialog ); |
1345 | } | 1345 | } |
1346 | } | 1346 | } |
1347 | 1347 | ||
1348 | /** | 1348 | /** |
1349 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1349 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1350 | the method will try to find a selected addressee in the view. | 1350 | the method will try to find a selected addressee in the view. |
1351 | */ | 1351 | */ |
1352 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1352 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1353 | { | 1353 | { |
1354 | if ( mMultipleViewsAtOnce ) | 1354 | if ( mMultipleViewsAtOnce ) |
1355 | { | 1355 | { |
1356 | editContact( uid ); | 1356 | editContact( uid ); |
1357 | } | 1357 | } |
1358 | else | 1358 | else |
1359 | { | 1359 | { |
1360 | setDetailsVisible( true ); | 1360 | setDetailsVisible( true ); |
1361 | mActionDetails->setChecked(true); | 1361 | mActionDetails->setChecked(true); |
1362 | } | 1362 | } |
1363 | 1363 | ||
1364 | } | 1364 | } |
1365 | 1365 | ||
1366 | void KABCore::save() | 1366 | void KABCore::save() |
1367 | { | 1367 | { |
1368 | if (syncManager->blockSave()) | 1368 | if (syncManager->blockSave()) |
1369 | return; | 1369 | return; |
1370 | if ( !mModified ) | 1370 | if ( !mModified ) |
1371 | return; | 1371 | return; |
1372 | 1372 | ||
1373 | syncManager->setBlockSave(true); | 1373 | syncManager->setBlockSave(true); |
1374 | QString text = i18n( "There was an error while attempting to save\n the " | 1374 | QString text = i18n( "There was an error while attempting to save\n the " |
1375 | "address book. Please check that some \nother application is " | 1375 | "address book. Please check that some \nother application is " |
1376 | "not using it. " ); | 1376 | "not using it. " ); |
1377 | message(i18n("Saving ... please wait! ")); | 1377 | message(i18n("Saving ... please wait! "), false); |
1378 | qApp->processEvents(); | 1378 | //qApp->processEvents(); |
1379 | #ifndef KAB_EMBEDDED | 1379 | #ifndef KAB_EMBEDDED |
1380 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1380 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1381 | if ( !b || !b->save() ) { | 1381 | if ( !b || !b->save() ) { |
1382 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1382 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1383 | } | 1383 | } |
1384 | #else //KAB_EMBEDDED | 1384 | #else //KAB_EMBEDDED |
1385 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1385 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1386 | if ( !b || !b->save() ) { | 1386 | if ( !b || !b->save() ) { |
1387 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1387 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1388 | } | 1388 | } |
1389 | #endif //KAB_EMBEDDED | 1389 | #endif //KAB_EMBEDDED |
1390 | 1390 | ||
1391 | message(i18n("Addressbook saved!")); | 1391 | message(i18n("Addressbook saved!")); |
1392 | setModified( false ); | 1392 | setModified( false ); |
1393 | syncManager->setBlockSave(false); | 1393 | syncManager->setBlockSave(false); |
1394 | } | 1394 | } |
1395 | 1395 | ||
1396 | 1396 | ||
1397 | void KABCore::undo() | 1397 | void KABCore::undo() |
1398 | { | 1398 | { |
1399 | UndoStack::instance()->undo(); | 1399 | UndoStack::instance()->undo(); |
1400 | 1400 | ||
1401 | // Refresh the view | 1401 | // Refresh the view |
1402 | mViewManager->refreshView(); | 1402 | mViewManager->refreshView(); |
1403 | } | 1403 | } |
1404 | 1404 | ||
1405 | void KABCore::redo() | 1405 | void KABCore::redo() |
1406 | { | 1406 | { |
1407 | RedoStack::instance()->redo(); | 1407 | RedoStack::instance()->redo(); |
1408 | 1408 | ||
1409 | // Refresh the view | 1409 | // Refresh the view |
1410 | mViewManager->refreshView(); | 1410 | mViewManager->refreshView(); |
1411 | } | 1411 | } |
1412 | 1412 | ||
1413 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1413 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1414 | { | 1414 | { |
1415 | if (mMultipleViewsAtOnce) | 1415 | if (mMultipleViewsAtOnce) |
1416 | { | 1416 | { |
1417 | if ( visible ) | 1417 | if ( visible ) |
1418 | mJumpButtonBar->show(); | 1418 | mJumpButtonBar->show(); |
1419 | else | 1419 | else |
1420 | mJumpButtonBar->hide(); | 1420 | mJumpButtonBar->hide(); |
1421 | } | 1421 | } |
1422 | else | 1422 | else |
1423 | { | 1423 | { |
1424 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1424 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1425 | if (mViewManager->isVisible()) | 1425 | if (mViewManager->isVisible()) |
1426 | { | 1426 | { |
1427 | if ( visible ) | 1427 | if ( visible ) |
1428 | mJumpButtonBar->show(); | 1428 | mJumpButtonBar->show(); |
1429 | else | 1429 | else |
1430 | mJumpButtonBar->hide(); | 1430 | mJumpButtonBar->hide(); |
1431 | } | 1431 | } |
1432 | else | 1432 | else |
1433 | { | 1433 | { |
1434 | mJumpButtonBar->hide(); | 1434 | mJumpButtonBar->hide(); |
1435 | } | 1435 | } |
1436 | } | 1436 | } |
1437 | } | 1437 | } |
1438 | 1438 | ||
1439 | 1439 | ||
1440 | void KABCore::setDetailsToState() | 1440 | void KABCore::setDetailsToState() |
1441 | { | 1441 | { |
1442 | setDetailsVisible( mActionDetails->isChecked() ); | 1442 | setDetailsVisible( mActionDetails->isChecked() ); |
1443 | } | 1443 | } |
1444 | void KABCore::setDetailsToggle() | 1444 | void KABCore::setDetailsToggle() |
1445 | { | 1445 | { |
1446 | mActionDetails->setChecked( !mActionDetails->isChecked() ); | 1446 | mActionDetails->setChecked( !mActionDetails->isChecked() ); |
1447 | setDetailsToState(); | 1447 | setDetailsToState(); |
1448 | } | 1448 | } |
1449 | 1449 | ||
1450 | 1450 | ||
1451 | 1451 | ||
1452 | void KABCore::setDetailsVisible( bool visible ) | 1452 | void KABCore::setDetailsVisible( bool visible ) |
1453 | { | 1453 | { |
1454 | if (visible && mDetails->isHidden()) | 1454 | if (visible && mDetails->isHidden()) |
1455 | { | 1455 | { |
1456 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1456 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1457 | if ( addrList.count() > 0 ) | 1457 | if ( addrList.count() > 0 ) |
1458 | mDetails->setAddressee( addrList[ 0 ] ); | 1458 | mDetails->setAddressee( addrList[ 0 ] ); |
1459 | } | 1459 | } |
1460 | 1460 | ||
1461 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1461 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1462 | // the listview and the detailview. We do that by changing the splitbar size. | 1462 | // the listview and the detailview. We do that by changing the splitbar size. |
1463 | if (mMultipleViewsAtOnce) | 1463 | if (mMultipleViewsAtOnce) |
1464 | { | 1464 | { |
1465 | if ( visible ) | 1465 | if ( visible ) |
1466 | mDetails->show(); | 1466 | mDetails->show(); |
1467 | else | 1467 | else |
1468 | mDetails->hide(); | 1468 | mDetails->hide(); |
1469 | } | 1469 | } |
1470 | else | 1470 | else |
1471 | { | 1471 | { |
1472 | if ( visible ) { | 1472 | if ( visible ) { |
1473 | mViewManager->hide(); | 1473 | mViewManager->hide(); |
1474 | mDetails->show(); | 1474 | mDetails->show(); |
1475 | mIncSearchWidget->setFocus(); | 1475 | mIncSearchWidget->setFocus(); |
1476 | } | 1476 | } |
1477 | else { | 1477 | else { |
1478 | mViewManager->show(); | 1478 | mViewManager->show(); |
1479 | mDetails->hide(); | 1479 | mDetails->hide(); |
1480 | mViewManager->setFocusAV(); | 1480 | mViewManager->setFocusAV(); |
1481 | } | 1481 | } |
1482 | setJumpButtonBarVisible( !visible ); | 1482 | setJumpButtonBarVisible( !visible ); |
1483 | } | 1483 | } |
1484 | 1484 | ||
1485 | } | 1485 | } |
1486 | 1486 | ||
1487 | void KABCore::extensionChanged( int id ) | 1487 | void KABCore::extensionChanged( int id ) |
1488 | { | 1488 | { |
1489 | //change the details view only for non desktop systems | 1489 | //change the details view only for non desktop systems |
1490 | #ifndef DESKTOP_VERSION | 1490 | #ifndef DESKTOP_VERSION |
1491 | 1491 | ||
1492 | if (id == 0) | 1492 | if (id == 0) |
1493 | { | 1493 | { |
1494 | //the user disabled the extension. | 1494 | //the user disabled the extension. |
1495 | 1495 | ||
1496 | if (mMultipleViewsAtOnce) | 1496 | if (mMultipleViewsAtOnce) |
1497 | { // enable detailsview again | 1497 | { // enable detailsview again |
1498 | setDetailsVisible( true ); | 1498 | setDetailsVisible( true ); |
1499 | mActionDetails->setChecked( true ); | 1499 | mActionDetails->setChecked( true ); |
1500 | } | 1500 | } |
1501 | else | 1501 | else |
1502 | { //go back to the listview | 1502 | { //go back to the listview |
1503 | setDetailsVisible( false ); | 1503 | setDetailsVisible( false ); |
1504 | mActionDetails->setChecked( false ); | 1504 | mActionDetails->setChecked( false ); |
1505 | mActionDetails->setEnabled(true); | 1505 | mActionDetails->setEnabled(true); |
1506 | } | 1506 | } |
1507 | 1507 | ||
1508 | } | 1508 | } |
1509 | else | 1509 | else |
1510 | { | 1510 | { |
1511 | //the user enabled the extension. | 1511 | //the user enabled the extension. |
1512 | setDetailsVisible( false ); | 1512 | setDetailsVisible( false ); |
1513 | mActionDetails->setChecked( false ); | 1513 | mActionDetails->setChecked( false ); |
1514 | 1514 | ||
1515 | if (!mMultipleViewsAtOnce) | 1515 | if (!mMultipleViewsAtOnce) |
1516 | { | 1516 | { |
1517 | mActionDetails->setEnabled(false); | 1517 | mActionDetails->setEnabled(false); |
1518 | } | 1518 | } |
1519 | 1519 | ||
1520 | mExtensionManager->setSelectionChanged(); | 1520 | mExtensionManager->setSelectionChanged(); |
1521 | 1521 | ||
1522 | } | 1522 | } |
1523 | 1523 | ||
1524 | #endif// DESKTOP_VERSION | 1524 | #endif// DESKTOP_VERSION |
1525 | 1525 | ||
1526 | } | 1526 | } |
1527 | 1527 | ||
1528 | 1528 | ||
1529 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1529 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1530 | { | 1530 | { |
1531 | 1531 | ||
1532 | if ( list.count() != 0 ) { | 1532 | if ( list.count() != 0 ) { |
1533 | KABC::Addressee::List::ConstIterator it; | 1533 | KABC::Addressee::List::ConstIterator it; |
1534 | for ( it = list.begin(); it != list.end(); ++it ) | 1534 | for ( it = list.begin(); it != list.end(); ++it ) |
1535 | mAddressBook->insertAddressee( *it ); | 1535 | mAddressBook->insertAddressee( *it ); |
1536 | if ( list.count() > 1 ) | 1536 | if ( list.count() > 1 ) |
1537 | setModified(); | 1537 | setModified(); |
1538 | else | 1538 | else |
1539 | setModifiedWOrefresh(); | 1539 | setModifiedWOrefresh(); |
1540 | } | 1540 | } |
1541 | if ( list.count() == 0 ) | 1541 | if ( list.count() == 0 ) |
1542 | mViewManager->refreshView(); | 1542 | mViewManager->refreshView(); |
1543 | else | 1543 | else |
1544 | mViewManager->refreshView( list[ 0 ].uid() ); | 1544 | mViewManager->refreshView( list[ 0 ].uid() ); |
1545 | 1545 | ||
1546 | 1546 | ||
1547 | 1547 | ||
1548 | } | 1548 | } |
1549 | 1549 | ||
1550 | QString KABCore::getNameByPhone( const QString &phone ) | 1550 | QString KABCore::getNameByPhone( const QString &phone ) |
1551 | { | 1551 | { |
1552 | #ifndef KAB_EMBEDDED | 1552 | #ifndef KAB_EMBEDDED |
1553 | QRegExp r( "[/*/-/ ]" ); | 1553 | QRegExp r( "[/*/-/ ]" ); |
1554 | QString localPhone( phone ); | 1554 | QString localPhone( phone ); |
1555 | 1555 | ||
1556 | bool found = false; | 1556 | bool found = false; |
1557 | QString ownerName = ""; | 1557 | QString ownerName = ""; |
1558 | KABC::AddressBook::Iterator iter; | 1558 | KABC::AddressBook::Iterator iter; |
1559 | KABC::PhoneNumber::List::Iterator phoneIter; | 1559 | KABC::PhoneNumber::List::Iterator phoneIter; |
1560 | KABC::PhoneNumber::List phoneList; | 1560 | KABC::PhoneNumber::List phoneList; |
1561 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1561 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1562 | phoneList = (*iter).phoneNumbers(); | 1562 | phoneList = (*iter).phoneNumbers(); |
1563 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1563 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1564 | ++phoneIter) { | 1564 | ++phoneIter) { |
1565 | // Get rid of separator chars so just the numbers are compared. | 1565 | // Get rid of separator chars so just the numbers are compared. |
1566 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1566 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1567 | ownerName = (*iter).formattedName(); | 1567 | ownerName = (*iter).formattedName(); |
1568 | found = true; | 1568 | found = true; |
1569 | } | 1569 | } |
1570 | } | 1570 | } |
1571 | } | 1571 | } |
1572 | 1572 | ||
1573 | return ownerName; | 1573 | return ownerName; |
1574 | #else //KAB_EMBEDDED | 1574 | #else //KAB_EMBEDDED |
1575 | qDebug("KABCore::getNameByPhone finsih method"); | 1575 | qDebug("KABCore::getNameByPhone finsih method"); |
1576 | return ""; | 1576 | return ""; |
1577 | #endif //KAB_EMBEDDED | 1577 | #endif //KAB_EMBEDDED |
1578 | 1578 | ||
1579 | } | 1579 | } |
1580 | 1580 | ||
1581 | void KABCore::openConfigDialog() | 1581 | void KABCore::openConfigDialog() |
1582 | { | 1582 | { |
1583 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1583 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1584 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1584 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1585 | ConfigureDialog->addModule(kabcfg ); | 1585 | ConfigureDialog->addModule(kabcfg ); |
1586 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1586 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1587 | ConfigureDialog->addModule(kdelibcfg ); | 1587 | ConfigureDialog->addModule(kdelibcfg ); |
1588 | 1588 | ||
1589 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1589 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1590 | this, SLOT( configurationChanged() ) ); | 1590 | this, SLOT( configurationChanged() ) ); |
1591 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1591 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1592 | this, SLOT( configurationChanged() ) ); | 1592 | this, SLOT( configurationChanged() ) ); |
1593 | saveSettings(); | 1593 | saveSettings(); |
1594 | #ifndef DESKTOP_VERSION | 1594 | #ifndef DESKTOP_VERSION |
1595 | ConfigureDialog->showMaximized(); | 1595 | ConfigureDialog->showMaximized(); |
1596 | #endif | 1596 | #endif |
1597 | if ( ConfigureDialog->exec() ) | 1597 | if ( ConfigureDialog->exec() ) |
1598 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1598 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1599 | delete ConfigureDialog; | 1599 | delete ConfigureDialog; |
1600 | } | 1600 | } |
1601 | 1601 | ||
1602 | void KABCore::openLDAPDialog() | 1602 | void KABCore::openLDAPDialog() |
1603 | { | 1603 | { |
1604 | #ifndef KAB_EMBEDDED | 1604 | #ifndef KAB_EMBEDDED |
1605 | if ( !mLdapSearchDialog ) { | 1605 | if ( !mLdapSearchDialog ) { |
1606 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1606 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1607 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1607 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1608 | SLOT( refreshView() ) ); | 1608 | SLOT( refreshView() ) ); |
1609 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1609 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1610 | SLOT( setModified() ) ); | 1610 | SLOT( setModified() ) ); |
1611 | } else | 1611 | } else |
1612 | mLdapSearchDialog->restoreSettings(); | 1612 | mLdapSearchDialog->restoreSettings(); |
1613 | 1613 | ||
1614 | if ( mLdapSearchDialog->isOK() ) | 1614 | if ( mLdapSearchDialog->isOK() ) |
1615 | mLdapSearchDialog->exec(); | 1615 | mLdapSearchDialog->exec(); |
1616 | #else //KAB_EMBEDDED | 1616 | #else //KAB_EMBEDDED |
1617 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1617 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1618 | #endif //KAB_EMBEDDED | 1618 | #endif //KAB_EMBEDDED |
1619 | } | 1619 | } |
1620 | 1620 | ||
1621 | void KABCore::print() | 1621 | void KABCore::print() |
1622 | { | 1622 | { |
1623 | #ifndef KAB_EMBEDDED | 1623 | #ifndef KAB_EMBEDDED |
1624 | KPrinter printer; | 1624 | KPrinter printer; |
1625 | if ( !printer.setup( this ) ) | 1625 | if ( !printer.setup( this ) ) |
1626 | return; | 1626 | return; |
1627 | 1627 | ||
1628 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1628 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1629 | mViewManager->selectedUids(), this ); | 1629 | mViewManager->selectedUids(), this ); |
1630 | 1630 | ||
1631 | wizard.exec(); | 1631 | wizard.exec(); |
1632 | #else //KAB_EMBEDDED | 1632 | #else //KAB_EMBEDDED |
1633 | qDebug("KABCore::print() finsih method"); | 1633 | qDebug("KABCore::print() finsih method"); |
1634 | #endif //KAB_EMBEDDED | 1634 | #endif //KAB_EMBEDDED |
1635 | 1635 | ||
1636 | } | 1636 | } |
1637 | 1637 | ||
1638 | 1638 | ||
1639 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1639 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1640 | { | 1640 | { |
1641 | if ( mGUIClient ) | 1641 | if ( mGUIClient ) |
1642 | mGUIClient->insertChildClient( client ); | 1642 | mGUIClient->insertChildClient( client ); |
1643 | else | 1643 | else |
1644 | KMessageBox::error( this, "no KXMLGUICLient"); | 1644 | KMessageBox::error( this, "no KXMLGUICLient"); |
1645 | } | 1645 | } |
1646 | 1646 | ||
1647 | 1647 | ||
1648 | void KABCore::configurationChanged() | 1648 | void KABCore::configurationChanged() |
1649 | { | 1649 | { |
1650 | mExtensionManager->reconfigure(); | 1650 | mExtensionManager->reconfigure(); |
1651 | } | 1651 | } |
1652 | 1652 | ||
1653 | void KABCore::addressBookChanged() | 1653 | void KABCore::addressBookChanged() |
1654 | { | 1654 | { |
1655 | /*US | 1655 | /*US |
1656 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1656 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1657 | while ( it.current() ) { | 1657 | while ( it.current() ) { |
1658 | if ( it.current()->dirty() ) { | 1658 | if ( it.current()->dirty() ) { |
1659 | QString text = i18n( "Data has been changed externally. Unsaved " | 1659 | QString text = i18n( "Data has been changed externally. Unsaved " |
1660 | "changes will be lost." ); | 1660 | "changes will be lost." ); |
1661 | KMessageBox::information( this, text ); | 1661 | KMessageBox::information( this, text ); |
1662 | } | 1662 | } |
1663 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1663 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1664 | ++it; | 1664 | ++it; |
1665 | } | 1665 | } |
1666 | */ | 1666 | */ |
1667 | if (mEditorDialog) | 1667 | if (mEditorDialog) |
1668 | { | 1668 | { |
1669 | if (mEditorDialog->dirty()) | 1669 | if (mEditorDialog->dirty()) |
1670 | { | 1670 | { |
1671 | QString text = i18n( "Data has been changed externally. Unsaved " | 1671 | QString text = i18n( "Data has been changed externally. Unsaved " |
1672 | "changes will be lost." ); | 1672 | "changes will be lost." ); |
1673 | KMessageBox::information( this, text ); | 1673 | KMessageBox::information( this, text ); |
1674 | } | 1674 | } |
1675 | QString currentuid = mEditorDialog->addressee().uid(); | 1675 | QString currentuid = mEditorDialog->addressee().uid(); |
1676 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1676 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1677 | } | 1677 | } |
1678 | mViewManager->refreshView(); | 1678 | mViewManager->refreshView(); |
1679 | 1679 | ||
1680 | 1680 | ||
1681 | } | 1681 | } |
1682 | 1682 | ||
1683 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1683 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1684 | const char *name ) | 1684 | const char *name ) |
1685 | { | 1685 | { |
1686 | 1686 | ||
1687 | if ( mEditorDialog == 0 ) { | 1687 | if ( mEditorDialog == 0 ) { |
1688 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1688 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1689 | name ? name : "editorDialog" ); | 1689 | name ? name : "editorDialog" ); |
1690 | 1690 | ||
1691 | 1691 | ||
1692 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1692 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1693 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1693 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1694 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1694 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1695 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1695 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1696 | } | 1696 | } |
1697 | 1697 | ||
1698 | return mEditorDialog; | 1698 | return mEditorDialog; |
1699 | } | 1699 | } |
1700 | 1700 | ||
1701 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1701 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1702 | { | 1702 | { |
1703 | //mEditorDict.remove( uid ); | 1703 | //mEditorDict.remove( uid ); |
1704 | } | 1704 | } |
1705 | 1705 | ||
1706 | void KABCore::initGUI() | 1706 | void KABCore::initGUI() |
1707 | { | 1707 | { |
1708 | #ifndef KAB_EMBEDDED | 1708 | #ifndef KAB_EMBEDDED |
1709 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1709 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1710 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1710 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1711 | 1711 | ||
1712 | mExtensionBarSplitter = new QSplitter( this ); | 1712 | mExtensionBarSplitter = new QSplitter( this ); |
1713 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1713 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1714 | 1714 | ||
1715 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1715 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1716 | 1716 | ||
1717 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1717 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1718 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1718 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1719 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1719 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1720 | SLOT( incrementalSearch( const QString& ) ) ); | 1720 | SLOT( incrementalSearch( const QString& ) ) ); |
1721 | 1721 | ||
1722 | mViewManager = new ViewManager( this, viewSpace ); | 1722 | mViewManager = new ViewManager( this, viewSpace ); |
1723 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1723 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1724 | 1724 | ||
1725 | mDetails = new ViewContainer( mDetailsSplitter ); | 1725 | mDetails = new ViewContainer( mDetailsSplitter ); |
1726 | 1726 | ||
1727 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1727 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1728 | 1728 | ||
1729 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1729 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1730 | 1730 | ||
1731 | topLayout->addWidget( mExtensionBarSplitter ); | 1731 | topLayout->addWidget( mExtensionBarSplitter ); |
1732 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1732 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1733 | topLayout->addWidget( mJumpButtonBar ); | 1733 | topLayout->addWidget( mJumpButtonBar ); |
1734 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1734 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1735 | 1735 | ||
1736 | mXXPortManager = new XXPortManager( this, this ); | 1736 | mXXPortManager = new XXPortManager( this, this ); |
1737 | 1737 | ||
1738 | #else //KAB_EMBEDDED | 1738 | #else //KAB_EMBEDDED |
1739 | //US initialize viewMenu before settingup viewmanager. | 1739 | //US initialize viewMenu before settingup viewmanager. |
1740 | // Viewmanager needs this menu to plugin submenues. | 1740 | // Viewmanager needs this menu to plugin submenues. |
1741 | viewMenu = new QPopupMenu( this ); | 1741 | viewMenu = new QPopupMenu( this ); |
1742 | settingsMenu = new QPopupMenu( this ); | 1742 | settingsMenu = new QPopupMenu( this ); |
1743 | //filterMenu = new QPopupMenu( this ); | 1743 | //filterMenu = new QPopupMenu( this ); |
1744 | ImportMenu = new QPopupMenu( this ); | 1744 | ImportMenu = new QPopupMenu( this ); |
1745 | ExportMenu = new QPopupMenu( this ); | 1745 | ExportMenu = new QPopupMenu( this ); |
1746 | syncMenu = new QPopupMenu( this ); | 1746 | syncMenu = new QPopupMenu( this ); |
1747 | changeMenu= new QPopupMenu( this ); | 1747 | changeMenu= new QPopupMenu( this ); |
1748 | beamMenu= new QPopupMenu( this ); | 1748 | beamMenu= new QPopupMenu( this ); |
1749 | 1749 | ||
1750 | //US since we have no splitter for the embedded system, setup | 1750 | //US since we have no splitter for the embedded system, setup |
1751 | // a layout with two frames. One left and one right. | 1751 | // a layout with two frames. One left and one right. |
1752 | 1752 | ||
1753 | QBoxLayout *topLayout; | 1753 | QBoxLayout *topLayout; |
1754 | 1754 | ||
1755 | // = new QHBoxLayout( this ); | 1755 | // = new QHBoxLayout( this ); |
1756 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1756 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1757 | 1757 | ||
1758 | // QWidget *mainBox = new QWidget( this ); | 1758 | // QWidget *mainBox = new QWidget( this ); |
1759 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1759 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1760 | 1760 | ||
1761 | #ifdef DESKTOP_VERSION | 1761 | #ifdef DESKTOP_VERSION |
1762 | topLayout = new QHBoxLayout( this ); | 1762 | topLayout = new QHBoxLayout( this ); |
1763 | 1763 | ||
1764 | 1764 | ||
1765 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1765 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1766 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1766 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1767 | 1767 | ||
1768 | topLayout->addWidget(mMiniSplitter ); | 1768 | topLayout->addWidget(mMiniSplitter ); |
1769 | 1769 | ||
1770 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1770 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1771 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1771 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1772 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1772 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1773 | mDetails = new ViewContainer( mMiniSplitter ); | 1773 | mDetails = new ViewContainer( mMiniSplitter ); |
1774 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1774 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1775 | #else | 1775 | #else |
1776 | if ( QApplication::desktop()->width() > 480 ) { | 1776 | if ( QApplication::desktop()->width() > 480 ) { |
1777 | topLayout = new QHBoxLayout( this ); | 1777 | topLayout = new QHBoxLayout( this ); |
1778 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1778 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1779 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1779 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1780 | } else { | 1780 | } else { |
1781 | 1781 | ||
1782 | topLayout = new QHBoxLayout( this ); | 1782 | topLayout = new QHBoxLayout( this ); |
1783 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1783 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1784 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1784 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1785 | } | 1785 | } |
1786 | 1786 | ||
1787 | topLayout->addWidget(mMiniSplitter ); | 1787 | topLayout->addWidget(mMiniSplitter ); |
1788 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1788 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1789 | mDetails = new ViewContainer( mMiniSplitter ); | 1789 | mDetails = new ViewContainer( mMiniSplitter ); |
1790 | 1790 | ||
1791 | 1791 | ||
1792 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1792 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1793 | #endif | 1793 | #endif |
1794 | //eh->hide(); | 1794 | //eh->hide(); |
1795 | // topLayout->addWidget(mExtensionManager ); | 1795 | // topLayout->addWidget(mExtensionManager ); |
1796 | 1796 | ||
1797 | 1797 | ||
1798 | /*US | 1798 | /*US |
1799 | #ifndef KAB_NOSPLITTER | 1799 | #ifndef KAB_NOSPLITTER |
1800 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1800 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1801 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1801 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1802 | topLayout->setSpacing( 10 ); | 1802 | topLayout->setSpacing( 10 ); |
1803 | 1803 | ||
1804 | mDetailsSplitter = new QSplitter( this ); | 1804 | mDetailsSplitter = new QSplitter( this ); |
1805 | 1805 | ||
1806 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1806 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1807 | 1807 | ||
1808 | mViewManager = new ViewManager( this, viewSpace ); | 1808 | mViewManager = new ViewManager( this, viewSpace ); |
1809 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1809 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1810 | 1810 | ||
1811 | mDetails = new ViewContainer( mDetailsSplitter ); | 1811 | mDetails = new ViewContainer( mDetailsSplitter ); |
1812 | 1812 | ||
1813 | topLayout->addWidget( mDetailsSplitter ); | 1813 | topLayout->addWidget( mDetailsSplitter ); |
1814 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1814 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1815 | #else //KAB_NOSPLITTER | 1815 | #else //KAB_NOSPLITTER |
1816 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1816 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1817 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1817 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1818 | topLayout->setSpacing( 10 ); | 1818 | topLayout->setSpacing( 10 ); |
1819 | 1819 | ||
1820 | // mDetailsSplitter = new QSplitter( this ); | 1820 | // mDetailsSplitter = new QSplitter( this ); |
1821 | 1821 | ||
1822 | QVBox *viewSpace = new QVBox( this ); | 1822 | QVBox *viewSpace = new QVBox( this ); |
1823 | 1823 | ||
1824 | mViewManager = new ViewManager( this, viewSpace ); | 1824 | mViewManager = new ViewManager( this, viewSpace ); |
1825 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1825 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1826 | 1826 | ||
1827 | mDetails = new ViewContainer( this ); | 1827 | mDetails = new ViewContainer( this ); |
1828 | 1828 | ||
1829 | topLayout->addWidget( viewSpace ); | 1829 | topLayout->addWidget( viewSpace ); |
1830 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1830 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1831 | topLayout->addWidget( mDetails ); | 1831 | topLayout->addWidget( mDetails ); |
1832 | #endif //KAB_NOSPLITTER | 1832 | #endif //KAB_NOSPLITTER |
1833 | */ | 1833 | */ |
1834 | 1834 | ||
1835 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1835 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1836 | syncManager->setBlockSave(false); | 1836 | syncManager->setBlockSave(false); |
1837 | 1837 | ||
1838 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1838 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1839 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1839 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1840 | QString sync_file = sentSyncFile(); | 1840 | QString sync_file = sentSyncFile(); |
1841 | qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); | 1841 | qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); |
1842 | syncManager->setDefaultFileName( sync_file ); | 1842 | syncManager->setDefaultFileName( sync_file ); |
1843 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1843 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1844 | 1844 | ||
1845 | #endif //KAB_EMBEDDED | 1845 | #endif //KAB_EMBEDDED |
1846 | initActions(); | 1846 | initActions(); |
1847 | 1847 | ||
1848 | #ifdef KAB_EMBEDDED | 1848 | #ifdef KAB_EMBEDDED |
1849 | addActionsManually(); | 1849 | addActionsManually(); |
1850 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1850 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1851 | mXXPortManager = new XXPortManager( this, this ); | 1851 | mXXPortManager = new XXPortManager( this, this ); |
1852 | 1852 | ||
1853 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1853 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1854 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1854 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1855 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1855 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1856 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1856 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1857 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1857 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1858 | // mIncSearchWidget->hide(); | 1858 | // mIncSearchWidget->hide(); |
1859 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1859 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1860 | SLOT( incrementalSearch( const QString& ) ) ); | 1860 | SLOT( incrementalSearch( const QString& ) ) ); |
1861 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | 1861 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); |
1862 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | 1862 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); |
1863 | 1863 | ||
1864 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1864 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1865 | 1865 | ||
1866 | topLayout->addWidget( mJumpButtonBar ); | 1866 | topLayout->addWidget( mJumpButtonBar ); |
1867 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1867 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1868 | 1868 | ||
1869 | // mMainWindow->getIconToolBar()->raise(); | 1869 | // mMainWindow->getIconToolBar()->raise(); |
1870 | 1870 | ||
1871 | #endif //KAB_EMBEDDED | 1871 | #endif //KAB_EMBEDDED |
1872 | 1872 | ||
1873 | } | 1873 | } |
1874 | void KABCore::initActions() | 1874 | void KABCore::initActions() |
1875 | { | 1875 | { |
1876 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1876 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1877 | 1877 | ||
1878 | #ifndef KAB_EMBEDDED | 1878 | #ifndef KAB_EMBEDDED |
1879 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1879 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1880 | SLOT( clipboardDataChanged() ) ); | 1880 | SLOT( clipboardDataChanged() ) ); |
1881 | #endif //KAB_EMBEDDED | 1881 | #endif //KAB_EMBEDDED |
1882 | 1882 | ||
1883 | // file menu | 1883 | // file menu |
1884 | 1884 | ||
1885 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1885 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1886 | //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1886 | //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1887 | mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, | 1887 | mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, |
1888 | SLOT( printView() ), actionCollection(), "kaddressbook_print" ); | 1888 | SLOT( printView() ), actionCollection(), "kaddressbook_print" ); |
1889 | 1889 | ||
1890 | 1890 | ||
1891 | mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, | 1891 | mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, |
1892 | SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); | 1892 | SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); |
1893 | 1893 | ||
1894 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1894 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1895 | SLOT( save() ), actionCollection(), "file_sync" ); | 1895 | SLOT( save() ), actionCollection(), "file_sync" ); |
1896 | 1896 | ||
1897 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1897 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1898 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1898 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1899 | 1899 | ||
1900 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1900 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1901 | this, SLOT( mailVCard() ), | 1901 | this, SLOT( mailVCard() ), |
1902 | actionCollection(), "file_mail_vcard"); | 1902 | actionCollection(), "file_mail_vcard"); |
1903 | 1903 | ||
1904 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, | 1904 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, |
1905 | SLOT( export2phone() ), actionCollection(), | 1905 | SLOT( export2phone() ), actionCollection(), |
1906 | "kaddressbook_ex2phone" ); | 1906 | "kaddressbook_ex2phone" ); |
1907 | 1907 | ||
1908 | mActionBeamVCard = 0; | 1908 | mActionBeamVCard = 0; |
1909 | mActionBeam = 0; | 1909 | mActionBeam = 0; |
1910 | 1910 | ||
1911 | #ifndef DESKTOP_VERSION | 1911 | #ifndef DESKTOP_VERSION |
1912 | if ( Ir::supported() ) { | 1912 | if ( Ir::supported() ) { |
1913 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, | 1913 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, |
1914 | SLOT( beamVCard() ), actionCollection(), | 1914 | SLOT( beamVCard() ), actionCollection(), |
1915 | "kaddressbook_beam_vcard" ); | 1915 | "kaddressbook_beam_vcard" ); |
1916 | 1916 | ||
1917 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1917 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1918 | SLOT( beamMySelf() ), actionCollection(), | 1918 | SLOT( beamMySelf() ), actionCollection(), |
1919 | "kaddressbook_beam_myself" ); | 1919 | "kaddressbook_beam_myself" ); |
1920 | } | 1920 | } |
1921 | #endif | 1921 | #endif |
1922 | 1922 | ||
1923 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1923 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1924 | this, SLOT( editContact2() ), | 1924 | this, SLOT( editContact2() ), |
1925 | actionCollection(), "file_properties" ); | 1925 | actionCollection(), "file_properties" ); |
1926 | 1926 | ||
1927 | #ifdef KAB_EMBEDDED | 1927 | #ifdef KAB_EMBEDDED |
1928 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1928 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1929 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1929 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1930 | mMainWindow, SLOT( exit() ), | 1930 | mMainWindow, SLOT( exit() ), |
1931 | actionCollection(), "quit" ); | 1931 | actionCollection(), "quit" ); |
1932 | #endif //KAB_EMBEDDED | 1932 | #endif //KAB_EMBEDDED |
1933 | 1933 | ||
1934 | // edit menu | 1934 | // edit menu |
1935 | if ( mIsPart ) { | 1935 | if ( mIsPart ) { |
1936 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1936 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1937 | SLOT( copyContacts() ), actionCollection(), | 1937 | SLOT( copyContacts() ), actionCollection(), |
1938 | "kaddressbook_copy" ); | 1938 | "kaddressbook_copy" ); |
1939 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1939 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1940 | SLOT( cutContacts() ), actionCollection(), | 1940 | SLOT( cutContacts() ), actionCollection(), |
1941 | "kaddressbook_cut" ); | 1941 | "kaddressbook_cut" ); |
1942 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1942 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1943 | SLOT( pasteContacts() ), actionCollection(), | 1943 | SLOT( pasteContacts() ), actionCollection(), |
1944 | "kaddressbook_paste" ); | 1944 | "kaddressbook_paste" ); |
1945 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1945 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1946 | SLOT( selectAllContacts() ), actionCollection(), | 1946 | SLOT( selectAllContacts() ), actionCollection(), |
1947 | "kaddressbook_select_all" ); | 1947 | "kaddressbook_select_all" ); |
1948 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1948 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1949 | SLOT( undo() ), actionCollection(), | 1949 | SLOT( undo() ), actionCollection(), |
1950 | "kaddressbook_undo" ); | 1950 | "kaddressbook_undo" ); |
1951 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1951 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1952 | this, SLOT( redo() ), actionCollection(), | 1952 | this, SLOT( redo() ), actionCollection(), |
1953 | "kaddressbook_redo" ); | 1953 | "kaddressbook_redo" ); |
1954 | } else { | 1954 | } else { |
1955 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1955 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1956 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1956 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1957 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1957 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1958 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1958 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1959 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1959 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1960 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1960 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1961 | } | 1961 | } |
1962 | 1962 | ||
1963 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1963 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1964 | Key_Delete, this, SLOT( deleteContacts() ), | 1964 | Key_Delete, this, SLOT( deleteContacts() ), |
1965 | actionCollection(), "edit_delete" ); | 1965 | actionCollection(), "edit_delete" ); |
1966 | 1966 | ||
1967 | mActionUndo->setEnabled( false ); | 1967 | mActionUndo->setEnabled( false ); |
1968 | mActionRedo->setEnabled( false ); | 1968 | mActionRedo->setEnabled( false ); |
1969 | 1969 | ||
1970 | // settings menu | 1970 | // settings menu |
1971 | #ifdef KAB_EMBEDDED | 1971 | #ifdef KAB_EMBEDDED |
1972 | //US special menuentry to configure the addressbook resources. On KDE | 1972 | //US special menuentry to configure the addressbook resources. On KDE |
1973 | // you do that through the control center !!! | 1973 | // you do that through the control center !!! |
1974 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1974 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1975 | SLOT( configureResources() ), actionCollection(), | 1975 | SLOT( configureResources() ), actionCollection(), |
1976 | "kaddressbook_configure_resources" ); | 1976 | "kaddressbook_configure_resources" ); |
1977 | #endif //KAB_EMBEDDED | 1977 | #endif //KAB_EMBEDDED |
1978 | 1978 | ||
1979 | if ( mIsPart ) { | 1979 | if ( mIsPart ) { |
1980 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1980 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1981 | SLOT( openConfigDialog() ), actionCollection(), | 1981 | SLOT( openConfigDialog() ), actionCollection(), |
1982 | "kaddressbook_configure" ); | 1982 | "kaddressbook_configure" ); |
1983 | 1983 | ||
1984 | //US not implemented yet | 1984 | //US not implemented yet |
1985 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1985 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1986 | // this, SLOT( configureKeyBindings() ), actionCollection(), | 1986 | // this, SLOT( configureKeyBindings() ), actionCollection(), |
1987 | // "kaddressbook_configure_shortcuts" ); | 1987 | // "kaddressbook_configure_shortcuts" ); |
1988 | #ifdef KAB_EMBEDDED | 1988 | #ifdef KAB_EMBEDDED |
1989 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1989 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1990 | mActionConfigureToolbars->setEnabled( false ); | 1990 | mActionConfigureToolbars->setEnabled( false ); |
1991 | #endif //KAB_EMBEDDED | 1991 | #endif //KAB_EMBEDDED |
1992 | 1992 | ||
1993 | } else { | 1993 | } else { |
1994 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1994 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1995 | 1995 | ||
1996 | //US not implemented yet | 1996 | //US not implemented yet |
1997 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1997 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1998 | } | 1998 | } |
1999 | 1999 | ||
2000 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 2000 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
2001 | actionCollection(), "options_show_jump_bar" ); | 2001 | actionCollection(), "options_show_jump_bar" ); |
2002 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 2002 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
2003 | 2003 | ||
2004 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 2004 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
2005 | actionCollection(), "options_show_details" ); | 2005 | actionCollection(), "options_show_details" ); |
2006 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 2006 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
2007 | 2007 | ||
2008 | 2008 | ||
2009 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, | 2009 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, |
2010 | SLOT( toggleBeamReceive() ), actionCollection(), | 2010 | SLOT( toggleBeamReceive() ), actionCollection(), |
2011 | "kaddressbook_beam_rec" ); | 2011 | "kaddressbook_beam_rec" ); |
2012 | 2012 | ||
2013 | 2013 | ||
2014 | // misc | 2014 | // misc |
2015 | // only enable LDAP lookup if we can handle the protocol | 2015 | // only enable LDAP lookup if we can handle the protocol |
2016 | #ifndef KAB_EMBEDDED | 2016 | #ifndef KAB_EMBEDDED |
2017 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 2017 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
2018 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 2018 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
2019 | this, SLOT( openLDAPDialog() ), actionCollection(), | 2019 | this, SLOT( openLDAPDialog() ), actionCollection(), |
2020 | "ldap_lookup" ); | 2020 | "ldap_lookup" ); |
2021 | } | 2021 | } |
2022 | #else //KAB_EMBEDDED | 2022 | #else //KAB_EMBEDDED |
2023 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 2023 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
2024 | #endif //KAB_EMBEDDED | 2024 | #endif //KAB_EMBEDDED |
2025 | 2025 | ||
2026 | 2026 | ||
2027 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 2027 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
2028 | SLOT( setWhoAmI() ), actionCollection(), | 2028 | SLOT( setWhoAmI() ), actionCollection(), |
2029 | "set_personal" ); | 2029 | "set_personal" ); |
2030 | 2030 | ||
2031 | 2031 | ||
2032 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 2032 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
2033 | SLOT( setCategories() ), actionCollection(), | 2033 | SLOT( setCategories() ), actionCollection(), |
2034 | "edit_set_categories" ); | 2034 | "edit_set_categories" ); |
2035 | mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, | 2035 | mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, |
2036 | SLOT( editCategories() ), actionCollection(), | 2036 | SLOT( editCategories() ), actionCollection(), |
2037 | "edit__categories" ); | 2037 | "edit__categories" ); |
2038 | 2038 | ||
2039 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 2039 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
2040 | SLOT( removeVoice() ), actionCollection(), | 2040 | SLOT( removeVoice() ), actionCollection(), |
2041 | "remove_voice" ); | 2041 | "remove_voice" ); |
2042 | mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, | 2042 | mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, |
2043 | SLOT( setFormattedName() ), actionCollection(), | 2043 | SLOT( setFormattedName() ), actionCollection(), |
2044 | "set_formatted" ); | 2044 | "set_formatted" ); |
2045 | 2045 | ||
2046 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, | 2046 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, |
2047 | SLOT( manageCategories() ), actionCollection(), | 2047 | SLOT( manageCategories() ), actionCollection(), |
2048 | "remove_voice" ); | 2048 | "remove_voice" ); |
2049 | 2049 | ||
2050 | 2050 | ||
2051 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 2051 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
2052 | SLOT( importFromOL() ), actionCollection(), | 2052 | SLOT( importFromOL() ), actionCollection(), |
2053 | "import_OL" ); | 2053 | "import_OL" ); |
2054 | #ifdef KAB_EMBEDDED | 2054 | #ifdef KAB_EMBEDDED |
2055 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 2055 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
2056 | this, SLOT( showLicence() ), actionCollection(), | 2056 | this, SLOT( showLicence() ), actionCollection(), |
2057 | "licence_about_data" ); | 2057 | "licence_about_data" ); |
2058 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 2058 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
2059 | this, SLOT( faq() ), actionCollection(), | 2059 | this, SLOT( faq() ), actionCollection(), |
2060 | "faq_about_data" ); | 2060 | "faq_about_data" ); |
2061 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 2061 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
2062 | this, SLOT( whatsnew() ), actionCollection(), | 2062 | this, SLOT( whatsnew() ), actionCollection(), |
2063 | "wn" ); | 2063 | "wn" ); |
2064 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 2064 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
2065 | this, SLOT( synchowto() ), actionCollection(), | 2065 | this, SLOT( synchowto() ), actionCollection(), |
2066 | "sync" ); | 2066 | "sync" ); |
2067 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, | 2067 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, |
2068 | this, SLOT( kdesynchowto() ), actionCollection(), | 2068 | this, SLOT( kdesynchowto() ), actionCollection(), |
2069 | "kdesync" ); | 2069 | "kdesync" ); |
2070 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, | 2070 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, |
2071 | this, SLOT( multisynchowto() ), actionCollection(), | 2071 | this, SLOT( multisynchowto() ), actionCollection(), |
2072 | "multisync" ); | 2072 | "multisync" ); |
2073 | 2073 | ||
2074 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 2074 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
2075 | this, SLOT( createAboutData() ), actionCollection(), | 2075 | this, SLOT( createAboutData() ), actionCollection(), |
2076 | "kaddressbook_about_data" ); | 2076 | "kaddressbook_about_data" ); |
2077 | #endif //KAB_EMBEDDED | 2077 | #endif //KAB_EMBEDDED |
2078 | 2078 | ||
2079 | clipboardDataChanged(); | 2079 | clipboardDataChanged(); |
2080 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2080 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2081 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2081 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2082 | } | 2082 | } |
2083 | 2083 | ||
2084 | //US we need this function, to plug all actions into the correct menues. | 2084 | //US we need this function, to plug all actions into the correct menues. |
2085 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 2085 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
2086 | void KABCore::addActionsManually() | 2086 | void KABCore::addActionsManually() |
2087 | { | 2087 | { |
2088 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 2088 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
2089 | 2089 | ||
2090 | #ifdef KAB_EMBEDDED | 2090 | #ifdef KAB_EMBEDDED |
2091 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 2091 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
2092 | QPopupMenu *editMenu = new QPopupMenu( this ); | 2092 | QPopupMenu *editMenu = new QPopupMenu( this ); |
2093 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 2093 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
2094 | 2094 | ||
2095 | KToolBar* tb = mMainWindow->toolBar(); | 2095 | KToolBar* tb = mMainWindow->toolBar(); |
2096 | 2096 | ||
2097 | #ifndef DESKTOP_VERSION | 2097 | #ifndef DESKTOP_VERSION |
2098 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { | 2098 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { |
2099 | #endif | 2099 | #endif |
2100 | QMenuBar* mb = mMainWindow->menuBar(); | 2100 | QMenuBar* mb = mMainWindow->menuBar(); |
2101 | 2101 | ||
2102 | //US setup menubar. | 2102 | //US setup menubar. |
2103 | //Disable the following block if you do not want to have a menubar. | 2103 | //Disable the following block if you do not want to have a menubar. |
2104 | mb->insertItem( i18n("&File"), fileMenu ); | 2104 | mb->insertItem( i18n("&File"), fileMenu ); |
2105 | mb->insertItem( i18n("&Edit"), editMenu ); | 2105 | mb->insertItem( i18n("&Edit"), editMenu ); |
2106 | mb->insertItem( i18n("&View"), viewMenu ); | 2106 | mb->insertItem( i18n("&View"), viewMenu ); |
2107 | mb->insertItem( i18n("&Settings"), settingsMenu ); | 2107 | mb->insertItem( i18n("&Settings"), settingsMenu ); |
2108 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 2108 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
2109 | //mb->insertItem( i18n("&Change"), changeMenu ); | 2109 | //mb->insertItem( i18n("&Change"), changeMenu ); |
2110 | mb->insertItem( i18n("&Help"), helpMenu ); | 2110 | mb->insertItem( i18n("&Help"), helpMenu ); |
2111 | mIncSearchWidget = new IncSearchWidget( tb ); | 2111 | mIncSearchWidget = new IncSearchWidget( tb ); |
2112 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 2112 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
2113 | #ifndef DESKTOP_VERSION | 2113 | #ifndef DESKTOP_VERSION |
2114 | } else { | 2114 | } else { |
2115 | //US setup toolbar | 2115 | //US setup toolbar |
2116 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 2116 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
2117 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 2117 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
2118 | menuBarTB->insertItem( "ME", popupBarTB); | 2118 | menuBarTB->insertItem( "ME", popupBarTB); |
2119 | tb->insertWidget(-1, 0, menuBarTB); | 2119 | tb->insertWidget(-1, 0, menuBarTB); |
2120 | mIncSearchWidget = new IncSearchWidget( tb ); | 2120 | mIncSearchWidget = new IncSearchWidget( tb ); |
2121 | 2121 | ||
2122 | tb->enableMoving(false); | 2122 | tb->enableMoving(false); |
2123 | popupBarTB->insertItem( i18n("&File"), fileMenu ); | 2123 | popupBarTB->insertItem( i18n("&File"), fileMenu ); |
2124 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); | 2124 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); |
2125 | popupBarTB->insertItem( i18n("&View"), viewMenu ); | 2125 | popupBarTB->insertItem( i18n("&View"), viewMenu ); |
2126 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); | 2126 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); |
2127 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 2127 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
2128 | mViewManager->getFilterAction()->plug ( popupBarTB); | 2128 | mViewManager->getFilterAction()->plug ( popupBarTB); |
2129 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); | 2129 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); |
2130 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); | 2130 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); |
2131 | if (QApplication::desktop()->width() > 320 ) { | 2131 | if (QApplication::desktop()->width() > 320 ) { |
2132 | // mViewManager->getFilterAction()->plug ( tb); | 2132 | // mViewManager->getFilterAction()->plug ( tb); |
2133 | } | 2133 | } |
2134 | } | 2134 | } |
2135 | #endif | 2135 | #endif |
2136 | // mActionQuit->plug ( mMainWindow->toolBar()); | 2136 | // mActionQuit->plug ( mMainWindow->toolBar()); |
2137 | 2137 | ||
2138 | 2138 | ||
2139 | 2139 | ||
2140 | //US Now connect the actions with the menue entries. | 2140 | //US Now connect the actions with the menue entries. |
2141 | #ifdef DESKTOP_VERSION | 2141 | #ifdef DESKTOP_VERSION |
2142 | mActionPrint->plug( fileMenu ); | 2142 | mActionPrint->plug( fileMenu ); |
2143 | mActionPrintDetails->plug( fileMenu ); | 2143 | mActionPrintDetails->plug( fileMenu ); |
2144 | fileMenu->insertSeparator(); | 2144 | fileMenu->insertSeparator(); |
2145 | #endif | 2145 | #endif |
2146 | mActionMail->plug( fileMenu ); | 2146 | mActionMail->plug( fileMenu ); |
2147 | fileMenu->insertSeparator(); | 2147 | fileMenu->insertSeparator(); |
2148 | 2148 | ||
2149 | mActionNewContact->plug( fileMenu ); | 2149 | mActionNewContact->plug( fileMenu ); |
2150 | mActionNewContact->plug( tb ); | 2150 | mActionNewContact->plug( tb ); |
2151 | 2151 | ||
2152 | mActionEditAddressee->plug( fileMenu ); | 2152 | mActionEditAddressee->plug( fileMenu ); |
2153 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 2153 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
2154 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 2154 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
2155 | mActionEditAddressee->plug( tb ); | 2155 | mActionEditAddressee->plug( tb ); |
2156 | 2156 | ||
2157 | fileMenu->insertSeparator(); | 2157 | fileMenu->insertSeparator(); |
2158 | mActionSave->plug( fileMenu ); | 2158 | mActionSave->plug( fileMenu ); |
2159 | fileMenu->insertItem( "&Import", ImportMenu ); | 2159 | fileMenu->insertItem( "&Import", ImportMenu ); |
2160 | fileMenu->insertItem( "&Export", ExportMenu ); | 2160 | fileMenu->insertItem( "&Export", ExportMenu ); |
2161 | fileMenu->insertItem( i18n("&Change"), changeMenu ); | 2161 | fileMenu->insertItem( i18n("&Change"), changeMenu ); |
2162 | #ifndef DESKTOP_VERSION | 2162 | #ifndef DESKTOP_VERSION |
2163 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); | 2163 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); |
2164 | #endif | 2164 | #endif |
2165 | #if 0 | 2165 | #if 0 |
2166 | // PENDING fix MailVCard | 2166 | // PENDING fix MailVCard |
2167 | fileMenu->insertSeparator(); | 2167 | fileMenu->insertSeparator(); |
2168 | mActionMailVCard->plug( fileMenu ); | 2168 | mActionMailVCard->plug( fileMenu ); |
2169 | #endif | 2169 | #endif |
2170 | #ifndef DESKTOP_VERSION | 2170 | #ifndef DESKTOP_VERSION |
2171 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); | 2171 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); |
2172 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); | 2172 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); |
2173 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); | 2173 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); |
2174 | #endif | 2174 | #endif |
2175 | fileMenu->insertSeparator(); | 2175 | fileMenu->insertSeparator(); |
2176 | mActionQuit->plug( fileMenu ); | 2176 | mActionQuit->plug( fileMenu ); |
2177 | #ifdef _WIN32_ | 2177 | #ifdef _WIN32_ |
2178 | mActionImportOL->plug( ImportMenu ); | 2178 | mActionImportOL->plug( ImportMenu ); |
2179 | #endif | 2179 | #endif |
2180 | // edit menu | 2180 | // edit menu |
2181 | mActionUndo->plug( editMenu ); | 2181 | mActionUndo->plug( editMenu ); |
2182 | mActionRedo->plug( editMenu ); | 2182 | mActionRedo->plug( editMenu ); |
2183 | editMenu->insertSeparator(); | 2183 | editMenu->insertSeparator(); |
2184 | mActionCut->plug( editMenu ); | 2184 | mActionCut->plug( editMenu ); |
2185 | mActionCopy->plug( editMenu ); | 2185 | mActionCopy->plug( editMenu ); |
2186 | mActionPaste->plug( editMenu ); | 2186 | mActionPaste->plug( editMenu ); |
2187 | mActionDelete->plug( editMenu ); | 2187 | mActionDelete->plug( editMenu ); |
2188 | editMenu->insertSeparator(); | 2188 | editMenu->insertSeparator(); |
2189 | mActionSelectAll->plug( editMenu ); | 2189 | mActionSelectAll->plug( editMenu ); |
2190 | 2190 | ||
2191 | mActionSetFormattedName->plug( changeMenu ); | 2191 | mActionSetFormattedName->plug( changeMenu ); |
2192 | mActionRemoveVoice->plug( changeMenu ); | 2192 | mActionRemoveVoice->plug( changeMenu ); |
2193 | // settings menu | 2193 | // settings menu |
2194 | //US special menuentry to configure the addressbook resources. On KDE | 2194 | //US special menuentry to configure the addressbook resources. On KDE |
2195 | // you do that through the control center !!! | 2195 | // you do that through the control center !!! |
2196 | mActionConfigResources->plug( settingsMenu ); | 2196 | mActionConfigResources->plug( settingsMenu ); |
2197 | settingsMenu->insertSeparator(); | 2197 | settingsMenu->insertSeparator(); |
2198 | 2198 | ||
2199 | mActionConfigKAddressbook->plug( settingsMenu ); | 2199 | mActionConfigKAddressbook->plug( settingsMenu ); |
2200 | 2200 | ||
2201 | if ( mIsPart ) { | 2201 | if ( mIsPart ) { |
2202 | //US not implemented yet | 2202 | //US not implemented yet |
2203 | //mActionConfigShortcuts->plug( settingsMenu ); | 2203 | //mActionConfigShortcuts->plug( settingsMenu ); |
2204 | //mActionConfigureToolbars->plug( settingsMenu ); | 2204 | //mActionConfigureToolbars->plug( settingsMenu ); |
2205 | 2205 | ||
2206 | } else { | 2206 | } else { |
2207 | //US not implemented yet | 2207 | //US not implemented yet |
2208 | //mActionKeyBindings->plug( settingsMenu ); | 2208 | //mActionKeyBindings->plug( settingsMenu ); |
2209 | } | 2209 | } |
2210 | 2210 | ||
2211 | settingsMenu->insertSeparator(); | 2211 | settingsMenu->insertSeparator(); |
2212 | 2212 | ||
2213 | mActionJumpBar->plug( settingsMenu ); | 2213 | mActionJumpBar->plug( settingsMenu ); |
2214 | mActionDetails->plug( settingsMenu ); | 2214 | mActionDetails->plug( settingsMenu ); |
2215 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2215 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2216 | mActionDetails->plug( tb ); | 2216 | mActionDetails->plug( tb ); |
2217 | settingsMenu->insertSeparator(); | 2217 | settingsMenu->insertSeparator(); |
2218 | #ifndef DESKTOP_VERSION | 2218 | #ifndef DESKTOP_VERSION |
2219 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); | 2219 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); |
2220 | #endif | 2220 | #endif |
2221 | settingsMenu->insertSeparator(); | 2221 | settingsMenu->insertSeparator(); |
2222 | 2222 | ||
2223 | mActionWhoAmI->plug( settingsMenu ); | 2223 | mActionWhoAmI->plug( settingsMenu ); |
2224 | mActionEditCategories->plug( settingsMenu ); | 2224 | mActionEditCategories->plug( settingsMenu ); |
2225 | mActionEditCategories->plug( changeMenu ); | 2225 | mActionEditCategories->plug( changeMenu ); |
2226 | mActionCategories->plug( changeMenu ); | 2226 | mActionCategories->plug( changeMenu ); |
2227 | mActionManageCategories->plug( changeMenu ); | 2227 | mActionManageCategories->plug( changeMenu ); |
2228 | 2228 | ||
2229 | mActionCategories->plug( settingsMenu ); | 2229 | mActionCategories->plug( settingsMenu ); |
2230 | mActionManageCategories->plug( settingsMenu ); | 2230 | mActionManageCategories->plug( settingsMenu ); |
2231 | 2231 | ||
2232 | 2232 | ||
2233 | mActionWN->plug( helpMenu ); | 2233 | mActionWN->plug( helpMenu ); |
2234 | mActionSyncHowto->plug( helpMenu ); | 2234 | mActionSyncHowto->plug( helpMenu ); |
2235 | mActionKdeSyncHowto->plug( helpMenu ); | 2235 | mActionKdeSyncHowto->plug( helpMenu ); |
2236 | mActionMultiSyncHowto->plug( helpMenu ); | 2236 | mActionMultiSyncHowto->plug( helpMenu ); |
2237 | mActionFaq->plug( helpMenu ); | 2237 | mActionFaq->plug( helpMenu ); |
2238 | mActionLicence->plug( helpMenu ); | 2238 | mActionLicence->plug( helpMenu ); |
2239 | mActionAboutKAddressbook->plug( helpMenu ); | 2239 | mActionAboutKAddressbook->plug( helpMenu ); |
2240 | 2240 | ||
2241 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2241 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2242 | 2242 | ||
2243 | mActionSave->plug( tb ); | 2243 | mActionSave->plug( tb ); |
2244 | mViewManager->getFilterAction()->plug ( tb); | 2244 | mViewManager->getFilterAction()->plug ( tb); |
2245 | //LR hide filteraction on started in 480x640 | 2245 | //LR hide filteraction on started in 480x640 |
2246 | if (QApplication::desktop()->width() == 480 ) { | 2246 | if (QApplication::desktop()->width() == 480 ) { |
2247 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 2247 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
2248 | } | 2248 | } |
2249 | mActionUndo->plug( tb ); | 2249 | mActionUndo->plug( tb ); |
2250 | mActionDelete->plug( tb ); | 2250 | mActionDelete->plug( tb ); |
2251 | mActionRedo->plug( tb ); | 2251 | mActionRedo->plug( tb ); |
2252 | } else { | 2252 | } else { |
2253 | mActionSave->plug( tb ); | 2253 | mActionSave->plug( tb ); |
2254 | tb->enableMoving(false); | 2254 | tb->enableMoving(false); |
2255 | } | 2255 | } |
2256 | //mActionQuit->plug ( tb ); | 2256 | //mActionQuit->plug ( tb ); |
2257 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2257 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2258 | 2258 | ||
2259 | //US link the searchwidget first to this. | 2259 | //US link the searchwidget first to this. |
2260 | // The real linkage to the toolbar happens later. | 2260 | // The real linkage to the toolbar happens later. |
2261 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2261 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2262 | //US tb->insertItem( mIncSearchWidget ); | 2262 | //US tb->insertItem( mIncSearchWidget ); |
2263 | /*US | 2263 | /*US |
2264 | mIncSearchWidget = new IncSearchWidget( tb ); | 2264 | mIncSearchWidget = new IncSearchWidget( tb ); |
2265 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2265 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2266 | SLOT( incrementalSearch( const QString& ) ) ); | 2266 | SLOT( incrementalSearch( const QString& ) ) ); |
2267 | 2267 | ||
2268 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2268 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2269 | 2269 | ||
2270 | //US topLayout->addWidget( mJumpButtonBar ); | 2270 | //US topLayout->addWidget( mJumpButtonBar ); |
2271 | this->layout()->add( mJumpButtonBar ); | 2271 | this->layout()->add( mJumpButtonBar ); |
2272 | */ | 2272 | */ |
2273 | 2273 | ||
2274 | #endif //KAB_EMBEDDED | 2274 | #endif //KAB_EMBEDDED |
2275 | 2275 | ||
2276 | mActionExport2phone->plug( ExportMenu ); | 2276 | mActionExport2phone->plug( ExportMenu ); |
2277 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2277 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2278 | syncManager->fillSyncMenu(); | 2278 | syncManager->fillSyncMenu(); |
2279 | 2279 | ||
2280 | } | 2280 | } |
2281 | void KABCore::showLicence() | 2281 | void KABCore::showLicence() |
2282 | { | 2282 | { |
2283 | KApplication::showLicence(); | 2283 | KApplication::showLicence(); |
2284 | } | 2284 | } |
2285 | 2285 | ||
2286 | void KABCore::manageCategories( ) | 2286 | void KABCore::manageCategories( ) |
2287 | { | 2287 | { |
2288 | KABCatPrefs* cp = new KABCatPrefs(); | 2288 | KABCatPrefs* cp = new KABCatPrefs(); |
2289 | cp->show(); | 2289 | cp->show(); |
2290 | int w =cp->sizeHint().width() ; | 2290 | int w =cp->sizeHint().width() ; |
2291 | int h = cp->sizeHint().height() ; | 2291 | int h = cp->sizeHint().height() ; |
2292 | int dw = QApplication::desktop()->width(); | 2292 | int dw = QApplication::desktop()->width(); |
2293 | int dh = QApplication::desktop()->height(); | 2293 | int dh = QApplication::desktop()->height(); |
2294 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2294 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2295 | if ( !cp->exec() ) { | 2295 | if ( !cp->exec() ) { |
2296 | delete cp; | 2296 | delete cp; |
2297 | return; | 2297 | return; |
2298 | } | 2298 | } |
2299 | int count = 0; | 2299 | int count = 0; |
2300 | int cc = 0; | ||
2300 | message( i18n("Please wait, processing categories...")); | 2301 | message( i18n("Please wait, processing categories...")); |
2301 | if ( cp->addCat() ) { | 2302 | if ( cp->addCat() ) { |
2302 | KABC::AddressBook::Iterator it; | 2303 | KABC::AddressBook::Iterator it; |
2303 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2304 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2304 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2305 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2306 | ++cc; | ||
2307 | if ( cc %10 == 0) | ||
2308 | message(i18n("Processing contact #%1").arg(cc)); | ||
2305 | QStringList catIncList = (*it).categories(); | 2309 | QStringList catIncList = (*it).categories(); |
2306 | int i; | 2310 | int i; |
2307 | for( i = 0; i< catIncList.count(); ++i ) { | 2311 | for( i = 0; i< catIncList.count(); ++i ) { |
2308 | if ( !catList.contains (catIncList[i])) { | 2312 | if ( !catList.contains (catIncList[i])) { |
2309 | catList.append( catIncList[i] ); | 2313 | catList.append( catIncList[i] ); |
2310 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2314 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2311 | ++count; | 2315 | ++count; |
2312 | } | 2316 | } |
2313 | } | 2317 | } |
2314 | } | 2318 | } |
2315 | catList.sort(); | 2319 | catList.sort(); |
2316 | KABPrefs::instance()->mCustomCategories = catList; | 2320 | KABPrefs::instance()->mCustomCategories = catList; |
2317 | KABPrefs::instance()->writeConfig(); | 2321 | KABPrefs::instance()->writeConfig(); |
2318 | message(QString::number( count )+ i18n(" categories added to list! ")); | 2322 | message(QString::number( count )+ i18n(" categories added to list! ")); |
2319 | } else { | 2323 | } else { |
2320 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2324 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2321 | QStringList catIncList; | 2325 | QStringList catIncList; |
2322 | QStringList newCatList; | 2326 | QStringList newCatList; |
2323 | KABC::AddressBook::Iterator it; | 2327 | KABC::AddressBook::Iterator it; |
2324 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2328 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2329 | ++cc; | ||
2330 | if ( cc %10 == 0) | ||
2331 | message(i18n("Processing contact #%1").arg(cc)); | ||
2325 | QStringList catIncList = (*it).categories(); | 2332 | QStringList catIncList = (*it).categories(); |
2326 | int i; | 2333 | int i; |
2327 | if ( catIncList.count() ) { | 2334 | if ( catIncList.count() ) { |
2328 | newCatList.clear(); | 2335 | newCatList.clear(); |
2329 | for( i = 0; i< catIncList.count(); ++i ) { | 2336 | for( i = 0; i< catIncList.count(); ++i ) { |
2330 | if ( catList.contains (catIncList[i])) { | 2337 | if ( catList.contains (catIncList[i])) { |
2331 | newCatList.append( catIncList[i] ); | 2338 | newCatList.append( catIncList[i] ); |
2332 | } | 2339 | } |
2333 | } | 2340 | } |
2334 | newCatList.sort(); | 2341 | newCatList.sort(); |
2335 | (*it).setCategories( newCatList ); | 2342 | (*it).setCategories( newCatList ); |
2336 | mAddressBook->insertAddressee( (*it) ); | 2343 | mAddressBook->insertAddressee( (*it) ); |
2337 | } | 2344 | } |
2338 | } | 2345 | } |
2339 | setModified( true ); | 2346 | setModified( true ); |
2340 | mViewManager->refreshView(); | 2347 | mViewManager->refreshView(); |
2341 | message( i18n("Removing categories done!")); | 2348 | message( i18n("Removing categories done!")); |
2342 | } | 2349 | } |
2343 | delete cp; | 2350 | delete cp; |
2344 | } | 2351 | } |
2345 | void KABCore::removeVoice() | 2352 | void KABCore::removeVoice() |
2346 | { | 2353 | { |
2347 | 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 ) | 2354 | 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 ) |
2348 | return; | 2355 | return; |
2349 | KABC::Addressee::List list; | 2356 | KABC::Addressee::List list; |
2350 | XXPortSelectDialog dlg( this, false, this ); | 2357 | XXPortSelectDialog dlg( this, false, this ); |
2351 | if ( dlg.exec() ) | 2358 | if ( dlg.exec() ) |
2352 | list = dlg.contacts(); | 2359 | list = dlg.contacts(); |
2353 | else | 2360 | else |
2354 | return; | 2361 | return; |
2355 | KABC::Addressee::List::Iterator it; | 2362 | KABC::Addressee::List::Iterator it; |
2356 | for ( it = list.begin(); it != list.end(); ++it ) { | 2363 | for ( it = list.begin(); it != list.end(); ++it ) { |
2357 | if ( (*it).removeVoice() ) | 2364 | if ( (*it).removeVoice() ) |
2358 | addrModified((*it), false ); | 2365 | addrModified((*it), false ); |
2359 | } | 2366 | } |
2360 | } | 2367 | } |
2361 | 2368 | ||
2362 | void KABCore::setFormattedName() | 2369 | void KABCore::setFormattedName() |
2363 | { | 2370 | { |
2364 | KABFormatPrefs setpref; | 2371 | KABFormatPrefs setpref; |
2365 | if ( !setpref.exec() ) { | 2372 | if ( !setpref.exec() ) { |
2366 | return; | 2373 | return; |
2367 | } | 2374 | } |
2368 | XXPortSelectDialog dlg( this, false, this ); | 2375 | XXPortSelectDialog dlg( this, false, this ); |
2369 | if ( !dlg.exec() ) | 2376 | if ( !dlg.exec() ) |
2370 | return; | 2377 | return; |
2371 | mAddressBook->setUntagged(); | 2378 | mAddressBook->setUntagged(); |
2372 | dlg.tagSelected(); | 2379 | dlg.tagSelected(); |
2373 | int count = 0; | 2380 | int count = 0; |
2374 | KABC::AddressBook::Iterator it; | 2381 | KABC::AddressBook::Iterator it; |
2375 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2382 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2376 | if ( (*it).tagged() ) { | 2383 | if ( (*it).tagged() ) { |
2377 | message(i18n("Changing contact #%1").arg( ++count ) ); | 2384 | ++count; |
2385 | if ( count %10 == 0 ) | ||
2386 | message(i18n("Changing contact #%1").arg( count ) ); | ||
2378 | qApp->processEvents(); | 2387 | qApp->processEvents(); |
2379 | QString fName; | 2388 | QString fName; |
2380 | if ( setpref.simple->isChecked() ) | 2389 | if ( setpref.simple->isChecked() ) |
2381 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); | 2390 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); |
2382 | else if ( setpref.full->isChecked() ) | 2391 | else if ( setpref.full->isChecked() ) |
2383 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); | 2392 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); |
2384 | else if ( setpref.reverse->isChecked() ) | 2393 | else if ( setpref.reverse->isChecked() ) |
2385 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); | 2394 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); |
2386 | else | 2395 | else |
2387 | fName = (*it).organization(); | 2396 | fName = (*it).organization(); |
2388 | if ( setpref.setCompany->isChecked() ) | 2397 | if ( setpref.setCompany->isChecked() ) |
2389 | if ( fName.isEmpty() || fName =="," ) | 2398 | if ( fName.isEmpty() || fName =="," ) |
2390 | fName = (*it).organization(); | 2399 | fName = (*it).organization(); |
2391 | (*it).setFormattedName( fName ); | 2400 | (*it).setFormattedName( fName ); |
2392 | } | 2401 | } |
2393 | } | 2402 | } |
2394 | message(i18n("Refreshing view...") ); | 2403 | message(i18n("Refreshing view...") ); |
2404 | qApp->processEvents(); | ||
2395 | mViewManager->refreshView( "" ); | 2405 | mViewManager->refreshView( "" ); |
2396 | Addressee add; | 2406 | Addressee add; |
2397 | mDetails->setAddressee( add ); | 2407 | mDetails->setAddressee( add ); |
2398 | message(i18n("Setting formatted name completed!") ); | 2408 | message(i18n("Setting formatted name completed!") ); |
2399 | } | 2409 | } |
2400 | 2410 | ||
2401 | void KABCore::clipboardDataChanged() | 2411 | void KABCore::clipboardDataChanged() |
2402 | { | 2412 | { |
2403 | 2413 | ||
2404 | if ( mReadWrite ) | 2414 | if ( mReadWrite ) |
2405 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2415 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2406 | 2416 | ||
2407 | } | 2417 | } |
2408 | 2418 | ||
2409 | void KABCore::updateActionMenu() | 2419 | void KABCore::updateActionMenu() |
2410 | { | 2420 | { |
2411 | UndoStack *undo = UndoStack::instance(); | 2421 | UndoStack *undo = UndoStack::instance(); |
2412 | RedoStack *redo = RedoStack::instance(); | 2422 | RedoStack *redo = RedoStack::instance(); |
2413 | 2423 | ||
2414 | if ( undo->isEmpty() ) | 2424 | if ( undo->isEmpty() ) |
2415 | mActionUndo->setText( i18n( "Undo" ) ); | 2425 | mActionUndo->setText( i18n( "Undo" ) ); |
2416 | else | 2426 | else |
2417 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2427 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2418 | 2428 | ||
2419 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2429 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2420 | 2430 | ||
2421 | if ( !redo->top() ) | 2431 | if ( !redo->top() ) |
2422 | mActionRedo->setText( i18n( "Redo" ) ); | 2432 | mActionRedo->setText( i18n( "Redo" ) ); |
2423 | else | 2433 | else |
2424 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2434 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2425 | 2435 | ||
2426 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2436 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2427 | } | 2437 | } |
2428 | 2438 | ||
2429 | void KABCore::configureKeyBindings() | 2439 | void KABCore::configureKeyBindings() |
2430 | { | 2440 | { |
2431 | #ifndef KAB_EMBEDDED | 2441 | #ifndef KAB_EMBEDDED |
2432 | KKeyDialog::configure( actionCollection(), true ); | 2442 | KKeyDialog::configure( actionCollection(), true ); |
2433 | #else //KAB_EMBEDDED | 2443 | #else //KAB_EMBEDDED |
2434 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2444 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2435 | #endif //KAB_EMBEDDED | 2445 | #endif //KAB_EMBEDDED |
2436 | } | 2446 | } |
2437 | 2447 | ||
2438 | #ifdef KAB_EMBEDDED | 2448 | #ifdef KAB_EMBEDDED |
2439 | void KABCore::configureResources() | 2449 | void KABCore::configureResources() |
2440 | { | 2450 | { |
2441 | KRES::KCMKResources dlg( this, "" , 0 ); | 2451 | KRES::KCMKResources dlg( this, "" , 0 ); |
2442 | 2452 | ||
2443 | if ( !dlg.exec() ) | 2453 | if ( !dlg.exec() ) |
2444 | return; | 2454 | return; |
2445 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2455 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2446 | } | 2456 | } |
2447 | #endif //KAB_EMBEDDED | 2457 | #endif //KAB_EMBEDDED |
2448 | 2458 | ||
2449 | 2459 | ||
2450 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2460 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2451 | * for the attendees list of an event. | 2461 | * for the attendees list of an event. |
2452 | */ | 2462 | */ |
2453 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2463 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2454 | { | 2464 | { |
2455 | QStringList nameList; | 2465 | QStringList nameList; |
2456 | QStringList emailList; | 2466 | QStringList emailList; |
2457 | QStringList uidList; | 2467 | QStringList uidList; |
2458 | 2468 | ||
2459 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2469 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2460 | uint i=0; | 2470 | uint i=0; |
2461 | for (i=0; i < list.count(); i++) | 2471 | for (i=0; i < list.count(); i++) |
2462 | { | 2472 | { |
2463 | nameList.append(list[i].realName()); | 2473 | nameList.append(list[i].realName()); |
2464 | emailList.append(list[i].preferredEmail()); | 2474 | emailList.append(list[i].preferredEmail()); |
2465 | uidList.append(list[i].uid()); | 2475 | uidList.append(list[i].uid()); |
2466 | } | 2476 | } |
2467 | 2477 | ||
2468 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2478 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2469 | 2479 | ||
2470 | } | 2480 | } |
2471 | 2481 | ||
2472 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2482 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2473 | * to put them into the calendar. | 2483 | * to put them into the calendar. |
2474 | */ | 2484 | */ |
2475 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2485 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2476 | { | 2486 | { |
2477 | // qDebug("KABCore::requestForBirthdayList"); | 2487 | // qDebug("KABCore::requestForBirthdayList"); |
2478 | QStringList birthdayList; | 2488 | QStringList birthdayList; |
2479 | QStringList anniversaryList; | 2489 | QStringList anniversaryList; |
2480 | QStringList realNameList; | 2490 | QStringList realNameList; |
2481 | QStringList preferredEmailList; | 2491 | QStringList preferredEmailList; |
2482 | QStringList assembledNameList; | 2492 | QStringList assembledNameList; |
2483 | QStringList uidList; | 2493 | QStringList uidList; |
2484 | 2494 | ||
2485 | KABC::AddressBook::Iterator it; | 2495 | KABC::AddressBook::Iterator it; |
2486 | 2496 | ||
2487 | int count = 0; | 2497 | int count = 0; |
2488 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2498 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2489 | ++count; | 2499 | ++count; |
2490 | } | 2500 | } |
2491 | QProgressBar bar(count,0 ); | 2501 | QProgressBar bar(count,0 ); |
2492 | int w = 300; | 2502 | int w = 300; |
2493 | if ( QApplication::desktop()->width() < 320 ) | 2503 | if ( QApplication::desktop()->width() < 320 ) |
2494 | w = 220; | 2504 | w = 220; |
2495 | int h = bar.sizeHint().height() ; | 2505 | int h = bar.sizeHint().height() ; |
2496 | int dw = QApplication::desktop()->width(); | 2506 | int dw = QApplication::desktop()->width(); |
2497 | int dh = QApplication::desktop()->height(); | 2507 | int dh = QApplication::desktop()->height(); |
2498 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2508 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2499 | bar.show(); | 2509 | bar.show(); |
2500 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2510 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2501 | qApp->processEvents(); | 2511 | qApp->processEvents(); |
2502 | 2512 | ||
2503 | QDate bday; | 2513 | QDate bday; |
2504 | QString anni; | 2514 | QString anni; |
2505 | QString formattedbday; | 2515 | QString formattedbday; |
2506 | 2516 | ||
2507 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2517 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2508 | { | 2518 | { |
2509 | if ( ! bar.isVisible() ) | 2519 | if ( ! bar.isVisible() ) |
2510 | return; | 2520 | return; |
2511 | bar.setProgress( count++ ); | 2521 | bar.setProgress( count++ ); |
2512 | qApp->processEvents(); | 2522 | qApp->processEvents(); |
2513 | bday = (*it).birthday().date(); | 2523 | bday = (*it).birthday().date(); |
2514 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2524 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2515 | 2525 | ||
2516 | if ( bday.isValid() || !anni.isEmpty()) | 2526 | if ( bday.isValid() || !anni.isEmpty()) |
2517 | { | 2527 | { |
2518 | if (bday.isValid()) | 2528 | if (bday.isValid()) |
2519 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2529 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2520 | else | 2530 | else |
2521 | formattedbday = "NOTVALID"; | 2531 | formattedbday = "NOTVALID"; |
2522 | if (anni.isEmpty()) | 2532 | if (anni.isEmpty()) |
2523 | anni = "INVALID"; | 2533 | anni = "INVALID"; |
2524 | 2534 | ||
2525 | birthdayList.append(formattedbday); | 2535 | birthdayList.append(formattedbday); |
2526 | anniversaryList.append(anni); //should be ISODate | 2536 | anniversaryList.append(anni); //should be ISODate |
2527 | realNameList.append((*it).realName()); | 2537 | realNameList.append((*it).realName()); |
2528 | preferredEmailList.append((*it).preferredEmail()); | 2538 | preferredEmailList.append((*it).preferredEmail()); |
2529 | assembledNameList.append((*it).assembledName()); | 2539 | assembledNameList.append((*it).assembledName()); |
2530 | uidList.append((*it).uid()); | 2540 | uidList.append((*it).uid()); |
2531 | 2541 | ||
2532 | //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() ); | 2542 | //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() ); |
2533 | } | 2543 | } |
2534 | } | 2544 | } |
2535 | 2545 | ||
2536 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2546 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2537 | 2547 | ||
2538 | } | 2548 | } |
2539 | 2549 | ||
2540 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2550 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2541 | */ | 2551 | */ |
2542 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2552 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2543 | { | 2553 | { |
2544 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2554 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2545 | 2555 | ||
2546 | QString foundUid = QString::null; | 2556 | QString foundUid = QString::null; |
2547 | if ( ! uid.isEmpty() ) { | 2557 | if ( ! uid.isEmpty() ) { |
2548 | Addressee adrr = mAddressBook->findByUid( uid ); | 2558 | Addressee adrr = mAddressBook->findByUid( uid ); |
2549 | if ( !adrr.isEmpty() ) { | 2559 | if ( !adrr.isEmpty() ) { |
2550 | foundUid = uid; | 2560 | foundUid = uid; |
2551 | } | 2561 | } |
2552 | if ( email == "sendbacklist" ) { | 2562 | if ( email == "sendbacklist" ) { |
2553 | //qDebug("ssssssssssssssssssssssend "); | 2563 | //qDebug("ssssssssssssssssssssssend "); |
2554 | QStringList nameList; | 2564 | QStringList nameList; |
2555 | QStringList emailList; | 2565 | QStringList emailList; |
2556 | QStringList uidList; | 2566 | QStringList uidList; |
2557 | nameList.append(adrr.realName()); | 2567 | nameList.append(adrr.realName()); |
2558 | emailList = adrr.emails(); | 2568 | emailList = adrr.emails(); |
2559 | uidList.append( adrr.preferredEmail()); | 2569 | uidList.append( adrr.preferredEmail()); |
2560 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2570 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2561 | return; | 2571 | return; |
2562 | } | 2572 | } |
2563 | 2573 | ||
2564 | } | 2574 | } |
2565 | 2575 | ||
2566 | if ( email == "sendbacklist" ) | 2576 | if ( email == "sendbacklist" ) |
2567 | return; | 2577 | return; |
2568 | if (foundUid.isEmpty()) | 2578 | if (foundUid.isEmpty()) |
2569 | { | 2579 | { |
2570 | //find the uid of the person first | 2580 | //find the uid of the person first |
2571 | Addressee::List namelist; | 2581 | Addressee::List namelist; |
2572 | Addressee::List emaillist; | 2582 | Addressee::List emaillist; |
2573 | 2583 | ||
2574 | if (!name.isEmpty()) | 2584 | if (!name.isEmpty()) |
2575 | namelist = mAddressBook->findByName( name ); | 2585 | namelist = mAddressBook->findByName( name ); |
2576 | 2586 | ||
2577 | if (!email.isEmpty()) | 2587 | if (!email.isEmpty()) |
2578 | emaillist = mAddressBook->findByEmail( email ); | 2588 | emaillist = mAddressBook->findByEmail( email ); |
2579 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2589 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2580 | //check if we have a match in Namelist and Emaillist | 2590 | //check if we have a match in Namelist and Emaillist |
2581 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2591 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2582 | foundUid = emaillist[0].uid(); | 2592 | foundUid = emaillist[0].uid(); |
2583 | } | 2593 | } |
2584 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2594 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2585 | foundUid = namelist[0].uid(); | 2595 | foundUid = namelist[0].uid(); |
2586 | else | 2596 | else |
2587 | { | 2597 | { |
2588 | for (int i = 0; i < namelist.count(); i++) | 2598 | for (int i = 0; i < namelist.count(); i++) |
2589 | { | 2599 | { |
2590 | for (int j = 0; j < emaillist.count(); j++) | 2600 | for (int j = 0; j < emaillist.count(); j++) |
2591 | { | 2601 | { |
2592 | if (namelist[i] == emaillist[j]) | 2602 | if (namelist[i] == emaillist[j]) |
2593 | { | 2603 | { |
2594 | foundUid = namelist[i].uid(); | 2604 | foundUid = namelist[i].uid(); |
2595 | } | 2605 | } |
2596 | } | 2606 | } |
2597 | } | 2607 | } |
2598 | } | 2608 | } |
2599 | } | 2609 | } |
2600 | else | 2610 | else |
2601 | { | 2611 | { |
2602 | foundUid = uid; | 2612 | foundUid = uid; |
2603 | } | 2613 | } |
2604 | 2614 | ||
2605 | if (!foundUid.isEmpty()) | 2615 | if (!foundUid.isEmpty()) |
2606 | { | 2616 | { |
2607 | 2617 | ||
2608 | // raise Ka/Pi if it is in the background | 2618 | // raise Ka/Pi if it is in the background |
2609 | #ifndef DESKTOP_VERSION | 2619 | #ifndef DESKTOP_VERSION |
2610 | #ifndef KORG_NODCOP | 2620 | #ifndef KORG_NODCOP |
2611 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2621 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2612 | #endif | 2622 | #endif |
2613 | #endif | 2623 | #endif |
2614 | 2624 | ||
2615 | mMainWindow->showMaximized(); | 2625 | mMainWindow->showMaximized(); |
2616 | mMainWindow-> raise(); | 2626 | mMainWindow-> raise(); |
2617 | 2627 | ||
2618 | mViewManager->setSelected( "", false); | 2628 | mViewManager->setSelected( "", false); |
2619 | mViewManager->refreshView( "" ); | 2629 | mViewManager->refreshView( "" ); |
2620 | mViewManager->setSelected( foundUid, true ); | 2630 | mViewManager->setSelected( foundUid, true ); |
2621 | mViewManager->refreshView( foundUid ); | 2631 | mViewManager->refreshView( foundUid ); |
2622 | 2632 | ||
2623 | if ( !mMultipleViewsAtOnce ) | 2633 | if ( !mMultipleViewsAtOnce ) |
2624 | { | 2634 | { |
2625 | setDetailsVisible( true ); | 2635 | setDetailsVisible( true ); |
2626 | mActionDetails->setChecked(true); | 2636 | mActionDetails->setChecked(true); |
2627 | } | 2637 | } |
2628 | } | 2638 | } |
2629 | } | 2639 | } |
2630 | 2640 | ||
2631 | void KABCore::whatsnew() | 2641 | void KABCore::whatsnew() |
2632 | { | 2642 | { |
2633 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2643 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2634 | } | 2644 | } |
2635 | void KABCore::synchowto() | 2645 | void KABCore::synchowto() |
2636 | { | 2646 | { |
2637 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2647 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2638 | } | 2648 | } |
2639 | void KABCore::kdesynchowto() | 2649 | void KABCore::kdesynchowto() |
2640 | { | 2650 | { |
2641 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 2651 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
2642 | } | 2652 | } |
2643 | void KABCore::multisynchowto() | 2653 | void KABCore::multisynchowto() |
2644 | { | 2654 | { |
2645 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 2655 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
2646 | } | 2656 | } |
2647 | void KABCore::faq() | 2657 | void KABCore::faq() |
2648 | { | 2658 | { |
2649 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2659 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2650 | } | 2660 | } |
2651 | 2661 | ||
2652 | #include <libkcal/syncdefines.h> | 2662 | #include <libkcal/syncdefines.h> |
2653 | 2663 | ||
2654 | KABC::Addressee KABCore::getLastSyncAddressee() | 2664 | KABC::Addressee KABCore::getLastSyncAddressee() |
2655 | { | 2665 | { |
2656 | Addressee lse; | 2666 | Addressee lse; |
2657 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2667 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2658 | 2668 | ||
2659 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2669 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2660 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2670 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2661 | if (lse.isEmpty()) { | 2671 | if (lse.isEmpty()) { |
2662 | qDebug("Creating new last-syncAddressee "); | 2672 | qDebug("Creating new last-syncAddressee "); |
2663 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2673 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2664 | QString sum = ""; | 2674 | QString sum = ""; |
2665 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2675 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2666 | sum = "E: "; | 2676 | sum = "E: "; |
2667 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2677 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2668 | lse.setRevision( mLastAddressbookSync ); | 2678 | lse.setRevision( mLastAddressbookSync ); |
2669 | lse.setCategories( i18n("SyncEvent") ); | 2679 | lse.setCategories( i18n("SyncEvent") ); |
2670 | mAddressBook->insertAddressee( lse ); | 2680 | mAddressBook->insertAddressee( lse ); |
2671 | } | 2681 | } |
2672 | return lse; | 2682 | return lse; |
2673 | } | 2683 | } |
2674 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2684 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2675 | { | 2685 | { |
2676 | 2686 | ||
2677 | //void setZaurusId(int id); | 2687 | //void setZaurusId(int id); |
2678 | // int zaurusId() const; | 2688 | // int zaurusId() const; |
2679 | // void setZaurusUid(int id); | 2689 | // void setZaurusUid(int id); |
2680 | // int zaurusUid() const; | 2690 | // int zaurusUid() const; |
2681 | // void setZaurusStat(int id); | 2691 | // void setZaurusStat(int id); |
2682 | // int zaurusStat() const; | 2692 | // int zaurusStat() const; |
2683 | // 0 equal | 2693 | // 0 equal |
2684 | // 1 take local | 2694 | // 1 take local |
2685 | // 2 take remote | 2695 | // 2 take remote |
2686 | // 3 cancel | 2696 | // 3 cancel |
2687 | QDateTime lastSync = mLastAddressbookSync; | 2697 | QDateTime lastSync = mLastAddressbookSync; |
2688 | QDateTime localMod = local->revision(); | 2698 | QDateTime localMod = local->revision(); |
2689 | QDateTime remoteMod = remote->revision(); | 2699 | QDateTime remoteMod = remote->revision(); |
2690 | 2700 | ||
2691 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2701 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2692 | 2702 | ||
2693 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2703 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2694 | bool remCh, locCh; | 2704 | bool remCh, locCh; |
2695 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2705 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2696 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2706 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2697 | locCh = ( localMod > mLastAddressbookSync ); | 2707 | locCh = ( localMod > mLastAddressbookSync ); |
2698 | //qDebug("cahnged rem %d loc %d",remCh, locCh ); | 2708 | //qDebug("cahnged rem %d loc %d",remCh, locCh ); |
2699 | if ( !remCh && ! locCh ) { | 2709 | if ( !remCh && ! locCh ) { |
2700 | //qDebug("both not changed "); | 2710 | //qDebug("both not changed "); |
2701 | lastSync = localMod.addDays(1); | 2711 | lastSync = localMod.addDays(1); |
2702 | if ( mode <= SYNC_PREF_ASK ) | 2712 | if ( mode <= SYNC_PREF_ASK ) |
2703 | return 0; | 2713 | return 0; |
2704 | } else { | 2714 | } else { |
2705 | if ( locCh ) { | 2715 | if ( locCh ) { |
2706 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2716 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2707 | lastSync = localMod.addDays( -1 ); | 2717 | lastSync = localMod.addDays( -1 ); |
2708 | if ( !remCh ) | 2718 | if ( !remCh ) |
2709 | remoteMod =( lastSync.addDays( -1 ) ); | 2719 | remoteMod =( lastSync.addDays( -1 ) ); |
2710 | } else { | 2720 | } else { |
2711 | //qDebug(" not loc changed "); | 2721 | //qDebug(" not loc changed "); |
2712 | lastSync = localMod.addDays( 1 ); | 2722 | lastSync = localMod.addDays( 1 ); |
2713 | if ( remCh ) { | 2723 | if ( remCh ) { |
2714 | //qDebug("rem changed "); | 2724 | //qDebug("rem changed "); |
2715 | remoteMod =( lastSync.addDays( 1 ) ); | 2725 | remoteMod =( lastSync.addDays( 1 ) ); |
2716 | } | 2726 | } |
2717 | 2727 | ||
2718 | } | 2728 | } |
2719 | } | 2729 | } |
2720 | full = true; | 2730 | full = true; |
2721 | if ( mode < SYNC_PREF_ASK ) | 2731 | if ( mode < SYNC_PREF_ASK ) |
2722 | mode = SYNC_PREF_ASK; | 2732 | mode = SYNC_PREF_ASK; |
2723 | } else { | 2733 | } else { |
2724 | if ( localMod == remoteMod ) | 2734 | if ( localMod == remoteMod ) |
2725 | return 0; | 2735 | return 0; |
2726 | 2736 | ||
2727 | } | 2737 | } |
2728 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); | 2738 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); |
2729 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); | 2739 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); |
2730 | //full = true; //debug only | 2740 | //full = true; //debug only |
2731 | if ( full ) { | 2741 | if ( full ) { |
2732 | bool equ = ( (*local) == (*remote) ); | 2742 | bool equ = ( (*local) == (*remote) ); |
2733 | if ( equ ) { | 2743 | if ( equ ) { |
2734 | //qDebug("equal "); | 2744 | //qDebug("equal "); |
2735 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2745 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2736 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2746 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2737 | } | 2747 | } |
2738 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2748 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2739 | return 0; | 2749 | return 0; |
2740 | 2750 | ||
2741 | }//else //debug only | 2751 | }//else //debug only |
2742 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2752 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2743 | } | 2753 | } |
2744 | int result; | 2754 | int result; |
2745 | bool localIsNew; | 2755 | bool localIsNew; |
2746 | //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() ); | 2756 | //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() ); |
2747 | 2757 | ||
2748 | if ( full && mode < SYNC_PREF_NEWEST ) | 2758 | if ( full && mode < SYNC_PREF_NEWEST ) |
2749 | mode = SYNC_PREF_ASK; | 2759 | mode = SYNC_PREF_ASK; |
2750 | 2760 | ||
2751 | switch( mode ) { | 2761 | switch( mode ) { |
2752 | case SYNC_PREF_LOCAL: | 2762 | case SYNC_PREF_LOCAL: |
2753 | if ( lastSync > remoteMod ) | 2763 | if ( lastSync > remoteMod ) |
2754 | return 1; | 2764 | return 1; |
2755 | if ( lastSync > localMod ) | 2765 | if ( lastSync > localMod ) |
2756 | return 2; | 2766 | return 2; |
2757 | return 1; | 2767 | return 1; |
2758 | break; | 2768 | break; |
2759 | case SYNC_PREF_REMOTE: | 2769 | case SYNC_PREF_REMOTE: |
2760 | if ( lastSync > remoteMod ) | 2770 | if ( lastSync > remoteMod ) |
2761 | return 1; | 2771 | return 1; |
2762 | if ( lastSync > localMod ) | 2772 | if ( lastSync > localMod ) |
2763 | return 2; | 2773 | return 2; |
2764 | return 2; | 2774 | return 2; |
2765 | break; | 2775 | break; |
2766 | case SYNC_PREF_NEWEST: | 2776 | case SYNC_PREF_NEWEST: |
2767 | if ( localMod > remoteMod ) | 2777 | if ( localMod > remoteMod ) |
2768 | return 1; | 2778 | return 1; |
2769 | else | 2779 | else |
2770 | return 2; | 2780 | return 2; |
2771 | break; | 2781 | break; |
2772 | case SYNC_PREF_ASK: | 2782 | case SYNC_PREF_ASK: |
2773 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2783 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2774 | if ( lastSync > remoteMod ) | 2784 | if ( lastSync > remoteMod ) |
2775 | return 1; | 2785 | return 1; |
2776 | if ( lastSync > localMod ) { | 2786 | if ( lastSync > localMod ) { |
2777 | return 2; | 2787 | return 2; |
2778 | } | 2788 | } |
2779 | localIsNew = localMod >= remoteMod; | 2789 | localIsNew = localMod >= remoteMod; |
2780 | //qDebug("conflict! ************************************** "); | 2790 | //qDebug("conflict! ************************************** "); |
2781 | { | 2791 | { |
2782 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2792 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2783 | result = acd.executeD(localIsNew); | 2793 | result = acd.executeD(localIsNew); |
2784 | return result; | 2794 | return result; |
2785 | } | 2795 | } |
2786 | break; | 2796 | break; |
2787 | case SYNC_PREF_FORCE_LOCAL: | 2797 | case SYNC_PREF_FORCE_LOCAL: |
2788 | return 1; | 2798 | return 1; |
2789 | break; | 2799 | break; |
2790 | case SYNC_PREF_FORCE_REMOTE: | 2800 | case SYNC_PREF_FORCE_REMOTE: |
2791 | return 2; | 2801 | return 2; |
2792 | break; | 2802 | break; |
2793 | 2803 | ||
2794 | default: | 2804 | default: |
2795 | // SYNC_PREF_TAKE_BOTH not implemented | 2805 | // SYNC_PREF_TAKE_BOTH not implemented |
2796 | break; | 2806 | break; |
2797 | } | 2807 | } |
2798 | return 0; | 2808 | return 0; |
2799 | } | 2809 | } |
2800 | 2810 | ||
2801 | 2811 | ||
2802 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2812 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2803 | { | 2813 | { |
2804 | bool syncOK = true; | 2814 | bool syncOK = true; |
2805 | int addedAddressee = 0; | 2815 | int addedAddressee = 0; |
2806 | int addedAddresseeR = 0; | 2816 | int addedAddresseeR = 0; |
2807 | int deletedAddresseeR = 0; | 2817 | int deletedAddresseeR = 0; |
2808 | int deletedAddresseeL = 0; | 2818 | int deletedAddresseeL = 0; |
2809 | int changedLocal = 0; | 2819 | int changedLocal = 0; |
2810 | int changedRemote = 0; | 2820 | int changedRemote = 0; |
2811 | int filteredIN = 0; | 2821 | int filteredIN = 0; |
2812 | int filteredOUT = 0; | 2822 | int filteredOUT = 0; |
2813 | 2823 | ||
2814 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2824 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2815 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2825 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2816 | 2826 | ||
2817 | //QPtrList<Addressee> el = local->rawAddressees(); | 2827 | //QPtrList<Addressee> el = local->rawAddressees(); |
2818 | Addressee addresseeR; | 2828 | Addressee addresseeR; |
2819 | QString uid; | 2829 | QString uid; |
2820 | int take; | 2830 | int take; |
2821 | Addressee addresseeL; | 2831 | Addressee addresseeL; |
2822 | Addressee addresseeRSync; | 2832 | Addressee addresseeRSync; |
2823 | Addressee addresseeLSync; | 2833 | Addressee addresseeLSync; |
2824 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2834 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2825 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2835 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2826 | bool fullDateRange = false; | 2836 | bool fullDateRange = false; |
2827 | local->resetTempSyncStat(); | 2837 | local->resetTempSyncStat(); |
2828 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2838 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2829 | if ( syncManager->syncWithDesktop() ) { | 2839 | if ( syncManager->syncWithDesktop() ) { |
2830 | // remote->removeSyncInfo( QString());//remove all info | 2840 | // remote->removeSyncInfo( QString());//remove all info |
2831 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 2841 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
2832 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | 2842 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; |
2833 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | 2843 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); |
2834 | } else { | 2844 | } else { |
2835 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 2845 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
2836 | } | 2846 | } |
2837 | } | 2847 | } |
2838 | QDateTime modifiedCalendar = mLastAddressbookSync; | 2848 | QDateTime modifiedCalendar = mLastAddressbookSync; |
2839 | addresseeLSync = getLastSyncAddressee(); | 2849 | addresseeLSync = getLastSyncAddressee(); |
2840 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2850 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2841 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2851 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2842 | if ( !addresseeR.isEmpty() ) { | 2852 | if ( !addresseeR.isEmpty() ) { |
2843 | addresseeRSync = addresseeR; | 2853 | addresseeRSync = addresseeR; |
2844 | remote->removeAddressee(addresseeR ); | 2854 | remote->removeAddressee(addresseeR ); |
2845 | 2855 | ||
2846 | } else { | 2856 | } else { |
2847 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2857 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2848 | addresseeRSync = addresseeLSync ; | 2858 | addresseeRSync = addresseeLSync ; |
2849 | } else { | 2859 | } else { |
2850 | //qDebug("FULLDATE 1"); | 2860 | //qDebug("FULLDATE 1"); |
2851 | fullDateRange = true; | 2861 | fullDateRange = true; |
2852 | Addressee newAdd; | 2862 | Addressee newAdd; |
2853 | addresseeRSync = newAdd; | 2863 | addresseeRSync = newAdd; |
2854 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2864 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2855 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2865 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2856 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2866 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2857 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2867 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2858 | } | 2868 | } |
2859 | } | 2869 | } |
2860 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2870 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2861 | // qDebug("FULLDATE 2"); | 2871 | // qDebug("FULLDATE 2"); |
2862 | fullDateRange = true; | 2872 | fullDateRange = true; |
2863 | } | 2873 | } |
2864 | if ( ! fullDateRange ) { | 2874 | if ( ! fullDateRange ) { |
2865 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2875 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2866 | 2876 | ||
2867 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2877 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2868 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2878 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2869 | fullDateRange = true; | 2879 | fullDateRange = true; |
2870 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2880 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2871 | } | 2881 | } |
2872 | } | 2882 | } |
2873 | // fullDateRange = true; // debug only! | 2883 | // fullDateRange = true; // debug only! |
2874 | if ( fullDateRange ) | 2884 | if ( fullDateRange ) |
2875 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2885 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2876 | else | 2886 | else |
2877 | mLastAddressbookSync = addresseeLSync.revision(); | 2887 | mLastAddressbookSync = addresseeLSync.revision(); |
2878 | // for resyncing if own file has changed | 2888 | // for resyncing if own file has changed |
2879 | // PENDING fixme later when implemented | 2889 | // PENDING fixme later when implemented |
2880 | #if 0 | 2890 | #if 0 |
2881 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2891 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2882 | mLastAddressbookSync = loadedFileVersion; | 2892 | mLastAddressbookSync = loadedFileVersion; |
2883 | qDebug("setting mLastAddressbookSync "); | 2893 | qDebug("setting mLastAddressbookSync "); |
2884 | } | 2894 | } |
2885 | #endif | 2895 | #endif |
2886 | 2896 | ||
2887 | 2897 | ||
2888 | // ********** setting filters **************** | 2898 | // ********** setting filters **************** |
2889 | Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); | 2899 | Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); |
2890 | Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); | 2900 | Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); |
2891 | 2901 | ||
2892 | //qDebug("*************************** "); | 2902 | //qDebug("*************************** "); |
2893 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2903 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2894 | QStringList er = remote->uidList(); | 2904 | QStringList er = remote->uidList(); |
2895 | Addressee inR ;//= er.first(); | 2905 | Addressee inR ;//= er.first(); |
2896 | Addressee inL; | 2906 | Addressee inL; |
2897 | 2907 | ||
2898 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2908 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2899 | 2909 | ||
2900 | int modulo = (er.count()/10)+1; | 2910 | int modulo = (er.count()/10)+1; |
2901 | int incCounter = 0; | 2911 | int incCounter = 0; |
2902 | while ( incCounter < er.count()) { | 2912 | while ( incCounter < er.count()) { |
2903 | if (syncManager->isProgressBarCanceled()) | 2913 | if (syncManager->isProgressBarCanceled()) |
2904 | return false; | 2914 | return false; |
2905 | if ( incCounter % modulo == 0 ) | 2915 | if ( incCounter % modulo == 0 ) |
2906 | syncManager->showProgressBar(incCounter); | 2916 | syncManager->showProgressBar(incCounter); |
2907 | 2917 | ||
2908 | uid = er[ incCounter ]; | 2918 | uid = er[ incCounter ]; |
2909 | bool skipIncidence = false; | 2919 | bool skipIncidence = false; |
2910 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2920 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2911 | skipIncidence = true; | 2921 | skipIncidence = true; |
2912 | QString idS,OidS; | 2922 | QString idS,OidS; |
2913 | qApp->processEvents(); | 2923 | qApp->processEvents(); |
2914 | if ( !skipIncidence ) { | 2924 | if ( !skipIncidence ) { |
2915 | inL = local->findByUid( uid ); | 2925 | inL = local->findByUid( uid ); |
2916 | inR = remote->findByUid( uid ); | 2926 | inR = remote->findByUid( uid ); |
2917 | //inL.setResource( 0 ); | 2927 | //inL.setResource( 0 ); |
2918 | //inR.setResource( 0 ); | 2928 | //inR.setResource( 0 ); |
2919 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2929 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2920 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2930 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2921 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { | 2931 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { |
2922 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2932 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2923 | if ( take == 3 ) | 2933 | if ( take == 3 ) |
2924 | return false; | 2934 | return false; |
2925 | if ( take == 1 ) {// take local ********************** | 2935 | if ( take == 1 ) {// take local ********************** |
2926 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2936 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2927 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2937 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2928 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2938 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2929 | local->insertAddressee( inL, false ); | 2939 | local->insertAddressee( inL, false ); |
2930 | idS = inR.externalUID(); | 2940 | idS = inR.externalUID(); |
2931 | OidS = inR.originalExternalUID(); | 2941 | OidS = inR.originalExternalUID(); |
2932 | } | 2942 | } |
2933 | else | 2943 | else |
2934 | idS = inR.IDStr(); | 2944 | idS = inR.IDStr(); |
2935 | remote->removeAddressee( inR ); | 2945 | remote->removeAddressee( inR ); |
2936 | inR = inL; | 2946 | inR = inL; |
2937 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2947 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2938 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2948 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2939 | inR.setOriginalExternalUID( OidS ); | 2949 | inR.setOriginalExternalUID( OidS ); |
2940 | inR.setExternalUID( idS ); | 2950 | inR.setExternalUID( idS ); |
2941 | if ( syncManager->syncWithDesktop() ) { | 2951 | if ( syncManager->syncWithDesktop() ) { |
2942 | inR.setIDStr("changed" ); | 2952 | inR.setIDStr("changed" ); |
2943 | } | 2953 | } |
2944 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); | 2954 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); |
2945 | } else { | 2955 | } else { |
2946 | inR.setIDStr( idS ); | 2956 | inR.setIDStr( idS ); |
2947 | } | 2957 | } |
2948 | inR.setResource( 0 ); | 2958 | inR.setResource( 0 ); |
2949 | remote->insertAddressee( inR , false); | 2959 | remote->insertAddressee( inR , false); |
2950 | ++changedRemote; | 2960 | ++changedRemote; |
2951 | } else { // take == 2 take remote ********************** | 2961 | } else { // take == 2 take remote ********************** |
2952 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2962 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2953 | if ( inR.revision().date().year() < 2004 ) | 2963 | if ( inR.revision().date().year() < 2004 ) |
2954 | inR.setRevision( modifiedCalendar ); | 2964 | inR.setRevision( modifiedCalendar ); |
2955 | } | 2965 | } |
2956 | idS = inL.IDStr(); | 2966 | idS = inL.IDStr(); |
2957 | local->removeAddressee( inL ); | 2967 | local->removeAddressee( inL ); |
2958 | inL = inR; | 2968 | inL = inR; |
2959 | inL.setIDStr( idS ); | 2969 | inL.setIDStr( idS ); |
2960 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2970 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2961 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2971 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2962 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2972 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2963 | } | 2973 | } |
2964 | inL.setResource( 0 ); | 2974 | inL.setResource( 0 ); |
2965 | local->insertAddressee( inL , false ); | 2975 | local->insertAddressee( inL , false ); |
2966 | ++changedLocal; | 2976 | ++changedLocal; |
2967 | } | 2977 | } |
2968 | } | 2978 | } |
2969 | } | 2979 | } |
2970 | } else { // no conflict ********** add or delete remote | 2980 | } else { // no conflict ********** add or delete remote |
2971 | if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { | 2981 | if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { |
2972 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2982 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2973 | QString des = addresseeLSync.note(); | 2983 | QString des = addresseeLSync.note(); |
2974 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2984 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2975 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2985 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2976 | remote->insertAddressee( inR, false ); | 2986 | remote->insertAddressee( inR, false ); |
2977 | ++deletedAddresseeR; | 2987 | ++deletedAddresseeR; |
2978 | } else { | 2988 | } else { |
2979 | inR.setRevision( modifiedCalendar ); | 2989 | inR.setRevision( modifiedCalendar ); |
2980 | remote->insertAddressee( inR, false ); | 2990 | remote->insertAddressee( inR, false ); |
2981 | inL = inR; | 2991 | inL = inR; |
2982 | inL.setIDStr( ":" ); | 2992 | inL.setIDStr( ":" ); |
2983 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2993 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2984 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2994 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2985 | inL.setResource( 0 ); | 2995 | inL.setResource( 0 ); |
2986 | local->insertAddressee( inL , false); | 2996 | local->insertAddressee( inL , false); |
2987 | ++addedAddressee; | 2997 | ++addedAddressee; |
2988 | } | 2998 | } |
2989 | } else { | 2999 | } else { |
2990 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 3000 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2991 | inR.setRevision( modifiedCalendar ); | 3001 | inR.setRevision( modifiedCalendar ); |
2992 | remote->insertAddressee( inR, false ); | 3002 | remote->insertAddressee( inR, false ); |
2993 | inR.setResource( 0 ); | 3003 | inR.setResource( 0 ); |
2994 | local->insertAddressee( inR, false ); | 3004 | local->insertAddressee( inR, false ); |
2995 | ++addedAddressee; | 3005 | ++addedAddressee; |
2996 | } else { | 3006 | } else { |
2997 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 3007 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2998 | remote->removeAddressee( inR ); | 3008 | remote->removeAddressee( inR ); |
2999 | ++deletedAddresseeR; | 3009 | ++deletedAddresseeR; |
3000 | } | 3010 | } |
3001 | } | 3011 | } |
3002 | } else { | 3012 | } else { |
3003 | ++filteredIN; | 3013 | ++filteredIN; |
3004 | } | 3014 | } |
3005 | } | 3015 | } |
3006 | } | 3016 | } |
3007 | ++incCounter; | 3017 | ++incCounter; |
3008 | } | 3018 | } |
3009 | er.clear(); | 3019 | er.clear(); |
3010 | QStringList el = local->uidList(); | 3020 | QStringList el = local->uidList(); |
3011 | modulo = (el.count()/10)+1; | 3021 | modulo = (el.count()/10)+1; |
3012 | 3022 | ||
3013 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 3023 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
3014 | incCounter = 0; | 3024 | incCounter = 0; |
3015 | while ( incCounter < el.count()) { | 3025 | while ( incCounter < el.count()) { |
3016 | qApp->processEvents(); | 3026 | qApp->processEvents(); |
3017 | if (syncManager->isProgressBarCanceled()) | 3027 | if (syncManager->isProgressBarCanceled()) |
3018 | return false; | 3028 | return false; |
3019 | if ( incCounter % modulo == 0 ) | 3029 | if ( incCounter % modulo == 0 ) |
3020 | syncManager->showProgressBar(incCounter); | 3030 | syncManager->showProgressBar(incCounter); |
3021 | uid = el[ incCounter ]; | 3031 | uid = el[ incCounter ]; |
3022 | bool skipIncidence = false; | 3032 | bool skipIncidence = false; |
3023 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 3033 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
3024 | skipIncidence = true; | 3034 | skipIncidence = true; |
3025 | if ( !skipIncidence ) { | 3035 | if ( !skipIncidence ) { |
3026 | inL = local->findByUid( uid ); | 3036 | inL = local->findByUid( uid ); |
3027 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 3037 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
3028 | inR = remote->findByUid( uid ); | 3038 | inR = remote->findByUid( uid ); |
3029 | if ( inR.isEmpty() ){ | 3039 | if ( inR.isEmpty() ){ |
3030 | if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { | 3040 | if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { |
3031 | // no conflict ********** add or delete local | 3041 | // no conflict ********** add or delete local |
3032 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3042 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3033 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 3043 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
3034 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3044 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3035 | local->removeAddressee( inL ); | 3045 | local->removeAddressee( inL ); |
3036 | ++deletedAddresseeL; | 3046 | ++deletedAddresseeL; |
3037 | } else { | 3047 | } else { |
3038 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3048 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3039 | inL.removeID(mCurrentSyncDevice ); | 3049 | inL.removeID(mCurrentSyncDevice ); |
3040 | ++addedAddresseeR; | 3050 | ++addedAddresseeR; |
3041 | inL.setRevision( modifiedCalendar ); | 3051 | inL.setRevision( modifiedCalendar ); |
3042 | local->insertAddressee( inL, false ); | 3052 | local->insertAddressee( inL, false ); |
3043 | inR = inL; | 3053 | inR = inL; |
3044 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 3054 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
3045 | inR.setResource( 0 ); | 3055 | inR.setResource( 0 ); |
3046 | remote->insertAddressee( inR, false ); | 3056 | remote->insertAddressee( inR, false ); |
3047 | } | 3057 | } |
3048 | } | 3058 | } |
3049 | } else { | 3059 | } else { |
3050 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 3060 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
3051 | //qDebug("data %s ", inL.revision().toString().latin1()); | 3061 | //qDebug("data %s ", inL.revision().toString().latin1()); |
3052 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3062 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3053 | local->removeAddressee( inL ); | 3063 | local->removeAddressee( inL ); |
3054 | ++deletedAddresseeL; | 3064 | ++deletedAddresseeL; |
3055 | } else { | 3065 | } else { |
3056 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3066 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3057 | ++addedAddresseeR; | 3067 | ++addedAddresseeR; |
3058 | inL.setRevision( modifiedCalendar ); | 3068 | inL.setRevision( modifiedCalendar ); |
3059 | local->insertAddressee( inL, false ); | 3069 | local->insertAddressee( inL, false ); |
3060 | inR = inL; | 3070 | inR = inL; |
3061 | inR.setIDStr( ":" ); | 3071 | inR.setIDStr( ":" ); |
3062 | inR.setResource( 0 ); | 3072 | inR.setResource( 0 ); |
3063 | remote->insertAddressee( inR, false ); | 3073 | remote->insertAddressee( inR, false ); |
3064 | } | 3074 | } |
3065 | } | 3075 | } |
3066 | } | 3076 | } |
3067 | } else { | 3077 | } else { |
3068 | ++filteredOUT; | 3078 | ++filteredOUT; |
3069 | } | 3079 | } |
3070 | } | 3080 | } |
3071 | } | 3081 | } |
3072 | } | 3082 | } |
3073 | ++incCounter; | 3083 | ++incCounter; |
3074 | } | 3084 | } |
3075 | el.clear(); | 3085 | el.clear(); |
3076 | syncManager->hideProgressBar(); | 3086 | syncManager->hideProgressBar(); |
3077 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 3087 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
3078 | // get rid of micro seconds | 3088 | // get rid of micro seconds |
3079 | QTime t = mLastAddressbookSync.time(); | 3089 | QTime t = mLastAddressbookSync.time(); |
3080 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 3090 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
3081 | addresseeLSync.setRevision( mLastAddressbookSync ); | 3091 | addresseeLSync.setRevision( mLastAddressbookSync ); |
3082 | addresseeRSync.setRevision( mLastAddressbookSync ); | 3092 | addresseeRSync.setRevision( mLastAddressbookSync ); |
3083 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 3093 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
3084 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 3094 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
3085 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 3095 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
3086 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 3096 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
3087 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 3097 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
3088 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 3098 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
3089 | addresseeRSync.setNote( "" ) ; | 3099 | addresseeRSync.setNote( "" ) ; |
3090 | addresseeLSync.setNote( "" ); | 3100 | addresseeLSync.setNote( "" ); |
3091 | 3101 | ||
3092 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 3102 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
3093 | remote->insertAddressee( addresseeRSync, false ); | 3103 | remote->insertAddressee( addresseeRSync, false ); |
3094 | local->insertAddressee( addresseeLSync, false ); | 3104 | local->insertAddressee( addresseeLSync, false ); |
3095 | QString mes; | 3105 | QString mes; |
3096 | 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 %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); | 3106 | 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 %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); |
3097 | qDebug( mes ); | 3107 | qDebug( mes ); |
3098 | mes = i18n("Local addressbook changed!\n") +mes; | 3108 | mes = i18n("Local addressbook changed!\n") +mes; |
3099 | if ( syncManager->mShowSyncSummary ) { | 3109 | if ( syncManager->mShowSyncSummary ) { |
3100 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 3110 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
3101 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { | 3111 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { |
3102 | qDebug("cancelled "); | 3112 | qDebug("cancelled "); |
3103 | return false; | 3113 | return false; |
3104 | } | 3114 | } |
3105 | } | 3115 | } |
3106 | return syncOK; | 3116 | return syncOK; |
3107 | } | 3117 | } |
3108 | 3118 | ||
3109 | 3119 | ||
3110 | //this is a overwritten callbackmethods from the syncinterface | 3120 | //this is a overwritten callbackmethods from the syncinterface |
3111 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 3121 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
3112 | { | 3122 | { |
3113 | 3123 | ||
3114 | //pending prepare addresseeview for output | 3124 | //pending prepare addresseeview for output |
3115 | //pending detect, if remote file has REV field. if not switch to external sync | 3125 | //pending detect, if remote file has REV field. if not switch to external sync |
3116 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 3126 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
3117 | if ( manager != syncManager ) | 3127 | if ( manager != syncManager ) |
3118 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); | 3128 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); |
3119 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3129 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3120 | 3130 | ||
3121 | AddressBook abLocal(filename,"syncContact"); | 3131 | AddressBook abLocal(filename,"syncContact"); |
3122 | bool syncOK = false; | 3132 | bool syncOK = false; |
3123 | if ( abLocal.load() ) { | 3133 | if ( abLocal.load() ) { |
3124 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 3134 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
3125 | bool external = false; | 3135 | bool external = false; |
3126 | bool isXML = false; | 3136 | bool isXML = false; |
3127 | if ( filename.right(4) == ".xml") { | 3137 | if ( filename.right(4) == ".xml") { |
3128 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3138 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3129 | isXML = true; | 3139 | isXML = true; |
3130 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3140 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3131 | } else { | 3141 | } else { |
3132 | external = !manager->mIsKapiFile; | 3142 | external = !manager->mIsKapiFile; |
3133 | if ( external ) { | 3143 | if ( external ) { |
3134 | qDebug("Setting vcf mode to external "); | 3144 | qDebug("Setting vcf mode to external "); |
3135 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3145 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3136 | AddressBook::Iterator it; | 3146 | AddressBook::Iterator it; |
3137 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3147 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3138 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 3148 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
3139 | (*it).computeCsum( mCurrentSyncDevice ); | 3149 | (*it).computeCsum( mCurrentSyncDevice ); |
3140 | } | 3150 | } |
3141 | } | 3151 | } |
3142 | } | 3152 | } |
3143 | //AddressBook::Iterator it; | 3153 | //AddressBook::Iterator it; |
3144 | //QStringList vcards; | 3154 | //QStringList vcards; |
3145 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3155 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3146 | // qDebug("Name %s ", (*it).familyName().latin1()); | 3156 | // qDebug("Name %s ", (*it).familyName().latin1()); |
3147 | //} | 3157 | //} |
3148 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 3158 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
3149 | if ( syncOK ) { | 3159 | if ( syncOK ) { |
3150 | if ( syncManager->mWriteBackFile ) | 3160 | if ( syncManager->mWriteBackFile ) |
3151 | { | 3161 | { |
3152 | if ( external ) | 3162 | if ( external ) |
3153 | abLocal.removeSyncAddressees( !isXML); | 3163 | abLocal.removeSyncAddressees( !isXML); |
3154 | qDebug("Saving remote AB "); | 3164 | qDebug("Saving remote AB "); |
3155 | if ( ! abLocal.saveAB()) | 3165 | if ( ! abLocal.saveAB()) |
3156 | qDebug("Error writing back AB to file "); | 3166 | qDebug("Error writing back AB to file "); |
3157 | if ( external ) { | 3167 | if ( external ) { |
3158 | // afterwrite processing | 3168 | // afterwrite processing |
3159 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 3169 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
3160 | } | 3170 | } |
3161 | } | 3171 | } |
3162 | } | 3172 | } |
3163 | setModified(); | 3173 | setModified(); |
3164 | 3174 | ||
3165 | } | 3175 | } |
3166 | abLocal.removeResources(); | 3176 | abLocal.removeResources(); |
3167 | if ( syncOK ) | 3177 | if ( syncOK ) |
3168 | mViewManager->refreshView(); | 3178 | mViewManager->refreshView(); |
3169 | return syncOK; | 3179 | return syncOK; |
3170 | 3180 | ||
3171 | } | 3181 | } |
3172 | void KABCore::removeSyncInfo( QString syncProfile) | 3182 | void KABCore::removeSyncInfo( QString syncProfile) |
3173 | { | 3183 | { |
3174 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 3184 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
3175 | mAddressBook->removeSyncInfo( syncProfile ); | 3185 | mAddressBook->removeSyncInfo( syncProfile ); |
3176 | setModified(); | 3186 | setModified(); |
3177 | } | 3187 | } |
3178 | 3188 | ||
3179 | 3189 | ||
3180 | //this is a overwritten callbackmethods from the syncinterface | 3190 | //this is a overwritten callbackmethods from the syncinterface |
3181 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 3191 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
3182 | { | 3192 | { |
3183 | if ( resource == "phone" ) | 3193 | if ( resource == "phone" ) |
3184 | return syncPhone(); | 3194 | return syncPhone(); |
3185 | disableBR( true ); | 3195 | disableBR( true ); |
3186 | if ( manager != syncManager ) | 3196 | if ( manager != syncManager ) |
3187 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); | 3197 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); |
3188 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3198 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3189 | 3199 | ||
3190 | AddressBook abLocal( resource,"syncContact"); | 3200 | AddressBook abLocal( resource,"syncContact"); |
3191 | bool syncOK = false; | 3201 | bool syncOK = false; |
3202 | message(i18n("Loading DTM address data..."), false); | ||
3192 | if ( abLocal.load() ) { | 3203 | if ( abLocal.load() ) { |
3193 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3204 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3194 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3205 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3206 | message(i18n("Sync preprocessing..."),false); | ||
3195 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 3207 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
3208 | message(i18n("Synchronizing..."),false); | ||
3196 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3209 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3197 | if ( syncOK ) { | 3210 | if ( syncOK ) { |
3198 | if ( syncManager->mWriteBackFile ) { | 3211 | if ( syncManager->mWriteBackFile ) { |
3199 | abLocal.removeSyncAddressees( false ); | 3212 | abLocal.removeSyncAddressees( false ); |
3213 | message(i18n("Saving DTM address data..."),false); | ||
3200 | abLocal.saveAB(); | 3214 | abLocal.saveAB(); |
3215 | message(i18n("Sync postprocessing..."),false); | ||
3201 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3216 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3202 | } | 3217 | } |
3203 | } else | 3218 | } else |
3204 | message( i18n("Sync cancelled or failed.") ); | 3219 | message( i18n("Sync cancelled or failed.") ); |
3205 | setModified(); | 3220 | setModified(); |
3206 | } | 3221 | } |
3207 | abLocal.removeResources(); | 3222 | abLocal.removeResources(); |
3208 | if ( syncOK ) | 3223 | if ( syncOK ) { |
3209 | mViewManager->refreshView(); | 3224 | mViewManager->refreshView(); |
3225 | message(i18n("DTM syncing finished.")); | ||
3226 | } | ||
3210 | disableBR( false ); | 3227 | disableBR( false ); |
3211 | return syncOK; | 3228 | return syncOK; |
3212 | 3229 | ||
3213 | } | 3230 | } |
3214 | void KABCore::message( QString m ) | 3231 | void KABCore::message( QString m, bool startTimer) |
3215 | { | 3232 | { |
3216 | topLevelWidget()->setCaption( m ); | 3233 | topLevelWidget()->setCaption( m ); |
3217 | mMessageTimer->start( 20000, true ); | 3234 | qApp->processEvents(); |
3235 | if ( startTimer ) | ||
3236 | mMessageTimer->start( 15000, true ); | ||
3237 | else | ||
3238 | mMessageTimer->stop(); | ||
3218 | } | 3239 | } |
3219 | bool KABCore::syncPhone() | 3240 | bool KABCore::syncPhone() |
3220 | { | 3241 | { |
3221 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 3242 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
3222 | QString fileName = getPhoneFile(); | 3243 | QString fileName = getPhoneFile(); |
3223 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 3244 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
3224 | message(i18n("Phone access failed!")); | 3245 | message(i18n("Phone access failed!")); |
3225 | return false; | 3246 | return false; |
3226 | } | 3247 | } |
3227 | AddressBook abLocal( fileName,"syncContact"); | 3248 | AddressBook abLocal( fileName,"syncContact"); |
3228 | bool syncOK = false; | 3249 | bool syncOK = false; |
3229 | { | 3250 | { |
3230 | abLocal.importFromFile( fileName ); | 3251 | abLocal.importFromFile( fileName ); |
3231 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3252 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3232 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3253 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3233 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 3254 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
3234 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3255 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3235 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3256 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3236 | if ( syncOK ) { | 3257 | if ( syncOK ) { |
3237 | if ( syncManager->mWriteBackFile ) { | 3258 | if ( syncManager->mWriteBackFile ) { |
3238 | abLocal.removeSyncAddressees( true ); | 3259 | abLocal.removeSyncAddressees( true ); |
3239 | abLocal.saveABphone( fileName ); | 3260 | abLocal.saveABphone( fileName ); |
3240 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 3261 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
3241 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 3262 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
3242 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3263 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3243 | } | 3264 | } |
3244 | } | 3265 | } |
3245 | setModified(); | 3266 | setModified(); |
3246 | } | 3267 | } |
3247 | abLocal.removeResources(); | 3268 | abLocal.removeResources(); |
3248 | if ( syncOK ) | 3269 | if ( syncOK ) |
3249 | mViewManager->refreshView(); | 3270 | mViewManager->refreshView(); |
3250 | return syncOK; | 3271 | return syncOK; |
3251 | } | 3272 | } |
3252 | void KABCore::getFile( bool success ) | 3273 | void KABCore::getFile( bool success ) |
3253 | { | 3274 | { |
3254 | if ( ! success ) { | 3275 | if ( ! success ) { |
3255 | message( i18n("Error receiving file. Nothing changed!") ); | 3276 | message( i18n("Error receiving file. Nothing changed!") ); |
3256 | return; | 3277 | return; |
3257 | } | 3278 | } |
3258 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 3279 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
3259 | if ( count ) | 3280 | if ( count ) |
3260 | setModified( true ); | 3281 | setModified( true ); |
3261 | message( i18n("Pi-Sync successful!") ); | 3282 | message( i18n("Pi-Sync successful!") ); |
3262 | mViewManager->refreshView(); | 3283 | mViewManager->refreshView(); |
3263 | } | 3284 | } |
3264 | void KABCore::syncFileRequest() | 3285 | void KABCore::syncFileRequest() |
3265 | { | 3286 | { |
3266 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | 3287 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { |
3267 | syncManager->slotSyncMenu( 999 ); | 3288 | syncManager->slotSyncMenu( 999 ); |
3268 | } | 3289 | } |
3269 | mAddressBook->export2File( sentSyncFile() ); | 3290 | mAddressBook->export2File( sentSyncFile() ); |
3270 | } | 3291 | } |
3271 | QString KABCore::sentSyncFile() | 3292 | QString KABCore::sentSyncFile() |
3272 | { | 3293 | { |
3273 | #ifdef DESKTOP_VERSION | 3294 | #ifdef DESKTOP_VERSION |
3274 | return locateLocal( "tmp", "copysyncab.vcf" ); | 3295 | return locateLocal( "tmp", "copysyncab.vcf" ); |
3275 | #else | 3296 | #else |
3276 | return QString( "/tmp/copysyncab.vcf" ); | 3297 | return QString( "/tmp/copysyncab.vcf" ); |
3277 | #endif | 3298 | #endif |
3278 | } | 3299 | } |
3279 | 3300 | ||
3280 | void KABCore::setCaptionBack() | 3301 | void KABCore::setCaptionBack() |
3281 | { | 3302 | { |
3282 | mMessageTimer->stop(); | 3303 | mMessageTimer->stop(); |
3283 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 3304 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
3284 | } | 3305 | } |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index ecfe6e9..786549a 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -1,519 +1,519 @@ | |||
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 | #ifndef KABCORE_H | 24 | #ifndef KABCORE_H |
25 | #define KABCORE_H | 25 | #define KABCORE_H |
26 | 26 | ||
27 | #include <kabc/field.h> | 27 | #include <kabc/field.h> |
28 | 28 | ||
29 | #ifndef KAB_EMBEDDED | 29 | #ifndef KAB_EMBEDDED |
30 | #endif //KAB_EMBEDDED | 30 | #endif //KAB_EMBEDDED |
31 | #include <qdict.h> | 31 | #include <qdict.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | ||
34 | #include <qwidget.h> | 34 | #include <qwidget.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | #include <ksyncmanager.h> | 36 | #include <ksyncmanager.h> |
37 | #ifndef DESKTOP_VERSION | 37 | #ifndef DESKTOP_VERSION |
38 | #include <qcopchannel_qws.h> | 38 | #include <qcopchannel_qws.h> |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | namespace KABC { | 41 | namespace KABC { |
42 | class AddressBook; | 42 | class AddressBook; |
43 | } | 43 | } |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | class KAboutData; | 46 | class KAboutData; |
47 | class KConfig; | 47 | class KConfig; |
48 | 48 | ||
49 | class KAddressBookService; | 49 | class KAddressBookService; |
50 | class LDAPSearchDialog; | 50 | class LDAPSearchDialog; |
51 | #else //KAB_EMBEDDED | 51 | #else //KAB_EMBEDDED |
52 | class KAddressBookMain; | 52 | class KAddressBookMain; |
53 | //US class QAction; | 53 | //US class QAction; |
54 | #endif //KAB_EMBEDDED | 54 | #endif //KAB_EMBEDDED |
55 | class KCMultiDialog; | 55 | class KCMultiDialog; |
56 | class KXMLGUIClient; | 56 | class KXMLGUIClient; |
57 | class ExtensionManager; | 57 | class ExtensionManager; |
58 | class XXPortManager; | 58 | class XXPortManager; |
59 | class JumpButtonBar; | 59 | class JumpButtonBar; |
60 | class IncSearchWidget; | 60 | class IncSearchWidget; |
61 | class KDGanttMinimizeSplitter; | 61 | class KDGanttMinimizeSplitter; |
62 | class KAction; | 62 | class KAction; |
63 | class KActionCollection; | 63 | class KActionCollection; |
64 | class KToggleAction; | 64 | class KToggleAction; |
65 | class KSyncProfile; | 65 | class KSyncProfile; |
66 | 66 | ||
67 | class QAction; | 67 | class QAction; |
68 | class QMenuBar; | 68 | class QMenuBar; |
69 | class QSplitter; | 69 | class QSplitter; |
70 | class ViewContainer; | 70 | class ViewContainer; |
71 | class ViewManager; | 71 | class ViewManager; |
72 | class AddresseeEditorDialog; | 72 | class AddresseeEditorDialog; |
73 | class Ir; | 73 | class Ir; |
74 | 74 | ||
75 | class KABCore : public QWidget, public KSyncInterface | 75 | class KABCore : public QWidget, public KSyncInterface |
76 | { | 76 | { |
77 | Q_OBJECT | 77 | Q_OBJECT |
78 | 78 | ||
79 | public: | 79 | public: |
80 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); | 80 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); |
81 | 81 | ||
82 | 82 | ||
83 | ~KABCore(); | 83 | ~KABCore(); |
84 | 84 | ||
85 | 85 | ||
86 | #ifdef KAB_EMBEDDED | 86 | #ifdef KAB_EMBEDDED |
87 | //US added functionality | 87 | //US added functionality |
88 | QPopupMenu* getViewMenu() {return viewMenu;} | 88 | QPopupMenu* getViewMenu() {return viewMenu;} |
89 | QPopupMenu* getFilterMenu() {return filterMenu;} | 89 | QPopupMenu* getFilterMenu() {return filterMenu;} |
90 | QPopupMenu* getSettingsMenu() {return settingsMenu;} | 90 | QPopupMenu* getSettingsMenu() {return settingsMenu;} |
91 | void addActionsManually(); | 91 | void addActionsManually(); |
92 | #endif //KAB_EMBEDDED | 92 | #endif //KAB_EMBEDDED |
93 | /** | 93 | /** |
94 | Restores the global settings. | 94 | Restores the global settings. |
95 | */ | 95 | */ |
96 | void restoreSettings(); | 96 | void restoreSettings(); |
97 | 97 | ||
98 | 98 | ||
99 | 99 | ||
100 | /** | 100 | /** |
101 | Returns a pointer to the StdAddressBook of the application. | 101 | Returns a pointer to the StdAddressBook of the application. |
102 | */ | 102 | */ |
103 | KABC::AddressBook *addressBook() const; | 103 | KABC::AddressBook *addressBook() const; |
104 | 104 | ||
105 | /** | 105 | /** |
106 | Returns a pointer to the KConfig object of the application. | 106 | Returns a pointer to the KConfig object of the application. |
107 | */ | 107 | */ |
108 | static KConfig *config(); | 108 | static KConfig *config(); |
109 | 109 | ||
110 | /** | 110 | /** |
111 | Returns a pointer to the global KActionCollection object. So | 111 | Returns a pointer to the global KActionCollection object. So |
112 | other classes can register their actions easily. | 112 | other classes can register their actions easily. |
113 | */ | 113 | */ |
114 | KActionCollection *actionCollection() const; | 114 | KActionCollection *actionCollection() const; |
115 | 115 | ||
116 | /** | 116 | /** |
117 | Returns the current search field of the Incremental Search Widget. | 117 | Returns the current search field of the Incremental Search Widget. |
118 | */ | 118 | */ |
119 | KABC::Field *currentSearchField() const; | 119 | KABC::Field *currentSearchField() const; |
120 | 120 | ||
121 | /** | 121 | /** |
122 | Returns the uid list of the currently selected contacts. | 122 | Returns the uid list of the currently selected contacts. |
123 | */ | 123 | */ |
124 | QStringList selectedUIDs() const; | 124 | QStringList selectedUIDs() const; |
125 | 125 | ||
126 | /** | 126 | /** |
127 | Displays the ResourceSelectDialog and returns the selected | 127 | Displays the ResourceSelectDialog and returns the selected |
128 | resource or a null pointer if no resource was selected by | 128 | resource or a null pointer if no resource was selected by |
129 | the user. | 129 | the user. |
130 | */ | 130 | */ |
131 | KABC::Resource *requestResource( QWidget *parent ); | 131 | KABC::Resource *requestResource( QWidget *parent ); |
132 | 132 | ||
133 | #ifndef KAB_EMBEDDED | 133 | #ifndef KAB_EMBEDDED |
134 | static KAboutData *createAboutData(); | 134 | static KAboutData *createAboutData(); |
135 | #endif //KAB_EMBEDDED | 135 | #endif //KAB_EMBEDDED |
136 | 136 | ||
137 | #ifdef KAB_EMBEDDED | 137 | #ifdef KAB_EMBEDDED |
138 | inline QPopupMenu* getImportMenu() { return ImportMenu;} | 138 | inline QPopupMenu* getImportMenu() { return ImportMenu;} |
139 | inline QPopupMenu* getExportMenu() { return ExportMenu;} | 139 | inline QPopupMenu* getExportMenu() { return ExportMenu;} |
140 | #endif //KAB_EMBEDDED | 140 | #endif //KAB_EMBEDDED |
141 | 141 | ||
142 | public slots: | 142 | public slots: |
143 | #ifdef KAB_EMBEDDED | 143 | #ifdef KAB_EMBEDDED |
144 | void createAboutData(); | 144 | void createAboutData(); |
145 | #endif //KAB_EMBEDDED | 145 | #endif //KAB_EMBEDDED |
146 | void setDetailsToggle(); | 146 | void setDetailsToggle(); |
147 | 147 | ||
148 | void showLicence(); | 148 | void showLicence(); |
149 | void faq(); | 149 | void faq(); |
150 | void whatsnew() ; | 150 | void whatsnew() ; |
151 | void synchowto() ; | 151 | void synchowto() ; |
152 | void multisynchowto() ; | 152 | void multisynchowto() ; |
153 | void kdesynchowto() ; | 153 | void kdesynchowto() ; |
154 | void writeToPhone(); | 154 | void writeToPhone(); |
155 | 155 | ||
156 | /** | 156 | /** |
157 | Is called whenever a contact is selected in the view. | 157 | Is called whenever a contact is selected in the view. |
158 | */ | 158 | */ |
159 | void setContactSelected( const QString &uid ); | 159 | void setContactSelected( const QString &uid ); |
160 | 160 | ||
161 | /** | 161 | /** |
162 | Opens the preferred mail composer with all selected contacts as | 162 | Opens the preferred mail composer with all selected contacts as |
163 | arguments. | 163 | arguments. |
164 | */ | 164 | */ |
165 | void sendMail(); | 165 | void sendMail(); |
166 | 166 | ||
167 | /** | 167 | /** |
168 | Opens the preferred mail composer with the given contacts as | 168 | Opens the preferred mail composer with the given contacts as |
169 | arguments. | 169 | arguments. |
170 | */ | 170 | */ |
171 | void sendMail( const QString& email ); | 171 | void sendMail( const QString& email ); |
172 | 172 | ||
173 | 173 | ||
174 | void mailVCard(); | 174 | void mailVCard(); |
175 | void mailVCard(const QStringList& uids); | 175 | void mailVCard(const QStringList& uids); |
176 | 176 | ||
177 | /** | 177 | /** |
178 | Beams the "WhoAmI contact. | 178 | Beams the "WhoAmI contact. |
179 | */ | 179 | */ |
180 | void beamMySelf(); | 180 | void beamMySelf(); |
181 | 181 | ||
182 | void beamVCard(); | 182 | void beamVCard(); |
183 | void export2phone(); | 183 | void export2phone(); |
184 | void beamVCard(const QStringList& uids); | 184 | void beamVCard(const QStringList& uids); |
185 | void beamDone( Ir *ir ); | 185 | void beamDone( Ir *ir ); |
186 | 186 | ||
187 | 187 | ||
188 | /** | 188 | /** |
189 | Starts the preferred web browser with the given URL as argument. | 189 | Starts the preferred web browser with the given URL as argument. |
190 | */ | 190 | */ |
191 | void browse( const QString& url ); | 191 | void browse( const QString& url ); |
192 | 192 | ||
193 | /** | 193 | /** |
194 | Select all contacts in the view. | 194 | Select all contacts in the view. |
195 | */ | 195 | */ |
196 | void selectAllContacts(); | 196 | void selectAllContacts(); |
197 | 197 | ||
198 | /** | 198 | /** |
199 | Deletes all selected contacts from the address book. | 199 | Deletes all selected contacts from the address book. |
200 | */ | 200 | */ |
201 | void deleteContacts(); | 201 | void deleteContacts(); |
202 | 202 | ||
203 | /** | 203 | /** |
204 | Deletes given contacts from the address book. | 204 | Deletes given contacts from the address book. |
205 | 205 | ||
206 | @param uids The uids of the contacts, which shall be deleted. | 206 | @param uids The uids of the contacts, which shall be deleted. |
207 | */ | 207 | */ |
208 | void deleteContacts( const QStringList &uids ); | 208 | void deleteContacts( const QStringList &uids ); |
209 | 209 | ||
210 | /** | 210 | /** |
211 | Copys the selected contacts into clipboard for later pasting. | 211 | Copys the selected contacts into clipboard for later pasting. |
212 | */ | 212 | */ |
213 | void copyContacts(); | 213 | void copyContacts(); |
214 | 214 | ||
215 | /** | 215 | /** |
216 | Cuts the selected contacts and stores them for later pasting. | 216 | Cuts the selected contacts and stores them for later pasting. |
217 | */ | 217 | */ |
218 | void cutContacts(); | 218 | void cutContacts(); |
219 | 219 | ||
220 | /** | 220 | /** |
221 | Paste contacts from clipboard into the address book. | 221 | Paste contacts from clipboard into the address book. |
222 | */ | 222 | */ |
223 | void pasteContacts(); | 223 | void pasteContacts(); |
224 | 224 | ||
225 | /** | 225 | /** |
226 | Paste given contacts into the address book. | 226 | Paste given contacts into the address book. |
227 | 227 | ||
228 | @param list The list of addressee, which shall be pasted. | 228 | @param list The list of addressee, which shall be pasted. |
229 | */ | 229 | */ |
230 | void pasteContacts( KABC::Addressee::List &list ); | 230 | void pasteContacts( KABC::Addressee::List &list ); |
231 | 231 | ||
232 | /** | 232 | /** |
233 | Sets the whoAmI contact, that is used by many other programs to | 233 | Sets the whoAmI contact, that is used by many other programs to |
234 | get personal information about the current user. | 234 | get personal information about the current user. |
235 | */ | 235 | */ |
236 | void setWhoAmI(); | 236 | void setWhoAmI(); |
237 | 237 | ||
238 | /** | 238 | /** |
239 | Displays the category dialog and applies the result to all | 239 | Displays the category dialog and applies the result to all |
240 | selected contacts. | 240 | selected contacts. |
241 | */ | 241 | */ |
242 | void setCategories(); | 242 | void setCategories(); |
243 | void manageCategories(); | 243 | void manageCategories(); |
244 | void editCategories(); | 244 | void editCategories(); |
245 | 245 | ||
246 | /** | 246 | /** |
247 | Sets the field list of the Incremental Search Widget. | 247 | Sets the field list of the Incremental Search Widget. |
248 | */ | 248 | */ |
249 | void setSearchFields( const KABC::Field::List &fields ); | 249 | void setSearchFields( const KABC::Field::List &fields ); |
250 | 250 | ||
251 | /** | 251 | /** |
252 | Search with the current search field for a contact, that matches | 252 | Search with the current search field for a contact, that matches |
253 | the given text, and selects it in the view. | 253 | the given text, and selects it in the view. |
254 | */ | 254 | */ |
255 | void incrementalSearch( const QString& text ); | 255 | void incrementalSearch( const QString& text ); |
256 | 256 | ||
257 | /** | 257 | /** |
258 | Marks the address book as modified. | 258 | Marks the address book as modified. |
259 | */ | 259 | */ |
260 | void setModified(); | 260 | void setModified(); |
261 | /** | 261 | /** |
262 | Marks the address book as modified without refreshing the view. | 262 | Marks the address book as modified without refreshing the view. |
263 | */ | 263 | */ |
264 | void setModifiedWOrefresh(); | 264 | void setModifiedWOrefresh(); |
265 | 265 | ||
266 | /** | 266 | /** |
267 | Marks the address book as modified concerning the argument. | 267 | Marks the address book as modified concerning the argument. |
268 | */ | 268 | */ |
269 | void setModified( bool modified ); | 269 | void setModified( bool modified ); |
270 | 270 | ||
271 | /** | 271 | /** |
272 | Returns whether the address book is modified. | 272 | Returns whether the address book is modified. |
273 | */ | 273 | */ |
274 | bool modified() const; | 274 | bool modified() const; |
275 | 275 | ||
276 | /** | 276 | /** |
277 | Called whenever an contact is modified in the contact editor | 277 | Called whenever an contact is modified in the contact editor |
278 | dialog or the quick edit. | 278 | dialog or the quick edit. |
279 | */ | 279 | */ |
280 | void contactModified( const KABC::Addressee &addr ); | 280 | void contactModified( const KABC::Addressee &addr ); |
281 | void addrModified( const KABC::Addressee &addr, bool updateDetails = true ); | 281 | void addrModified( const KABC::Addressee &addr, bool updateDetails = true ); |
282 | 282 | ||
283 | /** | 283 | /** |
284 | DCOP METHODS. | 284 | DCOP METHODS. |
285 | */ | 285 | */ |
286 | void addEmail( QString addr ); | 286 | void addEmail( QString addr ); |
287 | void importVCard( const KURL& url, bool showPreview ); | 287 | void importVCard( const KURL& url, bool showPreview ); |
288 | void importVCard( const QString& vCard, bool showPreview ); | 288 | void importVCard( const QString& vCard, bool showPreview ); |
289 | void newContact(); | 289 | void newContact(); |
290 | QString getNameByPhone( const QString& phone ); | 290 | QString getNameByPhone( const QString& phone ); |
291 | /** | 291 | /** |
292 | END DCOP METHODS | 292 | END DCOP METHODS |
293 | */ | 293 | */ |
294 | 294 | ||
295 | /** | 295 | /** |
296 | Saves the contents of the AddressBook back to disk. | 296 | Saves the contents of the AddressBook back to disk. |
297 | */ | 297 | */ |
298 | void save(); | 298 | void save(); |
299 | 299 | ||
300 | /** | 300 | /** |
301 | Undos the last command using the undo stack. | 301 | Undos the last command using the undo stack. |
302 | */ | 302 | */ |
303 | void undo(); | 303 | void undo(); |
304 | 304 | ||
305 | /** | 305 | /** |
306 | Redos the last command that was undone, using the redo stack. | 306 | Redos the last command that was undone, using the redo stack. |
307 | */ | 307 | */ |
308 | void redo(); | 308 | void redo(); |
309 | 309 | ||
310 | /** | 310 | /** |
311 | Shows the edit dialog for the given uid. If the uid is QString::null, | 311 | Shows the edit dialog for the given uid. If the uid is QString::null, |
312 | the method will try to find a selected addressee in the view. | 312 | the method will try to find a selected addressee in the view. |
313 | */ | 313 | */ |
314 | void editContact( const QString &uid /*US = QString::null*/ ); | 314 | void editContact( const QString &uid /*US = QString::null*/ ); |
315 | //US added a second method without defaultparameter | 315 | //US added a second method without defaultparameter |
316 | void editContact2(); | 316 | void editContact2(); |
317 | 317 | ||
318 | /** | 318 | /** |
319 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 319 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
320 | the method will try to find a selected addressee in the view. | 320 | the method will try to find a selected addressee in the view. |
321 | */ | 321 | */ |
322 | void executeContact( const QString &uid /*US = QString::null*/ ); | 322 | void executeContact( const QString &uid /*US = QString::null*/ ); |
323 | 323 | ||
324 | /** | 324 | /** |
325 | Launches the configuration dialog. | 325 | Launches the configuration dialog. |
326 | */ | 326 | */ |
327 | void openConfigDialog(); | 327 | void openConfigDialog(); |
328 | 328 | ||
329 | /** | 329 | /** |
330 | Launches the ldap search dialog. | 330 | Launches the ldap search dialog. |
331 | */ | 331 | */ |
332 | void openLDAPDialog(); | 332 | void openLDAPDialog(); |
333 | 333 | ||
334 | /** | 334 | /** |
335 | Creates a KAddressBookPrinter, which will display the print | 335 | Creates a KAddressBookPrinter, which will display the print |
336 | dialog and do the printing. | 336 | dialog and do the printing. |
337 | */ | 337 | */ |
338 | void print(); | 338 | void print(); |
339 | 339 | ||
340 | /** | 340 | /** |
341 | Registers a new GUI client, so plugins can register its actions. | 341 | Registers a new GUI client, so plugins can register its actions. |
342 | */ | 342 | */ |
343 | void addGUIClient( KXMLGUIClient *client ); | 343 | void addGUIClient( KXMLGUIClient *client ); |
344 | 344 | ||
345 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); | 345 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); |
346 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); | 346 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); |
347 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); | 347 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); |
348 | 348 | ||
349 | 349 | ||
350 | signals: | 350 | signals: |
351 | void contactSelected( const QString &name ); | 351 | void contactSelected( const QString &name ); |
352 | void contactSelected( const QPixmap &pixmap ); | 352 | void contactSelected( const QPixmap &pixmap ); |
353 | public slots: | 353 | public slots: |
354 | void recieve(QString cmsg ); | 354 | void recieve(QString cmsg ); |
355 | void getFile( bool success ); | 355 | void getFile( bool success ); |
356 | void syncFileRequest(); | 356 | void syncFileRequest(); |
357 | void setDetailsVisible( bool visible ); | 357 | void setDetailsVisible( bool visible ); |
358 | void setDetailsToState(); | 358 | void setDetailsToState(); |
359 | 359 | ||
360 | void saveSettings(); | 360 | void saveSettings(); |
361 | 361 | ||
362 | private slots: | 362 | private slots: |
363 | void updateToolBar(); | 363 | void updateToolBar(); |
364 | void updateMainWindow(); | 364 | void updateMainWindow(); |
365 | void receive( const QCString& cmsg, const QByteArray& data ); | 365 | void receive( const QCString& cmsg, const QByteArray& data ); |
366 | void toggleBeamReceive( ); | 366 | void toggleBeamReceive( ); |
367 | void disableBR(bool); | 367 | void disableBR(bool); |
368 | void setJumpButtonBarVisible( bool visible ); | 368 | void setJumpButtonBarVisible( bool visible ); |
369 | void setCaptionBack(); | 369 | void setCaptionBack(); |
370 | void importFromOL(); | 370 | void importFromOL(); |
371 | void extensionModified( const KABC::Addressee::List &list ); | 371 | void extensionModified( const KABC::Addressee::List &list ); |
372 | void extensionChanged( int id ); | 372 | void extensionChanged( int id ); |
373 | void clipboardDataChanged(); | 373 | void clipboardDataChanged(); |
374 | void updateActionMenu(); | 374 | void updateActionMenu(); |
375 | void configureKeyBindings(); | 375 | void configureKeyBindings(); |
376 | void removeVoice(); | 376 | void removeVoice(); |
377 | void setFormattedName(); | 377 | void setFormattedName(); |
378 | #ifdef KAB_EMBEDDED | 378 | #ifdef KAB_EMBEDDED |
379 | void configureResources(); | 379 | void configureResources(); |
380 | #endif //KAB_EMBEDDED | 380 | #endif //KAB_EMBEDDED |
381 | 381 | ||
382 | void slotEditorDestroyed( const QString &uid ); | 382 | void slotEditorDestroyed( const QString &uid ); |
383 | void configurationChanged(); | 383 | void configurationChanged(); |
384 | void addressBookChanged(); | 384 | void addressBookChanged(); |
385 | 385 | ||
386 | private: | 386 | private: |
387 | void resizeEvent(QResizeEvent* e ); | 387 | void resizeEvent(QResizeEvent* e ); |
388 | bool mBRdisabled; | 388 | bool mBRdisabled; |
389 | #ifndef DESKTOP_VERSION | 389 | #ifndef DESKTOP_VERSION |
390 | QCopChannel* infrared; | 390 | QCopChannel* infrared; |
391 | #endif | 391 | #endif |
392 | QTimer *mMessageTimer; | 392 | QTimer *mMessageTimer; |
393 | void initGUI(); | 393 | void initGUI(); |
394 | void initActions(); | 394 | void initActions(); |
395 | QString getPhoneFile(); | 395 | QString getPhoneFile(); |
396 | 396 | ||
397 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, | 397 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, |
398 | const char *name = 0 ); | 398 | const char *name = 0 ); |
399 | 399 | ||
400 | KXMLGUIClient *mGUIClient; | 400 | KXMLGUIClient *mGUIClient; |
401 | 401 | ||
402 | KABC::AddressBook *mAddressBook; | 402 | KABC::AddressBook *mAddressBook; |
403 | 403 | ||
404 | ViewManager *mViewManager; | 404 | ViewManager *mViewManager; |
405 | // QSplitter *mDetailsSplitter; | 405 | // QSplitter *mDetailsSplitter; |
406 | KDGanttMinimizeSplitter *mExtensionBarSplitter; | 406 | KDGanttMinimizeSplitter *mExtensionBarSplitter; |
407 | ViewContainer *mDetails; | 407 | ViewContainer *mDetails; |
408 | KDGanttMinimizeSplitter* mMiniSplitter; | 408 | KDGanttMinimizeSplitter* mMiniSplitter; |
409 | XXPortManager *mXXPortManager; | 409 | XXPortManager *mXXPortManager; |
410 | JumpButtonBar *mJumpButtonBar; | 410 | JumpButtonBar *mJumpButtonBar; |
411 | IncSearchWidget *mIncSearchWidget; | 411 | IncSearchWidget *mIncSearchWidget; |
412 | ExtensionManager *mExtensionManager; | 412 | ExtensionManager *mExtensionManager; |
413 | 413 | ||
414 | KCMultiDialog *mConfigureDialog; | 414 | KCMultiDialog *mConfigureDialog; |
415 | 415 | ||
416 | #ifndef KAB_EMBEDDED | 416 | #ifndef KAB_EMBEDDED |
417 | LDAPSearchDialog *mLdapSearchDialog; | 417 | LDAPSearchDialog *mLdapSearchDialog; |
418 | #endif //KAB_EMBEDDED | 418 | #endif //KAB_EMBEDDED |
419 | // QDict<AddresseeEditorDialog> mEditorDict; | 419 | // QDict<AddresseeEditorDialog> mEditorDict; |
420 | AddresseeEditorDialog *mEditorDialog; | 420 | AddresseeEditorDialog *mEditorDialog; |
421 | bool mReadWrite; | 421 | bool mReadWrite; |
422 | bool mModified; | 422 | bool mModified; |
423 | bool mIsPart; | 423 | bool mIsPart; |
424 | bool mMultipleViewsAtOnce; | 424 | bool mMultipleViewsAtOnce; |
425 | 425 | ||
426 | 426 | ||
427 | //US file menu | 427 | //US file menu |
428 | KAction *mActionMail; | 428 | KAction *mActionMail; |
429 | KAction *mActionBeam; | 429 | KAction *mActionBeam; |
430 | KToggleAction *mActionBR; | 430 | KToggleAction *mActionBR; |
431 | KAction *mActionExport2phone; | 431 | KAction *mActionExport2phone; |
432 | KAction* mActionPrint; | 432 | KAction* mActionPrint; |
433 | KAction* mActionPrintDetails; | 433 | KAction* mActionPrintDetails; |
434 | KAction* mActionNewContact; | 434 | KAction* mActionNewContact; |
435 | KAction *mActionSave; | 435 | KAction *mActionSave; |
436 | KAction *mActionEditAddressee; | 436 | KAction *mActionEditAddressee; |
437 | KAction *mActionMailVCard; | 437 | KAction *mActionMailVCard; |
438 | KAction *mActionBeamVCard; | 438 | KAction *mActionBeamVCard; |
439 | 439 | ||
440 | KAction *mActionQuit; | 440 | KAction *mActionQuit; |
441 | 441 | ||
442 | //US edit menu | 442 | //US edit menu |
443 | KAction *mActionCopy; | 443 | KAction *mActionCopy; |
444 | KAction *mActionCut; | 444 | KAction *mActionCut; |
445 | KAction *mActionPaste; | 445 | KAction *mActionPaste; |
446 | KAction *mActionSelectAll; | 446 | KAction *mActionSelectAll; |
447 | KAction *mActionUndo; | 447 | KAction *mActionUndo; |
448 | KAction *mActionRedo; | 448 | KAction *mActionRedo; |
449 | KAction *mActionDelete; | 449 | KAction *mActionDelete; |
450 | 450 | ||
451 | //US settings menu | 451 | //US settings menu |
452 | KAction *mActionConfigResources; | 452 | KAction *mActionConfigResources; |
453 | KAction *mActionConfigKAddressbook; | 453 | KAction *mActionConfigKAddressbook; |
454 | KAction *mActionConfigShortcuts; | 454 | KAction *mActionConfigShortcuts; |
455 | KAction *mActionConfigureToolbars; | 455 | KAction *mActionConfigureToolbars; |
456 | KAction *mActionKeyBindings; | 456 | KAction *mActionKeyBindings; |
457 | KToggleAction *mActionJumpBar; | 457 | KToggleAction *mActionJumpBar; |
458 | KToggleAction *mActionDetails; | 458 | KToggleAction *mActionDetails; |
459 | KAction *mActionWhoAmI; | 459 | KAction *mActionWhoAmI; |
460 | KAction *mActionCategories; | 460 | KAction *mActionCategories; |
461 | KAction *mActionEditCategories; | 461 | KAction *mActionEditCategories; |
462 | KAction *mActionManageCategories; | 462 | KAction *mActionManageCategories; |
463 | KAction *mActionAboutKAddressbook; | 463 | KAction *mActionAboutKAddressbook; |
464 | KAction *mActionLicence; | 464 | KAction *mActionLicence; |
465 | KAction *mActionFaq; | 465 | KAction *mActionFaq; |
466 | KAction *mActionWN; | 466 | KAction *mActionWN; |
467 | KAction *mActionSyncHowto; | 467 | KAction *mActionSyncHowto; |
468 | KAction *mActionKdeSyncHowto; | 468 | KAction *mActionKdeSyncHowto; |
469 | KAction *mActionMultiSyncHowto; | 469 | KAction *mActionMultiSyncHowto; |
470 | 470 | ||
471 | KAction *mActionDeleteView; | 471 | KAction *mActionDeleteView; |
472 | 472 | ||
473 | QPopupMenu *viewMenu; | 473 | QPopupMenu *viewMenu; |
474 | QPopupMenu *filterMenu; | 474 | QPopupMenu *filterMenu; |
475 | QPopupMenu *settingsMenu; | 475 | QPopupMenu *settingsMenu; |
476 | QPopupMenu *changeMenu; | 476 | QPopupMenu *changeMenu; |
477 | QPopupMenu *beamMenu; | 477 | QPopupMenu *beamMenu; |
478 | //US QAction *mActionSave; | 478 | //US QAction *mActionSave; |
479 | QPopupMenu *ImportMenu; | 479 | QPopupMenu *ImportMenu; |
480 | QPopupMenu *ExportMenu; | 480 | QPopupMenu *ExportMenu; |
481 | //LR additional methods | 481 | //LR additional methods |
482 | KAction *mActionRemoveVoice; | 482 | KAction *mActionRemoveVoice; |
483 | KAction *mActionSetFormattedName; | 483 | KAction *mActionSetFormattedName; |
484 | KAction * mActionImportOL; | 484 | KAction * mActionImportOL; |
485 | 485 | ||
486 | #ifndef KAB_EMBEDDED | 486 | #ifndef KAB_EMBEDDED |
487 | KAddressBookService *mAddressBookService; | 487 | KAddressBookService *mAddressBookService; |
488 | #endif //KAB_EMBEDDED | 488 | #endif //KAB_EMBEDDED |
489 | 489 | ||
490 | class KABCorePrivate; | 490 | class KABCorePrivate; |
491 | KABCorePrivate *d; | 491 | KABCorePrivate *d; |
492 | //US bool mBlockSaveFlag; | 492 | //US bool mBlockSaveFlag; |
493 | 493 | ||
494 | #ifdef KAB_EMBEDDED | 494 | #ifdef KAB_EMBEDDED |
495 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 495 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
496 | #endif //KAB_EMBEDDED | 496 | #endif //KAB_EMBEDDED |
497 | 497 | ||
498 | //this are the overwritten callbackmethods from the syncinterface | 498 | //this are the overwritten callbackmethods from the syncinterface |
499 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 499 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
500 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 500 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
501 | virtual void removeSyncInfo( QString syncProfile); | 501 | virtual void removeSyncInfo( QString syncProfile); |
502 | bool syncPhone(); | 502 | bool syncPhone(); |
503 | void message( QString m ); | 503 | void message( QString m , bool startTimer = true); |
504 | 504 | ||
505 | // LR ******************************* | 505 | // LR ******************************* |
506 | // sync stuff! | 506 | // sync stuff! |
507 | QString sentSyncFile(); | 507 | QString sentSyncFile(); |
508 | QPopupMenu *syncMenu; | 508 | QPopupMenu *syncMenu; |
509 | KSyncManager* syncManager; | 509 | KSyncManager* syncManager; |
510 | int mGlobalSyncMode; | 510 | int mGlobalSyncMode; |
511 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); | 511 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); |
512 | KABC::Addressee getLastSyncAddressee(); | 512 | KABC::Addressee getLastSyncAddressee(); |
513 | QDateTime mLastAddressbookSync; | 513 | QDateTime mLastAddressbookSync; |
514 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); | 514 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); |
515 | // ********************* | 515 | // ********************* |
516 | 516 | ||
517 | }; | 517 | }; |
518 | 518 | ||
519 | #endif | 519 | #endif |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 6c1f444..f488a07 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1,1484 +1,1485 @@ | |||
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 | 20 | ||
21 | // $Id$ | 21 | // $Id$ |
22 | 22 | ||
23 | #include "ksyncmanager.h" | 23 | #include "ksyncmanager.h" |
24 | 24 | ||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | 31 | ||
32 | #include "ksyncprofile.h" | 32 | #include "ksyncprofile.h" |
33 | #include "ksyncprefsdialog.h" | 33 | #include "ksyncprefsdialog.h" |
34 | #include "kpimprefs.h" | 34 | #include "kpimprefs.h" |
35 | #include <kmessagebox.h> | 35 | #include <kmessagebox.h> |
36 | 36 | ||
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
39 | #include <qpopupmenu.h> | 39 | #include <qpopupmenu.h> |
40 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
41 | #include <qradiobutton.h> | 41 | #include <qradiobutton.h> |
42 | #include <qbuttongroup.h> | 42 | #include <qbuttongroup.h> |
43 | #include <qtimer.h> | 43 | #include <qtimer.h> |
44 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
45 | #include <qapplication.h> | 45 | #include <qapplication.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #include <qlabel.h> | 50 | #include <qlabel.h> |
51 | #include <qcheckbox.h> | 51 | #include <qcheckbox.h> |
52 | 52 | ||
53 | #include <klocale.h> | 53 | #include <klocale.h> |
54 | #include <kglobal.h> | 54 | #include <kglobal.h> |
55 | #include <kconfig.h> | 55 | #include <kconfig.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | 57 | ||
58 | QDateTime KSyncManager::mRequestedSyncEvent; | 58 | QDateTime KSyncManager::mRequestedSyncEvent; |
59 | 59 | ||
60 | 60 | ||
61 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) | 61 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) |
62 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) | 62 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) |
63 | { | 63 | { |
64 | mServerSocket = 0; | 64 | mServerSocket = 0; |
65 | bar = new QProgressBar ( 1, 0 ); | 65 | bar = new QProgressBar ( 1, 0 ); |
66 | bar->setCaption (""); | 66 | bar->setCaption (""); |
67 | mWriteBackInPast = 2; | 67 | mWriteBackInPast = 2; |
68 | int w = 300; | 68 | int w = 300; |
69 | if ( QApplication::desktop()->width() < 320 ) | 69 | if ( QApplication::desktop()->width() < 320 ) |
70 | w = 220; | 70 | w = 220; |
71 | int h = bar->sizeHint().height() ; | 71 | int h = bar->sizeHint().height() ; |
72 | int dw = QApplication::desktop()->width(); | 72 | int dw = QApplication::desktop()->width(); |
73 | int dh = QApplication::desktop()->height(); | 73 | int dh = QApplication::desktop()->height(); |
74 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 74 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
75 | if ( mPrefs->mPassiveSyncAutoStart ) | 75 | if ( mPrefs->mPassiveSyncAutoStart ) |
76 | enableQuick( false ); | 76 | enableQuick( false ); |
77 | 77 | ||
78 | } | 78 | } |
79 | 79 | ||
80 | KSyncManager::~KSyncManager() | 80 | KSyncManager::~KSyncManager() |
81 | { | 81 | { |
82 | delete bar; | 82 | delete bar; |
83 | } | 83 | } |
84 | 84 | ||
85 | 85 | ||
86 | void KSyncManager::fillSyncMenu() | 86 | void KSyncManager::fillSyncMenu() |
87 | { | 87 | { |
88 | if ( mSyncMenu->count() ) | 88 | if ( mSyncMenu->count() ) |
89 | mSyncMenu->clear(); | 89 | mSyncMenu->clear(); |
90 | 90 | ||
91 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 91 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
92 | mSyncMenu->insertSeparator(); | 92 | mSyncMenu->insertSeparator(); |
93 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); | 93 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); |
94 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); | 94 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); |
95 | clearMenu->insertItem( i18n("For all profiles"), 1 ); | 95 | clearMenu->insertItem( i18n("For all profiles"), 1 ); |
96 | clearMenu->insertSeparator(); | 96 | clearMenu->insertSeparator(); |
97 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); | 97 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); |
98 | mSyncMenu->insertSeparator(); | 98 | mSyncMenu->insertSeparator(); |
99 | if ( mServerSocket == 0 ) { | 99 | if ( mServerSocket == 0 ) { |
100 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 100 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
101 | } else { | 101 | } else { |
102 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 102 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
103 | } | 103 | } |
104 | mSyncMenu->insertSeparator(); | 104 | mSyncMenu->insertSeparator(); |
105 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); | 105 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); |
106 | mSyncMenu->insertSeparator(); | 106 | mSyncMenu->insertSeparator(); |
107 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 107 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
108 | config.setGroup("General"); | 108 | config.setGroup("General"); |
109 | QStringList prof = config.readListEntry("SyncProfileNames"); | 109 | QStringList prof = config.readListEntry("SyncProfileNames"); |
110 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 110 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
111 | if ( prof.count() < 2 ) { | 111 | if ( prof.count() < 2 ) { |
112 | prof.clear(); | 112 | prof.clear(); |
113 | QString externalName; | 113 | QString externalName; |
114 | #ifdef DESKTOP_VERSION | 114 | #ifdef DESKTOP_VERSION |
115 | #ifdef _WIN32_ | 115 | #ifdef _WIN32_ |
116 | externalName = "OutLook(not_implemented)"; | 116 | externalName = "OutLook(not_implemented)"; |
117 | #else | 117 | #else |
118 | externalName = "KDE_Desktop"; | 118 | externalName = "KDE_Desktop"; |
119 | #endif | 119 | #endif |
120 | #else | 120 | #else |
121 | externalName = "Sharp_DTM"; | 121 | externalName = "Sharp_DTM"; |
122 | #endif | 122 | #endif |
123 | prof << externalName; | 123 | prof << externalName; |
124 | prof << i18n("Local_file"); | 124 | prof << i18n("Local_file"); |
125 | prof << i18n("Last_file"); | 125 | prof << i18n("Last_file"); |
126 | KSyncProfile* temp = new KSyncProfile (); | 126 | KSyncProfile* temp = new KSyncProfile (); |
127 | temp->setName( prof[0] ); | 127 | temp->setName( prof[0] ); |
128 | temp->writeConfig(&config); | 128 | temp->writeConfig(&config); |
129 | temp->setName( prof[1] ); | 129 | temp->setName( prof[1] ); |
130 | temp->writeConfig(&config); | 130 | temp->writeConfig(&config); |
131 | temp->setName( prof[2] ); | 131 | temp->setName( prof[2] ); |
132 | temp->writeConfig(&config); | 132 | temp->writeConfig(&config); |
133 | config.setGroup("General"); | 133 | config.setGroup("General"); |
134 | config.writeEntry("SyncProfileNames",prof); | 134 | config.writeEntry("SyncProfileNames",prof); |
135 | config.writeEntry("ExternSyncProfiles",externalName); | 135 | config.writeEntry("ExternSyncProfiles",externalName); |
136 | config.sync(); | 136 | config.sync(); |
137 | delete temp; | 137 | delete temp; |
138 | } | 138 | } |
139 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 139 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
140 | mSyncProfileNames = prof; | 140 | mSyncProfileNames = prof; |
141 | unsigned int i; | 141 | unsigned int i; |
142 | for ( i = 0; i < prof.count(); ++i ) { | 142 | for ( i = 0; i < prof.count(); ++i ) { |
143 | mSyncMenu->insertItem( prof[i], 1000+i ); | 143 | mSyncMenu->insertItem( prof[i], 1000+i ); |
144 | clearMenu->insertItem( prof[i], 1000+i ); | 144 | clearMenu->insertItem( prof[i], 1000+i ); |
145 | if ( i == 2 ) | 145 | if ( i == 2 ) |
146 | mSyncMenu->insertSeparator(); | 146 | mSyncMenu->insertSeparator(); |
147 | } | 147 | } |
148 | QDir app_dir; | 148 | QDir app_dir; |
149 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 149 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
150 | if ( mTargetApp == PWMPI) { | 150 | if ( mTargetApp == PWMPI) { |
151 | mSyncMenu->removeItem( 1000 ); | 151 | mSyncMenu->removeItem( 1000 ); |
152 | clearMenu->removeItem( 1000 ); | 152 | clearMenu->removeItem( 1000 ); |
153 | } | 153 | } |
154 | #ifndef DESKTOP_VERSION | 154 | #ifndef DESKTOP_VERSION |
155 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 155 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
156 | mSyncMenu->removeItem( 1000 ); | 156 | mSyncMenu->removeItem( 1000 ); |
157 | clearMenu->removeItem( 1000 ); | 157 | clearMenu->removeItem( 1000 ); |
158 | } | 158 | } |
159 | #endif | 159 | #endif |
160 | mSyncMenu->removeItem( 1002 ); | 160 | mSyncMenu->removeItem( 1002 ); |
161 | clearMenu->removeItem( 1002 ); | 161 | clearMenu->removeItem( 1002 ); |
162 | } | 162 | } |
163 | void KSyncManager::slotClearMenu( int action ) | 163 | void KSyncManager::slotClearMenu( int action ) |
164 | { | 164 | { |
165 | QString syncDevice; | 165 | QString syncDevice; |
166 | if ( action > 999 ) { | 166 | if ( action > 999 ) { |
167 | syncDevice = mSyncProfileNames[action - 1000] ; | 167 | syncDevice = mSyncProfileNames[action - 1000] ; |
168 | } | 168 | } |
169 | 169 | ||
170 | 170 | ||
171 | 171 | ||
172 | int result = 0; | 172 | int result = 0; |
173 | QString sd; | 173 | QString sd; |
174 | if ( syncDevice.isEmpty() ) | 174 | if ( syncDevice.isEmpty() ) |
175 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); | 175 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); |
176 | else | 176 | else |
177 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); | 177 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); |
178 | 178 | ||
179 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, | 179 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, |
180 | 0, 1 ); | 180 | 0, 1 ); |
181 | if ( result ) | 181 | if ( result ) |
182 | return; | 182 | return; |
183 | mImplementation->removeSyncInfo( syncDevice ); | 183 | mImplementation->removeSyncInfo( syncDevice ); |
184 | } | 184 | } |
185 | void KSyncManager::slotSyncMenu( int action ) | 185 | void KSyncManager::slotSyncMenu( int action ) |
186 | { | 186 | { |
187 | qDebug("syncaction %d ", action); | 187 | qDebug("syncaction %d ", action); |
188 | if ( action == 5000 ) | 188 | if ( action == 5000 ) |
189 | return; | 189 | return; |
190 | mSyncWithDesktop = false; | 190 | mSyncWithDesktop = false; |
191 | if ( action == 0 ) { | 191 | if ( action == 0 ) { |
192 | 192 | ||
193 | // seems to be a Qt2 event handling bug | 193 | // seems to be a Qt2 event handling bug |
194 | // syncmenu.clear causes a segfault at first time | 194 | // syncmenu.clear causes a segfault at first time |
195 | // when we call it after the main event loop, it is ok | 195 | // when we call it after the main event loop, it is ok |
196 | // same behaviour when calling OM/Pi via QCOP for the first time | 196 | // same behaviour when calling OM/Pi via QCOP for the first time |
197 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 197 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
198 | //confSync(); | 198 | //confSync(); |
199 | 199 | ||
200 | return; | 200 | return; |
201 | } | 201 | } |
202 | if ( action == 1 ) { | 202 | if ( action == 1 ) { |
203 | multiSync( true ); | 203 | multiSync( true ); |
204 | return; | 204 | return; |
205 | } | 205 | } |
206 | if ( action == 2 ) { | 206 | if ( action == 2 ) { |
207 | enableQuick(); | 207 | enableQuick(); |
208 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 208 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
209 | return; | 209 | return; |
210 | } | 210 | } |
211 | if ( action == 3 ) { | 211 | if ( action == 3 ) { |
212 | delete mServerSocket; | 212 | delete mServerSocket; |
213 | mServerSocket = 0; | 213 | mServerSocket = 0; |
214 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 214 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
215 | return; | 215 | return; |
216 | } | 216 | } |
217 | 217 | ||
218 | if (blockSave()) | 218 | if (blockSave()) |
219 | return; | 219 | return; |
220 | 220 | ||
221 | setBlockSave(true); | 221 | setBlockSave(true); |
222 | bool silent = false; | 222 | bool silent = false; |
223 | if ( action == 999 ) { | 223 | if ( action == 999 ) { |
224 | //special mode for silent syncing | 224 | //special mode for silent syncing |
225 | action = 1000; | 225 | action = 1000; |
226 | silent = true; | 226 | silent = true; |
227 | } | 227 | } |
228 | 228 | ||
229 | mCurrentSyncProfile = action - 1000 ; | 229 | mCurrentSyncProfile = action - 1000 ; |
230 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; | 230 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
231 | mCurrentSyncName = mLocalMachineName ; | 231 | mCurrentSyncName = mLocalMachineName ; |
232 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 232 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
233 | KSyncProfile* temp = new KSyncProfile (); | 233 | KSyncProfile* temp = new KSyncProfile (); |
234 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); | 234 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
235 | temp->readConfig(&config); | 235 | temp->readConfig(&config); |
236 | if (silent) { | 236 | if (silent) { |
237 | mAskForPreferences = false; | 237 | mAskForPreferences = false; |
238 | mShowSyncSummary = false; | 238 | mShowSyncSummary = false; |
239 | mWriteBackFile = true; | 239 | mWriteBackFile = true; |
240 | mSyncAlgoPrefs = 2;// take newest | 240 | mSyncAlgoPrefs = 2;// take newest |
241 | } | 241 | } |
242 | else { | 242 | else { |
243 | mAskForPreferences = temp->getAskForPreferences(); | 243 | mAskForPreferences = temp->getAskForPreferences(); |
244 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 244 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
245 | mWriteBackFile = temp->getWriteBackFile(); | 245 | mWriteBackFile = temp->getWriteBackFile(); |
246 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 246 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
247 | } | 247 | } |
248 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 248 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
249 | mIsKapiFile = temp->getIsKapiFile(); | 249 | mIsKapiFile = temp->getIsKapiFile(); |
250 | mWriteBackInFuture = 0; | 250 | mWriteBackInFuture = 0; |
251 | if ( temp->getWriteBackFuture() ) { | 251 | if ( temp->getWriteBackFuture() ) { |
252 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 252 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
253 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 253 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
254 | } | 254 | } |
255 | mFilterInCal = temp->getFilterInCal(); | 255 | mFilterInCal = temp->getFilterInCal(); |
256 | mFilterOutCal = temp->getFilterOutCal(); | 256 | mFilterOutCal = temp->getFilterOutCal(); |
257 | mFilterInAB = temp->getFilterInAB(); | 257 | mFilterInAB = temp->getFilterInAB(); |
258 | mFilterOutAB = temp->getFilterOutAB(); | 258 | mFilterOutAB = temp->getFilterOutAB(); |
259 | 259 | ||
260 | if ( action == 1000 ) { | 260 | if ( action == 1000 ) { |
261 | mIsKapiFile = false; | 261 | mIsKapiFile = false; |
262 | #ifdef DESKTOP_VERSION | 262 | #ifdef DESKTOP_VERSION |
263 | syncKDE(); | 263 | syncKDE(); |
264 | #else | 264 | #else |
265 | syncSharp(); | 265 | syncSharp(); |
266 | #endif | 266 | #endif |
267 | 267 | ||
268 | } else if ( action == 1001 ) { | 268 | } else if ( action == 1001 ) { |
269 | syncLocalFile(); | 269 | syncLocalFile(); |
270 | 270 | ||
271 | } else if ( action == 1002 ) { | 271 | } else if ( action == 1002 ) { |
272 | mWriteBackFile = false; | 272 | mWriteBackFile = false; |
273 | mAskForPreferences = false; | 273 | mAskForPreferences = false; |
274 | mShowSyncSummary = false; | 274 | mShowSyncSummary = false; |
275 | mSyncAlgoPrefs = 3; | 275 | mSyncAlgoPrefs = 3; |
276 | quickSyncLocalFile(); | 276 | quickSyncLocalFile(); |
277 | 277 | ||
278 | } else if ( action >= 1003 ) { | 278 | } else if ( action >= 1003 ) { |
279 | if ( temp->getIsLocalFileSync() ) { | 279 | if ( temp->getIsLocalFileSync() ) { |
280 | switch(mTargetApp) | 280 | switch(mTargetApp) |
281 | { | 281 | { |
282 | case (KAPI): | 282 | case (KAPI): |
283 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 283 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
284 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 284 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
285 | break; | 285 | break; |
286 | case (KOPI): | 286 | case (KOPI): |
287 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 287 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
288 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 288 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
289 | break; | 289 | break; |
290 | case (PWMPI): | 290 | case (PWMPI): |
291 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 291 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
292 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 292 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
293 | break; | 293 | break; |
294 | default: | 294 | default: |
295 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 295 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
296 | break; | 296 | break; |
297 | 297 | ||
298 | } | 298 | } |
299 | } else { | 299 | } else { |
300 | if ( temp->getIsPhoneSync() ) { | 300 | if ( temp->getIsPhoneSync() ) { |
301 | mPhoneDevice = temp->getPhoneDevice( ) ; | 301 | mPhoneDevice = temp->getPhoneDevice( ) ; |
302 | mPhoneConnection = temp->getPhoneConnection( ); | 302 | mPhoneConnection = temp->getPhoneConnection( ); |
303 | mPhoneModel = temp->getPhoneModel( ); | 303 | mPhoneModel = temp->getPhoneModel( ); |
304 | syncPhone(); | 304 | syncPhone(); |
305 | } else if ( temp->getIsPiSync() ) { | 305 | } else if ( temp->getIsPiSync() ) { |
306 | if ( mTargetApp == KAPI ) { | 306 | if ( mTargetApp == KAPI ) { |
307 | mPassWordPiSync = temp->getRemotePwAB(); | 307 | mPassWordPiSync = temp->getRemotePwAB(); |
308 | mActiveSyncPort = temp->getRemotePortAB(); | 308 | mActiveSyncPort = temp->getRemotePortAB(); |
309 | mActiveSyncIP = temp->getRemoteIPAB(); | 309 | mActiveSyncIP = temp->getRemoteIPAB(); |
310 | } else if ( mTargetApp == KOPI ) { | 310 | } else if ( mTargetApp == KOPI ) { |
311 | mPassWordPiSync = temp->getRemotePw(); | 311 | mPassWordPiSync = temp->getRemotePw(); |
312 | mActiveSyncPort = temp->getRemotePort(); | 312 | mActiveSyncPort = temp->getRemotePort(); |
313 | mActiveSyncIP = temp->getRemoteIP(); | 313 | mActiveSyncIP = temp->getRemoteIP(); |
314 | } else { | 314 | } else { |
315 | mPassWordPiSync = temp->getRemotePwPWM(); | 315 | mPassWordPiSync = temp->getRemotePwPWM(); |
316 | mActiveSyncPort = temp->getRemotePortPWM(); | 316 | mActiveSyncPort = temp->getRemotePortPWM(); |
317 | mActiveSyncIP = temp->getRemoteIPPWM(); | 317 | mActiveSyncIP = temp->getRemoteIPPWM(); |
318 | } | 318 | } |
319 | syncPi(); | 319 | syncPi(); |
320 | while ( !mPisyncFinished ) { | 320 | while ( !mPisyncFinished ) { |
321 | //qDebug("waiting "); | 321 | //qDebug("waiting "); |
322 | qApp->processEvents(); | 322 | qApp->processEvents(); |
323 | } | 323 | } |
324 | } else | 324 | } else |
325 | syncRemote( temp ); | 325 | syncRemote( temp ); |
326 | 326 | ||
327 | } | 327 | } |
328 | } | 328 | } |
329 | delete temp; | 329 | delete temp; |
330 | setBlockSave(false); | 330 | setBlockSave(false); |
331 | } | 331 | } |
332 | 332 | ||
333 | void KSyncManager::enableQuick( bool ask ) | 333 | void KSyncManager::enableQuick( bool ask ) |
334 | { | 334 | { |
335 | bool autoStart; | 335 | bool autoStart; |
336 | bool changed = false; | 336 | bool changed = false; |
337 | if ( ask ) { | 337 | if ( ask ) { |
338 | QDialog dia ( 0, "input-dialog", true ); | 338 | QDialog dia ( 0, "input-dialog", true ); |
339 | QLineEdit lab ( &dia ); | 339 | QLineEdit lab ( &dia ); |
340 | QVBoxLayout lay( &dia ); | 340 | QVBoxLayout lay( &dia ); |
341 | lab.setText( mPrefs->mPassiveSyncPort ); | 341 | lab.setText( mPrefs->mPassiveSyncPort ); |
342 | lay.setMargin(7); | 342 | lay.setMargin(7); |
343 | lay.setSpacing(7); | 343 | lay.setSpacing(7); |
344 | int po = 9197+mTargetApp; | 344 | int po = 9197+mTargetApp; |
345 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); | 345 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); |
346 | lay.addWidget( &label); | 346 | lay.addWidget( &label); |
347 | lay.addWidget( &lab); | 347 | lay.addWidget( &lab); |
348 | 348 | ||
349 | QLineEdit lepw ( &dia ); | 349 | QLineEdit lepw ( &dia ); |
350 | lepw.setText( mPrefs->mPassiveSyncPw ); | 350 | lepw.setText( mPrefs->mPassiveSyncPw ); |
351 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 351 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
352 | lay.addWidget( &label2); | 352 | lay.addWidget( &label2); |
353 | lay.addWidget( &lepw); | 353 | lay.addWidget( &lepw); |
354 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); | 354 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); |
355 | lay.addWidget( &autostart); | 355 | lay.addWidget( &autostart); |
356 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); | 356 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); |
357 | #ifdef DESKTOP_VERSION | 357 | #ifdef DESKTOP_VERSION |
358 | #ifdef _WIN32_ | 358 | #ifdef _WIN32_ |
359 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); | 359 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); |
360 | syncdesktop.hide();// not implemented! | 360 | syncdesktop.hide();// not implemented! |
361 | #else | 361 | #else |
362 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); | 362 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); |
363 | #endif | 363 | #endif |
364 | lay.addWidget( &syncdesktop); | 364 | lay.addWidget( &syncdesktop); |
365 | #else | 365 | #else |
366 | mPrefs->mPassiveSyncWithDesktop = false; | 366 | mPrefs->mPassiveSyncWithDesktop = false; |
367 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); | 367 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); |
368 | syncdesktop.hide(); | 368 | syncdesktop.hide(); |
369 | #endif | 369 | #endif |
370 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); | 370 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); |
371 | 371 | ||
372 | dia.setFixedSize( 230,120 ); | 372 | dia.setFixedSize( 230,120 ); |
373 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 373 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
374 | QPushButton pb ( "OK", &dia); | 374 | QPushButton pb ( "OK", &dia); |
375 | lay.addWidget( &pb ); | 375 | lay.addWidget( &pb ); |
376 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 376 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
377 | dia.show(); | 377 | dia.show(); |
378 | if ( ! dia.exec() ) | 378 | if ( ! dia.exec() ) |
379 | return; | 379 | return; |
380 | dia.hide(); | 380 | dia.hide(); |
381 | qApp->processEvents(); | 381 | qApp->processEvents(); |
382 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { | 382 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { |
383 | changed = true; | 383 | changed = true; |
384 | mPrefs->mPassiveSyncPw = lepw.text(); | 384 | mPrefs->mPassiveSyncPw = lepw.text(); |
385 | } | 385 | } |
386 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { | 386 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { |
387 | mPrefs->mPassiveSyncPort = lab.text(); | 387 | mPrefs->mPassiveSyncPort = lab.text(); |
388 | changed = true; | 388 | changed = true; |
389 | } | 389 | } |
390 | autoStart = autostart.isChecked(); | 390 | autoStart = autostart.isChecked(); |
391 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { | 391 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { |
392 | changed = true; | 392 | changed = true; |
393 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); | 393 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); |
394 | } | 394 | } |
395 | } | 395 | } |
396 | else | 396 | else |
397 | autoStart = mPrefs->mPassiveSyncAutoStart; | 397 | autoStart = mPrefs->mPassiveSyncAutoStart; |
398 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) | 398 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) |
399 | changed = true; | 399 | changed = true; |
400 | bool ok; | 400 | bool ok; |
401 | mPrefs->mPassiveSyncAutoStart = false; | 401 | mPrefs->mPassiveSyncAutoStart = false; |
402 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); | 402 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); |
403 | if ( ! ok ) { | 403 | if ( ! ok ) { |
404 | KMessageBox::information( 0, i18n("No valid port")); | 404 | KMessageBox::information( 0, i18n("No valid port")); |
405 | return; | 405 | return; |
406 | } | 406 | } |
407 | //qDebug("port %d ", port); | 407 | //qDebug("port %d ", port); |
408 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); | 408 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); |
409 | mServerSocket->setFileName( defaultFileName() );//bbb | 409 | mServerSocket->setFileName( defaultFileName() );//bbb |
410 | //qDebug("connected "); | 410 | //qDebug("connected "); |
411 | if ( !mServerSocket->ok() ) { | 411 | if ( !mServerSocket->ok() ) { |
412 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); | 412 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); |
413 | delete mServerSocket; | 413 | delete mServerSocket; |
414 | mServerSocket = 0; | 414 | mServerSocket = 0; |
415 | return; | 415 | return; |
416 | } | 416 | } |
417 | mPrefs->mPassiveSyncAutoStart = autoStart; | 417 | mPrefs->mPassiveSyncAutoStart = autoStart; |
418 | if ( changed ) { | 418 | if ( changed ) { |
419 | mPrefs->writeConfig(); | 419 | mPrefs->writeConfig(); |
420 | } | 420 | } |
421 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); | 421 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); |
422 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); | 422 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); |
423 | } | 423 | } |
424 | 424 | ||
425 | void KSyncManager::syncLocalFile() | 425 | void KSyncManager::syncLocalFile() |
426 | { | 426 | { |
427 | 427 | ||
428 | QString fn =mPrefs->mLastSyncedLocalFile; | 428 | QString fn =mPrefs->mLastSyncedLocalFile; |
429 | QString ext; | 429 | QString ext; |
430 | 430 | ||
431 | switch(mTargetApp) | 431 | switch(mTargetApp) |
432 | { | 432 | { |
433 | case (KAPI): | 433 | case (KAPI): |
434 | ext = "(*.vcf)"; | 434 | ext = "(*.vcf)"; |
435 | break; | 435 | break; |
436 | case (KOPI): | 436 | case (KOPI): |
437 | ext = "(*.ics/*.vcs)"; | 437 | ext = "(*.ics/*.vcs)"; |
438 | break; | 438 | break; |
439 | case (PWMPI): | 439 | case (PWMPI): |
440 | ext = "(*.pwm)"; | 440 | ext = "(*.pwm)"; |
441 | break; | 441 | break; |
442 | default: | 442 | default: |
443 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); | 443 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); |
444 | break; | 444 | break; |
445 | 445 | ||
446 | } | 446 | } |
447 | 447 | ||
448 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 448 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
449 | if ( fn == "" ) | 449 | if ( fn == "" ) |
450 | return; | 450 | return; |
451 | if ( syncWithFile( fn, false ) ) { | 451 | if ( syncWithFile( fn, false ) ) { |
452 | qDebug("syncLocalFile() successful "); | 452 | qDebug("syncLocalFile() successful "); |
453 | } | 453 | } |
454 | 454 | ||
455 | } | 455 | } |
456 | 456 | ||
457 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 457 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
458 | { | 458 | { |
459 | bool ret = false; | 459 | bool ret = false; |
460 | QFileInfo info; | 460 | QFileInfo info; |
461 | info.setFile( fn ); | 461 | info.setFile( fn ); |
462 | QString mess; | 462 | QString mess; |
463 | bool loadbup = true; | 463 | bool loadbup = true; |
464 | if ( !info. exists() ) { | 464 | if ( !info. exists() ) { |
465 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 465 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
466 | int result = QMessageBox::warning( mParent, i18n("Warning!"), | 466 | int result = QMessageBox::warning( mParent, i18n("Warning!"), |
467 | mess ); | 467 | mess ); |
468 | return ret; | 468 | return ret; |
469 | } | 469 | } |
470 | int result = 0; | 470 | int result = 0; |
471 | if ( !quick ) { | 471 | if ( !quick ) { |
472 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 472 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
473 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 473 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
474 | mess, | 474 | mess, |
475 | i18n("Sync"), i18n("Cancel"), 0, | 475 | i18n("Sync"), i18n("Cancel"), 0, |
476 | 0, 1 ); | 476 | 0, 1 ); |
477 | if ( result ) | 477 | if ( result ) |
478 | return false; | 478 | return false; |
479 | } | 479 | } |
480 | if ( mAskForPreferences ) | 480 | if ( mAskForPreferences ) |
481 | if ( !edit_sync_options()) { | 481 | if ( !edit_sync_options()) { |
482 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 482 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
483 | return false; | 483 | return false; |
484 | } | 484 | } |
485 | if ( result == 0 ) { | 485 | if ( result == 0 ) { |
486 | //qDebug("Now sycing ... "); | 486 | //qDebug("Now sycing ... "); |
487 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) | 487 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
488 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); | 488 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
489 | else | 489 | else |
490 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 490 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
491 | if ( ! quick ) | 491 | if ( ! quick ) |
492 | mPrefs->mLastSyncedLocalFile = fn; | 492 | mPrefs->mLastSyncedLocalFile = fn; |
493 | } | 493 | } |
494 | return ret; | 494 | return ret; |
495 | } | 495 | } |
496 | 496 | ||
497 | void KSyncManager::quickSyncLocalFile() | 497 | void KSyncManager::quickSyncLocalFile() |
498 | { | 498 | { |
499 | 499 | ||
500 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { | 500 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { |
501 | qDebug("quick syncLocalFile() successful "); | 501 | qDebug("quick syncLocalFile() successful "); |
502 | 502 | ||
503 | } | 503 | } |
504 | } | 504 | } |
505 | 505 | ||
506 | void KSyncManager::multiSync( bool askforPrefs ) | 506 | void KSyncManager::multiSync( bool askforPrefs ) |
507 | { | 507 | { |
508 | if (blockSave()) | 508 | if (blockSave()) |
509 | return; | 509 | return; |
510 | setBlockSave(true); | 510 | setBlockSave(true); |
511 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 511 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
512 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), | 512 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), |
513 | question, | 513 | question, |
514 | i18n("Yes"), i18n("No"), | 514 | i18n("Yes"), i18n("No"), |
515 | 0, 0 ) != 0 ) { | 515 | 0, 0 ) != 0 ) { |
516 | setBlockSave(false); | 516 | setBlockSave(false); |
517 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); | 517 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
518 | return; | 518 | return; |
519 | } | 519 | } |
520 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 520 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
521 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 521 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; |
522 | if ( askforPrefs ) { | 522 | if ( askforPrefs ) { |
523 | if ( !edit_sync_options()) { | 523 | if ( !edit_sync_options()) { |
524 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); | 524 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); |
525 | return; | 525 | return; |
526 | } | 526 | } |
527 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 527 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
528 | } | 528 | } |
529 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); | 529 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
530 | qApp->processEvents(); | 530 | qApp->processEvents(); |
531 | int num = ringSync() ; | 531 | int num = ringSync() ; |
532 | if ( num > 1 ) | 532 | if ( num > 1 ) |
533 | ringSync(); | 533 | ringSync(); |
534 | setBlockSave(false); | 534 | setBlockSave(false); |
535 | if ( num ) | 535 | if ( num ) |
536 | emit save(); | 536 | emit save(); |
537 | if ( num ) | 537 | if ( num ) |
538 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); | 538 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); |
539 | else | 539 | else |
540 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 540 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
541 | return; | 541 | return; |
542 | } | 542 | } |
543 | 543 | ||
544 | int KSyncManager::ringSync() | 544 | int KSyncManager::ringSync() |
545 | { | 545 | { |
546 | 546 | ||
547 | int syncedProfiles = 0; | 547 | int syncedProfiles = 0; |
548 | unsigned int i; | 548 | unsigned int i; |
549 | QTime timer; | 549 | QTime timer; |
550 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 550 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
551 | QStringList syncProfileNames = mSyncProfileNames; | 551 | QStringList syncProfileNames = mSyncProfileNames; |
552 | KSyncProfile* temp = new KSyncProfile (); | 552 | KSyncProfile* temp = new KSyncProfile (); |
553 | mAskForPreferences = false; | 553 | mAskForPreferences = false; |
554 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 554 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
555 | mCurrentSyncProfile = i; | 555 | mCurrentSyncProfile = i; |
556 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 556 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
557 | temp->readConfig(&config); | 557 | temp->readConfig(&config); |
558 | 558 | ||
559 | bool includeInRingSync; | 559 | bool includeInRingSync; |
560 | switch(mTargetApp) | 560 | switch(mTargetApp) |
561 | { | 561 | { |
562 | case (KAPI): | 562 | case (KAPI): |
563 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 563 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
564 | break; | 564 | break; |
565 | case (KOPI): | 565 | case (KOPI): |
566 | includeInRingSync = temp->getIncludeInRingSync(); | 566 | includeInRingSync = temp->getIncludeInRingSync(); |
567 | break; | 567 | break; |
568 | case (PWMPI): | 568 | case (PWMPI): |
569 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 569 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
570 | break; | 570 | break; |
571 | default: | 571 | default: |
572 | qDebug("KSyncManager::ringSync: invalid apptype selected"); | 572 | qDebug("KSyncManager::ringSync: invalid apptype selected"); |
573 | break; | 573 | break; |
574 | 574 | ||
575 | } | 575 | } |
576 | 576 | ||
577 | 577 | ||
578 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 578 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
579 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 579 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
580 | ++syncedProfiles; | 580 | ++syncedProfiles; |
581 | mSyncWithDesktop = false; | 581 | mSyncWithDesktop = false; |
582 | // mAskForPreferences = temp->getAskForPreferences(); | 582 | // mAskForPreferences = temp->getAskForPreferences(); |
583 | mWriteBackFile = temp->getWriteBackFile(); | 583 | mWriteBackFile = temp->getWriteBackFile(); |
584 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 584 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
585 | mIsKapiFile = temp->getIsKapiFile(); | 585 | mIsKapiFile = temp->getIsKapiFile(); |
586 | mWriteBackInFuture = 0; | 586 | mWriteBackInFuture = 0; |
587 | if ( temp->getWriteBackFuture() ) { | 587 | if ( temp->getWriteBackFuture() ) { |
588 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 588 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
589 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 589 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
590 | } | 590 | } |
591 | mFilterInCal = temp->getFilterInCal(); | 591 | mFilterInCal = temp->getFilterInCal(); |
592 | mFilterOutCal = temp->getFilterOutCal(); | 592 | mFilterOutCal = temp->getFilterOutCal(); |
593 | mFilterInAB = temp->getFilterInAB(); | 593 | mFilterInAB = temp->getFilterInAB(); |
594 | mFilterOutAB = temp->getFilterOutAB(); | 594 | mFilterOutAB = temp->getFilterOutAB(); |
595 | mShowSyncSummary = false; | 595 | mShowSyncSummary = false; |
596 | mCurrentSyncDevice = syncProfileNames[i] ; | 596 | mCurrentSyncDevice = syncProfileNames[i] ; |
597 | mCurrentSyncName = mLocalMachineName; | 597 | mCurrentSyncName = mLocalMachineName; |
598 | if ( i == 0 ) { | 598 | if ( i == 0 ) { |
599 | mIsKapiFile = false; | 599 | mIsKapiFile = false; |
600 | #ifdef DESKTOP_VERSION | 600 | #ifdef DESKTOP_VERSION |
601 | syncKDE(); | 601 | syncKDE(); |
602 | #else | 602 | #else |
603 | syncSharp(); | 603 | syncSharp(); |
604 | #endif | 604 | #endif |
605 | } else { | 605 | } else { |
606 | if ( temp->getIsLocalFileSync() ) { | 606 | if ( temp->getIsLocalFileSync() ) { |
607 | switch(mTargetApp) | 607 | switch(mTargetApp) |
608 | { | 608 | { |
609 | case (KAPI): | 609 | case (KAPI): |
610 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 610 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
611 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 611 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
612 | break; | 612 | break; |
613 | case (KOPI): | 613 | case (KOPI): |
614 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 614 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
615 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 615 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
616 | break; | 616 | break; |
617 | case (PWMPI): | 617 | case (PWMPI): |
618 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 618 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
619 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 619 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
620 | break; | 620 | break; |
621 | default: | 621 | default: |
622 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 622 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
623 | break; | 623 | break; |
624 | } | 624 | } |
625 | } else { | 625 | } else { |
626 | if ( temp->getIsPhoneSync() ) { | 626 | if ( temp->getIsPhoneSync() ) { |
627 | mPhoneDevice = temp->getPhoneDevice( ) ; | 627 | mPhoneDevice = temp->getPhoneDevice( ) ; |
628 | mPhoneConnection = temp->getPhoneConnection( ); | 628 | mPhoneConnection = temp->getPhoneConnection( ); |
629 | mPhoneModel = temp->getPhoneModel( ); | 629 | mPhoneModel = temp->getPhoneModel( ); |
630 | syncPhone(); | 630 | syncPhone(); |
631 | } else if ( temp->getIsPiSync() ) { | 631 | } else if ( temp->getIsPiSync() ) { |
632 | if ( mTargetApp == KAPI ) { | 632 | if ( mTargetApp == KAPI ) { |
633 | mPassWordPiSync = temp->getRemotePwAB(); | 633 | mPassWordPiSync = temp->getRemotePwAB(); |
634 | mActiveSyncPort = temp->getRemotePortAB(); | 634 | mActiveSyncPort = temp->getRemotePortAB(); |
635 | mActiveSyncIP = temp->getRemoteIPAB(); | 635 | mActiveSyncIP = temp->getRemoteIPAB(); |
636 | } else if ( mTargetApp == KOPI ) { | 636 | } else if ( mTargetApp == KOPI ) { |
637 | mPassWordPiSync = temp->getRemotePw(); | 637 | mPassWordPiSync = temp->getRemotePw(); |
638 | mActiveSyncPort = temp->getRemotePort(); | 638 | mActiveSyncPort = temp->getRemotePort(); |
639 | mActiveSyncIP = temp->getRemoteIP(); | 639 | mActiveSyncIP = temp->getRemoteIP(); |
640 | } else { | 640 | } else { |
641 | mPassWordPiSync = temp->getRemotePwPWM(); | 641 | mPassWordPiSync = temp->getRemotePwPWM(); |
642 | mActiveSyncPort = temp->getRemotePortPWM(); | 642 | mActiveSyncPort = temp->getRemotePortPWM(); |
643 | mActiveSyncIP = temp->getRemoteIPPWM(); | 643 | mActiveSyncIP = temp->getRemoteIPPWM(); |
644 | } | 644 | } |
645 | syncPi(); | 645 | syncPi(); |
646 | while ( !mPisyncFinished ) { | 646 | while ( !mPisyncFinished ) { |
647 | //qDebug("waiting "); | 647 | //qDebug("waiting "); |
648 | qApp->processEvents(); | 648 | qApp->processEvents(); |
649 | } | 649 | } |
650 | timer.start(); | 650 | timer.start(); |
651 | while ( timer.elapsed () < 2000 ) { | 651 | while ( timer.elapsed () < 2000 ) { |
652 | qApp->processEvents(); | 652 | qApp->processEvents(); |
653 | } | 653 | } |
654 | } else | 654 | } else |
655 | syncRemote( temp, false ); | 655 | syncRemote( temp, false ); |
656 | 656 | ||
657 | } | 657 | } |
658 | } | 658 | } |
659 | timer.start(); | 659 | timer.start(); |
660 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 660 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
661 | while ( timer.elapsed () < 2000 ) { | 661 | while ( timer.elapsed () < 2000 ) { |
662 | qApp->processEvents(); | 662 | qApp->processEvents(); |
663 | #ifndef _WIN32_ | 663 | #ifndef _WIN32_ |
664 | sleep (1); | 664 | sleep (1); |
665 | #endif | 665 | #endif |
666 | } | 666 | } |
667 | 667 | ||
668 | } | 668 | } |
669 | 669 | ||
670 | } | 670 | } |
671 | delete temp; | 671 | delete temp; |
672 | return syncedProfiles; | 672 | return syncedProfiles; |
673 | } | 673 | } |
674 | 674 | ||
675 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | 675 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) |
676 | { | 676 | { |
677 | QString question; | 677 | QString question; |
678 | if ( ask ) { | 678 | if ( ask ) { |
679 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 679 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
680 | if ( QMessageBox::information( mParent, i18n("Sync"), | 680 | if ( QMessageBox::information( mParent, i18n("Sync"), |
681 | question, | 681 | question, |
682 | i18n("Yes"), i18n("No"), | 682 | i18n("Yes"), i18n("No"), |
683 | 0, 0 ) != 0 ) | 683 | 0, 0 ) != 0 ) |
684 | return; | 684 | return; |
685 | } | 685 | } |
686 | 686 | ||
687 | QString preCommand; | 687 | QString preCommand; |
688 | QString localTempFile; | 688 | QString localTempFile; |
689 | QString postCommand; | 689 | QString postCommand; |
690 | 690 | ||
691 | switch(mTargetApp) | 691 | switch(mTargetApp) |
692 | { | 692 | { |
693 | case (KAPI): | 693 | case (KAPI): |
694 | preCommand = prof->getPreSyncCommandAB(); | 694 | preCommand = prof->getPreSyncCommandAB(); |
695 | postCommand = prof->getPostSyncCommandAB(); | 695 | postCommand = prof->getPostSyncCommandAB(); |
696 | localTempFile = prof->getLocalTempFileAB(); | 696 | localTempFile = prof->getLocalTempFileAB(); |
697 | break; | 697 | break; |
698 | case (KOPI): | 698 | case (KOPI): |
699 | preCommand = prof->getPreSyncCommand(); | 699 | preCommand = prof->getPreSyncCommand(); |
700 | postCommand = prof->getPostSyncCommand(); | 700 | postCommand = prof->getPostSyncCommand(); |
701 | localTempFile = prof->getLocalTempFile(); | 701 | localTempFile = prof->getLocalTempFile(); |
702 | break; | 702 | break; |
703 | case (PWMPI): | 703 | case (PWMPI): |
704 | preCommand = prof->getPreSyncCommandPWM(); | 704 | preCommand = prof->getPreSyncCommandPWM(); |
705 | postCommand = prof->getPostSyncCommandPWM(); | 705 | postCommand = prof->getPostSyncCommandPWM(); |
706 | localTempFile = prof->getLocalTempFilePWM(); | 706 | localTempFile = prof->getLocalTempFilePWM(); |
707 | break; | 707 | break; |
708 | default: | 708 | default: |
709 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); | 709 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); |
710 | break; | 710 | break; |
711 | } | 711 | } |
712 | 712 | ||
713 | 713 | ||
714 | int fi; | 714 | int fi; |
715 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { | 715 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { |
716 | QString pwd = getPassword(); | 716 | QString pwd = getPassword(); |
717 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); | 717 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); |
718 | 718 | ||
719 | } | 719 | } |
720 | int maxlen = 30; | 720 | int maxlen = 30; |
721 | if ( QApplication::desktop()->width() > 320 ) | 721 | if ( QApplication::desktop()->width() > 320 ) |
722 | maxlen += 25; | 722 | maxlen += 25; |
723 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); | 723 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); |
724 | int fileSize = 0; | 724 | int fileSize = 0; |
725 | int result = system ( preCommand ); | 725 | int result = system ( preCommand ); |
726 | // 0 : okay | 726 | // 0 : okay |
727 | // 256: no such file or dir | 727 | // 256: no such file or dir |
728 | // | 728 | // |
729 | qDebug("Sync: Remote copy result(0 = okay): %d ",result ); | 729 | qDebug("Sync: Remote copy result(0 = okay): %d ",result ); |
730 | if ( result != 0 ) { | 730 | if ( result != 0 ) { |
731 | unsigned int len = maxlen; | 731 | unsigned int len = maxlen; |
732 | while ( len < preCommand.length() ) { | 732 | while ( len < preCommand.length() ) { |
733 | preCommand.insert( len , "\n" ); | 733 | preCommand.insert( len , "\n" ); |
734 | len += maxlen +2; | 734 | len += maxlen +2; |
735 | } | 735 | } |
736 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; | 736 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; |
737 | QMessageBox::information( mParent, i18n("Sync - ERROR"), | 737 | QMessageBox::information( mParent, i18n("Sync - ERROR"), |
738 | question, | 738 | question, |
739 | i18n("Okay!")) ; | 739 | i18n("Okay!")) ; |
740 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); | 740 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); |
741 | return; | 741 | return; |
742 | } | 742 | } |
743 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); | 743 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); |
744 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 744 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
745 | 745 | ||
746 | if ( syncWithFile( localTempFile, true ) ) { | 746 | if ( syncWithFile( localTempFile, true ) ) { |
747 | 747 | ||
748 | if ( mWriteBackFile ) { | 748 | if ( mWriteBackFile ) { |
749 | int fi; | 749 | int fi; |
750 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { | 750 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { |
751 | QString pwd = getPassword(); | 751 | QString pwd = getPassword(); |
752 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); | 752 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); |
753 | 753 | ||
754 | } | 754 | } |
755 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); | 755 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); |
756 | result = system ( postCommand ); | 756 | result = system ( postCommand ); |
757 | qDebug("Sync:Writing back file result: %d ", result); | 757 | qDebug("Sync:Writing back file result: %d ", result); |
758 | if ( result != 0 ) { | 758 | if ( result != 0 ) { |
759 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 759 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
760 | return; | 760 | return; |
761 | } else { | 761 | } else { |
762 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 762 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
763 | } | 763 | } |
764 | } | 764 | } |
765 | } | 765 | } |
766 | return; | 766 | return; |
767 | } | 767 | } |
768 | bool KSyncManager::edit_pisync_options() | 768 | bool KSyncManager::edit_pisync_options() |
769 | { | 769 | { |
770 | QDialog dia( mParent, "dia", true ); | 770 | QDialog dia( mParent, "dia", true ); |
771 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); | 771 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); |
772 | QVBoxLayout lay ( &dia ); | 772 | QVBoxLayout lay ( &dia ); |
773 | lay.setSpacing( 5 ); | 773 | lay.setSpacing( 5 ); |
774 | lay.setMargin( 3 ); | 774 | lay.setMargin( 3 ); |
775 | QLabel lab1 ( i18n("Password for remote access:"), &dia); | 775 | QLabel lab1 ( i18n("Password for remote access:"), &dia); |
776 | lay.addWidget( &lab1 ); | 776 | lay.addWidget( &lab1 ); |
777 | QLineEdit le1 (&dia ); | 777 | QLineEdit le1 (&dia ); |
778 | lay.addWidget( &le1 ); | 778 | lay.addWidget( &le1 ); |
779 | QLabel lab2 ( i18n("Remote IP address:"), &dia); | 779 | QLabel lab2 ( i18n("Remote IP address:"), &dia); |
780 | lay.addWidget( &lab2 ); | 780 | lay.addWidget( &lab2 ); |
781 | QLineEdit le2 (&dia ); | 781 | QLineEdit le2 (&dia ); |
782 | lay.addWidget( &le2 ); | 782 | lay.addWidget( &le2 ); |
783 | QLabel lab3 ( i18n("Remote port number:"), &dia); | 783 | QLabel lab3 ( i18n("Remote port number:"), &dia); |
784 | lay.addWidget( &lab3 ); | 784 | lay.addWidget( &lab3 ); |
785 | QLineEdit le3 (&dia ); | 785 | QLineEdit le3 (&dia ); |
786 | lay.addWidget( &le3 ); | 786 | lay.addWidget( &le3 ); |
787 | QPushButton pb ( "OK", &dia); | 787 | QPushButton pb ( "OK", &dia); |
788 | lay.addWidget( &pb ); | 788 | lay.addWidget( &pb ); |
789 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 789 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
790 | le1.setText( mPassWordPiSync ); | 790 | le1.setText( mPassWordPiSync ); |
791 | le2.setText( mActiveSyncIP ); | 791 | le2.setText( mActiveSyncIP ); |
792 | le3.setText( mActiveSyncPort ); | 792 | le3.setText( mActiveSyncPort ); |
793 | if ( dia.exec() ) { | 793 | if ( dia.exec() ) { |
794 | mPassWordPiSync = le1.text(); | 794 | mPassWordPiSync = le1.text(); |
795 | mActiveSyncPort = le3.text(); | 795 | mActiveSyncPort = le3.text(); |
796 | mActiveSyncIP = le2.text(); | 796 | mActiveSyncIP = le2.text(); |
797 | return true; | 797 | return true; |
798 | } | 798 | } |
799 | return false; | 799 | return false; |
800 | } | 800 | } |
801 | bool KSyncManager::edit_sync_options() | 801 | bool KSyncManager::edit_sync_options() |
802 | { | 802 | { |
803 | 803 | ||
804 | QDialog dia( mParent, "dia", true ); | 804 | QDialog dia( mParent, "dia", true ); |
805 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 805 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
806 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 806 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
807 | QVBoxLayout lay ( &dia ); | 807 | QVBoxLayout lay ( &dia ); |
808 | lay.setSpacing( 2 ); | 808 | lay.setSpacing( 2 ); |
809 | lay.setMargin( 3 ); | 809 | lay.setMargin( 3 ); |
810 | lay.addWidget(&gr); | 810 | lay.addWidget(&gr); |
811 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 811 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
812 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 812 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
813 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 813 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
814 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 814 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
815 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 815 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
816 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 816 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
817 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 817 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
818 | QPushButton pb ( "OK", &dia); | 818 | QPushButton pb ( "OK", &dia); |
819 | lay.addWidget( &pb ); | 819 | lay.addWidget( &pb ); |
820 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 820 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
821 | switch ( mSyncAlgoPrefs ) { | 821 | switch ( mSyncAlgoPrefs ) { |
822 | case 0: | 822 | case 0: |
823 | loc.setChecked( true); | 823 | loc.setChecked( true); |
824 | break; | 824 | break; |
825 | case 1: | 825 | case 1: |
826 | rem.setChecked( true ); | 826 | rem.setChecked( true ); |
827 | break; | 827 | break; |
828 | case 2: | 828 | case 2: |
829 | newest.setChecked( true); | 829 | newest.setChecked( true); |
830 | break; | 830 | break; |
831 | case 3: | 831 | case 3: |
832 | ask.setChecked( true); | 832 | ask.setChecked( true); |
833 | break; | 833 | break; |
834 | case 4: | 834 | case 4: |
835 | f_loc.setChecked( true); | 835 | f_loc.setChecked( true); |
836 | break; | 836 | break; |
837 | case 5: | 837 | case 5: |
838 | f_rem.setChecked( true); | 838 | f_rem.setChecked( true); |
839 | break; | 839 | break; |
840 | case 6: | 840 | case 6: |
841 | // both.setChecked( true); | 841 | // both.setChecked( true); |
842 | break; | 842 | break; |
843 | default: | 843 | default: |
844 | break; | 844 | break; |
845 | } | 845 | } |
846 | if ( dia.exec() ) { | 846 | if ( dia.exec() ) { |
847 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 847 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
848 | return true; | 848 | return true; |
849 | } | 849 | } |
850 | return false; | 850 | return false; |
851 | } | 851 | } |
852 | 852 | ||
853 | QString KSyncManager::getPassword( ) | 853 | QString KSyncManager::getPassword( ) |
854 | { | 854 | { |
855 | QString retfile = ""; | 855 | QString retfile = ""; |
856 | QDialog dia ( mParent, "input-dialog", true ); | 856 | QDialog dia ( mParent, "input-dialog", true ); |
857 | QLineEdit lab ( &dia ); | 857 | QLineEdit lab ( &dia ); |
858 | lab.setEchoMode( QLineEdit::Password ); | 858 | lab.setEchoMode( QLineEdit::Password ); |
859 | QVBoxLayout lay( &dia ); | 859 | QVBoxLayout lay( &dia ); |
860 | lay.setMargin(7); | 860 | lay.setMargin(7); |
861 | lay.setSpacing(7); | 861 | lay.setSpacing(7); |
862 | lay.addWidget( &lab); | 862 | lay.addWidget( &lab); |
863 | dia.setFixedSize( 230,50 ); | 863 | dia.setFixedSize( 230,50 ); |
864 | dia.setCaption( i18n("Enter password") ); | 864 | dia.setCaption( i18n("Enter password") ); |
865 | QPushButton pb ( "OK", &dia); | 865 | QPushButton pb ( "OK", &dia); |
866 | lay.addWidget( &pb ); | 866 | lay.addWidget( &pb ); |
867 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 867 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
868 | dia.show(); | 868 | dia.show(); |
869 | int res = dia.exec(); | 869 | int res = dia.exec(); |
870 | if ( res ) | 870 | if ( res ) |
871 | retfile = lab.text(); | 871 | retfile = lab.text(); |
872 | dia.hide(); | 872 | dia.hide(); |
873 | qApp->processEvents(); | 873 | qApp->processEvents(); |
874 | return retfile; | 874 | return retfile; |
875 | 875 | ||
876 | } | 876 | } |
877 | 877 | ||
878 | 878 | ||
879 | void KSyncManager::confSync() | 879 | void KSyncManager::confSync() |
880 | { | 880 | { |
881 | static KSyncPrefsDialog* sp = 0; | 881 | static KSyncPrefsDialog* sp = 0; |
882 | if ( ! sp ) { | 882 | if ( ! sp ) { |
883 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 883 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
884 | } | 884 | } |
885 | sp->usrReadConfig(); | 885 | sp->usrReadConfig(); |
886 | #ifndef DESKTOP_VERSION | 886 | #ifndef DESKTOP_VERSION |
887 | sp->showMaximized(); | 887 | sp->showMaximized(); |
888 | #else | 888 | #else |
889 | sp->show(); | 889 | sp->show(); |
890 | #endif | 890 | #endif |
891 | sp->exec(); | 891 | sp->exec(); |
892 | QStringList oldSyncProfileNames = mSyncProfileNames; | 892 | QStringList oldSyncProfileNames = mSyncProfileNames; |
893 | mSyncProfileNames = sp->getSyncProfileNames(); | 893 | mSyncProfileNames = sp->getSyncProfileNames(); |
894 | mLocalMachineName = sp->getLocalMachineName (); | 894 | mLocalMachineName = sp->getLocalMachineName (); |
895 | int ii; | 895 | int ii; |
896 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { | 896 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { |
897 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) | 897 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) |
898 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); | 898 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); |
899 | } | 899 | } |
900 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 900 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
901 | } | 901 | } |
902 | void KSyncManager::syncKDE() | 902 | void KSyncManager::syncKDE() |
903 | { | 903 | { |
904 | mSyncWithDesktop = true; | 904 | mSyncWithDesktop = true; |
905 | emit save(); | 905 | emit save(); |
906 | switch(mTargetApp) | 906 | switch(mTargetApp) |
907 | { | 907 | { |
908 | case (KAPI): | 908 | case (KAPI): |
909 | { | 909 | { |
910 | #ifdef DESKTOP_VERSION | 910 | #ifdef DESKTOP_VERSION |
911 | QString command = qApp->applicationDirPath () + "/kdeabdump"; | 911 | QString command = qApp->applicationDirPath () + "/kdeabdump"; |
912 | #else | 912 | #else |
913 | QString command = "kdeabdump"; | 913 | QString command = "kdeabdump"; |
914 | #endif | 914 | #endif |
915 | if ( ! QFile::exists ( command ) ) | 915 | if ( ! QFile::exists ( command ) ) |
916 | command = "kdeabdump"; | 916 | command = "kdeabdump"; |
917 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; | 917 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; |
918 | system ( command.latin1()); | 918 | system ( command.latin1()); |
919 | if ( syncWithFile( fileName,true ) ) { | 919 | if ( syncWithFile( fileName,true ) ) { |
920 | if ( mWriteBackFile ) { | 920 | if ( mWriteBackFile ) { |
921 | command += " --read"; | 921 | command += " --read"; |
922 | system ( command.latin1()); | 922 | system ( command.latin1()); |
923 | } | 923 | } |
924 | } | 924 | } |
925 | 925 | ||
926 | } | 926 | } |
927 | break; | 927 | break; |
928 | case (KOPI): | 928 | case (KOPI): |
929 | { | 929 | { |
930 | #ifdef DESKTOP_VERSION | 930 | #ifdef DESKTOP_VERSION |
931 | QString command = qApp->applicationDirPath () + "/kdecaldump"; | 931 | QString command = qApp->applicationDirPath () + "/kdecaldump"; |
932 | #else | 932 | #else |
933 | QString command = "kdecaldump"; | 933 | QString command = "kdecaldump"; |
934 | #endif | 934 | #endif |
935 | if ( ! QFile::exists ( command ) ) | 935 | if ( ! QFile::exists ( command ) ) |
936 | command = "kdecaldump"; | 936 | command = "kdecaldump"; |
937 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | 937 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; |
938 | system ( command.latin1()); | 938 | system ( command.latin1()); |
939 | if ( syncWithFile( fileName,true ) ) { | 939 | if ( syncWithFile( fileName,true ) ) { |
940 | if ( mWriteBackFile ) { | 940 | if ( mWriteBackFile ) { |
941 | command += " --read"; | 941 | command += " --read"; |
942 | system ( command.latin1()); | 942 | system ( command.latin1()); |
943 | } | 943 | } |
944 | } | 944 | } |
945 | 945 | ||
946 | } | 946 | } |
947 | break; | 947 | break; |
948 | case (PWMPI): | 948 | case (PWMPI): |
949 | 949 | ||
950 | break; | 950 | break; |
951 | default: | 951 | default: |
952 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 952 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
953 | break; | 953 | break; |
954 | 954 | ||
955 | } | 955 | } |
956 | } | 956 | } |
957 | 957 | ||
958 | void KSyncManager::syncSharp() | 958 | void KSyncManager::syncSharp() |
959 | { | 959 | { |
960 | 960 | ||
961 | if ( ! syncExternalApplication("sharp") ) | 961 | if ( ! syncExternalApplication("sharp") ) |
962 | qDebug("ERROR sync sharp "); | 962 | qDebug("ERROR sync sharp "); |
963 | } | 963 | } |
964 | 964 | ||
965 | bool KSyncManager::syncExternalApplication(QString resource) | 965 | bool KSyncManager::syncExternalApplication(QString resource) |
966 | { | 966 | { |
967 | 967 | ||
968 | emit save(); | 968 | emit save(); |
969 | 969 | ||
970 | if ( mAskForPreferences ) | 970 | if ( mAskForPreferences ) |
971 | if ( !edit_sync_options()) { | 971 | if ( !edit_sync_options()) { |
972 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 972 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
973 | return false; | 973 | return false; |
974 | } | 974 | } |
975 | 975 | ||
976 | qDebug("Sync extern %s", resource.latin1()); | 976 | qDebug("Sync extern %s", resource.latin1()); |
977 | 977 | ||
978 | bool syncOK = mImplementation->syncExternal(this, resource); | 978 | bool syncOK = mImplementation->syncExternal(this, resource); |
979 | 979 | ||
980 | return syncOK; | 980 | return syncOK; |
981 | 981 | ||
982 | } | 982 | } |
983 | 983 | ||
984 | void KSyncManager::syncPhone() | 984 | void KSyncManager::syncPhone() |
985 | { | 985 | { |
986 | 986 | ||
987 | syncExternalApplication("phone"); | 987 | syncExternalApplication("phone"); |
988 | 988 | ||
989 | } | 989 | } |
990 | 990 | ||
991 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 991 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
992 | { | 992 | { |
993 | if (!bar->isVisible()) | 993 | if (!bar->isVisible()) |
994 | { | 994 | { |
995 | bar->setCaption (caption); | 995 | bar->setCaption (caption); |
996 | bar->setTotalSteps ( total ) ; | 996 | bar->setTotalSteps ( total ) ; |
997 | |||
998 | bar->show(); | 997 | bar->show(); |
999 | } | 998 | } |
1000 | 999 | bar->raise(); | |
1001 | bar->setProgress( percentage ); | 1000 | bar->setProgress( percentage ); |
1001 | qApp->processEvents(); | ||
1002 | } | 1002 | } |
1003 | 1003 | ||
1004 | void KSyncManager::hideProgressBar() | 1004 | void KSyncManager::hideProgressBar() |
1005 | { | 1005 | { |
1006 | bar->hide(); | 1006 | bar->hide(); |
1007 | qApp->processEvents(); | ||
1007 | } | 1008 | } |
1008 | 1009 | ||
1009 | bool KSyncManager::isProgressBarCanceled() | 1010 | bool KSyncManager::isProgressBarCanceled() |
1010 | { | 1011 | { |
1011 | return !bar->isVisible(); | 1012 | return !bar->isVisible(); |
1012 | } | 1013 | } |
1013 | 1014 | ||
1014 | QString KSyncManager::syncFileName() | 1015 | QString KSyncManager::syncFileName() |
1015 | { | 1016 | { |
1016 | 1017 | ||
1017 | QString fn = "tempfile"; | 1018 | QString fn = "tempfile"; |
1018 | switch(mTargetApp) | 1019 | switch(mTargetApp) |
1019 | { | 1020 | { |
1020 | case (KAPI): | 1021 | case (KAPI): |
1021 | fn = "tempsyncab.vcf"; | 1022 | fn = "tempsyncab.vcf"; |
1022 | break; | 1023 | break; |
1023 | case (KOPI): | 1024 | case (KOPI): |
1024 | fn = "tempsynccal.ics"; | 1025 | fn = "tempsynccal.ics"; |
1025 | break; | 1026 | break; |
1026 | case (PWMPI): | 1027 | case (PWMPI): |
1027 | fn = "tempsyncpw.pwm"; | 1028 | fn = "tempsyncpw.pwm"; |
1028 | break; | 1029 | break; |
1029 | default: | 1030 | default: |
1030 | break; | 1031 | break; |
1031 | } | 1032 | } |
1032 | #ifdef _WIN32_ | 1033 | #ifdef _WIN32_ |
1033 | return locateLocal( "tmp", fn ); | 1034 | return locateLocal( "tmp", fn ); |
1034 | #else | 1035 | #else |
1035 | return (QString( "/tmp/" )+ fn ); | 1036 | return (QString( "/tmp/" )+ fn ); |
1036 | #endif | 1037 | #endif |
1037 | } | 1038 | } |
1038 | 1039 | ||
1039 | void KSyncManager::syncPi() | 1040 | void KSyncManager::syncPi() |
1040 | { | 1041 | { |
1041 | mIsKapiFile = true; | 1042 | mIsKapiFile = true; |
1042 | mPisyncFinished = false; | 1043 | mPisyncFinished = false; |
1043 | qApp->processEvents(); | 1044 | qApp->processEvents(); |
1044 | if ( mAskForPreferences ) | 1045 | if ( mAskForPreferences ) |
1045 | if ( !edit_pisync_options()) { | 1046 | if ( !edit_pisync_options()) { |
1046 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 1047 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
1047 | return; | 1048 | return; |
1048 | } | 1049 | } |
1049 | bool ok; | 1050 | bool ok; |
1050 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 1051 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
1051 | if ( ! ok ) { | 1052 | if ( ! ok ) { |
1052 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 1053 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
1053 | return; | 1054 | return; |
1054 | } | 1055 | } |
1055 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); | 1056 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); |
1056 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 1057 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
1057 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); | 1058 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); |
1058 | commandSocket->readFile( syncFileName() ); | 1059 | commandSocket->readFile( syncFileName() ); |
1059 | } | 1060 | } |
1060 | 1061 | ||
1061 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 1062 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
1062 | { | 1063 | { |
1063 | //enum { success, errorW, errorR, quiet }; | 1064 | //enum { success, errorW, errorR, quiet }; |
1064 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { | 1065 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { |
1065 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 1066 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
1066 | delete s; | 1067 | delete s; |
1067 | if ( state == KCommandSocket::errorR ) { | 1068 | if ( state == KCommandSocket::errorR ) { |
1068 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 1069 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
1069 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1070 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1070 | commandSocket->sendStop(); | 1071 | commandSocket->sendStop(); |
1071 | } | 1072 | } |
1072 | mPisyncFinished = true; | 1073 | mPisyncFinished = true; |
1073 | return; | 1074 | return; |
1074 | 1075 | ||
1075 | } else if ( state == KCommandSocket::errorW ) { | 1076 | } else if ( state == KCommandSocket::errorW ) { |
1076 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); | 1077 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); |
1077 | mPisyncFinished = true; | 1078 | mPisyncFinished = true; |
1078 | 1079 | ||
1079 | } else if ( state == KCommandSocket::successR ) { | 1080 | } else if ( state == KCommandSocket::successR ) { |
1080 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 1081 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
1081 | 1082 | ||
1082 | } else if ( state == KCommandSocket::successW ) { | 1083 | } else if ( state == KCommandSocket::successW ) { |
1083 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 1084 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
1084 | mPisyncFinished = true; | 1085 | mPisyncFinished = true; |
1085 | } | 1086 | } |
1086 | 1087 | ||
1087 | delete s; | 1088 | delete s; |
1088 | } | 1089 | } |
1089 | 1090 | ||
1090 | void KSyncManager::readFileFromSocket() | 1091 | void KSyncManager::readFileFromSocket() |
1091 | { | 1092 | { |
1092 | QString fileName = syncFileName(); | 1093 | QString fileName = syncFileName(); |
1093 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); | 1094 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); |
1094 | if ( ! syncWithFile( fileName , true ) ) { | 1095 | if ( ! syncWithFile( fileName , true ) ) { |
1095 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); | 1096 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); |
1096 | mPisyncFinished = true; | 1097 | mPisyncFinished = true; |
1097 | return; | 1098 | return; |
1098 | } | 1099 | } |
1099 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 1100 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
1100 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1101 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1101 | if ( mWriteBackFile ) | 1102 | if ( mWriteBackFile ) |
1102 | commandSocket->writeFile( fileName ); | 1103 | commandSocket->writeFile( fileName ); |
1103 | else { | 1104 | else { |
1104 | commandSocket->sendStop(); | 1105 | commandSocket->sendStop(); |
1105 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 1106 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
1106 | mPisyncFinished = true; | 1107 | mPisyncFinished = true; |
1107 | } | 1108 | } |
1108 | } | 1109 | } |
1109 | 1110 | ||
1110 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 1111 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
1111 | { | 1112 | { |
1112 | mPassWord = pw; | 1113 | mPassWord = pw; |
1113 | mSocket = 0; | 1114 | mSocket = 0; |
1114 | mSyncActionDialog = 0; | 1115 | mSyncActionDialog = 0; |
1115 | blockRC = false; | 1116 | blockRC = false; |
1116 | }; | 1117 | }; |
1117 | 1118 | ||
1118 | void KServerSocket::newConnection ( int socket ) | 1119 | void KServerSocket::newConnection ( int socket ) |
1119 | { | 1120 | { |
1120 | // qDebug("KServerSocket:New connection %d ", socket); | 1121 | // qDebug("KServerSocket:New connection %d ", socket); |
1121 | if ( mSocket ) { | 1122 | if ( mSocket ) { |
1122 | qDebug("KServerSocket::newConnection Socket deleted! "); | 1123 | qDebug("KServerSocket::newConnection Socket deleted! "); |
1123 | delete mSocket; | 1124 | delete mSocket; |
1124 | mSocket = 0; | 1125 | mSocket = 0; |
1125 | } | 1126 | } |
1126 | mSocket = new QSocket( this ); | 1127 | mSocket = new QSocket( this ); |
1127 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 1128 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
1128 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 1129 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
1129 | mSocket->setSocket( socket ); | 1130 | mSocket->setSocket( socket ); |
1130 | } | 1131 | } |
1131 | 1132 | ||
1132 | void KServerSocket::discardClient() | 1133 | void KServerSocket::discardClient() |
1133 | { | 1134 | { |
1134 | //qDebug(" KServerSocket::discardClient()"); | 1135 | //qDebug(" KServerSocket::discardClient()"); |
1135 | if ( mSocket ) { | 1136 | if ( mSocket ) { |
1136 | delete mSocket; | 1137 | delete mSocket; |
1137 | mSocket = 0; | 1138 | mSocket = 0; |
1138 | } | 1139 | } |
1139 | //emit endConnect(); | 1140 | //emit endConnect(); |
1140 | } | 1141 | } |
1141 | void KServerSocket::readClient() | 1142 | void KServerSocket::readClient() |
1142 | { | 1143 | { |
1143 | if ( blockRC ) | 1144 | if ( blockRC ) |
1144 | return; | 1145 | return; |
1145 | if ( mSocket == 0 ) { | 1146 | if ( mSocket == 0 ) { |
1146 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); | 1147 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); |
1147 | return; | 1148 | return; |
1148 | } | 1149 | } |
1149 | //qDebug("KServerSocket::readClient()"); | 1150 | //qDebug("KServerSocket::readClient()"); |
1150 | if ( mSocket->canReadLine() ) { | 1151 | if ( mSocket->canReadLine() ) { |
1151 | QString line = mSocket->readLine(); | 1152 | QString line = mSocket->readLine(); |
1152 | //qDebug("KServerSocket readline: %s ", line.latin1()); | 1153 | //qDebug("KServerSocket readline: %s ", line.latin1()); |
1153 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); | 1154 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); |
1154 | if ( tokens[0] == "GET" ) { | 1155 | if ( tokens[0] == "GET" ) { |
1155 | if ( tokens[1] == mPassWord ) { | 1156 | if ( tokens[1] == mPassWord ) { |
1156 | //emit sendFile( mSocket ); | 1157 | //emit sendFile( mSocket ); |
1157 | bool ok = false; | 1158 | bool ok = false; |
1158 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); | 1159 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); |
1159 | if ( ok ) { | 1160 | if ( ok ) { |
1160 | KSyncManager::mRequestedSyncEvent = dt; | 1161 | KSyncManager::mRequestedSyncEvent = dt; |
1161 | } | 1162 | } |
1162 | else | 1163 | else |
1163 | KSyncManager::mRequestedSyncEvent = QDateTime(); | 1164 | KSyncManager::mRequestedSyncEvent = QDateTime(); |
1164 | send_file(); | 1165 | send_file(); |
1165 | } | 1166 | } |
1166 | else { | 1167 | else { |
1167 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); | 1168 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); |
1168 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 1169 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
1169 | } | 1170 | } |
1170 | } | 1171 | } |
1171 | if ( tokens[0] == "PUT" ) { | 1172 | if ( tokens[0] == "PUT" ) { |
1172 | if ( tokens[1] == mPassWord ) { | 1173 | if ( tokens[1] == mPassWord ) { |
1173 | //emit getFile( mSocket ); | 1174 | //emit getFile( mSocket ); |
1174 | blockRC = true; | 1175 | blockRC = true; |
1175 | get_file(); | 1176 | get_file(); |
1176 | } | 1177 | } |
1177 | else { | 1178 | else { |
1178 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); | 1179 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); |
1179 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 1180 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
1180 | } | 1181 | } |
1181 | } | 1182 | } |
1182 | if ( tokens[0] == "STOP" ) { | 1183 | if ( tokens[0] == "STOP" ) { |
1183 | //emit endConnect(); | 1184 | //emit endConnect(); |
1184 | end_connect(); | 1185 | end_connect(); |
1185 | } | 1186 | } |
1186 | } | 1187 | } |
1187 | } | 1188 | } |
1188 | void KServerSocket::end_connect() | 1189 | void KServerSocket::end_connect() |
1189 | { | 1190 | { |
1190 | delete mSyncActionDialog; | 1191 | delete mSyncActionDialog; |
1191 | mSyncActionDialog = 0; | 1192 | mSyncActionDialog = 0; |
1192 | } | 1193 | } |
1193 | void KServerSocket::send_file() | 1194 | void KServerSocket::send_file() |
1194 | { | 1195 | { |
1195 | //qDebug("MainWindow::sendFile(QSocket* s) "); | 1196 | //qDebug("MainWindow::sendFile(QSocket* s) "); |
1196 | if ( mSyncActionDialog ) | 1197 | if ( mSyncActionDialog ) |
1197 | delete mSyncActionDialog; | 1198 | delete mSyncActionDialog; |
1198 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | 1199 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); |
1199 | mSyncActionDialog->setCaption(i18n("Received sync request")); | 1200 | mSyncActionDialog->setCaption(i18n("Received sync request")); |
1200 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); | 1201 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); |
1201 | label->setAlignment ( Qt::AlignHCenter ); | 1202 | label->setAlignment ( Qt::AlignHCenter ); |
1202 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 1203 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
1203 | lay->addWidget( label); | 1204 | lay->addWidget( label); |
1204 | lay->setMargin(7); | 1205 | lay->setMargin(7); |
1205 | lay->setSpacing(7); | 1206 | lay->setSpacing(7); |
1206 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1207 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1207 | int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); | 1208 | int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); |
1208 | if ( secs < 0 ) | 1209 | if ( secs < 0 ) |
1209 | secs = secs * (-1); | 1210 | secs = secs * (-1); |
1210 | if ( secs > 30 ) | 1211 | if ( secs > 30 ) |
1211 | //if ( true ) | 1212 | //if ( true ) |
1212 | { | 1213 | { |
1213 | QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); | 1214 | QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); |
1214 | QLabel* label = new QLabel( warning, mSyncActionDialog ); | 1215 | QLabel* label = new QLabel( warning, mSyncActionDialog ); |
1215 | label->setAlignment ( Qt::AlignHCenter ); | 1216 | label->setAlignment ( Qt::AlignHCenter ); |
1216 | lay->addWidget( label); | 1217 | lay->addWidget( label); |
1217 | if ( secs > 180 ) | 1218 | if ( secs > 180 ) |
1218 | { | 1219 | { |
1219 | if ( secs > 300 ) { | 1220 | if ( secs > 300 ) { |
1220 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\n of more than 5 minutes.\nPlease adjust your clocks.\n<b>You may get wrong syncing results!<\b>\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { | 1221 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\n of more than 5 minutes.\nPlease adjust your clocks.\n<b>You may get wrong syncing results!<\b>\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { |
1221 | qDebug("cancelled "); | 1222 | qDebug("cancelled "); |
1222 | return ; | 1223 | return ; |
1223 | } | 1224 | } |
1224 | } | 1225 | } |
1225 | QFont f = label->font(); | 1226 | QFont f = label->font(); |
1226 | f.setPointSize ( f.pointSize() *2 ); | 1227 | f.setPointSize ( f.pointSize() *2 ); |
1227 | f. setBold (true ); | 1228 | f. setBold (true ); |
1228 | QLabel* label = new QLabel( warning, mSyncActionDialog ); | 1229 | QLabel* label = new QLabel( warning, mSyncActionDialog ); |
1229 | label->setFont( f ); | 1230 | label->setFont( f ); |
1230 | warning = i18n("ADJUST\nYOUR\nCLOCKS!"); | 1231 | warning = i18n("ADJUST\nYOUR\nCLOCKS!"); |
1231 | label->setText( warning ); | 1232 | label->setText( warning ); |
1232 | label->setAlignment ( Qt::AlignHCenter ); | 1233 | label->setAlignment ( Qt::AlignHCenter ); |
1233 | lay->addWidget( label); | 1234 | lay->addWidget( label); |
1234 | mSyncActionDialog->setFixedSize( 230, 300); | 1235 | mSyncActionDialog->setFixedSize( 230, 300); |
1235 | } else { | 1236 | } else { |
1236 | mSyncActionDialog->setFixedSize( 230, 200); | 1237 | mSyncActionDialog->setFixedSize( 230, 200); |
1237 | } | 1238 | } |
1238 | } else { | 1239 | } else { |
1239 | mSyncActionDialog->setFixedSize( 230, 120); | 1240 | mSyncActionDialog->setFixedSize( 230, 120); |
1240 | } | 1241 | } |
1241 | } else | 1242 | } else |
1242 | mSyncActionDialog->setFixedSize( 230, 120); | 1243 | mSyncActionDialog->setFixedSize( 230, 120); |
1243 | mSyncActionDialog->show(); | 1244 | mSyncActionDialog->show(); |
1244 | mSyncActionDialog->raise(); | 1245 | mSyncActionDialog->raise(); |
1245 | emit request_file(); | 1246 | emit request_file(); |
1246 | qApp->processEvents(); | 1247 | qApp->processEvents(); |
1247 | QString fileName = mFileName; | 1248 | QString fileName = mFileName; |
1248 | QFile file( fileName ); | 1249 | QFile file( fileName ); |
1249 | if (!file.open( IO_ReadOnly ) ) { | 1250 | if (!file.open( IO_ReadOnly ) ) { |
1250 | delete mSyncActionDialog; | 1251 | delete mSyncActionDialog; |
1251 | mSyncActionDialog = 0; | 1252 | mSyncActionDialog = 0; |
1252 | qDebug("KSS::error open sync file: %s ", fileName.latin1()); | 1253 | qDebug("KSS::error open sync file: %s ", fileName.latin1()); |
1253 | mSocket->close(); | 1254 | mSocket->close(); |
1254 | if ( mSocket->state() == QSocket::Idle ) | 1255 | if ( mSocket->state() == QSocket::Idle ) |
1255 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1256 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1256 | return ; | 1257 | return ; |
1257 | 1258 | ||
1258 | } | 1259 | } |
1259 | mSyncActionDialog->setCaption( i18n("Sending file...") ); | 1260 | mSyncActionDialog->setCaption( i18n("Sending file...") ); |
1260 | QTextStream ts( &file ); | 1261 | QTextStream ts( &file ); |
1261 | ts.setEncoding( QTextStream::Latin1 ); | 1262 | ts.setEncoding( QTextStream::Latin1 ); |
1262 | 1263 | ||
1263 | QTextStream os( mSocket ); | 1264 | QTextStream os( mSocket ); |
1264 | os.setEncoding( QTextStream::Latin1 ); | 1265 | os.setEncoding( QTextStream::Latin1 ); |
1265 | while ( ! ts.atEnd() ) { | 1266 | while ( ! ts.atEnd() ) { |
1266 | os << ts.readLine() << "\r\n"; | 1267 | os << ts.readLine() << "\r\n"; |
1267 | } | 1268 | } |
1268 | //os << ts.read(); | 1269 | //os << ts.read(); |
1269 | file.close(); | 1270 | file.close(); |
1270 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | 1271 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); |
1271 | mSocket->close(); | 1272 | mSocket->close(); |
1272 | if ( mSocket->state() == QSocket::Idle ) | 1273 | if ( mSocket->state() == QSocket::Idle ) |
1273 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1274 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1274 | } | 1275 | } |
1275 | void KServerSocket::get_file() | 1276 | void KServerSocket::get_file() |
1276 | { | 1277 | { |
1277 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | 1278 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); |
1278 | 1279 | ||
1279 | piTime.start(); | 1280 | piTime.start(); |
1280 | piFileString = ""; | 1281 | piFileString = ""; |
1281 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | 1282 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); |
1282 | } | 1283 | } |
1283 | 1284 | ||
1284 | 1285 | ||
1285 | void KServerSocket::readBackFileFromSocket() | 1286 | void KServerSocket::readBackFileFromSocket() |
1286 | { | 1287 | { |
1287 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | 1288 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); |
1288 | while ( mSocket->canReadLine () ) { | 1289 | while ( mSocket->canReadLine () ) { |
1289 | piTime.restart(); | 1290 | piTime.restart(); |
1290 | QString line = mSocket->readLine (); | 1291 | QString line = mSocket->readLine (); |
1291 | piFileString += line; | 1292 | piFileString += line; |
1292 | //qDebug("readline: %s ", line.latin1()); | 1293 | //qDebug("readline: %s ", line.latin1()); |
1293 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | 1294 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); |
1294 | 1295 | ||
1295 | } | 1296 | } |
1296 | if ( piTime.elapsed () < 3000 ) { | 1297 | if ( piTime.elapsed () < 3000 ) { |
1297 | // wait for more | 1298 | // wait for more |
1298 | //qDebug("waitformore "); | 1299 | //qDebug("waitformore "); |
1299 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | 1300 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); |
1300 | return; | 1301 | return; |
1301 | } | 1302 | } |
1302 | QString fileName = mFileName; | 1303 | QString fileName = mFileName; |
1303 | QFile file ( fileName ); | 1304 | QFile file ( fileName ); |
1304 | if (!file.open( IO_WriteOnly ) ) { | 1305 | if (!file.open( IO_WriteOnly ) ) { |
1305 | delete mSyncActionDialog; | 1306 | delete mSyncActionDialog; |
1306 | mSyncActionDialog = 0; | 1307 | mSyncActionDialog = 0; |
1307 | qDebug("KSS:Error open read back file "); | 1308 | qDebug("KSS:Error open read back file "); |
1308 | piFileString = ""; | 1309 | piFileString = ""; |
1309 | emit file_received( false ); | 1310 | emit file_received( false ); |
1310 | blockRC = false; | 1311 | blockRC = false; |
1311 | return ; | 1312 | return ; |
1312 | 1313 | ||
1313 | } | 1314 | } |
1314 | 1315 | ||
1315 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1316 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1316 | QTextStream ts ( &file ); | 1317 | QTextStream ts ( &file ); |
1317 | ts.setEncoding( QTextStream::Latin1 ); | 1318 | ts.setEncoding( QTextStream::Latin1 ); |
1318 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | 1319 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); |
1319 | ts << piFileString; | 1320 | ts << piFileString; |
1320 | mSocket->close(); | 1321 | mSocket->close(); |
1321 | if ( mSocket->state() == QSocket::Idle ) | 1322 | if ( mSocket->state() == QSocket::Idle ) |
1322 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1323 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1323 | file.close(); | 1324 | file.close(); |
1324 | piFileString = ""; | 1325 | piFileString = ""; |
1325 | emit file_received( true ); | 1326 | emit file_received( true ); |
1326 | delete mSyncActionDialog; | 1327 | delete mSyncActionDialog; |
1327 | mSyncActionDialog = 0; | 1328 | mSyncActionDialog = 0; |
1328 | blockRC = false; | 1329 | blockRC = false; |
1329 | 1330 | ||
1330 | } | 1331 | } |
1331 | 1332 | ||
1332 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) | 1333 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) |
1333 | { | 1334 | { |
1334 | mPassWord = password; | 1335 | mPassWord = password; |
1335 | mSocket = 0; | 1336 | mSocket = 0; |
1336 | mPort = port; | 1337 | mPort = port; |
1337 | mHost = host; | 1338 | mHost = host; |
1338 | 1339 | ||
1339 | mRetVal = quiet; | 1340 | mRetVal = quiet; |
1340 | mTimerSocket = new QTimer ( this ); | 1341 | mTimerSocket = new QTimer ( this ); |
1341 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); | 1342 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); |
1342 | } | 1343 | } |
1343 | void KCommandSocket::readFile( QString fn ) | 1344 | void KCommandSocket::readFile( QString fn ) |
1344 | { | 1345 | { |
1345 | if ( !mSocket ) { | 1346 | if ( !mSocket ) { |
1346 | mSocket = new QSocket( this ); | 1347 | mSocket = new QSocket( this ); |
1347 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | 1348 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); |
1348 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1349 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1349 | } | 1350 | } |
1350 | mFileString = ""; | 1351 | mFileString = ""; |
1351 | mFileName = fn; | 1352 | mFileName = fn; |
1352 | mFirst = true; | 1353 | mFirst = true; |
1353 | mSocket->connectToHost( mHost, mPort ); | 1354 | mSocket->connectToHost( mHost, mPort ); |
1354 | QTextStream os( mSocket ); | 1355 | QTextStream os( mSocket ); |
1355 | os.setEncoding( QTextStream::Latin1 ); | 1356 | os.setEncoding( QTextStream::Latin1 ); |
1356 | 1357 | ||
1357 | QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); | 1358 | QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); |
1358 | os << "GET " << mPassWord << curDt <<"\r\n"; | 1359 | os << "GET " << mPassWord << curDt <<"\r\n"; |
1359 | mTimerSocket->start( 300000 ); | 1360 | mTimerSocket->start( 300000 ); |
1360 | } | 1361 | } |
1361 | 1362 | ||
1362 | void KCommandSocket::writeFile( QString fileName ) | 1363 | void KCommandSocket::writeFile( QString fileName ) |
1363 | { | 1364 | { |
1364 | if ( !mSocket ) { | 1365 | if ( !mSocket ) { |
1365 | mSocket = new QSocket( this ); | 1366 | mSocket = new QSocket( this ); |
1366 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1367 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1367 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); | 1368 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); |
1368 | } | 1369 | } |
1369 | mFileName = fileName ; | 1370 | mFileName = fileName ; |
1370 | mSocket->connectToHost( mHost, mPort ); | 1371 | mSocket->connectToHost( mHost, mPort ); |
1371 | } | 1372 | } |
1372 | void KCommandSocket::writeFileToSocket() | 1373 | void KCommandSocket::writeFileToSocket() |
1373 | { | 1374 | { |
1374 | QFile file2( mFileName ); | 1375 | QFile file2( mFileName ); |
1375 | if (!file2.open( IO_ReadOnly ) ) { | 1376 | if (!file2.open( IO_ReadOnly ) ) { |
1376 | mRetVal= errorW; | 1377 | mRetVal= errorW; |
1377 | mSocket->close(); | 1378 | mSocket->close(); |
1378 | if ( mSocket->state() == QSocket::Idle ) | 1379 | if ( mSocket->state() == QSocket::Idle ) |
1379 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1380 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1380 | return ; | 1381 | return ; |
1381 | } | 1382 | } |
1382 | QTextStream ts2( &file2 ); | 1383 | QTextStream ts2( &file2 ); |
1383 | ts2.setEncoding( QTextStream::Latin1 ); | 1384 | ts2.setEncoding( QTextStream::Latin1 ); |
1384 | QTextStream os2( mSocket ); | 1385 | QTextStream os2( mSocket ); |
1385 | os2.setEncoding( QTextStream::Latin1 ); | 1386 | os2.setEncoding( QTextStream::Latin1 ); |
1386 | os2 << "PUT " << mPassWord << "\r\n";; | 1387 | os2 << "PUT " << mPassWord << "\r\n";; |
1387 | while ( ! ts2.atEnd() ) { | 1388 | while ( ! ts2.atEnd() ) { |
1388 | os2 << ts2.readLine() << "\r\n"; | 1389 | os2 << ts2.readLine() << "\r\n"; |
1389 | } | 1390 | } |
1390 | mRetVal= successW; | 1391 | mRetVal= successW; |
1391 | file2.close(); | 1392 | file2.close(); |
1392 | mSocket->close(); | 1393 | mSocket->close(); |
1393 | if ( mSocket->state() == QSocket::Idle ) | 1394 | if ( mSocket->state() == QSocket::Idle ) |
1394 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1395 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1395 | } | 1396 | } |
1396 | void KCommandSocket::sendStop() | 1397 | void KCommandSocket::sendStop() |
1397 | { | 1398 | { |
1398 | if ( !mSocket ) { | 1399 | if ( !mSocket ) { |
1399 | mSocket = new QSocket( this ); | 1400 | mSocket = new QSocket( this ); |
1400 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1401 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1401 | } | 1402 | } |
1402 | mSocket->connectToHost( mHost, mPort ); | 1403 | mSocket->connectToHost( mHost, mPort ); |
1403 | QTextStream os2( mSocket ); | 1404 | QTextStream os2( mSocket ); |
1404 | os2.setEncoding( QTextStream::Latin1 ); | 1405 | os2.setEncoding( QTextStream::Latin1 ); |
1405 | os2 << "STOP\r\n"; | 1406 | os2 << "STOP\r\n"; |
1406 | mSocket->close(); | 1407 | mSocket->close(); |
1407 | if ( mSocket->state() == QSocket::Idle ) | 1408 | if ( mSocket->state() == QSocket::Idle ) |
1408 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1409 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1409 | } | 1410 | } |
1410 | 1411 | ||
1411 | void KCommandSocket::startReadFileFromSocket() | 1412 | void KCommandSocket::startReadFileFromSocket() |
1412 | { | 1413 | { |
1413 | if ( ! mFirst ) | 1414 | if ( ! mFirst ) |
1414 | return; | 1415 | return; |
1415 | mFirst = false; | 1416 | mFirst = false; |
1416 | mTimerSocket->stop(); | 1417 | mTimerSocket->stop(); |
1417 | mFileString = ""; | 1418 | mFileString = ""; |
1418 | mTime.start(); | 1419 | mTime.start(); |
1419 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | 1420 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); |
1420 | 1421 | ||
1421 | } | 1422 | } |
1422 | void KCommandSocket::readFileFromSocket() | 1423 | void KCommandSocket::readFileFromSocket() |
1423 | { | 1424 | { |
1424 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | 1425 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); |
1425 | while ( mSocket->canReadLine () ) { | 1426 | while ( mSocket->canReadLine () ) { |
1426 | mTime.restart(); | 1427 | mTime.restart(); |
1427 | QString line = mSocket->readLine (); | 1428 | QString line = mSocket->readLine (); |
1428 | mFileString += line; | 1429 | mFileString += line; |
1429 | //qDebug("readline: %s ", line.latin1()); | 1430 | //qDebug("readline: %s ", line.latin1()); |
1430 | } | 1431 | } |
1431 | if ( mTime.elapsed () < 3000 ) { | 1432 | if ( mTime.elapsed () < 3000 ) { |
1432 | // wait for more | 1433 | // wait for more |
1433 | //qDebug("waitformore "); | 1434 | //qDebug("waitformore "); |
1434 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); | 1435 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); |
1435 | return; | 1436 | return; |
1436 | } | 1437 | } |
1437 | QString fileName = mFileName; | 1438 | QString fileName = mFileName; |
1438 | QFile file ( fileName ); | 1439 | QFile file ( fileName ); |
1439 | if (!file.open( IO_WriteOnly ) ) { | 1440 | if (!file.open( IO_WriteOnly ) ) { |
1440 | mFileString = ""; | 1441 | mFileString = ""; |
1441 | mRetVal = errorR; | 1442 | mRetVal = errorR; |
1442 | qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); | 1443 | qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); |
1443 | deleteSocket(); | 1444 | deleteSocket(); |
1444 | return ; | 1445 | return ; |
1445 | 1446 | ||
1446 | } | 1447 | } |
1447 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1448 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1448 | QTextStream ts ( &file ); | 1449 | QTextStream ts ( &file ); |
1449 | ts.setEncoding( QTextStream::Latin1 ); | 1450 | ts.setEncoding( QTextStream::Latin1 ); |
1450 | ts << mFileString; | 1451 | ts << mFileString; |
1451 | file.close(); | 1452 | file.close(); |
1452 | mFileString = ""; | 1453 | mFileString = ""; |
1453 | mRetVal = successR; | 1454 | mRetVal = successR; |
1454 | mSocket->close(); | 1455 | mSocket->close(); |
1455 | // if state is not idle, deleteSocket(); is called via | 1456 | // if state is not idle, deleteSocket(); is called via |
1456 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1457 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1457 | if ( mSocket->state() == QSocket::Idle ) | 1458 | if ( mSocket->state() == QSocket::Idle ) |
1458 | deleteSocket(); | 1459 | deleteSocket(); |
1459 | } | 1460 | } |
1460 | 1461 | ||
1461 | void KCommandSocket::deleteSocket() | 1462 | void KCommandSocket::deleteSocket() |
1462 | { | 1463 | { |
1463 | //qDebug("KCommandSocket::deleteSocket() "); | 1464 | //qDebug("KCommandSocket::deleteSocket() "); |
1464 | if ( mTimerSocket->isActive () ) { | 1465 | if ( mTimerSocket->isActive () ) { |
1465 | mTimerSocket->stop(); | 1466 | mTimerSocket->stop(); |
1466 | mRetVal = errorTO; | 1467 | mRetVal = errorTO; |
1467 | qDebug("Connection to remote host timed out"); | 1468 | qDebug("Connection to remote host timed out"); |
1468 | if ( mSocket ) { | 1469 | if ( mSocket ) { |
1469 | mSocket->close(); | 1470 | mSocket->close(); |
1470 | //if ( mSocket->state() == QSocket::Idle ) | 1471 | //if ( mSocket->state() == QSocket::Idle ) |
1471 | // deleteSocket(); | 1472 | // deleteSocket(); |
1472 | delete mSocket; | 1473 | delete mSocket; |
1473 | mSocket = 0; | 1474 | mSocket = 0; |
1474 | } | 1475 | } |
1475 | KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | 1476 | KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); |
1476 | emit commandFinished( this, mRetVal ); | 1477 | emit commandFinished( this, mRetVal ); |
1477 | return; | 1478 | return; |
1478 | } | 1479 | } |
1479 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); | 1480 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); |
1480 | if ( mSocket) | 1481 | if ( mSocket) |
1481 | delete mSocket; | 1482 | delete mSocket; |
1482 | mSocket = 0; | 1483 | mSocket = 0; |
1483 | emit commandFinished( this, mRetVal ); | 1484 | emit commandFinished( this, mRetVal ); |
1484 | } | 1485 | } |
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp index 2101bbb..3db58ec 100644 --- a/libkdepim/ksyncprefsdialog.cpp +++ b/libkdepim/ksyncprefsdialog.cpp | |||
@@ -1,830 +1,830 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | 3 | Copyright (c) 2004 Lutz Rogowski <rogowski@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 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qlabel.h> | 25 | #include <qlabel.h> |
26 | #include <qgroupbox.h> | 26 | #include <qgroupbox.h> |
27 | #include <qbuttongroup.h> | 27 | #include <qbuttongroup.h> |
28 | #include <qlineedit.h> | 28 | #include <qlineedit.h> |
29 | #include <qfont.h> | 29 | #include <qfont.h> |
30 | #include <qslider.h> | 30 | #include <qslider.h> |
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qdir.h> | 32 | #include <qdir.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
35 | #include <qvbox.h> | 35 | #include <qvbox.h> |
36 | #include <qhbox.h> | 36 | #include <qhbox.h> |
37 | #include <qspinbox.h> | 37 | #include <qspinbox.h> |
38 | #include <qdatetime.h> | 38 | #include <qdatetime.h> |
39 | #include <qcheckbox.h> | 39 | #include <qcheckbox.h> |
40 | #include <qradiobutton.h> | 40 | #include <qradiobutton.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qstrlist.h> | 42 | #include <qstrlist.h> |
43 | #include <qapplication.h> | 43 | #include <qapplication.h> |
44 | #include <qlayout.h> | 44 | #include <qlayout.h> |
45 | #include <qscrollview.h> | 45 | #include <qscrollview.h> |
46 | #include <qvgroupbox.h> | 46 | #include <qvgroupbox.h> |
47 | #include <qhgroupbox.h> | 47 | #include <qhgroupbox.h> |
48 | 48 | ||
49 | #include <kcolorbutton.h> | 49 | #include <kcolorbutton.h> |
50 | #include <kdebug.h> | 50 | #include <kdebug.h> |
51 | #include <klocale.h> | 51 | #include <klocale.h> |
52 | #include <kglobal.h> | 52 | #include <kglobal.h> |
53 | #include <kfontdialog.h> | 53 | #include <kfontdialog.h> |
54 | #include <kmessagebox.h> | 54 | #include <kmessagebox.h> |
55 | #include <kcolordialog.h> | 55 | #include <kcolordialog.h> |
56 | #include <kiconloader.h> | 56 | #include <kiconloader.h> |
57 | #include <kemailsettings.h> | 57 | #include <kemailsettings.h> |
58 | #include <kstandarddirs.h> | 58 | #include <kstandarddirs.h> |
59 | #include <kfiledialog.h> | 59 | #include <kfiledialog.h> |
60 | #include <kmessagebox.h> | 60 | #include <kmessagebox.h> |
61 | 61 | ||
62 | //#include <kurlrequester.h> | 62 | //#include <kurlrequester.h> |
63 | #include <klineedit.h> | 63 | #include <klineedit.h> |
64 | #include "ksyncprofile.h" | 64 | #include "ksyncprofile.h" |
65 | 65 | ||
66 | 66 | ||
67 | //#include "koprefs.h" | 67 | //#include "koprefs.h" |
68 | 68 | ||
69 | #include "ksyncprefsdialog.h" | 69 | #include "ksyncprefsdialog.h" |
70 | //#include "koglobals.h" | 70 | //#include "koglobals.h" |
71 | 71 | ||
72 | 72 | ||
73 | KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) : | 73 | KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) : |
74 | KDialog(parent,name,true) | 74 | KDialog(parent,name,true) |
75 | { | 75 | { |
76 | 76 | ||
77 | setCaption( i18n("Synchronization Preferences")); | 77 | setCaption( i18n("Synchronization Preferences")); |
78 | 78 | ||
79 | mSyncProfiles.setAutoDelete( true ); | 79 | mSyncProfiles.setAutoDelete( true ); |
80 | setupSyncAlgTab(); | 80 | setupSyncAlgTab(); |
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | ||
84 | KSyncPrefsDialog::~KSyncPrefsDialog() | 84 | KSyncPrefsDialog::~KSyncPrefsDialog() |
85 | { | 85 | { |
86 | } | 86 | } |
87 | 87 | ||
88 | void KSyncPrefsDialog::setupSyncAlgTab() | 88 | void KSyncPrefsDialog::setupSyncAlgTab() |
89 | { | 89 | { |
90 | QLabel * lab; | 90 | QLabel * lab; |
91 | //QFrame *page = addPage(i18n("Sync Prefs"),0,0); | 91 | //QFrame *page = addPage(i18n("Sync Prefs"),0,0); |
92 | QVBox * mainbox = new QVBox( this ); | 92 | QVBox * mainbox = new QVBox( this ); |
93 | QScrollView* sv = new QScrollView( mainbox ); | 93 | QScrollView* sv = new QScrollView( mainbox ); |
94 | QHBoxLayout * lay = new QHBoxLayout( this ); | 94 | QHBoxLayout * lay = new QHBoxLayout( this ); |
95 | lay->addWidget( mainbox ); | 95 | lay->addWidget( mainbox ); |
96 | QHBox * b_box = new QHBox( mainbox ); | 96 | QHBox * b_box = new QHBox( mainbox ); |
97 | 97 | ||
98 | QPushButton* button = new QPushButton( i18n("Ok"), b_box ); | 98 | QPushButton* button = new QPushButton( i18n("Ok"), b_box ); |
99 | connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); | 99 | connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); |
100 | button = new QPushButton( i18n("Cancel"), b_box ); | 100 | button = new QPushButton( i18n("Cancel"), b_box ); |
101 | connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); | 101 | connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); |
102 | //QBoxLayout * sl = new QVBoxLayout(this ); | 102 | //QBoxLayout * sl = new QVBoxLayout(this ); |
103 | //sl->addWidget ( sv ); | 103 | //sl->addWidget ( sv ); |
104 | sv->setResizePolicy ( QScrollView::AutoOneFit ); | 104 | sv->setResizePolicy ( QScrollView::AutoOneFit ); |
105 | QFrame *topFrame = new QFrame ( sv ); | 105 | QFrame *topFrame = new QFrame ( sv ); |
106 | sv->addChild( topFrame ); | 106 | sv->addChild( topFrame ); |
107 | mSetupSyncAlgTab = topFrame; | 107 | mSetupSyncAlgTab = topFrame; |
108 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); | 108 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); |
109 | topLayout->setSpacing(spacingHint()); | 109 | topLayout->setSpacing(spacingHint()); |
110 | topLayout->setMargin(marginHint()); | 110 | topLayout->setMargin(marginHint()); |
111 | 111 | ||
112 | //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); | 112 | //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); |
113 | int iii = 0; | 113 | int iii = 0; |
114 | //topLayout->addMultiCellWidget(lab , iii,iii,0,1); | 114 | //topLayout->addMultiCellWidget(lab , iii,iii,0,1); |
115 | //++iii; | 115 | //++iii; |
116 | 116 | ||
117 | mMyMachineName = new QLineEdit(topFrame); | 117 | mMyMachineName = new QLineEdit(topFrame); |
118 | lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); | 118 | lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); |
119 | topLayout->addWidget(lab ,iii,0); | 119 | topLayout->addWidget(lab ,iii,0); |
120 | topLayout->addWidget(mMyMachineName,iii,1); | 120 | topLayout->addWidget(mMyMachineName,iii,1); |
121 | ++iii; | 121 | ++iii; |
122 | 122 | ||
123 | QHBox* buttonbox = new QHBox( topFrame); | 123 | QHBox* buttonbox = new QHBox( topFrame); |
124 | topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); | 124 | topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); |
125 | ++iii; | 125 | ++iii; |
126 | button = new QPushButton( i18n("New profile"), buttonbox ); | 126 | button = new QPushButton( i18n("New profile"), buttonbox ); |
127 | connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); | 127 | connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); |
128 | 128 | ||
129 | button = new QPushButton( i18n("Clone profile"), buttonbox ); | 129 | button = new QPushButton( i18n("Clone profile"), buttonbox ); |
130 | connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); | 130 | connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); |
131 | 131 | ||
132 | button = new QPushButton( i18n("Delete profile"), buttonbox ); | 132 | button = new QPushButton( i18n("Delete profile"), buttonbox ); |
133 | connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); | 133 | connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); |
134 | 134 | ||
135 | mProfileBox = new QComboBox(topFrame); | 135 | mProfileBox = new QComboBox(topFrame); |
136 | mProfileBox->setEditable ( true ); | 136 | mProfileBox->setEditable ( true ); |
137 | mProfileBox->setInsertionPolicy(QComboBox::NoInsertion); | 137 | mProfileBox->setInsertionPolicy(QComboBox::NoInsertion); |
138 | connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); | 138 | connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); |
139 | connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); | 139 | connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); |
140 | 140 | ||
141 | lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); | 141 | lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); |
142 | topLayout->addWidget(lab ,iii,0); | 142 | topLayout->addWidget(lab ,iii,0); |
143 | topLayout->addWidget(mProfileBox, iii,1); | 143 | topLayout->addWidget(mProfileBox, iii,1); |
144 | ++iii; | 144 | ++iii; |
145 | 145 | ||
146 | 146 | ||
147 | 147 | ||
148 | QHGroupBox *iims = new QHGroupBox( i18n("Multiple Sync options"), topFrame); | 148 | QHGroupBox *iims = new QHGroupBox( i18n("Multiple Sync options"), topFrame); |
149 | new QLabel( i18n("Include in multiple "), iims ); | 149 | new QLabel( i18n("Include in multiple "), iims ); |
150 | mIncludeInRing = new QCheckBox( i18n("calendar "), iims ); | 150 | mIncludeInRing = new QCheckBox( i18n("calendar "), iims ); |
151 | mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims ); | 151 | mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims ); |
152 | mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims ); | 152 | mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims ); |
153 | new QLabel( i18n(" sync"), iims ); | 153 | new QLabel( i18n(" sync"), iims ); |
154 | topLayout->addMultiCellWidget(iims, iii,iii,0,1); | 154 | topLayout->addMultiCellWidget(iims, iii,iii,0,1); |
155 | ++iii; | 155 | ++iii; |
156 | QVGroupBox* gb0 = new QVGroupBox( i18n("Sync algo options"), topFrame); | 156 | QVGroupBox* gb0 = new QVGroupBox( i18n("Sync algo options"), topFrame); |
157 | topLayout->addMultiCellWidget(gb0, iii,iii,0,1); | 157 | topLayout->addMultiCellWidget(gb0, iii,iii,0,1); |
158 | ++iii; | 158 | ++iii; |
159 | QButtonGroup* gr; | 159 | QButtonGroup* gr; |
160 | { | 160 | { |
161 | QVGroupBox* topFrame = gb0; | 161 | QVGroupBox* topFrame = gb0; |
162 | 162 | ||
163 | 163 | ||
164 | 164 | ||
165 | mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); | 165 | mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); |
166 | //topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); | 166 | //topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); |
167 | //++iii; | 167 | //++iii; |
168 | gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); | 168 | gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); |
169 | //topLayout->addMultiCellWidget(gr, iii,iii,0,1); | 169 | //topLayout->addMultiCellWidget(gr, iii,iii,0,1); |
170 | //++iii; | 170 | //++iii; |
171 | loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); | 171 | loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); |
172 | rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); | 172 | rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); |
173 | newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); | 173 | newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); |
174 | ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); | 174 | ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); |
175 | f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); | 175 | f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); |
176 | f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); | 176 | f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); |
177 | // both = new QRadioButton ( i18n("Take both on conflict"), gr ); | 177 | // both = new QRadioButton ( i18n("Take both on conflict"), gr ); |
178 | 178 | ||
179 | mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); | 179 | mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); |
180 | //topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); | 180 | //topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); |
181 | //++iii; | 181 | //++iii; |
182 | 182 | ||
183 | QHGroupBox* gb5 = new QHGroupBox( i18n("Apply filter when adding data to local:"), topFrame); | 183 | QHGroupBox* gb5 = new QHGroupBox( i18n("Apply filter when adding data to local:"), topFrame); |
184 | QVBox * fibo2 = new QVBox ( gb5 ); | 184 | QVBox * fibo2 = new QVBox ( gb5 ); |
185 | new QLabel ( i18n("Incoming calendar filter:"), fibo2 ); | 185 | new QLabel ( i18n("Incoming calendar filter:"), fibo2 ); |
186 | mFilterInCal = new QComboBox( fibo2 ); | 186 | mFilterInCal = new QComboBox( fibo2 ); |
187 | fibo2 = new QVBox ( gb5 ); | 187 | fibo2 = new QVBox ( gb5 ); |
188 | new QLabel ( i18n("Incoming adressbook filter:"), fibo2 ); | 188 | new QLabel ( i18n("Incoming addressbook filter:"), fibo2 ); |
189 | mFilterInAB = new QComboBox( fibo2 ); | 189 | mFilterInAB = new QComboBox( fibo2 ); |
190 | 190 | ||
191 | mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame ); | 191 | mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame ); |
192 | // topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); | 192 | // topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); |
193 | // ++iii; | 193 | // ++iii; |
194 | 194 | ||
195 | QVGroupBox* gb2 = new QVGroupBox( i18n("Write back options"), topFrame); | 195 | QVGroupBox* gb2 = new QVGroupBox( i18n("Write back options"), topFrame); |
196 | //topLayout->addMultiCellWidget(gb2, iii,iii,0,1); | 196 | //topLayout->addMultiCellWidget(gb2, iii,iii,0,1); |
197 | //++iii; | 197 | //++iii; |
198 | { | 198 | { |
199 | QVGroupBox*topFrame = gb2; | 199 | QVGroupBox*topFrame = gb2; |
200 | mWriteBackExisting= new QCheckBox( i18n("Write back (on remote) existing entries only"), topFrame ); | 200 | mWriteBackExisting= new QCheckBox( i18n("Write back (on remote) existing entries only"), topFrame ); |
201 | QHGroupBox* gb4 = new QHGroupBox( i18n("Apply filter when adding data to remote:"), topFrame); | 201 | QHGroupBox* gb4 = new QHGroupBox( i18n("Apply filter when adding data to remote:"), topFrame); |
202 | QVBox * fibo = new QVBox ( gb4 ); | 202 | QVBox * fibo = new QVBox ( gb4 ); |
203 | new QLabel ( i18n("Outgoing calendar filter:"), fibo ); | 203 | new QLabel ( i18n("Outgoing calendar filter:"), fibo ); |
204 | mFilterOutCal = new QComboBox( fibo ); | 204 | mFilterOutCal = new QComboBox( fibo ); |
205 | fibo = new QVBox ( gb4 ); | 205 | fibo = new QVBox ( gb4 ); |
206 | new QLabel ( i18n("Outgoing addressbook filter:"), fibo ); | 206 | new QLabel ( i18n("Outgoing addressbook filter:"), fibo ); |
207 | mFilterOutAB = new QComboBox( fibo ); | 207 | mFilterOutAB = new QComboBox( fibo ); |
208 | //topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); | 208 | //topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); |
209 | //++iii; | 209 | //++iii; |
210 | mWriteBackFuture= new QCheckBox( i18n("Write back (calendar) entries for time period only"), topFrame ); | 210 | mWriteBackFuture= new QCheckBox( i18n("Write back (calendar) entries for time period only"), topFrame ); |
211 | //topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1); | 211 | //topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1); |
212 | //++iii; | 212 | //++iii; |
213 | QHGroupBox* gb3 = new QHGroupBox( i18n("Time period"), topFrame); | 213 | QHGroupBox* gb3 = new QHGroupBox( i18n("Time period"), topFrame); |
214 | connect ( mWriteBackFuture, SIGNAL( toggled ( bool ) ), gb3, SLOT ( setEnabled ( bool ) ) ); | 214 | connect ( mWriteBackFuture, SIGNAL( toggled ( bool ) ), gb3, SLOT ( setEnabled ( bool ) ) ); |
215 | new QLabel( i18n("From ") , gb3 ); | 215 | new QLabel( i18n("From ") , gb3 ); |
216 | mWriteBackPastWeeks= new QSpinBox(1,104, 1, gb3); | 216 | mWriteBackPastWeeks= new QSpinBox(1,104, 1, gb3); |
217 | new QLabel( i18n(" weeks in the past to ") , gb3 ); | 217 | new QLabel( i18n(" weeks in the past to ") , gb3 ); |
218 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, gb3); | 218 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, gb3); |
219 | new QLabel( i18n(" weeks in the future ") , gb3 ); | 219 | new QLabel( i18n(" weeks in the future ") , gb3 ); |
220 | //topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1); | 220 | //topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1); |
221 | //++iii; | 221 | //++iii; |
222 | gb3->setEnabled( false ); | 222 | gb3->setEnabled( false ); |
223 | connect ( mWriteBackExisting, SIGNAL( toggled ( bool ) ), gb4, SLOT ( setDisabled ( bool ) ) ); | 223 | connect ( mWriteBackExisting, SIGNAL( toggled ( bool ) ), gb4, SLOT ( setDisabled ( bool ) ) ); |
224 | } | 224 | } |
225 | connect ( mWriteBackFile, SIGNAL( toggled ( bool ) ), gb2, SLOT ( setEnabled ( bool ) ) ); | 225 | connect ( mWriteBackFile, SIGNAL( toggled ( bool ) ), gb2, SLOT ( setEnabled ( bool ) ) ); |
226 | 226 | ||
227 | } | 227 | } |
228 | proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); | 228 | proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); |
229 | gr = proGr; | 229 | gr = proGr; |
230 | topLayout->addMultiCellWidget(gr, iii,iii,0,1); | 230 | topLayout->addMultiCellWidget(gr, iii,iii,0,1); |
231 | ++iii; | 231 | ++iii; |
232 | mIsLocal = new QRadioButton ( i18n("Local file"), gr ); | 232 | mIsLocal = new QRadioButton ( i18n("Local file"), gr ); |
233 | mIsPi = new QRadioButton ( i18n("Pi-Sync ( direct Kx/Pi to Kx/Pi sync )"), gr ); | 233 | mIsPi = new QRadioButton ( i18n("Pi-Sync ( direct Kx/Pi to Kx/Pi sync )"), gr ); |
234 | connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); | 234 | connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); |
235 | mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); | 235 | mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); |
236 | connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); | 236 | connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); |
237 | mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr ); | 237 | mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr ); |
238 | connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); | 238 | connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); |
239 | 239 | ||
240 | QVGroupBox* gb1 = new QVGroupBox( i18n("Profile kind specific settings"), topFrame); | 240 | QVGroupBox* gb1 = new QVGroupBox( i18n("Profile kind specific settings"), topFrame); |
241 | topLayout->addMultiCellWidget(gb1, iii,iii,0,1); | 241 | topLayout->addMultiCellWidget(gb1, iii,iii,0,1); |
242 | ++iii; | 242 | ++iii; |
243 | 243 | ||
244 | // ****************************************** | 244 | // ****************************************** |
245 | // Profile kind specific settings | 245 | // Profile kind specific settings |
246 | { | 246 | { |
247 | // *** phone ******************************* | 247 | // *** phone ******************************* |
248 | QVGroupBox* topFrame = gb1; | 248 | QVGroupBox* topFrame = gb1; |
249 | phoneWidget = new QVBox( topFrame); | 249 | phoneWidget = new QVBox( topFrame); |
250 | //topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1); | 250 | //topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1); |
251 | //++iii; | 251 | //++iii; |
252 | mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget ); | 252 | mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget ); |
253 | QHBox* temphb = new QHBox( phoneWidget ); | 253 | QHBox* temphb = new QHBox( phoneWidget ); |
254 | new QLabel( i18n("I/O device: "), temphb ); | 254 | new QLabel( i18n("I/O device: "), temphb ); |
255 | mPhoneDevice = new QLineEdit( temphb); | 255 | mPhoneDevice = new QLineEdit( temphb); |
256 | button = new QPushButton( i18n("Help..."), temphb ); | 256 | button = new QPushButton( i18n("Help..."), temphb ); |
257 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) ); | 257 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) ); |
258 | 258 | ||
259 | 259 | ||
260 | temphb = new QHBox( phoneWidget ); | 260 | temphb = new QHBox( phoneWidget ); |
261 | new QLabel( i18n("Connection: "), temphb ); | 261 | new QLabel( i18n("Connection: "), temphb ); |
262 | mPhoneConnection = new QLineEdit( temphb); | 262 | mPhoneConnection = new QLineEdit( temphb); |
263 | button = new QPushButton( i18n("Help..."), temphb ); | 263 | button = new QPushButton( i18n("Help..."), temphb ); |
264 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) ); | 264 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) ); |
265 | 265 | ||
266 | 266 | ||
267 | temphb = new QHBox( phoneWidget ); | 267 | temphb = new QHBox( phoneWidget ); |
268 | new QLabel( i18n("Model(opt.): "), temphb ); | 268 | new QLabel( i18n("Model(opt.): "), temphb ); |
269 | mPhoneModel = new QLineEdit( temphb); | 269 | mPhoneModel = new QLineEdit( temphb); |
270 | button = new QPushButton( i18n("Help..."), temphb ); | 270 | button = new QPushButton( i18n("Help..."), temphb ); |
271 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) ); | 271 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) ); |
272 | 272 | ||
273 | // *** local******************************* | 273 | // *** local******************************* |
274 | localFileWidget = new QVBox( topFrame); | 274 | localFileWidget = new QVBox( topFrame); |
275 | //topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); | 275 | //topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); |
276 | //++iii; | 276 | //++iii; |
277 | temphb = new QHBox( localFileWidget ); | 277 | temphb = new QHBox( localFileWidget ); |
278 | 278 | ||
279 | lab = new QLabel( i18n("Local file Cal:"), temphb ); | 279 | lab = new QLabel( i18n("Local file Cal:"), temphb ); |
280 | lab = new QLabel( i18n("Local file ABook:"), temphb ); | 280 | lab = new QLabel( i18n("Local file ABook:"), temphb ); |
281 | lab = new QLabel( i18n("Local file PWMgr:"), temphb ); | 281 | lab = new QLabel( i18n("Local file PWMgr:"), temphb ); |
282 | temphb = new QHBox( localFileWidget ); | 282 | temphb = new QHBox( localFileWidget ); |
283 | button = new QPushButton( i18n("Choose..."), temphb ); | 283 | button = new QPushButton( i18n("Choose..."), temphb ); |
284 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); | 284 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); |
285 | button = new QPushButton( i18n("Choose..."), temphb ); | 285 | button = new QPushButton( i18n("Choose..."), temphb ); |
286 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) ); | 286 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) ); |
287 | button = new QPushButton( i18n("Choose..."), temphb ); | 287 | button = new QPushButton( i18n("Choose..."), temphb ); |
288 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) ); | 288 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) ); |
289 | temphb = new QHBox( localFileWidget ); | 289 | temphb = new QHBox( localFileWidget ); |
290 | 290 | ||
291 | mRemoteFile = new QLineEdit( temphb); | 291 | mRemoteFile = new QLineEdit( temphb); |
292 | mRemoteFileAB = new QLineEdit( temphb); | 292 | mRemoteFileAB = new QLineEdit( temphb); |
293 | mRemoteFilePWM = new QLineEdit( temphb); | 293 | mRemoteFilePWM = new QLineEdit( temphb); |
294 | mIsKapiFileL = new QCheckBox( i18n("Addressbook file (*.vcf) is used by KA/Pi"), localFileWidget ); | 294 | mIsKapiFileL = new QCheckBox( i18n("Addressbook file (*.vcf) is used by KA/Pi"), localFileWidget ); |
295 | 295 | ||
296 | 296 | ||
297 | // *** remote******************************* | 297 | // *** remote******************************* |
298 | remoteFileWidget = new QVBox( topFrame); | 298 | remoteFileWidget = new QVBox( topFrame); |
299 | //topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); | 299 | //topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); |
300 | //++iii; | 300 | //++iii; |
301 | temphb = new QHBox( remoteFileWidget ); | 301 | temphb = new QHBox( remoteFileWidget ); |
302 | new QLabel( i18n("Calendar:"), temphb); | 302 | new QLabel( i18n("Calendar:"), temphb); |
303 | new QLabel( i18n("AddressBook:"), temphb); | 303 | new QLabel( i18n("AddressBook:"), temphb); |
304 | new QLabel( i18n("PWManager:"), temphb); | 304 | new QLabel( i18n("PWManager:"), temphb); |
305 | 305 | ||
306 | lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); | 306 | lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); |
307 | temphb = new QHBox( remoteFileWidget ); | 307 | temphb = new QHBox( remoteFileWidget ); |
308 | mRemotePrecommand = new QLineEdit(temphb); | 308 | mRemotePrecommand = new QLineEdit(temphb); |
309 | mRemotePrecommandAB = new QLineEdit(temphb); | 309 | mRemotePrecommandAB = new QLineEdit(temphb); |
310 | mRemotePrecommandPWM = new QLineEdit(temphb); | 310 | mRemotePrecommandPWM = new QLineEdit(temphb); |
311 | 311 | ||
312 | lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); | 312 | lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); |
313 | temphb = new QHBox( remoteFileWidget ); | 313 | temphb = new QHBox( remoteFileWidget ); |
314 | mLocalTempFile = new QLineEdit(temphb); | 314 | mLocalTempFile = new QLineEdit(temphb); |
315 | mLocalTempFileAB = new QLineEdit(temphb); | 315 | mLocalTempFileAB = new QLineEdit(temphb); |
316 | mLocalTempFilePWM = new QLineEdit(temphb); | 316 | mLocalTempFilePWM = new QLineEdit(temphb); |
317 | 317 | ||
318 | lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); | 318 | lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); |
319 | temphb = new QHBox( remoteFileWidget ); | 319 | temphb = new QHBox( remoteFileWidget ); |
320 | mRemotePostcommand = new QLineEdit(temphb ); | 320 | mRemotePostcommand = new QLineEdit(temphb ); |
321 | mRemotePostcommandAB = new QLineEdit(temphb ); | 321 | mRemotePostcommandAB = new QLineEdit(temphb ); |
322 | mRemotePostcommandPWM = new QLineEdit(temphb ); | 322 | mRemotePostcommandPWM = new QLineEdit(temphb ); |
323 | mIsKapiFileR = new QCheckBox( i18n("Addressbook file is used by KA/Pi"), remoteFileWidget ); | 323 | mIsKapiFileR = new QCheckBox( i18n("Addressbook file is used by KA/Pi"), remoteFileWidget ); |
324 | lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); | 324 | lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); |
325 | temphb = new QHBox( remoteFileWidget ); | 325 | temphb = new QHBox( remoteFileWidget ); |
326 | button = new QPushButton( i18n("ssh/scp"), temphb ); | 326 | button = new QPushButton( i18n("ssh/scp"), temphb ); |
327 | connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); | 327 | connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); |
328 | button = new QPushButton( i18n("ftp"), temphb ); | 328 | button = new QPushButton( i18n("ftp"), temphb ); |
329 | connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); | 329 | connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); |
330 | lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); | 330 | lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); |
331 | 331 | ||
332 | // *** pi-sync******************************* | 332 | // *** pi-sync******************************* |
333 | piWidget = new QVBox( topFrame); | 333 | piWidget = new QVBox( topFrame); |
334 | //topLayout->addMultiCellWidget(piWidget, iii,iii,0,1); | 334 | //topLayout->addMultiCellWidget(piWidget, iii,iii,0,1); |
335 | //++iii; | 335 | //++iii; |
336 | temphb = new QHBox( piWidget ); | 336 | temphb = new QHBox( piWidget ); |
337 | new QLabel( i18n("Calendar:"), temphb); | 337 | new QLabel( i18n("Calendar:"), temphb); |
338 | new QLabel( i18n("AddressBook:"), temphb); | 338 | new QLabel( i18n("AddressBook:"), temphb); |
339 | new QLabel( i18n("PWManager:"), temphb); | 339 | new QLabel( i18n("PWManager:"), temphb); |
340 | 340 | ||
341 | lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget); | 341 | lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget); |
342 | temphb = new QHBox( piWidget ); | 342 | temphb = new QHBox( piWidget ); |
343 | mRemotePw = new QLineEdit(temphb); | 343 | mRemotePw = new QLineEdit(temphb); |
344 | mRemotePwAB = new QLineEdit(temphb); | 344 | mRemotePwAB = new QLineEdit(temphb); |
345 | mRemotePwPWM = new QLineEdit(temphb); | 345 | mRemotePwPWM = new QLineEdit(temphb); |
346 | 346 | ||
347 | lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget); | 347 | lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget); |
348 | temphb = new QHBox( piWidget ); | 348 | temphb = new QHBox( piWidget ); |
349 | mRemoteIP = new QLineEdit(temphb); | 349 | mRemoteIP = new QLineEdit(temphb); |
350 | mRemoteIPAB = new QLineEdit(temphb); | 350 | mRemoteIPAB = new QLineEdit(temphb); |
351 | mRemoteIPPWM = new QLineEdit(temphb); | 351 | mRemoteIPPWM = new QLineEdit(temphb); |
352 | 352 | ||
353 | lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget); | 353 | lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget); |
354 | temphb = new QHBox( piWidget ); | 354 | temphb = new QHBox( piWidget ); |
355 | mRemotePort = new QLineEdit(temphb); | 355 | mRemotePort = new QLineEdit(temphb); |
356 | mRemotePortAB = new QLineEdit(temphb); | 356 | mRemotePortAB = new QLineEdit(temphb); |
357 | mRemotePortPWM = new QLineEdit(temphb); | 357 | mRemotePortPWM = new QLineEdit(temphb); |
358 | } | 358 | } |
359 | // ****************************************** | 359 | // ****************************************** |
360 | // Profile kind specific settings END | 360 | // Profile kind specific settings END |
361 | 361 | ||
362 | } | 362 | } |
363 | 363 | ||
364 | void KSyncPrefsDialog::readFilter() | 364 | void KSyncPrefsDialog::readFilter() |
365 | { | 365 | { |
366 | mFilterKapi.clear(); | 366 | mFilterKapi.clear(); |
367 | mFilterKopi.clear(); | 367 | mFilterKopi.clear(); |
368 | KConfig cfgko(locateLocal("config","korganizerrc")); | 368 | KConfig cfgko(locateLocal("config","korganizerrc")); |
369 | KConfig cfgka(locateLocal("config","kaddressbookrc")); | 369 | KConfig cfgka(locateLocal("config","kaddressbookrc")); |
370 | cfgko.setGroup("General"); | 370 | cfgko.setGroup("General"); |
371 | mFilterKopi = cfgko.readListEntry("CalendarFilters"); | 371 | mFilterKopi = cfgko.readListEntry("CalendarFilters"); |
372 | cfgka.setGroup("Filter"); | 372 | cfgka.setGroup("Filter"); |
373 | int count = cfgka.readNumEntry( "Count", 0 ); | 373 | int count = cfgka.readNumEntry( "Count", 0 ); |
374 | for ( int i = 0; i < count; i++ ) { | 374 | for ( int i = 0; i < count; i++ ) { |
375 | cfgka.setGroup("Filter_"+QString::number( i ) ); | 375 | cfgka.setGroup("Filter_"+QString::number( i ) ); |
376 | mFilterKapi.append( cfgka.readEntry("Name", "internal error") ); | 376 | mFilterKapi.append( cfgka.readEntry("Name", "internal error") ); |
377 | } | 377 | } |
378 | mFilterOutCal->clear(); | 378 | mFilterOutCal->clear(); |
379 | mFilterInCal->clear(); | 379 | mFilterInCal->clear(); |
380 | mFilterOutAB->clear(); | 380 | mFilterOutAB->clear(); |
381 | mFilterInAB->clear(); | 381 | mFilterInAB->clear(); |
382 | QStringList temp = mFilterKopi; | 382 | QStringList temp = mFilterKopi; |
383 | temp.prepend(i18n("No Filter") ); | 383 | temp.prepend(i18n("No Filter") ); |
384 | mFilterOutCal->insertStringList( temp ); | 384 | mFilterOutCal->insertStringList( temp ); |
385 | mFilterInCal->insertStringList( temp ); | 385 | mFilterInCal->insertStringList( temp ); |
386 | temp = mFilterKapi; | 386 | temp = mFilterKapi; |
387 | temp.prepend(i18n("No Filter") ); | 387 | temp.prepend(i18n("No Filter") ); |
388 | mFilterOutAB->insertStringList( temp ); | 388 | mFilterOutAB->insertStringList( temp ); |
389 | mFilterInAB->insertStringList( temp ); | 389 | mFilterInAB->insertStringList( temp ); |
390 | } | 390 | } |
391 | 391 | ||
392 | void KSyncPrefsDialog::slotOK() | 392 | void KSyncPrefsDialog::slotOK() |
393 | { | 393 | { |
394 | if ( mMyMachineName->text() == "undefined" ) { | 394 | if ( mMyMachineName->text() == "undefined" ) { |
395 | KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); | 395 | KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); |
396 | return; | 396 | return; |
397 | } | 397 | } |
398 | int i; | 398 | int i; |
399 | for (i = 0; i < mSyncProfileNames.count(); ++ i) { | 399 | for (i = 0; i < mSyncProfileNames.count(); ++ i) { |
400 | if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { | 400 | if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { |
401 | KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); | 401 | KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); |
402 | return; | 402 | return; |
403 | } | 403 | } |
404 | } | 404 | } |
405 | usrWriteConfig(); | 405 | usrWriteConfig(); |
406 | QDialog::accept(); | 406 | QDialog::accept(); |
407 | } | 407 | } |
408 | void KSyncPrefsDialog::accept() | 408 | void KSyncPrefsDialog::accept() |
409 | { | 409 | { |
410 | slotOK(); | 410 | slotOK(); |
411 | } | 411 | } |
412 | void KSyncPrefsDialog::chooseFile() | 412 | void KSyncPrefsDialog::chooseFile() |
413 | { | 413 | { |
414 | QString fn = QDir::homeDirPath(); | 414 | QString fn = QDir::homeDirPath(); |
415 | 415 | ||
416 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 416 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
417 | if ( fn == "" ) | 417 | if ( fn == "" ) |
418 | return; | 418 | return; |
419 | mRemoteFile->setText( fn ); | 419 | mRemoteFile->setText( fn ); |
420 | } | 420 | } |
421 | 421 | ||
422 | void KSyncPrefsDialog::chooseFileAB() | 422 | void KSyncPrefsDialog::chooseFileAB() |
423 | { | 423 | { |
424 | QString fn = QDir::homeDirPath(); | 424 | QString fn = QDir::homeDirPath(); |
425 | 425 | ||
426 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this ); | 426 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this ); |
427 | if ( fn == "" ) | 427 | if ( fn == "" ) |
428 | return; | 428 | return; |
429 | mRemoteFileAB->setText( fn ); | 429 | mRemoteFileAB->setText( fn ); |
430 | } | 430 | } |
431 | 431 | ||
432 | void KSyncPrefsDialog::chooseFilePWM() | 432 | void KSyncPrefsDialog::chooseFilePWM() |
433 | { | 433 | { |
434 | QString fn = QDir::homeDirPath(); | 434 | QString fn = QDir::homeDirPath(); |
435 | 435 | ||
436 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this ); | 436 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this ); |
437 | if ( fn == "" ) | 437 | if ( fn == "" ) |
438 | return; | 438 | return; |
439 | mRemoteFilePWM->setText( fn ); | 439 | mRemoteFilePWM->setText( fn ); |
440 | } | 440 | } |
441 | 441 | ||
442 | void KSyncPrefsDialog::textChanged( const QString & s ) | 442 | void KSyncPrefsDialog::textChanged( const QString & s ) |
443 | { | 443 | { |
444 | if ( mProfileBox->count() == 0 ) | 444 | if ( mProfileBox->count() == 0 ) |
445 | return; | 445 | return; |
446 | if ( currentSelection < 3 ) { | 446 | if ( currentSelection < 3 ) { |
447 | //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); | 447 | //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); |
448 | mProfileBox->blockSignals( true ); | 448 | mProfileBox->blockSignals( true ); |
449 | mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); | 449 | mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); |
450 | mProfileBox->blockSignals( false ); | 450 | mProfileBox->blockSignals( false ); |
451 | return; | 451 | return; |
452 | } | 452 | } |
453 | //qDebug("cur i %d ",mProfileBox-> currentItem () ); | 453 | //qDebug("cur i %d ",mProfileBox-> currentItem () ); |
454 | mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; | 454 | mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; |
455 | KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; | 455 | KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; |
456 | prof->setName( s ); | 456 | prof->setName( s ); |
457 | mSyncProfileNames[mProfileBox-> currentItem ()] = s; | 457 | mSyncProfileNames[mProfileBox-> currentItem ()] = s; |
458 | } | 458 | } |
459 | void KSyncPrefsDialog::profileChanged( int item ) | 459 | void KSyncPrefsDialog::profileChanged( int item ) |
460 | { | 460 | { |
461 | //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() ); | 461 | //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() ); |
462 | KSyncProfile* prof; | 462 | KSyncProfile* prof; |
463 | saveProfile(); | 463 | saveProfile(); |
464 | readFilter(); | 464 | readFilter(); |
465 | currentSelection = item; | 465 | currentSelection = item; |
466 | prof = mSyncProfiles.at(item) ; | 466 | prof = mSyncProfiles.at(item) ; |
467 | 467 | ||
468 | mRemotePw->setText(prof->getRemotePw()); | 468 | mRemotePw->setText(prof->getRemotePw()); |
469 | mRemoteIP->setText(prof->getRemoteIP()); | 469 | mRemoteIP->setText(prof->getRemoteIP()); |
470 | mRemotePort->setText(prof->getRemotePort()); | 470 | mRemotePort->setText(prof->getRemotePort()); |
471 | 471 | ||
472 | mRemotePwAB->setText(prof->getRemotePwAB()); | 472 | mRemotePwAB->setText(prof->getRemotePwAB()); |
473 | mRemoteIPAB->setText(prof->getRemoteIPAB()); | 473 | mRemoteIPAB->setText(prof->getRemoteIPAB()); |
474 | mRemotePortAB->setText(prof->getRemotePortAB()); | 474 | mRemotePortAB->setText(prof->getRemotePortAB()); |
475 | 475 | ||
476 | mRemotePwPWM->setText(prof->getRemotePwPWM()); | 476 | mRemotePwPWM->setText(prof->getRemotePwPWM()); |
477 | mRemoteIPPWM->setText(prof->getRemoteIPPWM()); | 477 | mRemoteIPPWM->setText(prof->getRemoteIPPWM()); |
478 | mRemotePortPWM->setText(prof->getRemotePortPWM()); | 478 | mRemotePortPWM->setText(prof->getRemotePortPWM()); |
479 | 479 | ||
480 | mRemotePrecommand->setText(prof->getPreSyncCommand()); | 480 | mRemotePrecommand->setText(prof->getPreSyncCommand()); |
481 | mRemotePostcommand->setText(prof->getPostSyncCommand()); | 481 | mRemotePostcommand->setText(prof->getPostSyncCommand()); |
482 | mLocalTempFile->setText(prof->getLocalTempFile()); | 482 | mLocalTempFile->setText(prof->getLocalTempFile()); |
483 | mRemoteFile->setText(prof->getRemoteFileName()) ; | 483 | mRemoteFile->setText(prof->getRemoteFileName()) ; |
484 | 484 | ||
485 | mRemotePrecommandAB->setText(prof->getPreSyncCommandAB()); | 485 | mRemotePrecommandAB->setText(prof->getPreSyncCommandAB()); |
486 | mRemotePostcommandAB->setText(prof->getPostSyncCommandAB()); | 486 | mRemotePostcommandAB->setText(prof->getPostSyncCommandAB()); |
487 | mLocalTempFileAB->setText(prof->getLocalTempFileAB()); | 487 | mLocalTempFileAB->setText(prof->getLocalTempFileAB()); |
488 | mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ; | 488 | mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ; |
489 | 489 | ||
490 | mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM()); | 490 | mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM()); |
491 | mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM()); | 491 | mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM()); |
492 | mLocalTempFilePWM->setText(prof->getLocalTempFilePWM()); | 492 | mLocalTempFilePWM->setText(prof->getLocalTempFilePWM()); |
493 | mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ; | 493 | mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ; |
494 | 494 | ||
495 | if ( mWriteContactToSIM ) | 495 | if ( mWriteContactToSIM ) |
496 | mWriteContactToSIM->setChecked( prof->getWriteContactToSIM()); | 496 | mWriteContactToSIM->setChecked( prof->getWriteContactToSIM()); |
497 | mPhoneDevice->setText(prof->getPhoneDevice()); | 497 | mPhoneDevice->setText(prof->getPhoneDevice()); |
498 | mPhoneConnection->setText(prof->getPhoneConnection()); | 498 | mPhoneConnection->setText(prof->getPhoneConnection()); |
499 | mPhoneModel->setText(prof->getPhoneModel()); | 499 | mPhoneModel->setText(prof->getPhoneModel()); |
500 | 500 | ||
501 | mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); | 501 | mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); |
502 | mAskForPreferences->setChecked( prof->getAskForPreferences()); | 502 | mAskForPreferences->setChecked( prof->getAskForPreferences()); |
503 | mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); | 503 | mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); |
504 | mWriteBackFile->setChecked( prof->getWriteBackFile()); | 504 | mWriteBackFile->setChecked( prof->getWriteBackFile()); |
505 | mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); | 505 | mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); |
506 | mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() ); | 506 | mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() ); |
507 | mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() ); | 507 | mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() ); |
508 | mWriteBackFuture->setChecked( prof->getWriteBackFuture()); | 508 | mWriteBackFuture->setChecked( prof->getWriteBackFuture()); |
509 | mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() ); | 509 | mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() ); |
510 | mWriteBackPastWeeks->setValue( prof->getWriteBackPastWeeks() ); | 510 | mWriteBackPastWeeks->setValue( prof->getWriteBackPastWeeks() ); |
511 | 511 | ||
512 | mFilterInCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterInCal () ) + 1 ); | 512 | mFilterInCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterInCal () ) + 1 ); |
513 | mFilterOutCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterOutCal () ) + 1 ); | 513 | mFilterOutCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterOutCal () ) + 1 ); |
514 | mFilterInAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterInAB () ) + 1 ); | 514 | mFilterInAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterInAB () ) + 1 ); |
515 | mFilterOutAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterOutAB () ) + 1 ); | 515 | mFilterOutAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterOutAB () ) + 1 ); |
516 | 516 | ||
517 | switch ( prof->getSyncPrefs() ) { | 517 | switch ( prof->getSyncPrefs() ) { |
518 | case 0: | 518 | case 0: |
519 | loc->setChecked( true); | 519 | loc->setChecked( true); |
520 | break; | 520 | break; |
521 | case 1: | 521 | case 1: |
522 | rem->setChecked( true ); | 522 | rem->setChecked( true ); |
523 | break; | 523 | break; |
524 | case 2: | 524 | case 2: |
525 | newest->setChecked( true); | 525 | newest->setChecked( true); |
526 | break; | 526 | break; |
527 | case 3: | 527 | case 3: |
528 | ask->setChecked( true); | 528 | ask->setChecked( true); |
529 | break; | 529 | break; |
530 | case 4: | 530 | case 4: |
531 | f_loc->setChecked( true); | 531 | f_loc->setChecked( true); |
532 | break; | 532 | break; |
533 | case 5: | 533 | case 5: |
534 | f_rem->setChecked( true); | 534 | f_rem->setChecked( true); |
535 | break; | 535 | break; |
536 | case 6: | 536 | case 6: |
537 | //both->setChecked( true); | 537 | //both->setChecked( true); |
538 | break; | 538 | break; |
539 | default: | 539 | default: |
540 | break; | 540 | break; |
541 | } | 541 | } |
542 | mIsLocal->setChecked(prof->getIsLocalFileSync()) ; | 542 | mIsLocal->setChecked(prof->getIsLocalFileSync()) ; |
543 | mIsPhone->setChecked(prof->getIsPhoneSync()) ; | 543 | mIsPhone->setChecked(prof->getIsPhoneSync()) ; |
544 | mIsPi->setChecked(prof->getIsPiSync()) ; | 544 | mIsPi->setChecked(prof->getIsPiSync()) ; |
545 | mIsKapiFileL->setChecked(prof->getIsKapiFile()) ; | 545 | mIsKapiFileL->setChecked(prof->getIsKapiFile()) ; |
546 | mIsKapiFileR->setChecked(prof->getIsKapiFile()) ; | 546 | mIsKapiFileR->setChecked(prof->getIsKapiFile()) ; |
547 | 547 | ||
548 | mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() ); | 548 | mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() ); |
549 | proGr->setEnabled( item > 2 ); | 549 | proGr->setEnabled( item > 2 ); |
550 | if ( item < 3 ) { | 550 | if ( item < 3 ) { |
551 | localFileWidget->hide(); | 551 | localFileWidget->hide(); |
552 | remoteFileWidget->hide(); | 552 | remoteFileWidget->hide(); |
553 | phoneWidget->hide(); | 553 | phoneWidget->hide(); |
554 | piWidget->hide(); | 554 | piWidget->hide(); |
555 | 555 | ||
556 | } else | 556 | } else |
557 | kindChanged( prof->getIsLocalFileSync() ); | 557 | kindChanged( prof->getIsLocalFileSync() ); |
558 | } | 558 | } |
559 | 559 | ||
560 | void KSyncPrefsDialog::fillSSH() | 560 | void KSyncPrefsDialog::fillSSH() |
561 | { | 561 | { |
562 | mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); | 562 | mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); |
563 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); | 563 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); |
564 | mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); | 564 | mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); |
565 | mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); | 565 | mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); |
566 | mLocalTempFileAB->setText("/tmp/std.vcf" ); | 566 | mLocalTempFileAB->setText("/tmp/std.vcf" ); |
567 | mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" ); | 567 | mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" ); |
568 | mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); | 568 | mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); |
569 | mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); | 569 | mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); |
570 | mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" ); | 570 | mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" ); |
571 | } | 571 | } |
572 | void KSyncPrefsDialog::fillFTP() | 572 | void KSyncPrefsDialog::fillFTP() |
573 | { | 573 | { |
574 | mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); | 574 | mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); |
575 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); | 575 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); |
576 | mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); | 576 | mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); |
577 | mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" ); | 577 | mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" ); |
578 | mLocalTempFileAB->setText("/tmp/std.vcf" ); | 578 | mLocalTempFileAB->setText("/tmp/std.vcf" ); |
579 | mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); | 579 | mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); |
580 | 580 | ||
581 | mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" ); | 581 | mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" ); |
582 | mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); | 582 | mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); |
583 | mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); | 583 | mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); |
584 | 584 | ||
585 | } | 585 | } |
586 | void KSyncPrefsDialog::kindChanged( bool b ) | 586 | void KSyncPrefsDialog::kindChanged( bool b ) |
587 | { | 587 | { |
588 | 588 | ||
589 | if ( mIsLocal->isChecked () ) { | 589 | if ( mIsLocal->isChecked () ) { |
590 | mIsKapiFileL->setChecked( mIsKapiFileR->isChecked() ); | 590 | mIsKapiFileL->setChecked( mIsKapiFileR->isChecked() ); |
591 | } else { | 591 | } else { |
592 | mIsKapiFileR->setChecked( mIsKapiFileL->isChecked() ); | 592 | mIsKapiFileR->setChecked( mIsKapiFileL->isChecked() ); |
593 | } | 593 | } |
594 | 594 | ||
595 | if ( mIsLocal->isChecked () ) | 595 | if ( mIsLocal->isChecked () ) |
596 | localFileWidget->show(); | 596 | localFileWidget->show(); |
597 | else | 597 | else |
598 | localFileWidget->hide(); | 598 | localFileWidget->hide(); |
599 | 599 | ||
600 | if ( mIsNotLocal->isChecked () ) | 600 | if ( mIsNotLocal->isChecked () ) |
601 | remoteFileWidget->show(); | 601 | remoteFileWidget->show(); |
602 | else | 602 | else |
603 | remoteFileWidget->hide(); | 603 | remoteFileWidget->hide(); |
604 | 604 | ||
605 | if ( mIsPhone->isChecked () ) { | 605 | if ( mIsPhone->isChecked () ) { |
606 | phoneWidget->show(); | 606 | phoneWidget->show(); |
607 | } | 607 | } |
608 | else { | 608 | else { |
609 | phoneWidget->hide(); | 609 | phoneWidget->hide(); |
610 | } | 610 | } |
611 | if ( mIsPi->isChecked () ) { | 611 | if ( mIsPi->isChecked () ) { |
612 | piWidget->show(); | 612 | piWidget->show(); |
613 | } | 613 | } |
614 | else { | 614 | else { |
615 | piWidget->hide(); | 615 | piWidget->hide(); |
616 | } | 616 | } |
617 | 617 | ||
618 | } | 618 | } |
619 | void KSyncPrefsDialog::deleteProfile() | 619 | void KSyncPrefsDialog::deleteProfile() |
620 | { | 620 | { |
621 | //qDebug("KSyncPrefsDialog::deleteProfile() "); | 621 | //qDebug("KSyncPrefsDialog::deleteProfile() "); |
622 | if ( currentSelection >= 0 ) { | 622 | if ( currentSelection >= 0 ) { |
623 | if ( currentSelection < 3 ) { | 623 | if ( currentSelection < 3 ) { |
624 | KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); | 624 | KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); |
625 | return; | 625 | return; |
626 | } | 626 | } |
627 | KSyncProfile* temp = mSyncProfiles.at(currentSelection); | 627 | KSyncProfile* temp = mSyncProfiles.at(currentSelection); |
628 | mSyncProfiles.remove( temp ); | 628 | mSyncProfiles.remove( temp ); |
629 | mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); | 629 | mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); |
630 | insertProfiles(); | 630 | insertProfiles(); |
631 | } | 631 | } |
632 | } | 632 | } |
633 | 633 | ||
634 | void KSyncPrefsDialog::saveProfile() | 634 | void KSyncPrefsDialog::saveProfile() |
635 | { | 635 | { |
636 | KSyncProfile* prof; | 636 | KSyncProfile* prof; |
637 | if ( currentSelection >= 0 ) { | 637 | if ( currentSelection >= 0 ) { |
638 | prof = mSyncProfiles.at(currentSelection) ; | 638 | prof = mSyncProfiles.at(currentSelection) ; |
639 | 639 | ||
640 | prof->setRemotePw( mRemotePw->text()); | 640 | prof->setRemotePw( mRemotePw->text()); |
641 | prof->setRemoteIP( mRemoteIP->text()); | 641 | prof->setRemoteIP( mRemoteIP->text()); |
642 | prof->setRemotePort( mRemotePort->text()); | 642 | prof->setRemotePort( mRemotePort->text()); |
643 | 643 | ||
644 | prof->setRemotePwAB( mRemotePwAB->text()); | 644 | prof->setRemotePwAB( mRemotePwAB->text()); |
645 | prof->setRemoteIPAB( mRemoteIPAB->text()); | 645 | prof->setRemoteIPAB( mRemoteIPAB->text()); |
646 | prof->setRemotePortAB( mRemotePortAB->text()); | 646 | prof->setRemotePortAB( mRemotePortAB->text()); |
647 | 647 | ||
648 | prof->setRemotePwPWM( mRemotePwPWM->text()); | 648 | prof->setRemotePwPWM( mRemotePwPWM->text()); |
649 | prof->setRemoteIPPWM( mRemoteIPPWM->text()); | 649 | prof->setRemoteIPPWM( mRemoteIPPWM->text()); |
650 | prof->setRemotePortPWM( mRemotePortPWM->text()); | 650 | prof->setRemotePortPWM( mRemotePortPWM->text()); |
651 | 651 | ||
652 | prof->setPreSyncCommand( mRemotePrecommand->text()); | 652 | prof->setPreSyncCommand( mRemotePrecommand->text()); |
653 | prof->setPostSyncCommand( mRemotePostcommand->text() ); | 653 | prof->setPostSyncCommand( mRemotePostcommand->text() ); |
654 | prof->setLocalTempFile( mLocalTempFile->text()); | 654 | prof->setLocalTempFile( mLocalTempFile->text()); |
655 | prof->setRemoteFileName( mRemoteFile->text() ); | 655 | prof->setRemoteFileName( mRemoteFile->text() ); |
656 | prof->setPreSyncCommandAB( mRemotePrecommandAB->text()); | 656 | prof->setPreSyncCommandAB( mRemotePrecommandAB->text()); |
657 | prof->setPostSyncCommandAB( mRemotePostcommandAB->text() ); | 657 | prof->setPostSyncCommandAB( mRemotePostcommandAB->text() ); |
658 | prof->setLocalTempFileAB( mLocalTempFileAB->text()); | 658 | prof->setLocalTempFileAB( mLocalTempFileAB->text()); |
659 | prof->setRemoteFileNameAB( mRemoteFileAB->text() ); | 659 | prof->setRemoteFileNameAB( mRemoteFileAB->text() ); |
660 | prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text()); | 660 | prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text()); |
661 | prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() ); | 661 | prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() ); |
662 | prof->setLocalTempFilePWM( mLocalTempFilePWM->text()); | 662 | prof->setLocalTempFilePWM( mLocalTempFilePWM->text()); |
663 | prof->setRemoteFileNamePWM( mRemoteFilePWM->text() ); | 663 | prof->setRemoteFileNamePWM( mRemoteFilePWM->text() ); |
664 | prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); | 664 | prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); |
665 | prof->setAskForPreferences( mAskForPreferences->isChecked()); | 665 | prof->setAskForPreferences( mAskForPreferences->isChecked()); |
666 | prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); | 666 | prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); |
667 | prof->setWriteBackFile( mWriteBackFile->isChecked()); | 667 | prof->setWriteBackFile( mWriteBackFile->isChecked()); |
668 | prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); | 668 | prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); |
669 | prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() ); | 669 | prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() ); |
670 | prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() ); | 670 | prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() ); |
671 | int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; | 671 | int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; |
672 | prof->setSyncPrefs( syncprefs); | 672 | prof->setSyncPrefs( syncprefs); |
673 | prof->setIsLocalFileSync( mIsLocal->isChecked() ); | 673 | prof->setIsLocalFileSync( mIsLocal->isChecked() ); |
674 | prof->setIsPhoneSync( mIsPhone->isChecked() ); | 674 | prof->setIsPhoneSync( mIsPhone->isChecked() ); |
675 | prof->setIsPiSync( mIsPi->isChecked() ); | 675 | prof->setIsPiSync( mIsPi->isChecked() ); |
676 | prof->setIsKapiFile( mIsKapiFileL->isChecked() ); | 676 | prof->setIsKapiFile( mIsKapiFileL->isChecked() ); |
677 | prof->setWriteBackFuture(mWriteBackFuture->isChecked()); | 677 | prof->setWriteBackFuture(mWriteBackFuture->isChecked()); |
678 | prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value()); | 678 | prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value()); |
679 | prof->setWriteBackPastWeeks(mWriteBackPastWeeks->value()); | 679 | prof->setWriteBackPastWeeks(mWriteBackPastWeeks->value()); |
680 | if ( mWriteContactToSIM ) | 680 | if ( mWriteContactToSIM ) |
681 | prof->setWriteContactToSIM(mWriteContactToSIM->isChecked()); | 681 | prof->setWriteContactToSIM(mWriteContactToSIM->isChecked()); |
682 | prof->setPhoneDevice( mPhoneDevice->text() ); | 682 | prof->setPhoneDevice( mPhoneDevice->text() ); |
683 | prof->setPhoneConnection( mPhoneConnection->text() ); | 683 | prof->setPhoneConnection( mPhoneConnection->text() ); |
684 | prof->setPhoneModel( mPhoneModel->text() ); | 684 | prof->setPhoneModel( mPhoneModel->text() ); |
685 | prof->setFilterInCal ( mFilterInCal->currentText ()); | 685 | prof->setFilterInCal ( mFilterInCal->currentText ()); |
686 | prof->setFilterOutCal ( mFilterOutCal ->currentText ()); | 686 | prof->setFilterOutCal ( mFilterOutCal ->currentText ()); |
687 | prof->setFilterInAB ( mFilterInAB ->currentText ()); | 687 | prof->setFilterInAB ( mFilterInAB ->currentText ()); |
688 | prof->setFilterOutAB ( mFilterOutAB ->currentText ()); | 688 | prof->setFilterOutAB ( mFilterOutAB ->currentText ()); |
689 | } | 689 | } |
690 | } | 690 | } |
691 | 691 | ||
692 | void KSyncPrefsDialog::insertProfiles() | 692 | void KSyncPrefsDialog::insertProfiles() |
693 | { | 693 | { |
694 | int curItem = mProfileBox->currentItem(); | 694 | int curItem = mProfileBox->currentItem(); |
695 | mProfileBox->blockSignals( true ); | 695 | mProfileBox->blockSignals( true ); |
696 | mProfileBox->clear(); | 696 | mProfileBox->clear(); |
697 | mProfileBox->insertStringList (mSyncProfileNames ); | 697 | mProfileBox->insertStringList (mSyncProfileNames ); |
698 | int item = mSyncProfileNames.count() -1; | 698 | int item = mSyncProfileNames.count() -1; |
699 | if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) | 699 | if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) |
700 | mProfileBox->setCurrentItem( curItem ); | 700 | mProfileBox->setCurrentItem( curItem ); |
701 | else if ( item >= 0 ) { | 701 | else if ( item >= 0 ) { |
702 | mProfileBox->setCurrentItem( item ); | 702 | mProfileBox->setCurrentItem( item ); |
703 | } | 703 | } |
704 | currentSelection = -1; | 704 | currentSelection = -1; |
705 | if ( mSyncProfileNames.count() > 0 ) { | 705 | if ( mSyncProfileNames.count() > 0 ) { |
706 | //qDebug(" profileChanged( mProfileBox->currentItem() "); | 706 | //qDebug(" profileChanged( mProfileBox->currentItem() "); |
707 | profileChanged( mProfileBox->currentItem() ); | 707 | profileChanged( mProfileBox->currentItem() ); |
708 | currentSelection = mProfileBox->currentItem(); | 708 | currentSelection = mProfileBox->currentItem(); |
709 | } | 709 | } |
710 | mProfileBox->blockSignals( false ); | 710 | mProfileBox->blockSignals( false ); |
711 | } | 711 | } |
712 | 712 | ||
713 | void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) | 713 | void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) |
714 | { | 714 | { |
715 | saveProfile(); | 715 | saveProfile(); |
716 | mSyncProfiles.append( temp ); | 716 | mSyncProfiles.append( temp ); |
717 | mSyncProfileNames << temp->getName(); | 717 | mSyncProfileNames << temp->getName(); |
718 | insertProfiles(); | 718 | insertProfiles(); |
719 | int last = mProfileBox->count() -1; | 719 | int last = mProfileBox->count() -1; |
720 | mProfileBox->blockSignals( true ); | 720 | mProfileBox->blockSignals( true ); |
721 | mProfileBox->setCurrentItem( last ); | 721 | mProfileBox->setCurrentItem( last ); |
722 | mProfileBox->blockSignals( false ); | 722 | mProfileBox->blockSignals( false ); |
723 | profileChanged(last); | 723 | profileChanged(last); |
724 | } | 724 | } |
725 | void KSyncPrefsDialog::newProfile() | 725 | void KSyncPrefsDialog::newProfile() |
726 | { | 726 | { |
727 | addProfile ( new KSyncProfile () ); | 727 | addProfile ( new KSyncProfile () ); |
728 | } | 728 | } |
729 | 729 | ||
730 | void KSyncPrefsDialog::cloneProfile() | 730 | void KSyncPrefsDialog::cloneProfile() |
731 | { | 731 | { |
732 | if ( currentSelection >= 0 ) | 732 | if ( currentSelection >= 0 ) |
733 | addProfile (mSyncProfiles.at(currentSelection)->clone()) ; | 733 | addProfile (mSyncProfiles.at(currentSelection)->clone()) ; |
734 | else | 734 | else |
735 | newProfile(); | 735 | newProfile(); |
736 | } | 736 | } |
737 | 737 | ||
738 | void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) | 738 | void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) |
739 | { | 739 | { |
740 | mMyMachineName->setText( name ); | 740 | mMyMachineName->setText( name ); |
741 | 741 | ||
742 | } | 742 | } |
743 | QString KSyncPrefsDialog::getLocalMachineName ( ) | 743 | QString KSyncPrefsDialog::getLocalMachineName ( ) |
744 | { | 744 | { |
745 | return mMyMachineName->text(); | 745 | return mMyMachineName->text(); |
746 | } | 746 | } |
747 | 747 | ||
748 | QStringList KSyncPrefsDialog::getSyncProfileNames() | 748 | QStringList KSyncPrefsDialog::getSyncProfileNames() |
749 | { | 749 | { |
750 | return mSyncProfileNames; | 750 | return mSyncProfileNames; |
751 | } | 751 | } |
752 | void KSyncPrefsDialog::usrReadConfig() | 752 | void KSyncPrefsDialog::usrReadConfig() |
753 | { | 753 | { |
754 | //KConfig *config = KOGlobals::config(); | 754 | //KConfig *config = KOGlobals::config(); |
755 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 755 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
756 | config.setGroup("General"); | 756 | config.setGroup("General"); |
757 | mSyncProfileNames =config.readListEntry("SyncProfileNames"); | 757 | mSyncProfileNames =config.readListEntry("SyncProfileNames"); |
758 | mMyMachineName->setText(config.readEntry("LocalMachineName","undefined")); | 758 | mMyMachineName->setText(config.readEntry("LocalMachineName","undefined")); |
759 | int i; | 759 | int i; |
760 | KSyncProfile* temp ; | 760 | KSyncProfile* temp ; |
761 | mSyncProfiles.clear(); | 761 | mSyncProfiles.clear(); |
762 | for ( i = 0; i < mSyncProfileNames.count();++i ) { | 762 | for ( i = 0; i < mSyncProfileNames.count();++i ) { |
763 | temp = new KSyncProfile (); | 763 | temp = new KSyncProfile (); |
764 | temp->setName( mSyncProfileNames[i] ); | 764 | temp->setName( mSyncProfileNames[i] ); |
765 | temp->readConfig( &config ); | 765 | temp->readConfig( &config ); |
766 | mSyncProfiles.append( temp ); | 766 | mSyncProfiles.append( temp ); |
767 | } | 767 | } |
768 | insertProfiles(); | 768 | insertProfiles(); |
769 | //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); | 769 | //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); |
770 | } | 770 | } |
771 | 771 | ||
772 | 772 | ||
773 | void KSyncPrefsDialog::usrWriteConfig() | 773 | void KSyncPrefsDialog::usrWriteConfig() |
774 | { | 774 | { |
775 | saveProfile(); | 775 | saveProfile(); |
776 | if ( currentSelection >= 0 ) | 776 | if ( currentSelection >= 0 ) |
777 | profileChanged(currentSelection); | 777 | profileChanged(currentSelection); |
778 | //KConfig *config = KOGlobals::config(); | 778 | //KConfig *config = KOGlobals::config(); |
779 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 779 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
780 | KSyncProfile* prof = mSyncProfiles.first(); | 780 | KSyncProfile* prof = mSyncProfiles.first(); |
781 | QStringList externalSyncProfileNames; | 781 | QStringList externalSyncProfileNames; |
782 | externalSyncProfileNames.append("Sharp_DTM");; | 782 | externalSyncProfileNames.append("Sharp_DTM");; |
783 | while ( prof ) { | 783 | while ( prof ) { |
784 | prof->writeConfig(&config); | 784 | prof->writeConfig(&config); |
785 | if ( prof->getIsPhoneSync( ) ) | 785 | if ( prof->getIsPhoneSync( ) ) |
786 | externalSyncProfileNames.append(prof->getName( ) ); | 786 | externalSyncProfileNames.append(prof->getName( ) ); |
787 | prof = mSyncProfiles.next(); | 787 | prof = mSyncProfiles.next(); |
788 | } | 788 | } |
789 | //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; | 789 | //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; |
790 | //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); | 790 | //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); |
791 | config.setGroup("General"); | 791 | config.setGroup("General"); |
792 | config.writeEntry("SyncProfileNames",mSyncProfileNames); | 792 | config.writeEntry("SyncProfileNames",mSyncProfileNames); |
793 | config.writeEntry("ExternSyncProfiles",externalSyncProfileNames); | 793 | config.writeEntry("ExternSyncProfiles",externalSyncProfileNames); |
794 | config.writeEntry("LocalMachineName",mMyMachineName->text()); | 794 | config.writeEntry("LocalMachineName",mMyMachineName->text()); |
795 | config.sync(); | 795 | config.sync(); |
796 | } | 796 | } |
797 | 797 | ||
798 | void KSyncPrefsDialog::helpDevice() | 798 | void KSyncPrefsDialog::helpDevice() |
799 | { | 799 | { |
800 | QString hint = i18n("Insert device where\nphone is connected. E.g.:\n"); | 800 | QString hint = i18n("Insert device where\nphone is connected. E.g.:\n"); |
801 | #ifdef _WIN32_ | 801 | #ifdef _WIN32_ |
802 | hint += "Leave empty for Irda.\n" | 802 | hint += "Leave empty for Irda.\n" |
803 | "com1:\n(first serial port)\n" | 803 | "com1:\n(first serial port)\n" |
804 | "usb not supported\n" | 804 | "usb not supported\n" |
805 | "???\n(bluetooth device address)\n"; | 805 | "???\n(bluetooth device address)\n"; |
806 | 806 | ||
807 | #else | 807 | #else |
808 | hint += "/dev/ircomm\n(Irda)\n" | 808 | hint += "/dev/ircomm\n(Irda)\n" |
809 | "/dev/ttyS0\n(first serial port)\n" | 809 | "/dev/ttyS0\n(first serial port)\n" |
810 | "/dev/ttyUSB0\n(first device usb port)\n" | 810 | "/dev/ttyUSB0\n(first device usb port)\n" |
811 | "???\n(bluetooth device address)\n"; | 811 | "???\n(bluetooth device address)\n"; |
812 | #endif | 812 | #endif |
813 | KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); | 813 | KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); |
814 | } | 814 | } |
815 | void KSyncPrefsDialog::helpModel() | 815 | void KSyncPrefsDialog::helpModel() |
816 | { | 816 | { |
817 | QString hint = i18n("Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n"); | 817 | QString hint = i18n("Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n"); |
818 | hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection"; | 818 | hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection"; |
819 | KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); | 819 | KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); |
820 | 820 | ||
821 | } | 821 | } |
822 | void KSyncPrefsDialog::helpConnection() | 822 | void KSyncPrefsDialog::helpConnection() |
823 | { | 823 | { |
824 | QString hint = i18n("Insert kind of connection,e.g.:\n"); | 824 | QString hint = i18n("Insert kind of connection,e.g.:\n"); |
825 | hint += "irda | Nokia FBUS over infrared\n" | 825 | hint += "irda | Nokia FBUS over infrared\n" |
826 | "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n" | 826 | "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n" |
827 | "irdaobex | set also model as obex\n" | 827 | "irdaobex | set also model as obex\n" |
828 | "fbus | Nokia FBUS2 serial\n"; | 828 | "fbus | Nokia FBUS2 serial\n"; |
829 | KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); | 829 | KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); |
830 | } | 830 | } |
diff --git a/microkde/kidmanager.cpp b/microkde/kidmanager.cpp index e687e5d..d712771 100644 --- a/microkde/kidmanager.cpp +++ b/microkde/kidmanager.cpp | |||
@@ -1,136 +1,136 @@ | |||
1 | #include "kidmanager.h" | 1 | #include "kidmanager.h" |
2 | 2 | ||
3 | KIdManager::KIdManager() | 3 | KIdManager::KIdManager() |
4 | { | 4 | { |
5 | 5 | ||
6 | } | 6 | } |
7 | // :profilename;12;id_withLen12;123456: | 7 | // :profilename;12;id_withLen12;123456: |
8 | // 123456 is the csum | 8 | // 123456 is the csum |
9 | QString KIdManager::setId (const QString& idString,const QString& prof,const QString& idvalue ) | 9 | const QString KIdManager::setId (const QString& idString,const QString& prof,const QString& idvalue ) |
10 | { | 10 | { |
11 | int startProf; | 11 | int startProf; |
12 | int startIDnum; | 12 | int startIDnum; |
13 | int startIDnumlen; | 13 | int startIDnumlen; |
14 | int startID; | 14 | int startID; |
15 | int lenID; | 15 | int lenID; |
16 | int startCsum; | 16 | int startCsum; |
17 | int lenCsum; | 17 | int lenCsum; |
18 | int endall; | 18 | int endall; |
19 | QString newIDString; | 19 | QString newIDString; |
20 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) { | 20 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) { |
21 | newIDString = idString.left(startIDnum ) + QString::number( idvalue.length() ) +";"+idvalue+ ";"+idString.mid( startCsum ); | 21 | newIDString = idString.left(startIDnum ) + QString::number( idvalue.length() ) +";"+idvalue+ ";"+idString.mid( startCsum ); |
22 | } else { | 22 | } else { |
23 | newIDString = idString + prof+";"+ QString::number( idvalue.length() ) +";"+idvalue +";0:"; | 23 | newIDString = idString + prof+";"+ QString::number( idvalue.length() ) +";"+idvalue +";0:"; |
24 | } | 24 | } |
25 | //qDebug("setID:profile:%s*retval:%s*idvalue:%s* ", prof.latin1(), newIDString.latin1() ,idvalue.latin1() ); | 25 | //qDebug("setID:profile:%s*retval:%s*idvalue:%s* ", prof.latin1(), newIDString.latin1() ,idvalue.latin1() ); |
26 | return newIDString; | 26 | return newIDString; |
27 | } | 27 | } |
28 | QString KIdManager::getId (const QString& idString,const QString& prof ) | 28 | const QString KIdManager::getId (const QString& idString,const QString& prof ) |
29 | { | 29 | { |
30 | int startProf; | 30 | int startProf; |
31 | int startIDnum; | 31 | int startIDnum; |
32 | int startIDnumlen; | 32 | int startIDnumlen; |
33 | int startID; | 33 | int startID; |
34 | int lenID; | 34 | int lenID; |
35 | int startCsum; | 35 | int startCsum; |
36 | int lenCsum; | 36 | int lenCsum; |
37 | int endall; | 37 | int endall; |
38 | QString idval = ""; | 38 | QString idval = ""; |
39 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) | 39 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) |
40 | idval = idString.mid( startID, lenID ); | 40 | idval = idString.mid( startID, lenID ); |
41 | 41 | ||
42 | //qDebug("getID:profile:%s*retval:%s*idstring:%s* ", prof.latin1(), idval.latin1() ,idString.latin1() ); | 42 | //qDebug("getID:profile:%s*retval:%s*idstring:%s* ", prof.latin1(), idval.latin1() ,idString.latin1() ); |
43 | return idval; | 43 | return idval; |
44 | 44 | ||
45 | } | 45 | } |
46 | 46 | ||
47 | QString KIdManager::removeId (const QString& idString,const QString& prof ) | 47 | const QString KIdManager::removeId (const QString& idString,const QString& prof ) |
48 | { | 48 | { |
49 | int startProf; | 49 | int startProf; |
50 | int startIDnum; | 50 | int startIDnum; |
51 | int startIDnumlen; | 51 | int startIDnumlen; |
52 | int startID; | 52 | int startID; |
53 | int lenID; | 53 | int lenID; |
54 | int startCsum; | 54 | int startCsum; |
55 | int lenCsum; | 55 | int lenCsum; |
56 | int endall; | 56 | int endall; |
57 | QString newIDString; | 57 | QString newIDString; |
58 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) { | 58 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) { |
59 | newIDString = idString.left(startProf) + idString.mid( endall+1 ); | 59 | newIDString = idString.left(startProf) + idString.mid( endall+1 ); |
60 | } else { | 60 | } else { |
61 | newIDString = idString; | 61 | newIDString = idString; |
62 | } | 62 | } |
63 | //qDebug("removeID:profile:%s*retval:%s*oldidstring:%s* ", prof.latin1(), newIDString.latin1() ,idString.latin1() ); | 63 | //qDebug("removeID:profile:%s*retval:%s*oldidstring:%s* ", prof.latin1(), newIDString.latin1() ,idString.latin1() ); |
64 | return newIDString; | 64 | return newIDString; |
65 | } | 65 | } |
66 | 66 | ||
67 | QString KIdManager::setCsum (const QString& idString,const QString& prof,const QString& idCsum ) | 67 | const QString KIdManager::setCsum (const QString& idString,const QString& prof,const QString& idCsum ) |
68 | { | 68 | { |
69 | int startProf; | 69 | int startProf; |
70 | int startIDnum; | 70 | int startIDnum; |
71 | int startIDnumlen; | 71 | int startIDnumlen; |
72 | int startID; | 72 | int startID; |
73 | int lenID; | 73 | int lenID; |
74 | int startCsum; | 74 | int startCsum; |
75 | int lenCsum; | 75 | int lenCsum; |
76 | int endall; | 76 | int endall; |
77 | QString newIDString; | 77 | QString newIDString; |
78 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) { | 78 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) { |
79 | newIDString = idString.left(startCsum) + idCsum+ idString.mid( endall +1); | 79 | newIDString = idString.left(startCsum) + idCsum+ idString.mid( endall +1); |
80 | } else { | 80 | } else { |
81 | newIDString = idString + prof + ";3;_u_;"+ idCsum + ":"; | 81 | newIDString = idString + prof + ";3;_u_;"+ idCsum + ":"; |
82 | } | 82 | } |
83 | //qDebug("setCsum:profile:%s*retval:%s*idCsum:%s* ", prof.latin1(), newIDString.latin1() ,idCsum.latin1() ); | 83 | //qDebug("setCsum:profile:%s*retval:%s*idCsum:%s* ", prof.latin1(), newIDString.latin1() ,idCsum.latin1() ); |
84 | return newIDString; | 84 | return newIDString; |
85 | } | 85 | } |
86 | QString KIdManager::getCsum (const QString& idString,const QString& prof ) | 86 | const QString KIdManager::getCsum (const QString& idString,const QString& prof ) |
87 | { | 87 | { |
88 | int startProf; | 88 | int startProf; |
89 | int startIDnum; | 89 | int startIDnum; |
90 | int startIDnumlen; | 90 | int startIDnumlen; |
91 | int startID; | 91 | int startID; |
92 | int lenID; | 92 | int lenID; |
93 | int startCsum; | 93 | int startCsum; |
94 | int lenCsum; | 94 | int lenCsum; |
95 | int endall; | 95 | int endall; |
96 | QString idval = ""; | 96 | QString idval = ""; |
97 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) | 97 | if ( KIdManager::getNumbers (idString, prof, startProf, startIDnum, startIDnumlen,startID, lenID, startCsum, lenCsum, endall) ) |
98 | idval = idString.mid( startCsum, lenCsum ); | 98 | idval = idString.mid( startCsum, lenCsum ); |
99 | 99 | ||
100 | //qDebug("getCsum:profile:%s*retval:%s*idstring:%s* ", prof.latin1(), idval.latin1() ,idString.latin1() ); | 100 | //qDebug("getCsum:profile:%s*retval:%s*idstring:%s* ", prof.latin1(), idval.latin1() ,idString.latin1() ); |
101 | return idval; | 101 | return idval; |
102 | } | 102 | } |
103 | // :profilename;12;id_withLen12;123456: | 103 | // :profilename;12;id_withLen12;123456: |
104 | bool KIdManager::getNumbers (const QString& idString,const QString& prof, int &startProf, int &startIDnum, int &startIDnumlen,int &startID, int& lenID, int &startCsum, int &lenCsum, int & endall) | 104 | bool KIdManager::getNumbers (const QString& idString,const QString& prof, int &startProf, int &startIDnum, int &startIDnumlen,int &startID, int& lenID, int &startCsum, int &lenCsum, int & endall) |
105 | { | 105 | { |
106 | startProf = idString.find( ":"+prof+";" ); | 106 | startProf = idString.find( ":"+prof+";" ); |
107 | if ( startProf >= 0 ) { | 107 | if ( startProf >= 0 ) { |
108 | startIDnum = prof.length()+2+startProf; | 108 | startIDnum = prof.length()+2+startProf; |
109 | startID = idString.find( ";", startIDnum ) +1; | 109 | startID = idString.find( ";", startIDnum ) +1; |
110 | startIDnumlen = startID - startIDnum - 1; | 110 | startIDnumlen = startID - startIDnum - 1; |
111 | if ( startIDnum > 0 ) { | 111 | if ( startIDnum > 0 ) { |
112 | bool ok; | 112 | bool ok; |
113 | lenID = idString.mid ( startIDnum,startIDnumlen).toInt( &ok ); | 113 | lenID = idString.mid ( startIDnum,startIDnumlen).toInt( &ok ); |
114 | if (ok) { | 114 | if (ok) { |
115 | startCsum = startID+lenID+1; | 115 | startCsum = startID+lenID+1; |
116 | endall = idString.find( ":", startCsum )-1; | 116 | endall = idString.find( ":", startCsum )-1; |
117 | if ( endall < 0 ) { | 117 | if ( endall < 0 ) { |
118 | qDebug("Error getNumbers: andall not found "); | 118 | qDebug("Error getNumbers: andall not found "); |
119 | return false; | 119 | return false; |
120 | } | 120 | } |
121 | lenCsum = endall-startCsum+1; | 121 | lenCsum = endall-startCsum+1; |
122 | } | 122 | } |
123 | else { | 123 | else { |
124 | qDebug("Error getNumbers:length is no number:*%s* ", idString.mid ( startIDnum,startIDnumlen).latin1()); | 124 | qDebug("Error getNumbers:length is no number:*%s* ", idString.mid ( startIDnum,startIDnumlen).latin1()); |
125 | return false; | 125 | return false; |
126 | } | 126 | } |
127 | } else { | 127 | } else { |
128 | qDebug("Error in KIdManager::getNumbers.startIDnum <= 0"); | 128 | qDebug("Error in KIdManager::getNumbers.startIDnum <= 0"); |
129 | return false; | 129 | return false; |
130 | } | 130 | } |
131 | } else { | 131 | } else { |
132 | //qDebug("getnumbers: profile not found *%s* ",prof.latin1() ); | 132 | //qDebug("getnumbers: profile not found *%s* ",prof.latin1() ); |
133 | return false; | 133 | return false; |
134 | } | 134 | } |
135 | return true; | 135 | return true; |
136 | } | 136 | } |
diff --git a/microkde/kidmanager.h b/microkde/kidmanager.h index 00580a0..9786c9f 100644 --- a/microkde/kidmanager.h +++ b/microkde/kidmanager.h | |||
@@ -1,24 +1,24 @@ | |||
1 | #ifndef MINIKDE_KIDMANAGER_H | 1 | #ifndef MINIKDE_KIDMANAGER_H |
2 | #define MINIKDE_KIDMANAGER_H | 2 | #define MINIKDE_KIDMANAGER_H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | 5 | ||
6 | #include <qobject.h> | 6 | #include <qobject.h> |
7 | class KIdManager : public QObject | 7 | class KIdManager : public QObject |
8 | { | 8 | { |
9 | Q_OBJECT | 9 | Q_OBJECT |
10 | public: | 10 | public: |
11 | KIdManager( ); | 11 | KIdManager( ); |
12 | static QString setId (const QString& idString,const QString& id,const QString& idvalue ) ; | 12 | static const QString setId (const QString& idString,const QString& id,const QString& idvalue ) ; |
13 | static QString getId (const QString& idString,const QString& id ) ; | 13 | static const QString getId (const QString& idString,const QString& id ) ; |
14 | static QString removeId (const QString& idString,const QString& id ) ; | 14 | static const QString removeId (const QString& idString,const QString& id ) ; |
15 | static QString setCsum (const QString& idString,const QString& id,const QString& idvalue ) ; | 15 | static const QString setCsum (const QString& idString,const QString& id,const QString& idvalue ) ; |
16 | static QString getCsum (const QString& idString,const QString& id ) ; | 16 | static const QString getCsum (const QString& idString,const QString& id ) ; |
17 | static bool getNumbers (const QString& idString,const QString& id, int &startProf, int &startIDnum, int &startIDnumlen,int &startID, int& lenID, int &startCsum, int &lenCsum, int & endall) ; | 17 | static bool getNumbers (const QString& idString,const QString& id, int &startProf, int &startIDnum, int &startIDnumlen,int &startID, int& lenID, int &startCsum, int &lenCsum, int & endall) ; |
18 | private: | 18 | private: |
19 | 19 | ||
20 | private slots: | 20 | private slots: |
21 | }; | 21 | }; |
22 | 22 | ||
23 | 23 | ||
24 | #endif | 24 | #endif |