summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-12-02 09:42:53 (UTC)
committer zautrix <zautrix>2005-12-02 09:42:53 (UTC)
commita75d2c26aba6cffae8c3f61e173940240042427b (patch) (unidiff)
tree68f4b61c150bc263a98c78fdf8671bbbc17cdaf8
parent64be8d64fc26d1025a24150d065197ba5d608f3d (diff)
downloadkdepimpi-a75d2c26aba6cffae8c3f61e173940240042427b.zip
kdepimpi-a75d2c26aba6cffae8c3f61e173940240042427b.tar.gz
kdepimpi-a75d2c26aba6cffae8c3f61e173940240042427b.tar.bz2
more sync
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp42
-rw-r--r--kabc/addressbook.h4
-rw-r--r--kaddressbook/kabcore.cpp6
-rw-r--r--kaddressbook/kabcore.h2
-rw-r--r--libkdepim/ksyncmanager.cpp4
5 files changed, 41 insertions, 17 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index e04f4b1..bdc2762 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -1,1272 +1,1296 @@
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/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (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
58using namespace KABC; 58using namespace KABC;
59 59
60struct AddressBook::AddressBookData 60struct 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
70struct AddressBook::Iterator::IteratorData 70struct AddressBook::Iterator::IteratorData
71{ 71{
72 Addressee::List::Iterator mIt; 72 Addressee::List::Iterator mIt;
73}; 73};
74 74
75struct AddressBook::ConstIterator::ConstIteratorData 75struct AddressBook::ConstIterator::ConstIteratorData
76{ 76{
77 Addressee::List::ConstIterator mIt; 77 Addressee::List::ConstIterator mIt;
78}; 78};
79 79
80AddressBook::Iterator::Iterator() 80AddressBook::Iterator::Iterator()
81{ 81{
82 d = new IteratorData; 82 d = new IteratorData;
83} 83}
84 84
85AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) 85AddressBook::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
91AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) 91AddressBook::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
100AddressBook::Iterator::~Iterator() 100AddressBook::Iterator::~Iterator()
101{ 101{
102 delete d; 102 delete d;
103} 103}
104 104
105const Addressee &AddressBook::Iterator::operator*() const 105const Addressee &AddressBook::Iterator::operator*() const
106{ 106{
107 return *(d->mIt); 107 return *(d->mIt);
108} 108}
109 109
110Addressee &AddressBook::Iterator::operator*() 110Addressee &AddressBook::Iterator::operator*()
111{ 111{
112 return *(d->mIt); 112 return *(d->mIt);
113} 113}
114 114
115Addressee *AddressBook::Iterator::operator->() 115Addressee *AddressBook::Iterator::operator->()
116{ 116{
117 return &(*(d->mIt)); 117 return &(*(d->mIt));
118} 118}
119 119
120AddressBook::Iterator &AddressBook::Iterator::operator++() 120AddressBook::Iterator &AddressBook::Iterator::operator++()
121{ 121{
122 (d->mIt)++; 122 (d->mIt)++;
123 return *this; 123 return *this;
124} 124}
125 125
126AddressBook::Iterator &AddressBook::Iterator::operator++(int) 126AddressBook::Iterator &AddressBook::Iterator::operator++(int)
127{ 127{
128 (d->mIt)++; 128 (d->mIt)++;
129 return *this; 129 return *this;
130} 130}
131 131
132AddressBook::Iterator &AddressBook::Iterator::operator--() 132AddressBook::Iterator &AddressBook::Iterator::operator--()
133{ 133{
134 (d->mIt)--; 134 (d->mIt)--;
135 return *this; 135 return *this;
136} 136}
137 137
138AddressBook::Iterator &AddressBook::Iterator::operator--(int) 138AddressBook::Iterator &AddressBook::Iterator::operator--(int)
139{ 139{
140 (d->mIt)--; 140 (d->mIt)--;
141 return *this; 141 return *this;
142} 142}
143 143
144bool AddressBook::Iterator::operator==( const Iterator &it ) 144bool 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
149bool AddressBook::Iterator::operator!=( const Iterator &it ) 149bool 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
155AddressBook::ConstIterator::ConstIterator() 155AddressBook::ConstIterator::ConstIterator()
156{ 156{
157 d = new ConstIteratorData; 157 d = new ConstIteratorData;
158} 158}
159 159
160AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) 160AddressBook::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
166AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) 166AddressBook::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
175AddressBook::ConstIterator::~ConstIterator() 175AddressBook::ConstIterator::~ConstIterator()
176{ 176{
177 delete d; 177 delete d;
178} 178}
179 179
180const Addressee &AddressBook::ConstIterator::operator*() const 180const Addressee &AddressBook::ConstIterator::operator*() const
181{ 181{
182 return *(d->mIt); 182 return *(d->mIt);
183} 183}
184 184
185const Addressee* AddressBook::ConstIterator::operator->() const 185const Addressee* AddressBook::ConstIterator::operator->() const
186{ 186{
187 return &(*(d->mIt)); 187 return &(*(d->mIt));
188} 188}
189 189
190AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() 190AddressBook::ConstIterator &AddressBook::ConstIterator::operator++()
191{ 191{
192 (d->mIt)++; 192 (d->mIt)++;
193 return *this; 193 return *this;
194} 194}
195 195
196AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) 196AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int)
197{ 197{
198 (d->mIt)++; 198 (d->mIt)++;
199 return *this; 199 return *this;
200} 200}
201 201
202AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() 202AddressBook::ConstIterator &AddressBook::ConstIterator::operator--()
203{ 203{
204 (d->mIt)--; 204 (d->mIt)--;
205 return *this; 205 return *this;
206} 206}
207 207
208AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) 208AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int)
209{ 209{
210 (d->mIt)--; 210 (d->mIt)--;
211 return *this; 211 return *this;
212} 212}
213 213
214bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) 214bool 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
219bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) 219bool 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
225AddressBook::AddressBook() 225AddressBook::AddressBook()
226{ 226{
227 init(0, "contact"); 227 init(0, "contact");
228} 228}
229 229
230AddressBook::AddressBook( const QString &config ) 230AddressBook::AddressBook( const QString &config )
231{ 231{
232 init(config, "contact"); 232 init(config, "contact");
233} 233}
234 234
235AddressBook::AddressBook( const QString &config, const QString &family ) 235AddressBook::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"
242void AddressBook::init(const QString &config, const QString &family ) 242void 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
333AddressBook::~AddressBook() 333AddressBook::~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
341bool AddressBook::load() 341bool 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
368bool AddressBook::save( Ticket *ticket ) 368bool 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
380void AddressBook::export2File( QString fileName, QString resourceName ) 380void AddressBook::export2File( QString fileName, QString resourceName )
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() ) { 395 if ( (*it).resource() ) {
396 bool include = (*it).resource()->includeInSync(); 396 bool include = (*it).resource()->includeInSync();
397 if ( !resourceName.isEmpty() ) 397 if ( !resourceName.isEmpty() )
398 include = (resourceName == (*it).resource()->name() ); 398 include = (resourceName == (*it).resource()->name() );
399 if ( include ) { 399 if ( include ) {
400 qDebug(QString ("Exporting resource %1 to file %2").arg( (*it).resource()->name() ).arg( fileName ) ); 400 qDebug(QString ("Exporting resource %1 to file %2").arg( (*it).resource()->name() ).arg( fileName ) );
401 if ( !(*it).IDStr().isEmpty() ) { 401 if ( !(*it).IDStr().isEmpty() ) {
402 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); 402 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() );
403 } 403 }
404 KABC::VCardConverter converter; 404 KABC::VCardConverter converter;
405 QString vcard; 405 QString vcard;
406 //Resource *resource() const; 406 //Resource *resource() const;
407 converter.addresseeToVCard( *it, vcard, version ); 407 converter.addresseeToVCard( *it, vcard, version );
408 t << vcard << "\r\n"; 408 t << vcard << "\r\n";
409 } 409 }
410 } 410 }
411 } 411 }
412 t << "\r\n\r\n"; 412 t << "\r\n\r\n";
413 outFile.close(); 413 outFile.close();
414} 414}
415// if QStringList uids is empty, all are exported 415// if QStringList uids is empty, all are exported
416bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) 416bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName )
417{ 417{
418 KABC::VCardConverter converter; 418 KABC::VCardConverter converter;
419 QString datastream; 419 QString datastream;
420 Iterator it; 420 Iterator it;
421 bool all = uids.isEmpty(); 421 bool all = uids.isEmpty();
422 for ( it = begin(); it != end(); ++it ) { 422 for ( it = begin(); it != end(); ++it ) {
423 // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 423 // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
424 if ( ! all ) { 424 if ( ! all ) {
425 if ( ! ( uids.contains((*it).uid() ) )) 425 if ( ! ( uids.contains((*it).uid() ) ))
426 continue; 426 continue;
427 } 427 }
428 KABC::Addressee a = ( *it ); 428 KABC::Addressee a = ( *it );
429 if ( a.isEmpty() ) 429 if ( a.isEmpty() )
430 continue; 430 continue;
431 if ( all && a.resource() && !a.resource()->includeInSync() ) 431 if ( all && a.resource() && !a.resource()->includeInSync() )
432 continue; 432 continue;
433 a.simplifyEmails(); 433 a.simplifyEmails();
434 a.simplifyPhoneNumbers(); 434 a.simplifyPhoneNumbers();
435 a.simplifyPhoneNumberTypes(); 435 a.simplifyPhoneNumberTypes();
436 a.simplifyAddresses(); 436 a.simplifyAddresses();
437 437
438 QString vcard; 438 QString vcard;
439 QString vcardnew; 439 QString vcardnew;
440 converter.addresseeToVCard( a, vcard ); 440 converter.addresseeToVCard( a, vcard );
441 int start = 0; 441 int start = 0;
442 int next; 442 int next;
443 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 443 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
444 int semi = vcard.find(";", next); 444 int semi = vcard.find(";", next);
445 int dopp = vcard.find(":", next); 445 int dopp = vcard.find(":", next);
446 int sep; 446 int sep;
447 if ( semi < dopp && semi >= 0 ) 447 if ( semi < dopp && semi >= 0 )
448 sep = semi ; 448 sep = semi ;
449 else 449 else
450 sep = dopp; 450 sep = dopp;
451 vcardnew +=vcard.mid( start, next - start); 451 vcardnew +=vcard.mid( start, next - start);
452 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); 452 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper();
453 start = sep; 453 start = sep;
454 } 454 }
455 vcardnew += vcard.mid( start,vcard.length() ); 455 vcardnew += vcard.mid( start,vcard.length() );
456 vcard = ""; 456 vcard = "";
457 start = 0; 457 start = 0;
458 while ( (next = vcardnew.find("ADR", start) )>= 0 ) { 458 while ( (next = vcardnew.find("ADR", start) )>= 0 ) {
459 int sep = vcardnew.find(":", next); 459 int sep = vcardnew.find(":", next);
460 vcard +=vcardnew.mid( start, next - start+3); 460 vcard +=vcardnew.mid( start, next - start+3);
461 start = sep; 461 start = sep;
462 } 462 }
463 vcard += vcardnew.mid( start,vcardnew.length() ); 463 vcard += vcardnew.mid( start,vcardnew.length() );
464 vcard.replace ( QRegExp(";;;") , "" ); 464 vcard.replace ( QRegExp(";;;") , "" );
465 vcard.replace ( QRegExp(";;") , "" ); 465 vcard.replace ( QRegExp(";;") , "" );
466 datastream += vcard; 466 datastream += vcard;
467 467
468 } 468 }
469 469
470 QFile outFile(fileName); 470 QFile outFile(fileName);
471 if ( outFile.open(IO_WriteOnly) ) { 471 if ( outFile.open(IO_WriteOnly) ) {
472 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 472 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
473 QTextStream t( &outFile ); // use a text stream 473 QTextStream t( &outFile ); // use a text stream
474 t.setEncoding( QTextStream::UnicodeUTF8 ); 474 t.setEncoding( QTextStream::UnicodeUTF8 );
475 t <<datastream; 475 t <<datastream;
476 t << "\r\n\r\n"; 476 t << "\r\n\r\n";
477 outFile.close(); 477 outFile.close();
478 478
479 } else { 479 } else {
480 qDebug("Error open temp file "); 480 qDebug("Error open temp file ");
481 return false; 481 return false;
482 } 482 }
483 return true; 483 return true;
484 484
485} 485}
486int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) 486int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld, QString resource )
487{ 487{
488 488
489 if ( removeOld ) 489 if ( removeOld )
490 setUntagged( true ); 490 setUntagged( true, resource );
491 KABC::Addressee::List list; 491 KABC::Addressee::List list;
492 QFile file( fileName ); 492 QFile file( fileName );
493 file.open( IO_ReadOnly ); 493 file.open( IO_ReadOnly );
494 QByteArray rawData = file.readAll(); 494 QByteArray rawData = file.readAll();
495 file.close(); 495 file.close();
496 QString data; 496 QString data;
497 if ( replaceLabel ) { 497 if ( replaceLabel ) {
498 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); 498 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 );
499 data.replace ( QRegExp("LABEL") , "ADR" ); 499 data.replace ( QRegExp("LABEL") , "ADR" );
500 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); 500 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" );
501 } else 501 } else
502 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 502 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
503 KABC::VCardTool tool; 503 KABC::VCardTool tool;
504 list = tool.parseVCards( data ); 504 list = tool.parseVCards( data );
505 KABC::Addressee::List::Iterator it; 505 KABC::Addressee::List::Iterator it;
506
507 Resource * setRes = 0;
508 if ( !resource.isEmpty() ) {
509 KRES::Manager<Resource>::ActiveIterator it;
510 KRES::Manager<Resource> *manager = d->mManager;
511 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
512 qDebug("SaveAB::checking resource..." );
513 if ( (*it)->name() == resource ) {
514 setRes = (*it);
515 qDebug("Inserting imported contacs to resource %s", resource.latin1());
516 break;
517 }
518 }
519 }
506 for ( it = list.begin(); it != list.end(); ++it ) { 520 for ( it = list.begin(); it != list.end(); ++it ) {
507 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); 521 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" );
508 if ( !id.isEmpty() ) 522 if ( !id.isEmpty() )
509 (*it).setIDStr(id ); 523 (*it).setIDStr(id );
510 (*it).setResource( 0 ); 524 (*it).setResource( setRes );
511 if ( replaceLabel ) 525 if ( replaceLabel )
512 (*it).removeVoice(); 526 (*it).removeVoice();
513 if ( removeOld ) 527 if ( removeOld )
514 (*it).setTagged( true ); 528 (*it).setTagged( true );
515 insertAddressee( (*it), false, true ); 529 insertAddressee( (*it), false, true );
516 } 530 }
517 if ( removeOld ) 531 if ( removeOld )
518 removeUntagged(); 532 removeUntagged();
519 return list.count(); 533 return list.count();
520} 534}
521void AddressBook::setUntagged(bool setNonSyncTagged) // = false) 535void AddressBook::setUntagged(bool setNonSyncTagged, QString resource) // = false , "")
522{ 536{
523 Iterator ait; 537 Iterator ait;
524 for ( ait = begin(); ait != end(); ++ait ) { 538 if ( !resource.isEmpty() ) {
525 if ( setNonSyncTagged ) { 539 for ( ait = begin(); ait != end(); ++ait ) {
526 if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { 540 if ( (*ait).resource() && (*ait).resource()->name() == resource ) {
541 (*ait).setTagged( false );
542 }
543 else
527 (*ait).setTagged( true ); 544 (*ait).setTagged( true );
545 }
546 } else {
547 for ( ait = begin(); ait != end(); ++ait ) {
548 if ( setNonSyncTagged ) {
549 if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) {
550 (*ait).setTagged( true );
551 } else
552 (*ait).setTagged( false );
528 } else 553 } else
529 (*ait).setTagged( false ); 554 (*ait).setTagged( false );
530 } else 555 }
531 (*ait).setTagged( false );
532 } 556 }
533} 557}
534void AddressBook::removeUntagged() 558void AddressBook::removeUntagged()
535{ 559{
536 Iterator ait; 560 Iterator ait;
537 bool todelete = false; 561 bool todelete = false;
538 Iterator todel; 562 Iterator todel;
539 for ( ait = begin(); ait != end(); ++ait ) { 563 for ( ait = begin(); ait != end(); ++ait ) {
540 if ( todelete ) 564 if ( todelete )
541 removeAddressee( todel ); 565 removeAddressee( todel );
542 if (!(*ait).tagged()) { 566 if (!(*ait).tagged()) {
543 todelete = true; 567 todelete = true;
544 todel = ait; 568 todel = ait;
545 } else 569 } else
546 todelete = false; 570 todelete = false;
547 } 571 }
548 if ( todelete ) 572 if ( todelete )
549 removeAddressee( todel ); 573 removeAddressee( todel );
550 deleteRemovedAddressees(); 574 deleteRemovedAddressees();
551} 575}
552void AddressBook::smplifyAddressees() 576void AddressBook::smplifyAddressees()
553{ 577{
554 Iterator ait; 578 Iterator ait;
555 for ( ait = begin(); ait != end(); ++ait ) { 579 for ( ait = begin(); ait != end(); ++ait ) {
556 (*ait).simplifyEmails(); 580 (*ait).simplifyEmails();
557 (*ait).simplifyPhoneNumbers(); 581 (*ait).simplifyPhoneNumbers();
558 (*ait).simplifyPhoneNumberTypes(); 582 (*ait).simplifyPhoneNumberTypes();
559 (*ait).simplifyAddresses(); 583 (*ait).simplifyAddresses();
560 } 584 }
561} 585}
562void AddressBook::removeSyncInfo( QString syncProfile) 586void AddressBook::removeSyncInfo( QString syncProfile)
563{ 587{
564 Iterator ait; 588 Iterator ait;
565 for ( ait = begin(); ait != end(); ++ait ) { 589 for ( ait = begin(); ait != end(); ++ait ) {
566 (*ait).removeID( syncProfile ); 590 (*ait).removeID( syncProfile );
567 } 591 }
568 if ( syncProfile.isEmpty() ) { 592 if ( syncProfile.isEmpty() ) {
569 Iterator it = begin(); 593 Iterator it = begin();
570 Iterator it2 ; 594 Iterator it2 ;
571 while ( it != end() ) { 595 while ( it != end() ) {
572 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 596 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
573 it2 = it; 597 it2 = it;
574 //qDebug("removing %s ",(*it).uid().latin1() ); 598 //qDebug("removing %s ",(*it).uid().latin1() );
575 ++it; 599 ++it;
576 removeAddressee( it2 ); 600 removeAddressee( it2 );
577 } else { 601 } else {
578 //qDebug("skipping %s ",(*it).uid().latin1() ); 602 //qDebug("skipping %s ",(*it).uid().latin1() );
579 ++it; 603 ++it;
580 } 604 }
581 } 605 }
582 } else { 606 } else {
583 Addressee lse; 607 Addressee lse;
584 lse = findByUid( "last-syncAddressee-"+ syncProfile ); 608 lse = findByUid( "last-syncAddressee-"+ syncProfile );
585 if ( ! lse.isEmpty() ) 609 if ( ! lse.isEmpty() )
586 removeAddressee( lse ); 610 removeAddressee( lse );
587 } 611 }
588 612
589} 613}
590void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) 614void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync )
591{ 615{
592 Iterator ait; 616 Iterator ait;
593 for ( ait = begin(); ait != end(); ++ait ) { 617 for ( ait = begin(); ait != end(); ++ait ) {
594 QString id = (*ait).IDStr(); 618 QString id = (*ait).IDStr();
595 (*ait).setIDStr( ":"); 619 (*ait).setIDStr( ":");
596 (*ait).setExternalUID( id ); 620 (*ait).setExternalUID( id );
597 (*ait).setOriginalExternalUID( id ); 621 (*ait).setOriginalExternalUID( id );
598 if ( isPreSync ) 622 if ( isPreSync )
599 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 623 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
600 else { 624 else {
601 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 625 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
602 (*ait).setID( currentSyncDevice,id ); 626 (*ait).setID( currentSyncDevice,id );
603 627
604 } 628 }
605 } 629 }
606} 630}
607void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) 631void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice )
608{ 632{
609 633
610 setUntagged(); 634 setUntagged();
611 KABC::Addressee::List list; 635 KABC::Addressee::List list;
612 QFile file( fileName ); 636 QFile file( fileName );
613 file.open( IO_ReadOnly ); 637 file.open( IO_ReadOnly );
614 QByteArray rawData = file.readAll(); 638 QByteArray rawData = file.readAll();
615 file.close(); 639 file.close();
616 QString data; 640 QString data;
617 641
618 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 642 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
619 KABC::VCardTool tool; 643 KABC::VCardTool tool;
620 list = tool.parseVCards( data ); 644 list = tool.parseVCards( data );
621 KABC::Addressee::List::Iterator it; 645 KABC::Addressee::List::Iterator it;
622 for ( it = list.begin(); it != list.end(); ++it ) { 646 for ( it = list.begin(); it != list.end(); ++it ) {
623 Iterator ait; 647 Iterator ait;
624 for ( ait = begin(); ait != end(); ++ait ) { 648 for ( ait = begin(); ait != end(); ++ait ) {
625 if ( !(*ait).tagged() ) { 649 if ( !(*ait).tagged() ) {
626 if ( (*ait).containsAdr(*it)) { 650 if ( (*ait).containsAdr(*it)) {
627 (*ait).setTagged(true); 651 (*ait).setTagged(true);
628 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); 652 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" );
629 (*it).setIDStr( ":"); 653 (*it).setIDStr( ":");
630 (*it).setID( currentSyncDevice,id ); 654 (*it).setID( currentSyncDevice,id );
631 (*it).setExternalUID( id ); 655 (*it).setExternalUID( id );
632 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 656 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
633 (*it).setUid( ( (*ait).uid() )); 657 (*it).setUid( ( (*ait).uid() ));
634 break; 658 break;
635 } 659 }
636 } 660 }
637 661
638 } 662 }
639 if ( ait == end() ) 663 if ( ait == end() )
640 qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); 664 qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1());
641 } 665 }
642 clear(); 666 clear();
643 for ( it = list.begin(); it != list.end(); ++it ) { 667 for ( it = list.begin(); it != list.end(); ++it ) {
644 insertAddressee( (*it) ); 668 insertAddressee( (*it) );
645 } 669 }
646} 670}
647 671
648bool AddressBook::saveABphone( QString fileName ) 672bool AddressBook::saveABphone( QString fileName )
649{ 673{
650 //smplifyAddressees(); 674 //smplifyAddressees();
651 qDebug("saveABphone:: saving AB... "); 675 qDebug("saveABphone:: saving AB... ");
652 if ( ! export2PhoneFormat( QStringList() ,fileName ) ) 676 if ( ! export2PhoneFormat( QStringList() ,fileName ) )
653 return false; 677 return false;
654 qDebug("saveABphone:: writing to phone... "); 678 qDebug("saveABphone:: writing to phone... ");
655 if ( !PhoneAccess::writeToPhone( fileName) ) { 679 if ( !PhoneAccess::writeToPhone( fileName) ) {
656 return false; 680 return false;
657 } 681 }
658 qDebug("saveABphone:: re-reading from phone... "); 682 qDebug("saveABphone:: re-reading from phone... ");
659 if ( !PhoneAccess::readFromPhone( fileName) ) { 683 if ( !PhoneAccess::readFromPhone( fileName) ) {
660 return false; 684 return false;
661 } 685 }
662 return true; 686 return true;
663} 687}
664bool AddressBook::saveAB() 688bool AddressBook::saveAB()
665{ 689{
666 bool ok = true; 690 bool ok = true;
667 691
668 deleteRemovedAddressees(); 692 deleteRemovedAddressees();
669 Iterator ait; 693 Iterator ait;
670 for ( ait = begin(); ait != end(); ++ait ) { 694 for ( ait = begin(); ait != end(); ++ait ) {
671 if ( !(*ait).IDStr().isEmpty() ) { 695 if ( !(*ait).IDStr().isEmpty() ) {
672 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 696 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
673 } 697 }
674 } 698 }
675 KRES::Manager<Resource>::ActiveIterator it; 699 KRES::Manager<Resource>::ActiveIterator it;
676 KRES::Manager<Resource> *manager = d->mManager; 700 KRES::Manager<Resource> *manager = d->mManager;
677 qDebug("SaveAB::saving..." ); 701 qDebug("SaveAB::saving..." );
678 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 702 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
679 qDebug("SaveAB::checking resource..." ); 703 qDebug("SaveAB::checking resource..." );
680 if ( (*it)->readOnly() ) 704 if ( (*it)->readOnly() )
681 qDebug("SaveAB::resource is readonly." ); 705 qDebug("SaveAB::resource is readonly." );
682 if ( (*it)->isOpen() ) 706 if ( (*it)->isOpen() )
683 qDebug("SaveAB::resource is open" ); 707 qDebug("SaveAB::resource is open" );
684 708
685 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 709 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
686 Ticket *ticket = requestSaveTicket( *it ); 710 Ticket *ticket = requestSaveTicket( *it );
687 qDebug("SaveAB::StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 711 qDebug("SaveAB::StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
688 if ( !ticket ) { 712 if ( !ticket ) {
689 qDebug( i18n( "SaveAB::Unable to save to resource '%1'. It is locked." ) 713 qDebug( i18n( "SaveAB::Unable to save to resource '%1'. It is locked." )
690 .arg( (*it)->resourceName() ) ); 714 .arg( (*it)->resourceName() ) );
691 return false; 715 return false;
692 } 716 }
693 717
694 //if ( !save( ticket ) ) 718 //if ( !save( ticket ) )
695 if ( ticket->resource() ) { 719 if ( ticket->resource() ) {
696 QString name = ticket->resource()->resourceName(); 720 QString name = ticket->resource()->resourceName();
697 if ( ! ticket->resource()->save( ticket ) ) 721 if ( ! ticket->resource()->save( ticket ) )
698 ok = false; 722 ok = false;
699 else 723 else
700 qDebug("SaveAB::resource saved '%s'", name.latin1() ); 724 qDebug("SaveAB::resource saved '%s'", name.latin1() );
701 725
702 } else 726 } else
703 ok = false; 727 ok = false;
704 728
705 } 729 }
706 } 730 }
707 return ok; 731 return ok;
708} 732}
709 733
710AddressBook::Iterator AddressBook::begin() 734AddressBook::Iterator AddressBook::begin()
711{ 735{
712 Iterator it = Iterator(); 736 Iterator it = Iterator();
713 it.d->mIt = d->mAddressees.begin(); 737 it.d->mIt = d->mAddressees.begin();
714 return it; 738 return it;
715} 739}
716 740
717AddressBook::ConstIterator AddressBook::begin() const 741AddressBook::ConstIterator AddressBook::begin() const
718{ 742{
719 ConstIterator it = ConstIterator(); 743 ConstIterator it = ConstIterator();
720 it.d->mIt = d->mAddressees.begin(); 744 it.d->mIt = d->mAddressees.begin();
721 return it; 745 return it;
722} 746}
723 747
724AddressBook::Iterator AddressBook::end() 748AddressBook::Iterator AddressBook::end()
725{ 749{
726 Iterator it = Iterator(); 750 Iterator it = Iterator();
727 it.d->mIt = d->mAddressees.end(); 751 it.d->mIt = d->mAddressees.end();
728 return it; 752 return it;
729} 753}
730 754
731AddressBook::ConstIterator AddressBook::end() const 755AddressBook::ConstIterator AddressBook::end() const
732{ 756{
733 ConstIterator it = ConstIterator(); 757 ConstIterator it = ConstIterator();
734 it.d->mIt = d->mAddressees.end(); 758 it.d->mIt = d->mAddressees.end();
735 return it; 759 return it;
736} 760}
737 761
738void AddressBook::clear() 762void AddressBook::clear()
739{ 763{
740 d->mAddressees.clear(); 764 d->mAddressees.clear();
741} 765}
742 766
743Ticket *AddressBook::requestSaveTicket( Resource *resource ) 767Ticket *AddressBook::requestSaveTicket( Resource *resource )
744{ 768{
745 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 769 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
746 770
747 if ( !resource ) 771 if ( !resource )
748 { 772 {
749 qDebug("AddressBook::requestSaveTicket no resource" ); 773 qDebug("AddressBook::requestSaveTicket no resource" );
750 resource = standardResource(); 774 resource = standardResource();
751 } 775 }
752 776
753 KRES::Manager<Resource>::ActiveIterator it; 777 KRES::Manager<Resource>::ActiveIterator it;
754 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 778 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
755 if ( (*it) == resource ) { 779 if ( (*it) == resource ) {
756 if ( (*it)->readOnly() || !(*it)->isOpen() ) 780 if ( (*it)->readOnly() || !(*it)->isOpen() )
757 return 0; 781 return 0;
758 else 782 else
759 return (*it)->requestSaveTicket(); 783 return (*it)->requestSaveTicket();
760 } 784 }
761 } 785 }
762 786
763 return 0; 787 return 0;
764} 788}
765//void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); 789//void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false);
766void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) 790void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource )
767{ 791{
768 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { 792 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) {
769 //qDebug("block insert "); 793 //qDebug("block insert ");
770 return; 794 return;
771 } 795 }
772 //qDebug("inserting.... %s ",a.uid().latin1() ); 796 //qDebug("inserting.... %s ",a.uid().latin1() );
773 bool found = false; 797 bool found = false;
774 Addressee::List::Iterator it; 798 Addressee::List::Iterator it;
775 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 799 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
776 if ( a.uid() == (*it).uid() ) { 800 if ( a.uid() == (*it).uid() ) {
777 801
778 bool changed = false; 802 bool changed = false;
779 Addressee addr = a; 803 Addressee addr = a;
780 if ( addr != (*it) ) 804 if ( addr != (*it) )
781 changed = true; 805 changed = true;
782 806
783 if ( takeResource ) { 807 if ( takeResource ) {
784 Resource * res = (*it).resource(); 808 Resource * res = (*it).resource();
785 (*it) = a; 809 (*it) = a;
786 (*it).setResource( res ); 810 (*it).setResource( res );
787 } else { 811 } else {
788 (*it) = a; 812 (*it) = a;
789 if ( (*it).resource() == 0 ) 813 if ( (*it).resource() == 0 )
790 (*it).setResource( standardResource() ); 814 (*it).setResource( standardResource() );
791 } 815 }
792 if ( changed ) { 816 if ( changed ) {
793 if ( setRev ) { 817 if ( setRev ) {
794 (*it).setRevision( QDateTime::currentDateTime() ); 818 (*it).setRevision( QDateTime::currentDateTime() );
795 } 819 }
796 (*it).setChanged( true ); 820 (*it).setChanged( true );
797 } 821 }
798 822
799 found = true; 823 found = true;
800 } else { 824 } else {
801 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 825 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
802 QString name = (*it).uid().mid( 19 ); 826 QString name = (*it).uid().mid( 19 );
803 Addressee b = a; 827 Addressee b = a;
804 QString id = b.getID( name ); 828 QString id = b.getID( name );
805 if ( ! id.isEmpty() ) { 829 if ( ! id.isEmpty() ) {
806 QString des = (*it).note(); 830 QString des = (*it).note();
807 int startN; 831 int startN;
808 if( (startN = des.find( id ) ) >= 0 ) { 832 if( (startN = des.find( id ) ) >= 0 ) {
809 int endN = des.find( ",", startN+1 ); 833 int endN = des.find( ",", startN+1 );
810 des = des.left( startN ) + des.mid( endN+1 ); 834 des = des.left( startN ) + des.mid( endN+1 );
811 (*it).setNote( des ); 835 (*it).setNote( des );
812 } 836 }
813 } 837 }
814 } 838 }
815 } 839 }
816 } 840 }
817 if ( found ) 841 if ( found )
818 return; 842 return;
819 843
820 d->mAddressees.append( a ); 844 d->mAddressees.append( a );
821 Addressee& addr = d->mAddressees.last(); 845 Addressee& addr = d->mAddressees.last();
822 if ( addr.resource() == 0 ) 846 if ( addr.resource() == 0 )
823 addr.setResource( standardResource() ); 847 addr.setResource( standardResource() );
824 addr.setChanged( true ); 848 addr.setChanged( true );
825} 849}
826 850
827void AddressBook::removeAddressee( const Addressee &a ) 851void AddressBook::removeAddressee( const Addressee &a )
828{ 852{
829 Iterator it; 853 Iterator it;
830 Iterator it2; 854 Iterator it2;
831 bool found = false; 855 bool found = false;
832 for ( it = begin(); it != end(); ++it ) { 856 for ( it = begin(); it != end(); ++it ) {
833 if ( a.uid() == (*it).uid() ) { 857 if ( a.uid() == (*it).uid() ) {
834 found = true; 858 found = true;
835 it2 = it; 859 it2 = it;
836 } else { 860 } else {
837 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 861 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
838 QString name = (*it).uid().mid( 19 ); 862 QString name = (*it).uid().mid( 19 );
839 Addressee b = a; 863 Addressee b = a;
840 QString id = b.getID( name ); 864 QString id = b.getID( name );
841 if ( ! id.isEmpty() ) { 865 if ( ! id.isEmpty() ) {
842 QString des = (*it).note(); 866 QString des = (*it).note();
843 if( des.find( id ) < 0 ) { 867 if( des.find( id ) < 0 ) {
844 des += id + ","; 868 des += id + ",";
845 (*it).setNote( des ); 869 (*it).setNote( des );
846 } 870 }
847 } 871 }
848 } 872 }
849 873
850 } 874 }
851 } 875 }
852 876
853 if ( found ) 877 if ( found )
854 removeAddressee( it2 ); 878 removeAddressee( it2 );
855 879
856} 880}
857 881
858void AddressBook::removeSyncAddressees( bool removeDeleted ) 882void AddressBook::removeSyncAddressees( bool removeDeleted )
859{ 883{
860 Iterator it = begin(); 884 Iterator it = begin();
861 Iterator it2 ; 885 Iterator it2 ;
862 QDateTime dt ( QDate( 2003,1,1) ); 886 QDateTime dt ( QDate( 2003,1,1) );
863 while ( it != end() ) { 887 while ( it != end() ) {
864 (*it).setRevision( dt ); 888 (*it).setRevision( dt );
865 if (( *it).IDStr() != "changed" ) { 889 if (( *it).IDStr() != "changed" ) {
866 // "changed" is used for tagging changed addressees when syncing with KDE or OL 890 // "changed" is used for tagging changed addressees when syncing with KDE or OL
867 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 891 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
868 (*it).setIDStr(":"); 892 (*it).setIDStr(":");
869 } 893 }
870 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { 894 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) {
871 it2 = it; 895 it2 = it;
872 //qDebug("removing %s ",(*it).uid().latin1() ); 896 //qDebug("removing %s ",(*it).uid().latin1() );
873 ++it; 897 ++it;
874 removeAddressee( it2 ); 898 removeAddressee( it2 );
875 } else { 899 } else {
876 //qDebug("skipping %s ",(*it).uid().latin1() ); 900 //qDebug("skipping %s ",(*it).uid().latin1() );
877 if ( removeDeleted ) { 901 if ( removeDeleted ) {
878 // we have no postprocessing in the resource, we have to do it here 902 // we have no postprocessing in the resource, we have to do it here
879 // we have to compute csum for all, because it could be the first sync 903 // we have to compute csum for all, because it could be the first sync
880 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 904 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
881 } 905 }
882 ++it; 906 ++it;
883 } 907 }
884 } 908 }
885 deleteRemovedAddressees(); 909 deleteRemovedAddressees();
886} 910}
887 911
888void AddressBook::removeAddressee( const Iterator &it ) 912void AddressBook::removeAddressee( const Iterator &it )
889{ 913{
890 d->mRemovedAddressees.append( (*it) ); 914 d->mRemovedAddressees.append( (*it) );
891 d->mAddressees.remove( it.d->mIt ); 915 d->mAddressees.remove( it.d->mIt );
892} 916}
893 917
894AddressBook::Iterator AddressBook::find( const Addressee &a ) 918AddressBook::Iterator AddressBook::find( const Addressee &a )
895{ 919{
896 Iterator it; 920 Iterator it;
897 for ( it = begin(); it != end(); ++it ) { 921 for ( it = begin(); it != end(); ++it ) {
898 if ( a.uid() == (*it).uid() ) { 922 if ( a.uid() == (*it).uid() ) {
899 return it; 923 return it;
900 } 924 }
901 } 925 }
902 return end(); 926 return end();
903} 927}
904 928
905Addressee AddressBook::findByUid( const QString &uid ) 929Addressee AddressBook::findByUid( const QString &uid )
906{ 930{
907 Iterator it; 931 Iterator it;
908 for ( it = begin(); it != end(); ++it ) { 932 for ( it = begin(); it != end(); ++it ) {
909 if ( uid == (*it).uid() ) { 933 if ( uid == (*it).uid() ) {
910 return *it; 934 return *it;
911 } 935 }
912 } 936 }
913 return Addressee(); 937 return Addressee();
914} 938}
915void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) 939void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset )
916{ 940{
917 //qDebug("AddressBook::preExternSync "); 941 //qDebug("AddressBook::preExternSync ");
918 AddressBook::Iterator it; 942 AddressBook::Iterator it;
919 for ( it = begin(); it != end(); ++it ) { 943 for ( it = begin(); it != end(); ++it ) {
920 (*it).setID( csd, (*it).externalUID() ); 944 (*it).setID( csd, (*it).externalUID() );
921 (*it).computeCsum( csd ); 945 (*it).computeCsum( csd );
922 } 946 }
923 mergeAB( aBook ,csd, isSubset ); 947 mergeAB( aBook ,csd, isSubset );
924} 948}
925void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) 949void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID)
926{ 950{
927 //qDebug("AddressBook::postExternSync "); 951 //qDebug("AddressBook::postExternSync ");
928 AddressBook::Iterator it; 952 AddressBook::Iterator it;
929 int foundEmpty = 0; 953 int foundEmpty = 0;
930 for ( it = begin(); it != end(); ++it ) { 954 for ( it = begin(); it != end(); ++it ) {
931 //qDebug("check uid %s ", (*it).uid().latin1() ); 955 //qDebug("check uid %s ", (*it).uid().latin1() );
932 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || 956 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
933 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM || 957 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ||
934 (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) { 958 (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) {
935 Addressee ad = aBook->findByUid( ( (*it).uid() )); 959 Addressee ad = aBook->findByUid( ( (*it).uid() ));
936 if ( ad.isEmpty() ) { 960 if ( ad.isEmpty() ) {
937 ++foundEmpty; 961 ++foundEmpty;
938 //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1()); 962 //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1());
939 //qDebug("-- formatted name %s ",(*it).formattedName().latin1() ); 963 //qDebug("-- formatted name %s ",(*it).formattedName().latin1() );
940 } else { 964 } else {
941 (*it).setIDStr(":"); 965 (*it).setIDStr(":");
942 if ( setID ) { 966 if ( setID ) {
943 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) 967 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
944 ad.setID( csd, (*it).externalUID() ); 968 ad.setID( csd, (*it).externalUID() );
945 } else 969 } else
946 ad.setID( csd, (*it).uid() ); 970 ad.setID( csd, (*it).uid() );
947 (*it).computeCsum( csd ); 971 (*it).computeCsum( csd );
948 ad.setCsum( csd, (*it).getCsum( csd ) ); 972 ad.setCsum( csd, (*it).getCsum( csd ) );
949 //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() ); 973 //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() );
950 aBook->insertAddressee( ad , false); 974 aBook->insertAddressee( ad , false);
951 } 975 }
952 } 976 }
953 } 977 }
954 if ( foundEmpty ) { 978 if ( foundEmpty ) {
955 qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty ); 979 qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty );
956 } 980 }
957 981
958} 982}
959 983
960bool AddressBook::containsExternalUid( const QString& uid ) 984bool AddressBook::containsExternalUid( const QString& uid )
961{ 985{
962 Iterator it; 986 Iterator it;
963 for ( it = begin(); it != end(); ++it ) { 987 for ( it = begin(); it != end(); ++it ) {
964 if ( uid == (*it).externalUID( ) ) 988 if ( uid == (*it).externalUID( ) )
965 return true; 989 return true;
966 } 990 }
967 return false; 991 return false;
968} 992}
969const Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) const 993const Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) const
970{ 994{
971 ConstIterator it; 995 ConstIterator it;
972 for ( it = begin(); it != end(); ++it ) { 996 for ( it = begin(); it != end(); ++it ) {
973 if ( uid == (*it).getID( profile ) ) 997 if ( uid == (*it).getID( profile ) )
974 return (*it); 998 return (*it);
975 } 999 }
976 return Addressee(); 1000 return Addressee();
977} 1001}
978void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) 1002void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset )
979{ 1003{
980 Iterator it; 1004 Iterator it;
981 Addressee ad; 1005 Addressee ad;
982 for ( it = begin(); it != end(); ++it ) { 1006 for ( it = begin(); it != end(); ++it ) {
983 ad = aBook->findByExternUid( (*it).externalUID(), profile ); 1007 ad = aBook->findByExternUid( (*it).externalUID(), profile );
984 if ( !ad.isEmpty() ) { 1008 if ( !ad.isEmpty() ) {
985 (*it).mergeContact( ad ,isSubset); 1009 (*it).mergeContact( ad ,isSubset);
986 } 1010 }
987 } 1011 }
988#if 0 1012#if 0
989 // test only 1013 // test only
990 for ( it = begin(); it != end(); ++it ) { 1014 for ( it = begin(); it != end(); ++it ) {
991 1015
992 qDebug("uid %s ", (*it).uid().latin1()); 1016 qDebug("uid %s ", (*it).uid().latin1());
993 } 1017 }
994#endif 1018#endif
995} 1019}
996 1020
997#if 0 1021#if 0
998Addressee::List AddressBook::getExternLastSyncAddressees() 1022Addressee::List AddressBook::getExternLastSyncAddressees()
999{ 1023{
1000 Addressee::List results; 1024 Addressee::List results;
1001 1025
1002 Iterator it; 1026 Iterator it;
1003 for ( it = begin(); it != end(); ++it ) { 1027 for ( it = begin(); it != end(); ++it ) {
1004 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { 1028 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) {
1005 if ( (*it).familyName().left(4) == "!E: " ) 1029 if ( (*it).familyName().left(4) == "!E: " )
1006 results.append( *it ); 1030 results.append( *it );
1007 } 1031 }
1008 } 1032 }
1009 1033
1010 return results; 1034 return results;
1011} 1035}
1012#endif 1036#endif
1013void AddressBook::resetTempSyncStat() 1037void AddressBook::resetTempSyncStat()
1014{ 1038{
1015 Iterator it; 1039 Iterator it;
1016 for ( it = begin(); it != end(); ++it ) { 1040 for ( it = begin(); it != end(); ++it ) {
1017 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); 1041 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
1018 } 1042 }
1019 1043
1020} 1044}
1021 1045
1022QStringList AddressBook:: uidList() 1046QStringList AddressBook:: uidList()
1023{ 1047{
1024 QStringList results; 1048 QStringList results;
1025 Iterator it; 1049 Iterator it;
1026 for ( it = begin(); it != end(); ++it ) { 1050 for ( it = begin(); it != end(); ++it ) {
1027 results.append( (*it).uid() ); 1051 results.append( (*it).uid() );
1028 } 1052 }
1029 return results; 1053 return results;
1030} 1054}
1031 1055
1032 1056
1033Addressee::List AddressBook::allAddressees() 1057Addressee::List AddressBook::allAddressees()
1034{ 1058{
1035 return d->mAddressees; 1059 return d->mAddressees;
1036 1060
1037} 1061}
1038 1062
1039Addressee::List AddressBook::findByName( const QString &name ) 1063Addressee::List AddressBook::findByName( const QString &name )
1040{ 1064{
1041 Addressee::List results; 1065 Addressee::List results;
1042 1066
1043 Iterator it; 1067 Iterator it;
1044 for ( it = begin(); it != end(); ++it ) { 1068 for ( it = begin(); it != end(); ++it ) {
1045 if ( name == (*it).realName() ) { 1069 if ( name == (*it).realName() ) {
1046 results.append( *it ); 1070 results.append( *it );
1047 } 1071 }
1048 } 1072 }
1049 1073
1050 return results; 1074 return results;
1051} 1075}
1052 1076
1053Addressee::List AddressBook::findByEmail( const QString &email ) 1077Addressee::List AddressBook::findByEmail( const QString &email )
1054{ 1078{
1055 Addressee::List results; 1079 Addressee::List results;
1056 QStringList mailList; 1080 QStringList mailList;
1057 1081
1058 Iterator it; 1082 Iterator it;
1059 for ( it = begin(); it != end(); ++it ) { 1083 for ( it = begin(); it != end(); ++it ) {
1060 mailList = (*it).emails(); 1084 mailList = (*it).emails();
1061 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { 1085 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
1062 if ( email == (*ite) ) { 1086 if ( email == (*ite) ) {
1063 results.append( *it ); 1087 results.append( *it );
1064 } 1088 }
1065 } 1089 }
1066 } 1090 }
1067 1091
1068 return results; 1092 return results;
1069} 1093}
1070 1094
1071Addressee::List AddressBook::findByCategory( const QString &category ) 1095Addressee::List AddressBook::findByCategory( const QString &category )
1072{ 1096{
1073 Addressee::List results; 1097 Addressee::List results;
1074 1098
1075 Iterator it; 1099 Iterator it;
1076 for ( it = begin(); it != end(); ++it ) { 1100 for ( it = begin(); it != end(); ++it ) {
1077 if ( (*it).hasCategory( category) ) { 1101 if ( (*it).hasCategory( category) ) {
1078 results.append( *it ); 1102 results.append( *it );
1079 } 1103 }
1080 } 1104 }
1081 1105
1082 return results; 1106 return results;
1083} 1107}
1084 1108
1085void AddressBook::dump() const 1109void AddressBook::dump() const
1086{ 1110{
1087 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; 1111 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl;
1088 1112
1089 ConstIterator it; 1113 ConstIterator it;
1090 for( it = begin(); it != end(); ++it ) { 1114 for( it = begin(); it != end(); ++it ) {
1091 (*it).dump(); 1115 (*it).dump();
1092 } 1116 }
1093 1117
1094 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; 1118 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl;
1095} 1119}
1096 1120
1097QString AddressBook::identifier() 1121QString AddressBook::identifier()
1098{ 1122{
1099 QStringList identifier; 1123 QStringList identifier;
1100 1124
1101 1125
1102 KRES::Manager<Resource>::ActiveIterator it; 1126 KRES::Manager<Resource>::ActiveIterator it;
1103 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 1127 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
1104 if ( !(*it)->identifier().isEmpty() ) 1128 if ( !(*it)->identifier().isEmpty() )
1105 identifier.append( (*it)->identifier() ); 1129 identifier.append( (*it)->identifier() );
1106 } 1130 }
1107 1131
1108 return identifier.join( ":" ); 1132 return identifier.join( ":" );
1109} 1133}
1110 1134
1111Field::List AddressBook::fields( int category ) 1135Field::List AddressBook::fields( int category )
1112{ 1136{
1113 if ( d->mAllFields.isEmpty() ) { 1137 if ( d->mAllFields.isEmpty() ) {
1114 d->mAllFields = Field::allFields(); 1138 d->mAllFields = Field::allFields();
1115 } 1139 }
1116 1140
1117 if ( category == Field::All ) return d->mAllFields; 1141 if ( category == Field::All ) return d->mAllFields;
1118 1142
1119 Field::List result; 1143 Field::List result;
1120 Field::List::ConstIterator it; 1144 Field::List::ConstIterator it;
1121 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { 1145 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) {
1122 if ( (*it)->category() & category ) result.append( *it ); 1146 if ( (*it)->category() & category ) result.append( *it );
1123 } 1147 }
1124 1148
1125 return result; 1149 return result;
1126} 1150}
1127 1151
1128bool AddressBook::addCustomField( const QString &label, int category, 1152bool AddressBook::addCustomField( const QString &label, int category,
1129 const QString &key, const QString &app ) 1153 const QString &key, const QString &app )
1130{ 1154{
1131 if ( d->mAllFields.isEmpty() ) { 1155 if ( d->mAllFields.isEmpty() ) {
1132 d->mAllFields = Field::allFields(); 1156 d->mAllFields = Field::allFields();
1133 } 1157 }
1134//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; 1158//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app;
1135 QString a = app.isNull() ? KGlobal::getAppName() : app; 1159 QString a = app.isNull() ? KGlobal::getAppName() : app;
1136 1160
1137 QString k = key.isNull() ? label : key; 1161 QString k = key.isNull() ? label : key;
1138 1162
1139 Field *field = Field::createCustomField( label, category, k, a ); 1163 Field *field = Field::createCustomField( label, category, k, a );
1140 1164
1141 if ( !field ) return false; 1165 if ( !field ) return false;
1142 1166
1143 d->mAllFields.append( field ); 1167 d->mAllFields.append( field );
1144 1168
1145 return true; 1169 return true;
1146} 1170}
1147 1171
1148QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) 1172QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab )
1149{ 1173{
1150 if (!ab.d) return s; 1174 if (!ab.d) return s;
1151 1175
1152 return s << ab.d->mAddressees; 1176 return s << ab.d->mAddressees;
1153} 1177}
1154 1178
1155QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) 1179QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab )
1156{ 1180{
1157 if (!ab.d) return s; 1181 if (!ab.d) return s;
1158 1182
1159 s >> ab.d->mAddressees; 1183 s >> ab.d->mAddressees;
1160 1184
1161 return s; 1185 return s;
1162} 1186}
1163 1187
1164bool AddressBook::addResource( Resource *resource ) 1188bool AddressBook::addResource( Resource *resource )
1165{ 1189{
1166 if ( !resource->open() ) { 1190 if ( !resource->open() ) {
1167 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; 1191 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl;
1168 return false; 1192 return false;
1169 } 1193 }
1170 1194
1171 resource->setAddressBook( this ); 1195 resource->setAddressBook( this );
1172 1196
1173 d->mManager->add( resource ); 1197 d->mManager->add( resource );
1174 return true; 1198 return true;
1175} 1199}
1176void AddressBook::removeResources() 1200void AddressBook::removeResources()
1177{ 1201{
1178 //remove all possible resources. This should cleanup the configfile. 1202 //remove all possible resources. This should cleanup the configfile.
1179 QPtrList<KABC::Resource> mResources = resources(); 1203 QPtrList<KABC::Resource> mResources = resources();
1180 1204
1181 QPtrListIterator<KABC::Resource> it(mResources); 1205 QPtrListIterator<KABC::Resource> it(mResources);
1182 for ( ; it.current(); ++it ) { 1206 for ( ; it.current(); ++it ) {
1183 KABC::Resource *res = it.current(); 1207 KABC::Resource *res = it.current();
1184 removeResource(res); 1208 removeResource(res);
1185 } 1209 }
1186} 1210}
1187 1211
1188bool AddressBook::removeResource( Resource *resource ) 1212bool AddressBook::removeResource( Resource *resource )
1189{ 1213{
1190 resource->close(); 1214 resource->close();
1191 1215
1192 if ( resource == standardResource() ) 1216 if ( resource == standardResource() )
1193 d->mManager->setStandardResource( 0 ); 1217 d->mManager->setStandardResource( 0 );
1194 1218
1195 resource->setAddressBook( 0 ); 1219 resource->setAddressBook( 0 );
1196 1220
1197 d->mManager->remove( resource ); 1221 d->mManager->remove( resource );
1198 return true; 1222 return true;
1199} 1223}
1200 1224
1201QPtrList<Resource> AddressBook::resources() 1225QPtrList<Resource> AddressBook::resources()
1202{ 1226{
1203 QPtrList<Resource> list; 1227 QPtrList<Resource> list;
1204 1228
1205// qDebug("AddressBook::resources() 1"); 1229// qDebug("AddressBook::resources() 1");
1206 1230
1207 KRES::Manager<Resource>::ActiveIterator it; 1231 KRES::Manager<Resource>::ActiveIterator it;
1208 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 1232 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
1209 list.append( *it ); 1233 list.append( *it );
1210 1234
1211 return list; 1235 return list;
1212} 1236}
1213 1237
1214/*US 1238/*US
1215void AddressBook::setErrorHandler( ErrorHandler *handler ) 1239void AddressBook::setErrorHandler( ErrorHandler *handler )
1216{ 1240{
1217 delete d->mErrorHandler; 1241 delete d->mErrorHandler;
1218 d->mErrorHandler = handler; 1242 d->mErrorHandler = handler;
1219} 1243}
1220*/ 1244*/
1221 1245
1222void AddressBook::error( const QString& msg ) 1246void AddressBook::error( const QString& msg )
1223{ 1247{
1224/*US 1248/*US
1225 if ( !d->mErrorHandler ) // create default error handler 1249 if ( !d->mErrorHandler ) // create default error handler
1226 d->mErrorHandler = new ConsoleErrorHandler; 1250 d->mErrorHandler = new ConsoleErrorHandler;
1227 1251
1228 if ( d->mErrorHandler ) 1252 if ( d->mErrorHandler )
1229 d->mErrorHandler->error( msg ); 1253 d->mErrorHandler->error( msg );
1230 else 1254 else
1231 kdError(5700) << "no error handler defined" << endl; 1255 kdError(5700) << "no error handler defined" << endl;
1232*/ 1256*/
1233 kdDebug(5700) << "msg" << endl; 1257 kdDebug(5700) << "msg" << endl;
1234 qDebug(msg); 1258 qDebug(msg);
1235} 1259}
1236 1260
1237void AddressBook::deleteRemovedAddressees() 1261void AddressBook::deleteRemovedAddressees()
1238{ 1262{
1239 Addressee::List::Iterator it; 1263 Addressee::List::Iterator it;
1240 for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { 1264 for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) {
1241 Resource *resource = (*it).resource(); 1265 Resource *resource = (*it).resource();
1242 if ( resource && !resource->readOnly() && resource->isOpen() ) 1266 if ( resource && !resource->readOnly() && resource->isOpen() )
1243 resource->removeAddressee( *it ); 1267 resource->removeAddressee( *it );
1244 } 1268 }
1245 1269
1246 d->mRemovedAddressees.clear(); 1270 d->mRemovedAddressees.clear();
1247} 1271}
1248 1272
1249void AddressBook::setStandardResource( Resource *resource ) 1273void AddressBook::setStandardResource( Resource *resource )
1250{ 1274{
1251// qDebug("AddressBook::setStandardResource 1"); 1275// qDebug("AddressBook::setStandardResource 1");
1252 d->mManager->setStandardResource( resource ); 1276 d->mManager->setStandardResource( resource );
1253} 1277}
1254 1278
1255Resource *AddressBook::standardResource() 1279Resource *AddressBook::standardResource()
1256{ 1280{
1257 return d->mManager->standardResource(); 1281 return d->mManager->standardResource();
1258} 1282}
1259 1283
1260KRES::Manager<Resource> *AddressBook::resourceManager() 1284KRES::Manager<Resource> *AddressBook::resourceManager()
1261{ 1285{
1262 return d->mManager; 1286 return d->mManager;
1263} 1287}
1264 1288
1265void AddressBook::cleanUp() 1289void AddressBook::cleanUp()
1266{ 1290{
1267 KRES::Manager<Resource>::ActiveIterator it; 1291 KRES::Manager<Resource>::ActiveIterator it;
1268 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 1292 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
1269 if ( !(*it)->readOnly() && (*it)->isOpen() ) 1293 if ( !(*it)->readOnly() && (*it)->isOpen() )
1270 (*it)->cleanUp(); 1294 (*it)->cleanUp();
1271 } 1295 }
1272} 1296}
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 4a0d0a3..e6daa5e 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/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (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
39namespace KABC { 39namespace KABC {
40 40
41class ErrorHandler; 41class ErrorHandler;
42class Resource; 42class Resource;
43class Ticket; 43class 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*/
50class AddressBook : public QObject 50class 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, QString resourceName = "" ); 149 void export2File( QString fileName, QString resourceName = "" );
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, QString resource = "" );
152 void setUntagged( bool setNonSyncTagged = false ); 152 void setUntagged( bool setNonSyncTagged = false, QString resource = "" );
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 const Addressee findByExternUid( const QString& uid , const QString& profile ) const; 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
345QDataStream &operator<<( QDataStream &, const AddressBook & ); 345QDataStream &operator<<( QDataStream &, const AddressBook & );
346QDataStream &operator>>( QDataStream &, AddressBook & ); 346QDataStream &operator>>( QDataStream &, AddressBook & );
347 347
348} 348}
349 349
350#endif 350#endif
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 5d377bf..7d8586a 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -916,2585 +916,2585 @@ void KABCore::export2phone()
916 return; 916 return;
917 // qDebug("count %d ", uids.count()); 917 // qDebug("count %d ", uids.count());
918 918
919 KAex2phonePrefs ex2phone; 919 KAex2phonePrefs ex2phone;
920 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 920 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
921 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 921 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
922 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 922 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
923 923
924 if ( !ex2phone.exec() ) { 924 if ( !ex2phone.exec() ) {
925 return; 925 return;
926 } 926 }
927 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 927 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
928 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 928 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
929 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 929 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
930 930
931 931
932 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 932 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
933 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 933 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
934 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 934 KPimGlobalPrefs::instance()->mEx2PhoneModel );
935 935
936 QString fileName = getPhoneFile(); 936 QString fileName = getPhoneFile();
937 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 937 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
938 return; 938 return;
939 939
940 message(i18n("Exporting to phone...")); 940 message(i18n("Exporting to phone..."));
941 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 941 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
942 942
943} 943}
944QString KABCore::getPhoneFile() 944QString KABCore::getPhoneFile()
945{ 945{
946#ifdef DESKTOP_VERSION 946#ifdef DESKTOP_VERSION
947 return locateLocal("tmp", "phonefile.vcf"); 947 return locateLocal("tmp", "phonefile.vcf");
948#else 948#else
949 return "/tmp/phonefile.vcf"; 949 return "/tmp/phonefile.vcf";
950#endif 950#endif
951 951
952} 952}
953void KABCore::writeToPhone( ) 953void KABCore::writeToPhone( )
954{ 954{
955 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 955 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
956 message(i18n("Export to phone finished!")); 956 message(i18n("Export to phone finished!"));
957 else 957 else
958 qDebug(i18n("KA: Error exporting to phone")); 958 qDebug(i18n("KA: Error exporting to phone"));
959} 959}
960void KABCore::beamVCard() 960void KABCore::beamVCard()
961{ 961{
962 QStringList uids; 962 QStringList uids;
963 XXPortSelectDialog dlg( this, false, this ); 963 XXPortSelectDialog dlg( this, false, this );
964 if ( dlg.exec() ) 964 if ( dlg.exec() )
965 uids = dlg.uids(); 965 uids = dlg.uids();
966 else 966 else
967 return; 967 return;
968 if ( uids.isEmpty() ) 968 if ( uids.isEmpty() )
969 return; 969 return;
970 beamVCard( uids ); 970 beamVCard( uids );
971} 971}
972 972
973 973
974void KABCore::beamVCard(const QStringList& uids) 974void KABCore::beamVCard(const QStringList& uids)
975{ 975{
976 976
977 // LR: we should use the /tmp dir on the Zaurus, 977 // LR: we should use the /tmp dir on the Zaurus,
978 // because: /tmp = RAM, (HOME)/kdepim = flash memory 978 // because: /tmp = RAM, (HOME)/kdepim = flash memory
979 979
980#ifdef DESKTOP_VERSION 980#ifdef DESKTOP_VERSION
981 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 981 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
982#else 982#else
983 QString fileName = "/tmp/kapibeamfile.vcf"; 983 QString fileName = "/tmp/kapibeamfile.vcf";
984#endif 984#endif
985 985
986 KABC::VCardConverter converter; 986 KABC::VCardConverter converter;
987 QString description; 987 QString description;
988 QString datastream; 988 QString datastream;
989 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 989 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
990 KABC::Addressee a = mAddressBook->findByUid( *it ); 990 KABC::Addressee a = mAddressBook->findByUid( *it );
991 991
992 if ( a.isEmpty() ) 992 if ( a.isEmpty() )
993 continue; 993 continue;
994 994
995 if (description.isEmpty()) 995 if (description.isEmpty())
996 description = a.formattedName(); 996 description = a.formattedName();
997 997
998 QString vcard; 998 QString vcard;
999 converter.addresseeToVCard( a, vcard ); 999 converter.addresseeToVCard( a, vcard );
1000 int start = 0; 1000 int start = 0;
1001 int next; 1001 int next;
1002 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 1002 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
1003 int semi = vcard.find(";", next); 1003 int semi = vcard.find(";", next);
1004 int dopp = vcard.find(":", next); 1004 int dopp = vcard.find(":", next);
1005 int sep; 1005 int sep;
1006 if ( semi < dopp && semi >= 0 ) 1006 if ( semi < dopp && semi >= 0 )
1007 sep = semi ; 1007 sep = semi ;
1008 else 1008 else
1009 sep = dopp; 1009 sep = dopp;
1010 datastream +=vcard.mid( start, next - start); 1010 datastream +=vcard.mid( start, next - start);
1011 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 1011 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
1012 start = sep; 1012 start = sep;
1013 } 1013 }
1014 datastream += vcard.mid( start,vcard.length() ); 1014 datastream += vcard.mid( start,vcard.length() );
1015 } 1015 }
1016#ifndef DESKTOP_VERSION 1016#ifndef DESKTOP_VERSION
1017 QFile outFile(fileName); 1017 QFile outFile(fileName);
1018 if ( outFile.open(IO_WriteOnly) ) { 1018 if ( outFile.open(IO_WriteOnly) ) {
1019 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 1019 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
1020 QTextStream t( &outFile ); // use a text stream 1020 QTextStream t( &outFile ); // use a text stream
1021 //t.setEncoding( QTextStream::UnicodeUTF8 ); 1021 //t.setEncoding( QTextStream::UnicodeUTF8 );
1022 t.setEncoding( QTextStream::Latin1 ); 1022 t.setEncoding( QTextStream::Latin1 );
1023 t <<datastream.latin1(); 1023 t <<datastream.latin1();
1024 outFile.close(); 1024 outFile.close();
1025 Ir *ir = new Ir( this ); 1025 Ir *ir = new Ir( this );
1026 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 1026 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
1027 ir->send( fileName, description, "text/x-vCard" ); 1027 ir->send( fileName, description, "text/x-vCard" );
1028 } else { 1028 } else {
1029 qDebug("KA: Error open temp beam file "); 1029 qDebug("KA: Error open temp beam file ");
1030 return; 1030 return;
1031 } 1031 }
1032#endif 1032#endif
1033 1033
1034} 1034}
1035 1035
1036void KABCore::beamDone( Ir *ir ) 1036void KABCore::beamDone( Ir *ir )
1037{ 1037{
1038#ifndef DESKTOP_VERSION 1038#ifndef DESKTOP_VERSION
1039 delete ir; 1039 delete ir;
1040#endif 1040#endif
1041 topLevelWidget()->raise(); 1041 topLevelWidget()->raise();
1042 message( i18n("Beaming finished!") ); 1042 message( i18n("Beaming finished!") );
1043} 1043}
1044 1044
1045 1045
1046void KABCore::browse( const QString& url ) 1046void KABCore::browse( const QString& url )
1047{ 1047{
1048#ifndef KAB_EMBEDDED 1048#ifndef KAB_EMBEDDED
1049 kapp->invokeBrowser( url ); 1049 kapp->invokeBrowser( url );
1050#else //KAB_EMBEDDED 1050#else //KAB_EMBEDDED
1051 qDebug("KABCore::browse must be fixed"); 1051 qDebug("KABCore::browse must be fixed");
1052#endif //KAB_EMBEDDED 1052#endif //KAB_EMBEDDED
1053} 1053}
1054 1054
1055void KABCore::selectAllContacts() 1055void KABCore::selectAllContacts()
1056{ 1056{
1057 mViewManager->setSelected( QString::null, true ); 1057 mViewManager->setSelected( QString::null, true );
1058} 1058}
1059 1059
1060void KABCore::deleteContacts() 1060void KABCore::deleteContacts()
1061{ 1061{
1062 QStringList uidList = mViewManager->selectedUids(); 1062 QStringList uidList = mViewManager->selectedUids();
1063 deleteContacts( uidList ); 1063 deleteContacts( uidList );
1064} 1064}
1065 1065
1066void KABCore::deleteContacts( const QStringList &uids ) 1066void KABCore::deleteContacts( const QStringList &uids )
1067{ 1067{
1068 1068
1069 if ( uids.count() > 0 ) { 1069 if ( uids.count() > 0 ) {
1070 1070
1071 if ( KABPrefs::instance()->mAskForDelete ) { 1071 if ( KABPrefs::instance()->mAskForDelete ) {
1072 int count = uids.count(); 1072 int count = uids.count();
1073 if ( count > 5 ) count = 5; 1073 if ( count > 5 ) count = 5;
1074 QString cNames; 1074 QString cNames;
1075 int i; 1075 int i;
1076 for ( i = 0; i < count ; ++i ) { 1076 for ( i = 0; i < count ; ++i ) {
1077 cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n"; 1077 cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n";
1078 } 1078 }
1079 if ( uids.count() > 5 ) 1079 if ( uids.count() > 5 )
1080 cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 ); 1080 cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 );
1081 QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ; 1081 QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ;
1082 if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes ) 1082 if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes )
1083 return; 1083 return;
1084 } 1084 }
1085 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 1085 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
1086 UndoStack::instance()->push( command ); 1086 UndoStack::instance()->push( command );
1087 RedoStack::instance()->clear(); 1087 RedoStack::instance()->clear();
1088 1088
1089 // now if we deleted anything, refresh 1089 // now if we deleted anything, refresh
1090 setContactSelected( QString::null ); 1090 setContactSelected( QString::null );
1091 setModified( true ); 1091 setModified( true );
1092 } 1092 }
1093} 1093}
1094 1094
1095void KABCore::copyContacts() 1095void KABCore::copyContacts()
1096{ 1096{
1097 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1097 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1098 1098
1099 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 1099 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
1100 1100
1101 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 1101 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
1102 1102
1103 QClipboard *cb = QApplication::clipboard(); 1103 QClipboard *cb = QApplication::clipboard();
1104 cb->setText( clipText ); 1104 cb->setText( clipText );
1105} 1105}
1106 1106
1107void KABCore::cutContacts() 1107void KABCore::cutContacts()
1108{ 1108{
1109 QStringList uidList = mViewManager->selectedUids(); 1109 QStringList uidList = mViewManager->selectedUids();
1110 1110
1111//US if ( uidList.size() > 0 ) { 1111//US if ( uidList.size() > 0 ) {
1112 if ( uidList.count() > 0 ) { 1112 if ( uidList.count() > 0 ) {
1113 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1113 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1114 UndoStack::instance()->push( command ); 1114 UndoStack::instance()->push( command );
1115 RedoStack::instance()->clear(); 1115 RedoStack::instance()->clear();
1116 1116
1117 setModified( true ); 1117 setModified( true );
1118 } 1118 }
1119} 1119}
1120 1120
1121void KABCore::pasteContacts() 1121void KABCore::pasteContacts()
1122{ 1122{
1123 QClipboard *cb = QApplication::clipboard(); 1123 QClipboard *cb = QApplication::clipboard();
1124 1124
1125 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1125 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1126 1126
1127 pasteContacts( list ); 1127 pasteContacts( list );
1128} 1128}
1129 1129
1130void KABCore::pasteContacts( KABC::Addressee::List &list ) 1130void KABCore::pasteContacts( KABC::Addressee::List &list )
1131{ 1131{
1132 KABC::Resource *resource = requestResource( this ); 1132 KABC::Resource *resource = requestResource( this );
1133 KABC::Addressee::List::Iterator it; 1133 KABC::Addressee::List::Iterator it;
1134 for ( it = list.begin(); it != list.end(); ++it ) 1134 for ( it = list.begin(); it != list.end(); ++it )
1135 (*it).setResource( resource ); 1135 (*it).setResource( resource );
1136 1136
1137 PwPasteCommand *command = new PwPasteCommand( this, list ); 1137 PwPasteCommand *command = new PwPasteCommand( this, list );
1138 UndoStack::instance()->push( command ); 1138 UndoStack::instance()->push( command );
1139 RedoStack::instance()->clear(); 1139 RedoStack::instance()->clear();
1140 1140
1141 setModified( true ); 1141 setModified( true );
1142} 1142}
1143 1143
1144void KABCore::setWhoAmI() 1144void KABCore::setWhoAmI()
1145{ 1145{
1146 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1146 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1147 1147
1148 if ( addrList.count() > 1 ) { 1148 if ( addrList.count() > 1 ) {
1149 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1149 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1150 return; 1150 return;
1151 } 1151 }
1152 1152
1153 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1153 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1154 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes ) 1154 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes )
1155 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1155 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1156} 1156}
1157void KABCore::editCategories() 1157void KABCore::editCategories()
1158{ 1158{
1159 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1159 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1160 dlg.exec(); 1160 dlg.exec();
1161} 1161}
1162void KABCore::setCategories() 1162void KABCore::setCategories()
1163{ 1163{
1164 1164
1165 QStringList uids; 1165 QStringList uids;
1166 XXPortSelectDialog dlgx( this, false, this ); 1166 XXPortSelectDialog dlgx( this, false, this );
1167 if ( dlgx.exec() ) 1167 if ( dlgx.exec() )
1168 uids = dlgx.uids(); 1168 uids = dlgx.uids();
1169 else 1169 else
1170 return; 1170 return;
1171 if ( uids.isEmpty() ) 1171 if ( uids.isEmpty() )
1172 return; 1172 return;
1173 // qDebug("count %d ", uids.count()); 1173 // qDebug("count %d ", uids.count());
1174 1174
1175 1175
1176 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1176 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1177 if ( !dlg.exec() ) { 1177 if ( !dlg.exec() ) {
1178 message( i18n("Setting categories cancelled") ); 1178 message( i18n("Setting categories cancelled") );
1179 return; 1179 return;
1180 } 1180 }
1181 bool merge = false; 1181 bool merge = false;
1182 QString msg = i18n( "Merge with existing categories?" ); 1182 QString msg = i18n( "Merge with existing categories?" );
1183 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1183 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1184 merge = true; 1184 merge = true;
1185 1185
1186 message( i18n("Setting categories ... please wait!") ); 1186 message( i18n("Setting categories ... please wait!") );
1187 QStringList categories = dlg.selectedCategories(); 1187 QStringList categories = dlg.selectedCategories();
1188 1188
1189 //QStringList uids = mViewManager->selectedUids(); 1189 //QStringList uids = mViewManager->selectedUids();
1190 QStringList::Iterator it; 1190 QStringList::Iterator it;
1191 for ( it = uids.begin(); it != uids.end(); ++it ) { 1191 for ( it = uids.begin(); it != uids.end(); ++it ) {
1192 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1192 KABC::Addressee addr = mAddressBook->findByUid( *it );
1193 if ( !addr.isEmpty() ) { 1193 if ( !addr.isEmpty() ) {
1194 if ( !merge ) 1194 if ( !merge )
1195 addr.setCategories( categories ); 1195 addr.setCategories( categories );
1196 else { 1196 else {
1197 QStringList addrCategories = addr.categories(); 1197 QStringList addrCategories = addr.categories();
1198 QStringList::Iterator catIt; 1198 QStringList::Iterator catIt;
1199 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1199 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1200 if ( !addrCategories.contains( *catIt ) ) 1200 if ( !addrCategories.contains( *catIt ) )
1201 addrCategories.append( *catIt ); 1201 addrCategories.append( *catIt );
1202 } 1202 }
1203 addr.setCategories( addrCategories ); 1203 addr.setCategories( addrCategories );
1204 } 1204 }
1205 mAddressBook->insertAddressee( addr ); 1205 mAddressBook->insertAddressee( addr );
1206 } 1206 }
1207 } 1207 }
1208 1208
1209 if ( uids.count() > 0 ) 1209 if ( uids.count() > 0 )
1210 setModified( true ); 1210 setModified( true );
1211 message( i18n("Setting categories completed!") ); 1211 message( i18n("Setting categories completed!") );
1212} 1212}
1213 1213
1214void KABCore::setSearchFields( const KABC::Field::List &fields ) 1214void KABCore::setSearchFields( const KABC::Field::List &fields )
1215{ 1215{
1216 mIncSearchWidget->setFields( fields ); 1216 mIncSearchWidget->setFields( fields );
1217} 1217}
1218 1218
1219void KABCore::incrementalSearch( const QString& text ) 1219void KABCore::incrementalSearch( const QString& text )
1220{ 1220{
1221 QString stext; 1221 QString stext;
1222 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { 1222 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) {
1223 stext = "*" + text; 1223 stext = "*" + text;
1224 } else { 1224 } else {
1225 stext = text; 1225 stext = text;
1226 } 1226 }
1227 mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); 1227 mViewManager->doSearch( stext, mIncSearchWidget->currentField() );
1228} 1228}
1229void KABCore::incrementalSearchJump( const QString& text ) 1229void KABCore::incrementalSearchJump( const QString& text )
1230{ 1230{
1231 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1231 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1232} 1232}
1233 1233
1234void KABCore::setModified() 1234void KABCore::setModified()
1235{ 1235{
1236 setModified( true ); 1236 setModified( true );
1237} 1237}
1238 1238
1239void KABCore::setModifiedWOrefresh() 1239void KABCore::setModifiedWOrefresh()
1240{ 1240{
1241 // qDebug("KABCore::setModifiedWOrefresh() "); 1241 // qDebug("KABCore::setModifiedWOrefresh() ");
1242 mModified = true; 1242 mModified = true;
1243 mActionSave->setEnabled( mModified ); 1243 mActionSave->setEnabled( mModified );
1244 1244
1245 1245
1246} 1246}
1247void KABCore::setModified( bool modified ) 1247void KABCore::setModified( bool modified )
1248{ 1248{
1249 mModified = modified; 1249 mModified = modified;
1250 mActionSave->setEnabled( mModified ); 1250 mActionSave->setEnabled( mModified );
1251 1251
1252 if ( modified ) 1252 if ( modified )
1253 mJumpButtonBar->recreateButtons(); 1253 mJumpButtonBar->recreateButtons();
1254 1254
1255 mViewManager->refreshView(); 1255 mViewManager->refreshView();
1256 1256
1257} 1257}
1258 1258
1259bool KABCore::modified() const 1259bool KABCore::modified() const
1260{ 1260{
1261 return mModified; 1261 return mModified;
1262} 1262}
1263 1263
1264void KABCore::contactModified( const KABC::Addressee &addr ) 1264void KABCore::contactModified( const KABC::Addressee &addr )
1265{ 1265{
1266 addrModified( addr ); 1266 addrModified( addr );
1267#if 0 // debug only 1267#if 0 // debug only
1268 KABC::Addressee ad = addr; 1268 KABC::Addressee ad = addr;
1269 ad.computeCsum( "123"); 1269 ad.computeCsum( "123");
1270#endif 1270#endif
1271} 1271}
1272 1272
1273void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) 1273void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
1274{ 1274{
1275 1275
1276 Command *command = 0; 1276 Command *command = 0;
1277 QString uid; 1277 QString uid;
1278 1278
1279 // check if it exists already 1279 // check if it exists already
1280 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1280 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1281 if ( origAddr.isEmpty() ) 1281 if ( origAddr.isEmpty() )
1282 command = new PwNewCommand( mAddressBook, addr ); 1282 command = new PwNewCommand( mAddressBook, addr );
1283 else { 1283 else {
1284 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1284 command = new PwEditCommand( mAddressBook, origAddr, addr );
1285 uid = addr.uid(); 1285 uid = addr.uid();
1286 } 1286 }
1287 1287
1288 UndoStack::instance()->push( command ); 1288 UndoStack::instance()->push( command );
1289 RedoStack::instance()->clear(); 1289 RedoStack::instance()->clear();
1290 if ( updateDetails ) 1290 if ( updateDetails )
1291 mDetails->setAddressee( addr ); 1291 mDetails->setAddressee( addr );
1292 setModified( true ); 1292 setModified( true );
1293} 1293}
1294 1294
1295void KABCore::newContact() 1295void KABCore::newContact()
1296{ 1296{
1297 1297
1298 1298
1299 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1299 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1300 1300
1301 QPtrList<KRES::Resource> kresResources; 1301 QPtrList<KRES::Resource> kresResources;
1302 QPtrListIterator<KABC::Resource> it( kabcResources ); 1302 QPtrListIterator<KABC::Resource> it( kabcResources );
1303 KABC::Resource *resource; 1303 KABC::Resource *resource;
1304 while ( ( resource = it.current() ) != 0 ) { 1304 while ( ( resource = it.current() ) != 0 ) {
1305 ++it; 1305 ++it;
1306 if ( !resource->readOnly() ) { 1306 if ( !resource->readOnly() ) {
1307 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1307 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1308 if ( res ) 1308 if ( res )
1309 kresResources.append( res ); 1309 kresResources.append( res );
1310 } 1310 }
1311 } 1311 }
1312 1312
1313 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1313 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1314 resource = static_cast<KABC::Resource*>( res ); 1314 resource = static_cast<KABC::Resource*>( res );
1315 1315
1316 if ( resource ) { 1316 if ( resource ) {
1317 KABC::Addressee addr; 1317 KABC::Addressee addr;
1318 addr.setResource( resource ); 1318 addr.setResource( resource );
1319 mEditorDialog->setAddressee( addr ); 1319 mEditorDialog->setAddressee( addr );
1320 mEditorDialog->setCaption( i18n("Edit new contact")); 1320 mEditorDialog->setCaption( i18n("Edit new contact"));
1321 KApplication::execDialog ( mEditorDialog ); 1321 KApplication::execDialog ( mEditorDialog );
1322 1322
1323 } else 1323 } else
1324 return; 1324 return;
1325 1325
1326 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1326 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1327 1327
1328 1328
1329} 1329}
1330 1330
1331void KABCore::addEmail( QString aStr ) 1331void KABCore::addEmail( QString aStr )
1332{ 1332{
1333#ifndef KAB_EMBEDDED 1333#ifndef KAB_EMBEDDED
1334 QString fullName, email; 1334 QString fullName, email;
1335 1335
1336 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1336 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1337 1337
1338 // Try to lookup the addressee matching the email address 1338 // Try to lookup the addressee matching the email address
1339 bool found = false; 1339 bool found = false;
1340 QStringList emailList; 1340 QStringList emailList;
1341 KABC::AddressBook::Iterator it; 1341 KABC::AddressBook::Iterator it;
1342 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1342 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1343 emailList = (*it).emails(); 1343 emailList = (*it).emails();
1344 if ( emailList.contains( email ) > 0 ) { 1344 if ( emailList.contains( email ) > 0 ) {
1345 found = true; 1345 found = true;
1346 (*it).setNameFromString( fullName ); 1346 (*it).setNameFromString( fullName );
1347 editContact( (*it).uid() ); 1347 editContact( (*it).uid() );
1348 } 1348 }
1349 } 1349 }
1350 1350
1351 if ( !found ) { 1351 if ( !found ) {
1352 KABC::Addressee addr; 1352 KABC::Addressee addr;
1353 addr.setNameFromString( fullName ); 1353 addr.setNameFromString( fullName );
1354 addr.insertEmail( email, true ); 1354 addr.insertEmail( email, true );
1355 1355
1356 mAddressBook->insertAddressee( addr ); 1356 mAddressBook->insertAddressee( addr );
1357 mViewManager->refreshView( addr.uid() ); 1357 mViewManager->refreshView( addr.uid() );
1358 editContact( addr.uid() ); 1358 editContact( addr.uid() );
1359 } 1359 }
1360#else //KAB_EMBEDDED 1360#else //KAB_EMBEDDED
1361 qDebug("KABCore::addEmail finsih method"); 1361 qDebug("KABCore::addEmail finsih method");
1362#endif //KAB_EMBEDDED 1362#endif //KAB_EMBEDDED
1363} 1363}
1364 1364
1365void KABCore::importVCard( const KURL &url, bool showPreview ) 1365void KABCore::importVCard( const KURL &url, bool showPreview )
1366{ 1366{
1367 mXXPortManager->importVCard( url, showPreview ); 1367 mXXPortManager->importVCard( url, showPreview );
1368} 1368}
1369void KABCore::importFromOL() 1369void KABCore::importFromOL()
1370{ 1370{
1371#ifdef _OL_IMPORT_ 1371#ifdef _OL_IMPORT_
1372 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1372 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1373 idgl->exec(); 1373 idgl->exec();
1374 KABC::Addressee::List list = idgl->getAddressList(); 1374 KABC::Addressee::List list = idgl->getAddressList();
1375 if ( list.count() > 0 ) { 1375 if ( list.count() > 0 ) {
1376 KABC::Addressee::List listNew; 1376 KABC::Addressee::List listNew;
1377 KABC::Addressee::List listExisting; 1377 KABC::Addressee::List listExisting;
1378 KABC::Addressee::List::Iterator it; 1378 KABC::Addressee::List::Iterator it;
1379 KABC::AddressBook::Iterator iter; 1379 KABC::AddressBook::Iterator iter;
1380 for ( it = list.begin(); it != list.end(); ++it ) { 1380 for ( it = list.begin(); it != list.end(); ++it ) {
1381 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1381 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1382 listNew.append( (*it) ); 1382 listNew.append( (*it) );
1383 else 1383 else
1384 listExisting.append( (*it) ); 1384 listExisting.append( (*it) );
1385 } 1385 }
1386 if ( listExisting.count() > 0 ) 1386 if ( listExisting.count() > 0 )
1387 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1387 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1388 if ( listNew.count() > 0 ) { 1388 if ( listNew.count() > 0 ) {
1389 pasteWithNewUid = false; 1389 pasteWithNewUid = false;
1390 pasteContacts( listNew ); 1390 pasteContacts( listNew );
1391 pasteWithNewUid = true; 1391 pasteWithNewUid = true;
1392 } 1392 }
1393 } 1393 }
1394 delete idgl; 1394 delete idgl;
1395#endif 1395#endif
1396} 1396}
1397 1397
1398void KABCore::importVCard( const QString &vCard, bool showPreview ) 1398void KABCore::importVCard( const QString &vCard, bool showPreview )
1399{ 1399{
1400 mXXPortManager->importVCard( vCard, showPreview ); 1400 mXXPortManager->importVCard( vCard, showPreview );
1401} 1401}
1402 1402
1403//US added a second method without defaultparameter 1403//US added a second method without defaultparameter
1404void KABCore::editContact2() { 1404void KABCore::editContact2() {
1405 editContact( QString::null ); 1405 editContact( QString::null );
1406} 1406}
1407 1407
1408void KABCore::editContact( const QString &uid ) 1408void KABCore::editContact( const QString &uid )
1409{ 1409{
1410 1410
1411 if ( mExtensionManager->isQuickEditVisible() ) 1411 if ( mExtensionManager->isQuickEditVisible() )
1412 return; 1412 return;
1413 1413
1414 // First, locate the contact entry 1414 // First, locate the contact entry
1415 QString localUID = uid; 1415 QString localUID = uid;
1416 if ( localUID.isNull() ) { 1416 if ( localUID.isNull() ) {
1417 QStringList uidList = mViewManager->selectedUids(); 1417 QStringList uidList = mViewManager->selectedUids();
1418 if ( uidList.count() > 0 ) 1418 if ( uidList.count() > 0 )
1419 localUID = *( uidList.at( 0 ) ); 1419 localUID = *( uidList.at( 0 ) );
1420 } 1420 }
1421 1421
1422 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1422 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1423 if ( !addr.isEmpty() ) { 1423 if ( !addr.isEmpty() ) {
1424 mEditorDialog->setAddressee( addr ); 1424 mEditorDialog->setAddressee( addr );
1425 KApplication::execDialog ( mEditorDialog ); 1425 KApplication::execDialog ( mEditorDialog );
1426 } 1426 }
1427} 1427}
1428 1428
1429/** 1429/**
1430 Shows or edits the detail view for the given uid. If the uid is QString::null, 1430 Shows or edits the detail view for the given uid. If the uid is QString::null,
1431 the method will try to find a selected addressee in the view. 1431 the method will try to find a selected addressee in the view.
1432 */ 1432 */
1433void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1433void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1434{ 1434{
1435 if ( mMultipleViewsAtOnce ) 1435 if ( mMultipleViewsAtOnce )
1436 { 1436 {
1437 editContact( uid ); 1437 editContact( uid );
1438 } 1438 }
1439 else 1439 else
1440 { 1440 {
1441 setDetailsVisible( true ); 1441 setDetailsVisible( true );
1442 mActionDetails->setChecked(true); 1442 mActionDetails->setChecked(true);
1443 } 1443 }
1444 1444
1445} 1445}
1446 1446
1447void KABCore::save() 1447void KABCore::save()
1448{ 1448{
1449 if (syncManager->blockSave()) 1449 if (syncManager->blockSave())
1450 return; 1450 return;
1451 if ( !mModified ) 1451 if ( !mModified )
1452 return; 1452 return;
1453 1453
1454 syncManager->setBlockSave(true); 1454 syncManager->setBlockSave(true);
1455 QString text = i18n( "There was an error while attempting to save\n the " 1455 QString text = i18n( "There was an error while attempting to save\n the "
1456 "address book. Please check that some \nother application is " 1456 "address book. Please check that some \nother application is "
1457 "not using it. " ); 1457 "not using it. " );
1458 message(i18n("Saving ... please wait! "), false); 1458 message(i18n("Saving ... please wait! "), false);
1459 //qApp->processEvents(); 1459 //qApp->processEvents();
1460#ifndef KAB_EMBEDDED 1460#ifndef KAB_EMBEDDED
1461 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1461 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1462 if ( !b || !b->save() ) { 1462 if ( !b || !b->save() ) {
1463 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1463 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1464 } 1464 }
1465#else //KAB_EMBEDDED 1465#else //KAB_EMBEDDED
1466 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1466 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1467 if ( !b || !b->save() ) { 1467 if ( !b || !b->save() ) {
1468 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1468 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1469 } 1469 }
1470#endif //KAB_EMBEDDED 1470#endif //KAB_EMBEDDED
1471 1471
1472 message(i18n("Addressbook saved!")); 1472 message(i18n("Addressbook saved!"));
1473 setModified( false ); 1473 setModified( false );
1474 syncManager->setBlockSave(false); 1474 syncManager->setBlockSave(false);
1475} 1475}
1476 1476
1477 1477
1478void KABCore::undo() 1478void KABCore::undo()
1479{ 1479{
1480 UndoStack::instance()->undo(); 1480 UndoStack::instance()->undo();
1481 1481
1482 // Refresh the view 1482 // Refresh the view
1483 mViewManager->refreshView(); 1483 mViewManager->refreshView();
1484} 1484}
1485 1485
1486void KABCore::redo() 1486void KABCore::redo()
1487{ 1487{
1488 RedoStack::instance()->redo(); 1488 RedoStack::instance()->redo();
1489 1489
1490 // Refresh the view 1490 // Refresh the view
1491 mViewManager->refreshView(); 1491 mViewManager->refreshView();
1492} 1492}
1493void KABCore::setJumpButtonBar( bool visible ) 1493void KABCore::setJumpButtonBar( bool visible )
1494{ 1494{
1495 setJumpButtonBarVisible(visible ); 1495 setJumpButtonBarVisible(visible );
1496 saveSettings(); 1496 saveSettings();
1497} 1497}
1498void KABCore::setJumpButtonBarVisible( bool visible ) 1498void KABCore::setJumpButtonBarVisible( bool visible )
1499{ 1499{
1500 if (mMultipleViewsAtOnce) 1500 if (mMultipleViewsAtOnce)
1501 { 1501 {
1502 if ( visible ) 1502 if ( visible )
1503 mJumpButtonBar->show(); 1503 mJumpButtonBar->show();
1504 else 1504 else
1505 mJumpButtonBar->hide(); 1505 mJumpButtonBar->hide();
1506 } 1506 }
1507 else 1507 else
1508 { 1508 {
1509 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1509 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1510 if (mViewManager->isVisible()) 1510 if (mViewManager->isVisible())
1511 { 1511 {
1512 if ( visible ) 1512 if ( visible )
1513 mJumpButtonBar->show(); 1513 mJumpButtonBar->show();
1514 else 1514 else
1515 mJumpButtonBar->hide(); 1515 mJumpButtonBar->hide();
1516 } 1516 }
1517 else 1517 else
1518 { 1518 {
1519 mJumpButtonBar->hide(); 1519 mJumpButtonBar->hide();
1520 } 1520 }
1521 } 1521 }
1522 if ( visible ) { 1522 if ( visible ) {
1523 if ( mIncSearchWidget->currentItem() == 0 ) { 1523 if ( mIncSearchWidget->currentItem() == 0 ) {
1524 message( i18n("Change search field enable jump bar") ); 1524 message( i18n("Change search field enable jump bar") );
1525 } 1525 }
1526 } 1526 }
1527} 1527}
1528 1528
1529 1529
1530void KABCore::setDetailsToState() 1530void KABCore::setDetailsToState()
1531{ 1531{
1532 setDetailsVisible( mActionDetails->isChecked() ); 1532 setDetailsVisible( mActionDetails->isChecked() );
1533} 1533}
1534void KABCore::setDetailsToggle() 1534void KABCore::setDetailsToggle()
1535{ 1535{
1536 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1536 mActionDetails->setChecked( !mActionDetails->isChecked() );
1537 setDetailsToState(); 1537 setDetailsToState();
1538} 1538}
1539 1539
1540 1540
1541 1541
1542void KABCore::setDetailsVisible( bool visible ) 1542void KABCore::setDetailsVisible( bool visible )
1543{ 1543{
1544 if (visible && mDetails->isHidden()) 1544 if (visible && mDetails->isHidden())
1545 { 1545 {
1546 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1546 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1547 if ( addrList.count() > 0 ) 1547 if ( addrList.count() > 0 )
1548 mDetails->setAddressee( addrList[ 0 ] ); 1548 mDetails->setAddressee( addrList[ 0 ] );
1549 } 1549 }
1550 1550
1551 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1551 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1552 // the listview and the detailview. We do that by changing the splitbar size. 1552 // the listview and the detailview. We do that by changing the splitbar size.
1553 if (mMultipleViewsAtOnce) 1553 if (mMultipleViewsAtOnce)
1554 { 1554 {
1555 if ( visible ) 1555 if ( visible )
1556 mDetails->show(); 1556 mDetails->show();
1557 else 1557 else
1558 mDetails->hide(); 1558 mDetails->hide();
1559 } 1559 }
1560 else 1560 else
1561 { 1561 {
1562 if ( visible ) { 1562 if ( visible ) {
1563 mViewManager->hide(); 1563 mViewManager->hide();
1564 mDetails->show(); 1564 mDetails->show();
1565 mIncSearchWidget->setFocus(); 1565 mIncSearchWidget->setFocus();
1566 } 1566 }
1567 else { 1567 else {
1568 mViewManager->show(); 1568 mViewManager->show();
1569 mDetails->hide(); 1569 mDetails->hide();
1570 mViewManager->setFocusAV(); 1570 mViewManager->setFocusAV();
1571 } 1571 }
1572 setJumpButtonBarVisible( !visible ); 1572 setJumpButtonBarVisible( !visible );
1573 } 1573 }
1574 1574
1575} 1575}
1576 1576
1577void KABCore::extensionChanged( int id ) 1577void KABCore::extensionChanged( int id )
1578{ 1578{
1579 //change the details view only for non desktop systems 1579 //change the details view only for non desktop systems
1580#ifndef DESKTOP_VERSION 1580#ifndef DESKTOP_VERSION
1581 1581
1582 if (id == 0) 1582 if (id == 0)
1583 { 1583 {
1584 //the user disabled the extension. 1584 //the user disabled the extension.
1585 1585
1586 if (mMultipleViewsAtOnce) 1586 if (mMultipleViewsAtOnce)
1587 { // enable detailsview again 1587 { // enable detailsview again
1588 setDetailsVisible( true ); 1588 setDetailsVisible( true );
1589 mActionDetails->setChecked( true ); 1589 mActionDetails->setChecked( true );
1590 } 1590 }
1591 else 1591 else
1592 { //go back to the listview 1592 { //go back to the listview
1593 setDetailsVisible( false ); 1593 setDetailsVisible( false );
1594 mActionDetails->setChecked( false ); 1594 mActionDetails->setChecked( false );
1595 mActionDetails->setEnabled(true); 1595 mActionDetails->setEnabled(true);
1596 } 1596 }
1597 1597
1598 } 1598 }
1599 else 1599 else
1600 { 1600 {
1601 //the user enabled the extension. 1601 //the user enabled the extension.
1602 setDetailsVisible( false ); 1602 setDetailsVisible( false );
1603 mActionDetails->setChecked( false ); 1603 mActionDetails->setChecked( false );
1604 1604
1605 if (!mMultipleViewsAtOnce) 1605 if (!mMultipleViewsAtOnce)
1606 { 1606 {
1607 mActionDetails->setEnabled(false); 1607 mActionDetails->setEnabled(false);
1608 } 1608 }
1609 1609
1610 mExtensionManager->setSelectionChanged(); 1610 mExtensionManager->setSelectionChanged();
1611 1611
1612 } 1612 }
1613 1613
1614#endif// DESKTOP_VERSION 1614#endif// DESKTOP_VERSION
1615 1615
1616} 1616}
1617 1617
1618 1618
1619void KABCore::extensionModified( const KABC::Addressee::List &list ) 1619void KABCore::extensionModified( const KABC::Addressee::List &list )
1620{ 1620{
1621 1621
1622 if ( list.count() != 0 ) { 1622 if ( list.count() != 0 ) {
1623 KABC::Addressee::List::ConstIterator it; 1623 KABC::Addressee::List::ConstIterator it;
1624 for ( it = list.begin(); it != list.end(); ++it ) 1624 for ( it = list.begin(); it != list.end(); ++it )
1625 mAddressBook->insertAddressee( *it ); 1625 mAddressBook->insertAddressee( *it );
1626 if ( list.count() > 1 ) 1626 if ( list.count() > 1 )
1627 setModified(); 1627 setModified();
1628 else 1628 else
1629 setModifiedWOrefresh(); 1629 setModifiedWOrefresh();
1630 } 1630 }
1631 if ( list.count() == 0 ) 1631 if ( list.count() == 0 )
1632 mViewManager->refreshView(); 1632 mViewManager->refreshView();
1633 else 1633 else
1634 mViewManager->refreshView( list[ 0 ].uid() ); 1634 mViewManager->refreshView( list[ 0 ].uid() );
1635 1635
1636 1636
1637 1637
1638} 1638}
1639 1639
1640QString KABCore::getNameByPhone( const QString &phone ) 1640QString KABCore::getNameByPhone( const QString &phone )
1641{ 1641{
1642#ifndef KAB_EMBEDDED 1642#ifndef KAB_EMBEDDED
1643 QRegExp r( "[/*/-/ ]" ); 1643 QRegExp r( "[/*/-/ ]" );
1644 QString localPhone( phone ); 1644 QString localPhone( phone );
1645 1645
1646 bool found = false; 1646 bool found = false;
1647 QString ownerName = ""; 1647 QString ownerName = "";
1648 KABC::AddressBook::Iterator iter; 1648 KABC::AddressBook::Iterator iter;
1649 KABC::PhoneNumber::List::Iterator phoneIter; 1649 KABC::PhoneNumber::List::Iterator phoneIter;
1650 KABC::PhoneNumber::List phoneList; 1650 KABC::PhoneNumber::List phoneList;
1651 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1651 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1652 phoneList = (*iter).phoneNumbers(); 1652 phoneList = (*iter).phoneNumbers();
1653 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1653 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1654 ++phoneIter) { 1654 ++phoneIter) {
1655 // Get rid of separator chars so just the numbers are compared. 1655 // Get rid of separator chars so just the numbers are compared.
1656 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1656 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1657 ownerName = (*iter).formattedName(); 1657 ownerName = (*iter).formattedName();
1658 found = true; 1658 found = true;
1659 } 1659 }
1660 } 1660 }
1661 } 1661 }
1662 1662
1663 return ownerName; 1663 return ownerName;
1664#else //KAB_EMBEDDED 1664#else //KAB_EMBEDDED
1665 qDebug("KABCore::getNameByPhone finsih method"); 1665 qDebug("KABCore::getNameByPhone finsih method");
1666 return ""; 1666 return "";
1667#endif //KAB_EMBEDDED 1667#endif //KAB_EMBEDDED
1668 1668
1669} 1669}
1670void KABCore::openConfigGlobalDialog() 1670void KABCore::openConfigGlobalDialog()
1671{ 1671{
1672 KPimPrefsGlobalDialog gc ( this ); 1672 KPimPrefsGlobalDialog gc ( this );
1673 gc.exec(); 1673 gc.exec();
1674} 1674}
1675void KABCore::openConfigDialog() 1675void KABCore::openConfigDialog()
1676{ 1676{
1677 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true); 1677 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true);
1678 1678
1679 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" ); 1679 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" );
1680 ConfigureDialog->setMainWidget( kabcfg ); 1680 ConfigureDialog->setMainWidget( kabcfg );
1681 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1681 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1682 this, SLOT( configurationChanged() ) ); 1682 this, SLOT( configurationChanged() ) );
1683 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1683 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1684 kabcfg, SLOT( save() ) ); 1684 kabcfg, SLOT( save() ) );
1685 connect( ConfigureDialog, SIGNAL( acceptClicked() ), 1685 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
1686 this, SLOT( configurationChanged() ) ); 1686 this, SLOT( configurationChanged() ) );
1687 connect( ConfigureDialog, SIGNAL( acceptClicked() ), 1687 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
1688 kabcfg, SLOT( save() ) ); 1688 kabcfg, SLOT( save() ) );
1689 connect( ConfigureDialog, SIGNAL( defaultClicked() ), 1689 connect( ConfigureDialog, SIGNAL( defaultClicked() ),
1690 kabcfg, SLOT( defaults() ) ); 1690 kabcfg, SLOT( defaults() ) );
1691 saveSettings(); 1691 saveSettings();
1692 kabcfg->load(); 1692 kabcfg->load();
1693#ifndef DESKTOP_VERSION 1693#ifndef DESKTOP_VERSION
1694 if ( QApplication::desktop()->height() <= 480 ) 1694 if ( QApplication::desktop()->height() <= 480 )
1695 ConfigureDialog->hideButtons(); 1695 ConfigureDialog->hideButtons();
1696 ConfigureDialog->showMaximized(); 1696 ConfigureDialog->showMaximized();
1697#endif 1697#endif
1698 if ( ConfigureDialog->exec() ) 1698 if ( ConfigureDialog->exec() )
1699 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1699 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1700 delete ConfigureDialog; 1700 delete ConfigureDialog;
1701} 1701}
1702 1702
1703void KABCore::openLDAPDialog() 1703void KABCore::openLDAPDialog()
1704{ 1704{
1705#ifndef KAB_EMBEDDED 1705#ifndef KAB_EMBEDDED
1706 if ( !mLdapSearchDialog ) { 1706 if ( !mLdapSearchDialog ) {
1707 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1707 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1708 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1708 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1709 SLOT( refreshView() ) ); 1709 SLOT( refreshView() ) );
1710 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1710 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1711 SLOT( setModified() ) ); 1711 SLOT( setModified() ) );
1712 } else 1712 } else
1713 mLdapSearchDialog->restoreSettings(); 1713 mLdapSearchDialog->restoreSettings();
1714 1714
1715 if ( mLdapSearchDialog->isOK() ) 1715 if ( mLdapSearchDialog->isOK() )
1716 mLdapSearchDialog->exec(); 1716 mLdapSearchDialog->exec();
1717#else //KAB_EMBEDDED 1717#else //KAB_EMBEDDED
1718 qDebug("KABCore::openLDAPDialog() finsih method"); 1718 qDebug("KABCore::openLDAPDialog() finsih method");
1719#endif //KAB_EMBEDDED 1719#endif //KAB_EMBEDDED
1720} 1720}
1721 1721
1722void KABCore::print() 1722void KABCore::print()
1723{ 1723{
1724#ifndef KAB_EMBEDDED 1724#ifndef KAB_EMBEDDED
1725 KPrinter printer; 1725 KPrinter printer;
1726 if ( !printer.setup( this ) ) 1726 if ( !printer.setup( this ) )
1727 return; 1727 return;
1728 1728
1729 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1729 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1730 mViewManager->selectedUids(), this ); 1730 mViewManager->selectedUids(), this );
1731 1731
1732 wizard.exec(); 1732 wizard.exec();
1733#else //KAB_EMBEDDED 1733#else //KAB_EMBEDDED
1734 qDebug("KABCore::print() finsih method"); 1734 qDebug("KABCore::print() finsih method");
1735#endif //KAB_EMBEDDED 1735#endif //KAB_EMBEDDED
1736 1736
1737} 1737}
1738 1738
1739 1739
1740void KABCore::addGUIClient( KXMLGUIClient *client ) 1740void KABCore::addGUIClient( KXMLGUIClient *client )
1741{ 1741{
1742 if ( mGUIClient ) 1742 if ( mGUIClient )
1743 mGUIClient->insertChildClient( client ); 1743 mGUIClient->insertChildClient( client );
1744 else 1744 else
1745 KMessageBox::error( this, "no KXMLGUICLient"); 1745 KMessageBox::error( this, "no KXMLGUICLient");
1746} 1746}
1747 1747
1748 1748
1749void KABCore::configurationChanged() 1749void KABCore::configurationChanged()
1750{ 1750{
1751 mExtensionManager->reconfigure(); 1751 mExtensionManager->reconfigure();
1752} 1752}
1753 1753
1754void KABCore::addressBookChanged() 1754void KABCore::addressBookChanged()
1755{ 1755{
1756/*US 1756/*US
1757 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1757 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1758 while ( it.current() ) { 1758 while ( it.current() ) {
1759 if ( it.current()->dirty() ) { 1759 if ( it.current()->dirty() ) {
1760 QString text = i18n( "Data has been changed externally. Unsaved " 1760 QString text = i18n( "Data has been changed externally. Unsaved "
1761 "changes will be lost." ); 1761 "changes will be lost." );
1762 KMessageBox::information( this, text ); 1762 KMessageBox::information( this, text );
1763 } 1763 }
1764 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1764 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1765 ++it; 1765 ++it;
1766 } 1766 }
1767*/ 1767*/
1768 if (mEditorDialog) 1768 if (mEditorDialog)
1769 { 1769 {
1770 if (mEditorDialog->dirty()) 1770 if (mEditorDialog->dirty())
1771 { 1771 {
1772 QString text = i18n( "Data has been changed externally. Unsaved " 1772 QString text = i18n( "Data has been changed externally. Unsaved "
1773 "changes will be lost." ); 1773 "changes will be lost." );
1774 KMessageBox::information( this, text ); 1774 KMessageBox::information( this, text );
1775 } 1775 }
1776 QString currentuid = mEditorDialog->addressee().uid(); 1776 QString currentuid = mEditorDialog->addressee().uid();
1777 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1777 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1778 } 1778 }
1779 mViewManager->refreshView(); 1779 mViewManager->refreshView();
1780 1780
1781 1781
1782} 1782}
1783 1783
1784AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1784AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1785 const char *name ) 1785 const char *name )
1786{ 1786{
1787 1787
1788 if ( mEditorDialog == 0 ) { 1788 if ( mEditorDialog == 0 ) {
1789 mEditorDialog = new AddresseeEditorDialog( this, parent, 1789 mEditorDialog = new AddresseeEditorDialog( this, parent,
1790 name ? name : "editorDialog" ); 1790 name ? name : "editorDialog" );
1791 1791
1792 1792
1793 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1793 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1794 SLOT( contactModified( const KABC::Addressee& ) ) ); 1794 SLOT( contactModified( const KABC::Addressee& ) ) );
1795 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1795 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1796 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1796 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1797 } 1797 }
1798 1798
1799 return mEditorDialog; 1799 return mEditorDialog;
1800} 1800}
1801 1801
1802void KABCore::slotEditorDestroyed( const QString &uid ) 1802void KABCore::slotEditorDestroyed( const QString &uid )
1803{ 1803{
1804 //mEditorDict.remove( uid ); 1804 //mEditorDict.remove( uid );
1805} 1805}
1806 1806
1807void KABCore::initGUI() 1807void KABCore::initGUI()
1808{ 1808{
1809#ifndef KAB_EMBEDDED 1809#ifndef KAB_EMBEDDED
1810 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1810 QHBoxLayout *topLayout = new QHBoxLayout( this );
1811 topLayout->setSpacing( KDialogBase::spacingHint() ); 1811 topLayout->setSpacing( KDialogBase::spacingHint() );
1812 1812
1813 mExtensionBarSplitter = new QSplitter( this ); 1813 mExtensionBarSplitter = new QSplitter( this );
1814 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1814 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1815 1815
1816 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1816 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1817 1817
1818 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1818 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1819 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1819 mIncSearchWidget = new IncSearchWidget( viewSpace );
1820 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1820 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1821 SLOT( incrementalSearch( const QString& ) ) ); 1821 SLOT( incrementalSearch( const QString& ) ) );
1822 1822
1823 mViewManager = new ViewManager( this, viewSpace ); 1823 mViewManager = new ViewManager( this, viewSpace );
1824 viewSpace->setStretchFactor( mViewManager, 1 ); 1824 viewSpace->setStretchFactor( mViewManager, 1 );
1825 1825
1826 mDetails = new ViewContainer( mDetailsSplitter ); 1826 mDetails = new ViewContainer( mDetailsSplitter );
1827 1827
1828 mJumpButtonBar = new JumpButtonBar( this, this ); 1828 mJumpButtonBar = new JumpButtonBar( this, this );
1829 1829
1830 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1830 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1831 1831
1832 topLayout->addWidget( mExtensionBarSplitter ); 1832 topLayout->addWidget( mExtensionBarSplitter );
1833 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1833 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1834 topLayout->addWidget( mJumpButtonBar ); 1834 topLayout->addWidget( mJumpButtonBar );
1835 //topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1835 //topLayout->setStretchFactor( mJumpButtonBar, 1 );
1836 1836
1837 mXXPortManager = new XXPortManager( this, this ); 1837 mXXPortManager = new XXPortManager( this, this );
1838 1838
1839#else //KAB_EMBEDDED 1839#else //KAB_EMBEDDED
1840 //US initialize viewMenu before settingup viewmanager. 1840 //US initialize viewMenu before settingup viewmanager.
1841 // Viewmanager needs this menu to plugin submenues. 1841 // Viewmanager needs this menu to plugin submenues.
1842 viewMenu = new QPopupMenu( this ); 1842 viewMenu = new QPopupMenu( this );
1843 settingsMenu = new QPopupMenu( this ); 1843 settingsMenu = new QPopupMenu( this );
1844 //filterMenu = new QPopupMenu( this ); 1844 //filterMenu = new QPopupMenu( this );
1845 ImportMenu = new QPopupMenu( this ); 1845 ImportMenu = new QPopupMenu( this );
1846 ExportMenu = new QPopupMenu( this ); 1846 ExportMenu = new QPopupMenu( this );
1847 syncMenu = new QPopupMenu( this ); 1847 syncMenu = new QPopupMenu( this );
1848 changeMenu= new QPopupMenu( this ); 1848 changeMenu= new QPopupMenu( this );
1849 beamMenu= new QPopupMenu( this ); 1849 beamMenu= new QPopupMenu( this );
1850 1850
1851//US since we have no splitter for the embedded system, setup 1851//US since we have no splitter for the embedded system, setup
1852// a layout with two frames. One left and one right. 1852// a layout with two frames. One left and one right.
1853 1853
1854 QBoxLayout *topLayout; 1854 QBoxLayout *topLayout;
1855 1855
1856 // = new QHBoxLayout( this ); 1856 // = new QHBoxLayout( this );
1857// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1857// QBoxLayout *topLayout = (QBoxLayout*)layout();
1858 1858
1859// QWidget *mainBox = new QWidget( this ); 1859// QWidget *mainBox = new QWidget( this );
1860// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1860// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1861 1861
1862#ifdef DESKTOP_VERSION 1862#ifdef DESKTOP_VERSION
1863 topLayout = new QHBoxLayout( this ); 1863 topLayout = new QHBoxLayout( this );
1864 1864
1865 1865
1866 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1866 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1867 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1867 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1868 1868
1869 topLayout->addWidget(mMiniSplitter ); 1869 topLayout->addWidget(mMiniSplitter );
1870 1870
1871 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1871 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1872 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1872 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1873 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1873 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1874 mDetails = new ViewContainer( mMiniSplitter ); 1874 mDetails = new ViewContainer( mMiniSplitter );
1875 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1875 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1876#else 1876#else
1877 if ( QApplication::desktop()->width() > 480 ) { 1877 if ( QApplication::desktop()->width() > 480 ) {
1878 topLayout = new QHBoxLayout( this ); 1878 topLayout = new QHBoxLayout( this );
1879 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1879 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1880 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1880 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1881 } else { 1881 } else {
1882 1882
1883 topLayout = new QHBoxLayout( this ); 1883 topLayout = new QHBoxLayout( this );
1884 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1884 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1885 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1885 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1886 } 1886 }
1887 1887
1888 topLayout->addWidget(mMiniSplitter ); 1888 topLayout->addWidget(mMiniSplitter );
1889 mViewManager = new ViewManager( this, mMiniSplitter ); 1889 mViewManager = new ViewManager( this, mMiniSplitter );
1890 mDetails = new ViewContainer( mMiniSplitter ); 1890 mDetails = new ViewContainer( mMiniSplitter );
1891 1891
1892 1892
1893 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1893 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1894#endif 1894#endif
1895 //eh->hide(); 1895 //eh->hide();
1896 // topLayout->addWidget(mExtensionManager ); 1896 // topLayout->addWidget(mExtensionManager );
1897 1897
1898 1898
1899/*US 1899/*US
1900#ifndef KAB_NOSPLITTER 1900#ifndef KAB_NOSPLITTER
1901 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1901 QHBoxLayout *topLayout = new QHBoxLayout( this );
1902//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1902//US topLayout->setSpacing( KDialogBase::spacingHint() );
1903 topLayout->setSpacing( 10 ); 1903 topLayout->setSpacing( 10 );
1904 1904
1905 mDetailsSplitter = new QSplitter( this ); 1905 mDetailsSplitter = new QSplitter( this );
1906 1906
1907 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1907 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1908 1908
1909 mViewManager = new ViewManager( this, viewSpace ); 1909 mViewManager = new ViewManager( this, viewSpace );
1910 viewSpace->setStretchFactor( mViewManager, 1 ); 1910 viewSpace->setStretchFactor( mViewManager, 1 );
1911 1911
1912 mDetails = new ViewContainer( mDetailsSplitter ); 1912 mDetails = new ViewContainer( mDetailsSplitter );
1913 1913
1914 topLayout->addWidget( mDetailsSplitter ); 1914 topLayout->addWidget( mDetailsSplitter );
1915 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1915 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1916#else //KAB_NOSPLITTER 1916#else //KAB_NOSPLITTER
1917 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1917 QHBoxLayout *topLayout = new QHBoxLayout( this );
1918//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1918//US topLayout->setSpacing( KDialogBase::spacingHint() );
1919 topLayout->setSpacing( 10 ); 1919 topLayout->setSpacing( 10 );
1920 1920
1921// mDetailsSplitter = new QSplitter( this ); 1921// mDetailsSplitter = new QSplitter( this );
1922 1922
1923 QVBox *viewSpace = new QVBox( this ); 1923 QVBox *viewSpace = new QVBox( this );
1924 1924
1925 mViewManager = new ViewManager( this, viewSpace ); 1925 mViewManager = new ViewManager( this, viewSpace );
1926 viewSpace->setStretchFactor( mViewManager, 1 ); 1926 viewSpace->setStretchFactor( mViewManager, 1 );
1927 1927
1928 mDetails = new ViewContainer( this ); 1928 mDetails = new ViewContainer( this );
1929 1929
1930 topLayout->addWidget( viewSpace ); 1930 topLayout->addWidget( viewSpace );
1931// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1931// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1932 topLayout->addWidget( mDetails ); 1932 topLayout->addWidget( mDetails );
1933#endif //KAB_NOSPLITTER 1933#endif //KAB_NOSPLITTER
1934*/ 1934*/
1935 1935
1936 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1936 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1937 syncManager->setBlockSave(false); 1937 syncManager->setBlockSave(false);
1938 1938
1939 connect(syncManager , SIGNAL( request_file(const QString &) ), this, SLOT( syncFileRequest(const QString &) ) ); 1939 connect(syncManager , SIGNAL( request_file(const QString &) ), this, SLOT( syncFileRequest(const QString &) ) );
1940 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1940 connect(syncManager , SIGNAL( getFile( bool ,const QString &)), this, SLOT(getFile( bool ,const QString &) ) );
1941 QString sync_file = sentSyncFile(); 1941 QString sync_file = sentSyncFile();
1942 //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); 1942 //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1());
1943 syncManager->setDefaultFileName( sync_file ); 1943 syncManager->setDefaultFileName( sync_file );
1944 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1944 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1945 1945
1946#endif //KAB_EMBEDDED 1946#endif //KAB_EMBEDDED
1947 initActions(); 1947 initActions();
1948 1948
1949#ifdef KAB_EMBEDDED 1949#ifdef KAB_EMBEDDED
1950 addActionsManually(); 1950 addActionsManually();
1951 //US make sure the export and import menues are initialized before creating the xxPortManager. 1951 //US make sure the export and import menues are initialized before creating the xxPortManager.
1952 mXXPortManager = new XXPortManager( this, this ); 1952 mXXPortManager = new XXPortManager( this, this );
1953 1953
1954 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1954 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1955 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1955 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1956 // mActionQuit->plug ( mMainWindow->toolBar()); 1956 // mActionQuit->plug ( mMainWindow->toolBar());
1957 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1957 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1958 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1958 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1959 // mIncSearchWidget->hide(); 1959 // mIncSearchWidget->hide();
1960 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1960 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1961 SLOT( incrementalSearch( const QString& ) ) ); 1961 SLOT( incrementalSearch( const QString& ) ) );
1962 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1962 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1963 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1963 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1964 1964
1965 mJumpButtonBar = new JumpButtonBar( this, this ); 1965 mJumpButtonBar = new JumpButtonBar( this, this );
1966 1966
1967 topLayout->addWidget( mJumpButtonBar ); 1967 topLayout->addWidget( mJumpButtonBar );
1968//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1968//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1969 1969
1970// mMainWindow->getIconToolBar()->raise(); 1970// mMainWindow->getIconToolBar()->raise();
1971 1971
1972#endif //KAB_EMBEDDED 1972#endif //KAB_EMBEDDED
1973 1973
1974} 1974}
1975void KABCore::initActions() 1975void KABCore::initActions()
1976{ 1976{
1977//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1977//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1978 1978
1979#ifndef KAB_EMBEDDED 1979#ifndef KAB_EMBEDDED
1980 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1980 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1981 SLOT( clipboardDataChanged() ) ); 1981 SLOT( clipboardDataChanged() ) );
1982#endif //KAB_EMBEDDED 1982#endif //KAB_EMBEDDED
1983 1983
1984 // file menu 1984 // file menu
1985 1985
1986 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1986 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1987 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1987 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1988 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, 1988 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager,
1989 SLOT( printView() ), actionCollection(), "kaddressbook_print" ); 1989 SLOT( printView() ), actionCollection(), "kaddressbook_print" );
1990 1990
1991 1991
1992 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, 1992 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails,
1993 SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); 1993 SLOT( printView() ), actionCollection(), "kaddressbook_print2" );
1994 1994
1995 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1995 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1996 SLOT( save() ), actionCollection(), "file_sync" ); 1996 SLOT( save() ), actionCollection(), "file_sync" );
1997 1997
1998 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1998 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1999 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1999 SLOT( newContact() ), actionCollection(), "file_new_contact" );
2000 2000
2001 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 2001 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
2002 this, SLOT( mailVCard() ), 2002 this, SLOT( mailVCard() ),
2003 actionCollection(), "file_mail_vcard"); 2003 actionCollection(), "file_mail_vcard");
2004 2004
2005 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 2005 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
2006 SLOT( export2phone() ), actionCollection(), 2006 SLOT( export2phone() ), actionCollection(),
2007 "kaddressbook_ex2phone" ); 2007 "kaddressbook_ex2phone" );
2008 2008
2009 mActionBeamVCard = 0; 2009 mActionBeamVCard = 0;
2010 mActionBeam = 0; 2010 mActionBeam = 0;
2011 2011
2012#ifndef DESKTOP_VERSION 2012#ifndef DESKTOP_VERSION
2013 if ( Ir::supported() ) { 2013 if ( Ir::supported() ) {
2014 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, 2014 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this,
2015 SLOT( beamVCard() ), actionCollection(), 2015 SLOT( beamVCard() ), actionCollection(),
2016 "kaddressbook_beam_vcard" ); 2016 "kaddressbook_beam_vcard" );
2017 2017
2018 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 2018 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
2019 SLOT( beamMySelf() ), actionCollection(), 2019 SLOT( beamMySelf() ), actionCollection(),
2020 "kaddressbook_beam_myself" ); 2020 "kaddressbook_beam_myself" );
2021 } 2021 }
2022#endif 2022#endif
2023 2023
2024 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 2024 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
2025 this, SLOT( editContact2() ), 2025 this, SLOT( editContact2() ),
2026 actionCollection(), "file_properties" ); 2026 actionCollection(), "file_properties" );
2027 2027
2028#ifdef KAB_EMBEDDED 2028#ifdef KAB_EMBEDDED
2029 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 2029 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
2030 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 2030 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
2031 mMainWindow, SLOT( exit() ), 2031 mMainWindow, SLOT( exit() ),
2032 actionCollection(), "quit" ); 2032 actionCollection(), "quit" );
2033#endif //KAB_EMBEDDED 2033#endif //KAB_EMBEDDED
2034 2034
2035 // edit menu 2035 // edit menu
2036 if ( mIsPart ) { 2036 if ( mIsPart ) {
2037 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 2037 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
2038 SLOT( copyContacts() ), actionCollection(), 2038 SLOT( copyContacts() ), actionCollection(),
2039 "kaddressbook_copy" ); 2039 "kaddressbook_copy" );
2040 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 2040 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
2041 SLOT( cutContacts() ), actionCollection(), 2041 SLOT( cutContacts() ), actionCollection(),
2042 "kaddressbook_cut" ); 2042 "kaddressbook_cut" );
2043 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 2043 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
2044 SLOT( pasteContacts() ), actionCollection(), 2044 SLOT( pasteContacts() ), actionCollection(),
2045 "kaddressbook_paste" ); 2045 "kaddressbook_paste" );
2046 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 2046 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
2047 SLOT( selectAllContacts() ), actionCollection(), 2047 SLOT( selectAllContacts() ), actionCollection(),
2048 "kaddressbook_select_all" ); 2048 "kaddressbook_select_all" );
2049 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 2049 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
2050 SLOT( undo() ), actionCollection(), 2050 SLOT( undo() ), actionCollection(),
2051 "kaddressbook_undo" ); 2051 "kaddressbook_undo" );
2052 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 2052 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
2053 this, SLOT( redo() ), actionCollection(), 2053 this, SLOT( redo() ), actionCollection(),
2054 "kaddressbook_redo" ); 2054 "kaddressbook_redo" );
2055 } else { 2055 } else {
2056 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 2056 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
2057 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 2057 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
2058 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 2058 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
2059 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 2059 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
2060 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 2060 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
2061 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 2061 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
2062 } 2062 }
2063 2063
2064 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 2064 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
2065 Key_Delete, this, SLOT( deleteContacts() ), 2065 Key_Delete, this, SLOT( deleteContacts() ),
2066 actionCollection(), "edit_delete" ); 2066 actionCollection(), "edit_delete" );
2067 2067
2068 mActionUndo->setEnabled( false ); 2068 mActionUndo->setEnabled( false );
2069 mActionRedo->setEnabled( false ); 2069 mActionRedo->setEnabled( false );
2070 2070
2071 // settings menu 2071 // settings menu
2072#ifdef KAB_EMBEDDED 2072#ifdef KAB_EMBEDDED
2073//US special menuentry to configure the addressbook resources. On KDE 2073//US special menuentry to configure the addressbook resources. On KDE
2074// you do that through the control center !!! 2074// you do that through the control center !!!
2075 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 2075 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
2076 SLOT( configureResources() ), actionCollection(), 2076 SLOT( configureResources() ), actionCollection(),
2077 "kaddressbook_configure_resources" ); 2077 "kaddressbook_configure_resources" );
2078#endif //KAB_EMBEDDED 2078#endif //KAB_EMBEDDED
2079 2079
2080 if ( mIsPart ) { 2080 if ( mIsPart ) {
2081 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 2081 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
2082 SLOT( openConfigDialog() ), actionCollection(), 2082 SLOT( openConfigDialog() ), actionCollection(),
2083 "kaddressbook_configure" ); 2083 "kaddressbook_configure" );
2084 2084
2085 //US not implemented yet 2085 //US not implemented yet
2086 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 2086 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
2087 // this, SLOT( configureKeyBindings() ), actionCollection(), 2087 // this, SLOT( configureKeyBindings() ), actionCollection(),
2088 // "kaddressbook_configure_shortcuts" ); 2088 // "kaddressbook_configure_shortcuts" );
2089#ifdef KAB_EMBEDDED 2089#ifdef KAB_EMBEDDED
2090 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 2090 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
2091 mActionConfigureToolbars->setEnabled( false ); 2091 mActionConfigureToolbars->setEnabled( false );
2092#endif //KAB_EMBEDDED 2092#endif //KAB_EMBEDDED
2093 2093
2094 } else { 2094 } else {
2095 mActionConfigKAddressbook = new KAction( i18n( "&Configure KA/Pi..." ), "configure", 0, this, 2095 mActionConfigKAddressbook = new KAction( i18n( "&Configure KA/Pi..." ), "configure", 0, this,
2096 SLOT( openConfigDialog() ), actionCollection(), 2096 SLOT( openConfigDialog() ), actionCollection(),
2097 "kaddressbook_configure" ); 2097 "kaddressbook_configure" );
2098 mActionConfigGlobal = new KAction( i18n( "Global Settings..." ), "configure", 0, this, 2098 mActionConfigGlobal = new KAction( i18n( "Global Settings..." ), "configure", 0, this,
2099 SLOT( openConfigGlobalDialog() ), actionCollection(), 2099 SLOT( openConfigGlobalDialog() ), actionCollection(),
2100 "kaddressbook_configure" ); 2100 "kaddressbook_configure" );
2101 } 2101 }
2102 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 2102 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
2103 actionCollection(), "options_show_jump_bar" ); 2103 actionCollection(), "options_show_jump_bar" );
2104 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); 2104 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) );
2105 2105
2106 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 2106 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
2107 actionCollection(), "options_show_details" ); 2107 actionCollection(), "options_show_details" );
2108 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 2108 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
2109 2109
2110 2110
2111 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 2111 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
2112 SLOT( toggleBeamReceive() ), actionCollection(), 2112 SLOT( toggleBeamReceive() ), actionCollection(),
2113 "kaddressbook_beam_rec" ); 2113 "kaddressbook_beam_rec" );
2114 2114
2115 2115
2116 // misc 2116 // misc
2117 // only enable LDAP lookup if we can handle the protocol 2117 // only enable LDAP lookup if we can handle the protocol
2118#ifndef KAB_EMBEDDED 2118#ifndef KAB_EMBEDDED
2119 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 2119 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
2120 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 2120 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
2121 this, SLOT( openLDAPDialog() ), actionCollection(), 2121 this, SLOT( openLDAPDialog() ), actionCollection(),
2122 "ldap_lookup" ); 2122 "ldap_lookup" );
2123 } 2123 }
2124#else //KAB_EMBEDDED 2124#else //KAB_EMBEDDED
2125 //qDebug("KABCore::initActions() LDAP has to be implemented"); 2125 //qDebug("KABCore::initActions() LDAP has to be implemented");
2126#endif //KAB_EMBEDDED 2126#endif //KAB_EMBEDDED
2127 2127
2128 2128
2129 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 2129 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
2130 SLOT( setWhoAmI() ), actionCollection(), 2130 SLOT( setWhoAmI() ), actionCollection(),
2131 "set_personal" ); 2131 "set_personal" );
2132 2132
2133 2133
2134 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, 2134 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this,
2135 SLOT( setCategories() ), actionCollection(), 2135 SLOT( setCategories() ), actionCollection(),
2136 "edit_set_categories" ); 2136 "edit_set_categories" );
2137 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, 2137 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this,
2138 SLOT( editCategories() ), actionCollection(), 2138 SLOT( editCategories() ), actionCollection(),
2139 "edit__categories" ); 2139 "edit__categories" );
2140 2140
2141 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 2141 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
2142 SLOT( removeVoice() ), actionCollection(), 2142 SLOT( removeVoice() ), actionCollection(),
2143 "remove_voice" ); 2143 "remove_voice" );
2144 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, 2144 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this,
2145 SLOT( setFormattedName() ), actionCollection(), 2145 SLOT( setFormattedName() ), actionCollection(),
2146 "set_formatted" ); 2146 "set_formatted" );
2147 2147
2148 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2148 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2149 SLOT( manageCategories() ), actionCollection(), 2149 SLOT( manageCategories() ), actionCollection(),
2150 "remove_voice" ); 2150 "remove_voice" );
2151 2151
2152 2152
2153 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2153 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2154 SLOT( importFromOL() ), actionCollection(), 2154 SLOT( importFromOL() ), actionCollection(),
2155 "import_OL" ); 2155 "import_OL" );
2156#ifdef KAB_EMBEDDED 2156#ifdef KAB_EMBEDDED
2157 mActionLicence = new KAction( i18n( "Licence" ), 0, 2157 mActionLicence = new KAction( i18n( "Licence" ), 0,
2158 this, SLOT( showLicence() ), actionCollection(), 2158 this, SLOT( showLicence() ), actionCollection(),
2159 "licence_about_data" ); 2159 "licence_about_data" );
2160 mActionFaq = new KAction( i18n( "Faq" ), 0, 2160 mActionFaq = new KAction( i18n( "Faq" ), 0,
2161 this, SLOT( faq() ), actionCollection(), 2161 this, SLOT( faq() ), actionCollection(),
2162 "faq_about_data" ); 2162 "faq_about_data" );
2163 mActionWN = new KAction( i18n( "What's New?" ), 0, 2163 mActionWN = new KAction( i18n( "What's New?" ), 0,
2164 this, SLOT( whatsnew() ), actionCollection(), 2164 this, SLOT( whatsnew() ), actionCollection(),
2165 "wn" ); 2165 "wn" );
2166 2166
2167 2167
2168 2168
2169 mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0, 2169 mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0,
2170 this, SLOT( storagehowto() ), actionCollection(), 2170 this, SLOT( storagehowto() ), actionCollection(),
2171 "storage" ); 2171 "storage" );
2172 2172
2173 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2173 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2174 this, SLOT( synchowto() ), actionCollection(), 2174 this, SLOT( synchowto() ), actionCollection(),
2175 "sync" ); 2175 "sync" );
2176 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2176 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2177 this, SLOT( kdesynchowto() ), actionCollection(), 2177 this, SLOT( kdesynchowto() ), actionCollection(),
2178 "kdesync" ); 2178 "kdesync" );
2179 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2179 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2180 this, SLOT( multisynchowto() ), actionCollection(), 2180 this, SLOT( multisynchowto() ), actionCollection(),
2181 "multisync" ); 2181 "multisync" );
2182 2182
2183 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2183 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2184 this, SLOT( createAboutData() ), actionCollection(), 2184 this, SLOT( createAboutData() ), actionCollection(),
2185 "kaddressbook_about_data" ); 2185 "kaddressbook_about_data" );
2186#endif //KAB_EMBEDDED 2186#endif //KAB_EMBEDDED
2187 2187
2188 clipboardDataChanged(); 2188 clipboardDataChanged();
2189 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2189 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2190 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2190 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2191} 2191}
2192 2192
2193//US we need this function, to plug all actions into the correct menues. 2193//US we need this function, to plug all actions into the correct menues.
2194// KDE uses a XML format to plug the actions, but we work her without this overhead. 2194// KDE uses a XML format to plug the actions, but we work her without this overhead.
2195void KABCore::addActionsManually() 2195void KABCore::addActionsManually()
2196{ 2196{
2197//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2197//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2198 2198
2199#ifdef KAB_EMBEDDED 2199#ifdef KAB_EMBEDDED
2200 QPopupMenu *fileMenu = new QPopupMenu( this ); 2200 QPopupMenu *fileMenu = new QPopupMenu( this );
2201 QPopupMenu *editMenu = new QPopupMenu( this ); 2201 QPopupMenu *editMenu = new QPopupMenu( this );
2202 QPopupMenu *helpMenu = new QPopupMenu( this ); 2202 QPopupMenu *helpMenu = new QPopupMenu( this );
2203 2203
2204 KToolBar* tb = mMainWindow->toolBar(); 2204 KToolBar* tb = mMainWindow->toolBar();
2205 mMainWindow->setToolBarsMovable (false ); 2205 mMainWindow->setToolBarsMovable (false );
2206#ifndef DESKTOP_VERSION 2206#ifndef DESKTOP_VERSION
2207 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2207 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
2208#endif 2208#endif
2209 QMenuBar* mb = mMainWindow->menuBar(); 2209 QMenuBar* mb = mMainWindow->menuBar();
2210 2210
2211 //US setup menubar. 2211 //US setup menubar.
2212 //Disable the following block if you do not want to have a menubar. 2212 //Disable the following block if you do not want to have a menubar.
2213 mb->insertItem( i18n("&File"), fileMenu ); 2213 mb->insertItem( i18n("&File"), fileMenu );
2214 mb->insertItem( i18n("&Edit"), editMenu ); 2214 mb->insertItem( i18n("&Edit"), editMenu );
2215 mb->insertItem( i18n("&View"), viewMenu ); 2215 mb->insertItem( i18n("&View"), viewMenu );
2216 mb->insertItem( i18n("&Settings"), settingsMenu ); 2216 mb->insertItem( i18n("&Settings"), settingsMenu );
2217#ifdef DESKTOP_VERSION 2217#ifdef DESKTOP_VERSION
2218 mb->insertItem( i18n("Synchronize"), syncMenu ); 2218 mb->insertItem( i18n("Synchronize"), syncMenu );
2219#else 2219#else
2220 mb->insertItem( i18n("Sync"), syncMenu ); 2220 mb->insertItem( i18n("Sync"), syncMenu );
2221#endif 2221#endif
2222 //mb->insertItem( i18n("&Change"), changeMenu ); 2222 //mb->insertItem( i18n("&Change"), changeMenu );
2223 mb->insertItem( i18n("&Help"), helpMenu ); 2223 mb->insertItem( i18n("&Help"), helpMenu );
2224 mIncSearchWidget = new IncSearchWidget( tb ); 2224 mIncSearchWidget = new IncSearchWidget( tb );
2225 // tb->insertWidget(-1, 0, mIncSearchWidget); 2225 // tb->insertWidget(-1, 0, mIncSearchWidget);
2226#ifndef DESKTOP_VERSION 2226#ifndef DESKTOP_VERSION
2227 } else { 2227 } else {
2228 //US setup toolbar 2228 //US setup toolbar
2229 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2229 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2230 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2230 QPopupMenu *popupBarTB = new QPopupMenu( this );
2231 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); 2231 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB);
2232 tb->insertWidget(-1, 0, menuBarTB); 2232 tb->insertWidget(-1, 0, menuBarTB);
2233 mIncSearchWidget = new IncSearchWidget( tb ); 2233 mIncSearchWidget = new IncSearchWidget( tb );
2234 tb->enableMoving(false); 2234 tb->enableMoving(false);
2235 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2235 popupBarTB->insertItem( i18n("&File"), fileMenu );
2236 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2236 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2237 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2237 popupBarTB->insertItem( i18n("&View"), viewMenu );
2238 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2238 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2239 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2239 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2240 mViewManager->getFilterAction()->plug ( popupBarTB); 2240 mViewManager->getFilterAction()->plug ( popupBarTB);
2241 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2241 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2242 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2242 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2243 if (QApplication::desktop()->width() > 320 ) { 2243 if (QApplication::desktop()->width() > 320 ) {
2244 // mViewManager->getFilterAction()->plug ( tb); 2244 // mViewManager->getFilterAction()->plug ( tb);
2245 } 2245 }
2246 } 2246 }
2247#endif 2247#endif
2248 mIncSearchWidget->setSize(); 2248 mIncSearchWidget->setSize();
2249 // mActionQuit->plug ( mMainWindow->toolBar()); 2249 // mActionQuit->plug ( mMainWindow->toolBar());
2250 2250
2251 2251
2252 2252
2253 //US Now connect the actions with the menue entries. 2253 //US Now connect the actions with the menue entries.
2254#ifdef DESKTOP_VERSION 2254#ifdef DESKTOP_VERSION
2255 mActionPrint->plug( fileMenu ); 2255 mActionPrint->plug( fileMenu );
2256 mActionPrintDetails->plug( fileMenu ); 2256 mActionPrintDetails->plug( fileMenu );
2257 fileMenu->insertSeparator(); 2257 fileMenu->insertSeparator();
2258#endif 2258#endif
2259 mActionMail->plug( fileMenu ); 2259 mActionMail->plug( fileMenu );
2260 fileMenu->insertSeparator(); 2260 fileMenu->insertSeparator();
2261 2261
2262 mActionNewContact->plug( editMenu ); 2262 mActionNewContact->plug( editMenu );
2263 mActionNewContact->plug( tb ); 2263 mActionNewContact->plug( tb );
2264 2264
2265 mActionEditAddressee->plug( editMenu ); 2265 mActionEditAddressee->plug( editMenu );
2266 editMenu->insertSeparator(); 2266 editMenu->insertSeparator();
2267 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2267 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2268 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2268 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2269 mActionEditAddressee->plug( tb ); 2269 mActionEditAddressee->plug( tb );
2270 2270
2271 // fileMenu->insertSeparator(); 2271 // fileMenu->insertSeparator();
2272 mActionSave->plug( fileMenu ); 2272 mActionSave->plug( fileMenu );
2273 fileMenu->insertItem( "&Import", ImportMenu ); 2273 fileMenu->insertItem( "&Import", ImportMenu );
2274 fileMenu->insertItem( "&Export", ExportMenu ); 2274 fileMenu->insertItem( "&Export", ExportMenu );
2275 editMenu->insertItem( i18n("&Change"), changeMenu ); 2275 editMenu->insertItem( i18n("&Change"), changeMenu );
2276 editMenu->insertSeparator(); 2276 editMenu->insertSeparator();
2277#ifndef DESKTOP_VERSION 2277#ifndef DESKTOP_VERSION
2278 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); 2278 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu );
2279#endif 2279#endif
2280#if 0 2280#if 0
2281 // PENDING fix MailVCard 2281 // PENDING fix MailVCard
2282 fileMenu->insertSeparator(); 2282 fileMenu->insertSeparator();
2283 mActionMailVCard->plug( fileMenu ); 2283 mActionMailVCard->plug( fileMenu );
2284#endif 2284#endif
2285#ifndef DESKTOP_VERSION 2285#ifndef DESKTOP_VERSION
2286 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2286 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2287 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2287 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2288 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2288 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2289#endif 2289#endif
2290 fileMenu->insertSeparator(); 2290 fileMenu->insertSeparator();
2291 mActionQuit->plug( fileMenu ); 2291 mActionQuit->plug( fileMenu );
2292#ifdef _OL_IMPORT_ 2292#ifdef _OL_IMPORT_
2293 mActionImportOL->plug( ImportMenu ); 2293 mActionImportOL->plug( ImportMenu );
2294#endif 2294#endif
2295 // edit menu 2295 // edit menu
2296 mActionUndo->plug( editMenu ); 2296 mActionUndo->plug( editMenu );
2297 mActionRedo->plug( editMenu ); 2297 mActionRedo->plug( editMenu );
2298 editMenu->insertSeparator(); 2298 editMenu->insertSeparator();
2299 mActionCut->plug( editMenu ); 2299 mActionCut->plug( editMenu );
2300 mActionCopy->plug( editMenu ); 2300 mActionCopy->plug( editMenu );
2301 mActionPaste->plug( editMenu ); 2301 mActionPaste->plug( editMenu );
2302 mActionDelete->plug( editMenu ); 2302 mActionDelete->plug( editMenu );
2303 editMenu->insertSeparator(); 2303 editMenu->insertSeparator();
2304 mActionSelectAll->plug( editMenu ); 2304 mActionSelectAll->plug( editMenu );
2305 2305
2306 mActionSetFormattedName->plug( changeMenu ); 2306 mActionSetFormattedName->plug( changeMenu );
2307 mActionRemoveVoice->plug( changeMenu ); 2307 mActionRemoveVoice->plug( changeMenu );
2308 // settingsmings menu 2308 // settingsmings menu
2309//US special menuentry to configure the addressbook resources. On KDE 2309//US special menuentry to configure the addressbook resources. On KDE
2310// you do that through the control center !!! 2310// you do that through the control center !!!
2311 // settingsMenu->insertSeparator(); 2311 // settingsMenu->insertSeparator();
2312 2312
2313 mActionConfigKAddressbook->plug( settingsMenu, 0 ); 2313 mActionConfigKAddressbook->plug( settingsMenu, 0 );
2314 mActionConfigGlobal->plug( settingsMenu, 1 ); 2314 mActionConfigGlobal->plug( settingsMenu, 1 );
2315 mActionConfigResources->plug( settingsMenu,2 ); 2315 mActionConfigResources->plug( settingsMenu,2 );
2316 settingsMenu->insertSeparator(3); 2316 settingsMenu->insertSeparator(3);
2317 2317
2318 if ( mIsPart ) { 2318 if ( mIsPart ) {
2319 //US not implemented yet 2319 //US not implemented yet
2320 //mActionConfigShortcuts->plug( settingsMenu ); 2320 //mActionConfigShortcuts->plug( settingsMenu );
2321 //mActionConfigureToolbars->plug( settingsMenu ); 2321 //mActionConfigureToolbars->plug( settingsMenu );
2322 2322
2323 } else { 2323 } else {
2324 //US not implemented yet 2324 //US not implemented yet
2325 //mActionKeyBindings->plug( settingsMenu ); 2325 //mActionKeyBindings->plug( settingsMenu );
2326 } 2326 }
2327 2327
2328 mActionEditCategories->plug( settingsMenu ); 2328 mActionEditCategories->plug( settingsMenu );
2329 mActionManageCategories->plug( settingsMenu ); 2329 mActionManageCategories->plug( settingsMenu );
2330 mActionJumpBar->plug( viewMenu,0 ); 2330 mActionJumpBar->plug( viewMenu,0 );
2331 mActionDetails->plug( viewMenu,0 ); 2331 mActionDetails->plug( viewMenu,0 );
2332 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2332 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2333 mActionDetails->plug( tb ); 2333 mActionDetails->plug( tb );
2334 settingsMenu->insertSeparator(); 2334 settingsMenu->insertSeparator();
2335#ifndef DESKTOP_VERSION 2335#ifndef DESKTOP_VERSION
2336 if ( Ir::supported() ) mActionBR->plug(settingsMenu ); 2336 if ( Ir::supported() ) mActionBR->plug(settingsMenu );
2337 settingsMenu->insertSeparator(); 2337 settingsMenu->insertSeparator();
2338#endif 2338#endif
2339 2339
2340 mActionWhoAmI->plug( settingsMenu ); 2340 mActionWhoAmI->plug( settingsMenu );
2341 //mActionEditCategories->plug( changeMenu ); 2341 //mActionEditCategories->plug( changeMenu );
2342 mActionCategories->plug( changeMenu ); 2342 mActionCategories->plug( changeMenu );
2343 //mActionManageCategories->plug( changeMenu ); 2343 //mActionManageCategories->plug( changeMenu );
2344 2344
2345 //mActionCategories->plug( settingsMenu ); 2345 //mActionCategories->plug( settingsMenu );
2346 2346
2347 2347
2348 mActionWN->plug( helpMenu ); 2348 mActionWN->plug( helpMenu );
2349 mActionStorageHowto->plug( helpMenu ); 2349 mActionStorageHowto->plug( helpMenu );
2350 mActionSyncHowto->plug( helpMenu ); 2350 mActionSyncHowto->plug( helpMenu );
2351 mActionKdeSyncHowto->plug( helpMenu ); 2351 mActionKdeSyncHowto->plug( helpMenu );
2352 mActionMultiSyncHowto->plug( helpMenu ); 2352 mActionMultiSyncHowto->plug( helpMenu );
2353 mActionFaq->plug( helpMenu ); 2353 mActionFaq->plug( helpMenu );
2354 mActionLicence->plug( helpMenu ); 2354 mActionLicence->plug( helpMenu );
2355 mActionAboutKAddressbook->plug( helpMenu ); 2355 mActionAboutKAddressbook->plug( helpMenu );
2356 2356
2357 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2357 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2358 2358
2359 mActionSave->plug( tb ); 2359 mActionSave->plug( tb );
2360 mViewManager->getFilterAction()->plug ( tb); 2360 mViewManager->getFilterAction()->plug ( tb);
2361 //LR hide filteraction on started in 480x640 2361 //LR hide filteraction on started in 480x640
2362 if (QApplication::desktop()->width() == 480 ) { 2362 if (QApplication::desktop()->width() == 480 ) {
2363 mViewManager->getFilterAction()->setComboWidth( 0 ); 2363 mViewManager->getFilterAction()->setComboWidth( 0 );
2364 } 2364 }
2365 mActionUndo->plug( tb ); 2365 mActionUndo->plug( tb );
2366 mActionDelete->plug( tb ); 2366 mActionDelete->plug( tb );
2367 mActionRedo->plug( tb ); 2367 mActionRedo->plug( tb );
2368 } else { 2368 } else {
2369 mActionSave->plug( tb ); 2369 mActionSave->plug( tb );
2370 tb->enableMoving(false); 2370 tb->enableMoving(false);
2371 } 2371 }
2372 //mActionQuit->plug ( tb ); 2372 //mActionQuit->plug ( tb );
2373 //tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2373 //tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2374 2374
2375 //US link the searchwidget first to this. 2375 //US link the searchwidget first to this.
2376 // The real linkage to the toolbar happens later. 2376 // The real linkage to the toolbar happens later.
2377//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2377//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2378//US tb->insertItem( mIncSearchWidget ); 2378//US tb->insertItem( mIncSearchWidget );
2379/*US 2379/*US
2380 mIncSearchWidget = new IncSearchWidget( tb ); 2380 mIncSearchWidget = new IncSearchWidget( tb );
2381 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2381 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2382 SLOT( incrementalSearch( const QString& ) ) ); 2382 SLOT( incrementalSearch( const QString& ) ) );
2383 2383
2384 mJumpButtonBar = new JumpButtonBar( this, this ); 2384 mJumpButtonBar = new JumpButtonBar( this, this );
2385 2385
2386//US topLayout->addWidget( mJumpButtonBar ); 2386//US topLayout->addWidget( mJumpButtonBar );
2387 this->layout()->add( mJumpButtonBar ); 2387 this->layout()->add( mJumpButtonBar );
2388*/ 2388*/
2389 2389
2390#endif //KAB_EMBEDDED 2390#endif //KAB_EMBEDDED
2391 2391
2392 mActionExport2phone->plug( ExportMenu ); 2392 mActionExport2phone->plug( ExportMenu );
2393 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2393 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2394 syncManager->fillSyncMenu(); 2394 syncManager->fillSyncMenu();
2395 2395
2396} 2396}
2397void KABCore::showLicence() 2397void KABCore::showLicence()
2398{ 2398{
2399 KApplication::showLicence(); 2399 KApplication::showLicence();
2400} 2400}
2401 2401
2402void KABCore::manageCategories( ) 2402void KABCore::manageCategories( )
2403{ 2403{
2404 KABCatPrefs* cp = new KABCatPrefs(); 2404 KABCatPrefs* cp = new KABCatPrefs();
2405 cp->show(); 2405 cp->show();
2406 int w =cp->sizeHint().width() ; 2406 int w =cp->sizeHint().width() ;
2407 int h = cp->sizeHint().height() ; 2407 int h = cp->sizeHint().height() ;
2408 int dw = QApplication::desktop()->width(); 2408 int dw = QApplication::desktop()->width();
2409 int dh = QApplication::desktop()->height(); 2409 int dh = QApplication::desktop()->height();
2410 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2410 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2411 if ( !cp->exec() ) { 2411 if ( !cp->exec() ) {
2412 delete cp; 2412 delete cp;
2413 return; 2413 return;
2414 } 2414 }
2415 int count = 0; 2415 int count = 0;
2416 int cc = 0; 2416 int cc = 0;
2417 message( i18n("Please wait, processing categories...")); 2417 message( i18n("Please wait, processing categories..."));
2418 if ( cp->addCat() ) { 2418 if ( cp->addCat() ) {
2419 KABC::AddressBook::Iterator it; 2419 KABC::AddressBook::Iterator it;
2420 QStringList catList = KABPrefs::instance()->mCustomCategories; 2420 QStringList catList = KABPrefs::instance()->mCustomCategories;
2421 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2421 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2422 ++cc; 2422 ++cc;
2423 if ( cc %10 == 0) 2423 if ( cc %10 == 0)
2424 message(i18n("Processing contact #%1").arg(cc)); 2424 message(i18n("Processing contact #%1").arg(cc));
2425 QStringList catIncList = (*it).categories(); 2425 QStringList catIncList = (*it).categories();
2426 int i; 2426 int i;
2427 for( i = 0; i< catIncList.count(); ++i ) { 2427 for( i = 0; i< catIncList.count(); ++i ) {
2428 if ( !catList.contains (catIncList[i])) { 2428 if ( !catList.contains (catIncList[i])) {
2429 catList.append( catIncList[i] ); 2429 catList.append( catIncList[i] );
2430 //qDebug("add cat %s ", catIncList[i].latin1()); 2430 //qDebug("add cat %s ", catIncList[i].latin1());
2431 ++count; 2431 ++count;
2432 } 2432 }
2433 } 2433 }
2434 } 2434 }
2435 catList.sort(); 2435 catList.sort();
2436 KABPrefs::instance()->mCustomCategories = catList; 2436 KABPrefs::instance()->mCustomCategories = catList;
2437 KABPrefs::instance()->writeConfig(); 2437 KABPrefs::instance()->writeConfig();
2438 message(QString::number( count )+ i18n(" categories added to list! ")); 2438 message(QString::number( count )+ i18n(" categories added to list! "));
2439 } else { 2439 } else {
2440 QStringList catList = KABPrefs::instance()->mCustomCategories; 2440 QStringList catList = KABPrefs::instance()->mCustomCategories;
2441 QStringList catIncList; 2441 QStringList catIncList;
2442 QStringList newCatList; 2442 QStringList newCatList;
2443 KABC::AddressBook::Iterator it; 2443 KABC::AddressBook::Iterator it;
2444 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2444 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2445 ++cc; 2445 ++cc;
2446 if ( cc %10 == 0) 2446 if ( cc %10 == 0)
2447 message(i18n("Processing contact #%1").arg(cc)); 2447 message(i18n("Processing contact #%1").arg(cc));
2448 QStringList catIncList = (*it).categories(); 2448 QStringList catIncList = (*it).categories();
2449 int i; 2449 int i;
2450 if ( catIncList.count() ) { 2450 if ( catIncList.count() ) {
2451 newCatList.clear(); 2451 newCatList.clear();
2452 for( i = 0; i< catIncList.count(); ++i ) { 2452 for( i = 0; i< catIncList.count(); ++i ) {
2453 if ( catList.contains (catIncList[i])) { 2453 if ( catList.contains (catIncList[i])) {
2454 newCatList.append( catIncList[i] ); 2454 newCatList.append( catIncList[i] );
2455 } 2455 }
2456 } 2456 }
2457 newCatList.sort(); 2457 newCatList.sort();
2458 (*it).setCategories( newCatList ); 2458 (*it).setCategories( newCatList );
2459 mAddressBook->insertAddressee( (*it) ); 2459 mAddressBook->insertAddressee( (*it) );
2460 } 2460 }
2461 } 2461 }
2462 setModified( true ); 2462 setModified( true );
2463 mViewManager->refreshView(); 2463 mViewManager->refreshView();
2464 message( i18n("Removing categories done!")); 2464 message( i18n("Removing categories done!"));
2465 } 2465 }
2466 delete cp; 2466 delete cp;
2467} 2467}
2468void KABCore::removeVoice() 2468void KABCore::removeVoice()
2469{ 2469{
2470 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 ) 2470 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 )
2471 return; 2471 return;
2472 XXPortSelectDialog dlg( this, false, this ); 2472 XXPortSelectDialog dlg( this, false, this );
2473 if ( !dlg.exec() ) 2473 if ( !dlg.exec() )
2474 return; 2474 return;
2475 mAddressBook->setUntagged(); 2475 mAddressBook->setUntagged();
2476 dlg.tagSelected(); 2476 dlg.tagSelected();
2477 message(i18n("Removing voice..."), false ); 2477 message(i18n("Removing voice..."), false );
2478 KABC::AddressBook::Iterator it; 2478 KABC::AddressBook::Iterator it;
2479 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2479 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2480 if ( (*it).tagged() ) { 2480 if ( (*it).tagged() ) {
2481 (*it).removeVoice(); 2481 (*it).removeVoice();
2482 } 2482 }
2483 } 2483 }
2484 message(i18n("Refreshing view...") ); 2484 message(i18n("Refreshing view...") );
2485 mViewManager->refreshView( "" ); 2485 mViewManager->refreshView( "" );
2486 Addressee add; 2486 Addressee add;
2487 mDetails->setAddressee( add ); 2487 mDetails->setAddressee( add );
2488 message(i18n("Remove voice completed!") ); 2488 message(i18n("Remove voice completed!") );
2489 2489
2490 2490
2491 2491
2492} 2492}
2493 2493
2494void KABCore::setFormattedName() 2494void KABCore::setFormattedName()
2495{ 2495{
2496 KABFormatPrefs setpref; 2496 KABFormatPrefs setpref;
2497 if ( !setpref.exec() ) { 2497 if ( !setpref.exec() ) {
2498 return; 2498 return;
2499 } 2499 }
2500 XXPortSelectDialog dlg( this, false, this ); 2500 XXPortSelectDialog dlg( this, false, this );
2501 if ( !dlg.exec() ) 2501 if ( !dlg.exec() )
2502 return; 2502 return;
2503 mAddressBook->setUntagged(); 2503 mAddressBook->setUntagged();
2504 dlg.tagSelected(); 2504 dlg.tagSelected();
2505 int count = 0; 2505 int count = 0;
2506 KABC::AddressBook::Iterator it; 2506 KABC::AddressBook::Iterator it;
2507 bool modified = false; 2507 bool modified = false;
2508 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2508 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2509 if ( (*it).tagged() ) { 2509 if ( (*it).tagged() ) {
2510 if ( (*it).uid().left( 2 ) == "la" ) 2510 if ( (*it).uid().left( 2 ) == "la" )
2511 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) 2511 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") )
2512 continue; 2512 continue;
2513 ++count; 2513 ++count;
2514 if ( count %10 == 0 ) 2514 if ( count %10 == 0 )
2515 message(i18n("Changing contact #%1").arg( count ) ); 2515 message(i18n("Changing contact #%1").arg( count ) );
2516 QString fName; 2516 QString fName;
2517 if ( setpref.simple->isChecked() ) 2517 if ( setpref.simple->isChecked() )
2518 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); 2518 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName );
2519 else if ( setpref.full->isChecked() ) 2519 else if ( setpref.full->isChecked() )
2520 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); 2520 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName );
2521 else if ( setpref.reverse->isChecked() ) 2521 else if ( setpref.reverse->isChecked() )
2522 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); 2522 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName );
2523 else 2523 else
2524 fName = (*it).organization(); 2524 fName = (*it).organization();
2525 if ( setpref.setCompany->isChecked() ) 2525 if ( setpref.setCompany->isChecked() )
2526 if ( fName.isEmpty() || fName =="," ) 2526 if ( fName.isEmpty() || fName =="," )
2527 fName = (*it).organization(); 2527 fName = (*it).organization();
2528 (*it).setFormattedName( fName ); 2528 (*it).setFormattedName( fName );
2529 (*it).setChanged( true ); 2529 (*it).setChanged( true );
2530 modified = true; 2530 modified = true;
2531 (*it).setRevision( QDateTime::currentDateTime() ); 2531 (*it).setRevision( QDateTime::currentDateTime() );
2532 } 2532 }
2533 } 2533 }
2534 message(i18n("Refreshing view...") ); 2534 message(i18n("Refreshing view...") );
2535 if ( modified ) 2535 if ( modified )
2536 setModified( true ); 2536 setModified( true );
2537 Addressee add; 2537 Addressee add;
2538 mDetails->setAddressee( add ); 2538 mDetails->setAddressee( add );
2539 if ( count == 0 ) 2539 if ( count == 0 )
2540 message(i18n("No contact changed!") ); 2540 message(i18n("No contact changed!") );
2541 else 2541 else
2542 message(i18n("%1 contacts changed!").arg( count ) ); 2542 message(i18n("%1 contacts changed!").arg( count ) );
2543} 2543}
2544 2544
2545void KABCore::clipboardDataChanged() 2545void KABCore::clipboardDataChanged()
2546{ 2546{
2547 2547
2548 if ( mReadWrite ) 2548 if ( mReadWrite )
2549 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2549 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2550 2550
2551} 2551}
2552 2552
2553void KABCore::updateActionMenu() 2553void KABCore::updateActionMenu()
2554{ 2554{
2555 UndoStack *undo = UndoStack::instance(); 2555 UndoStack *undo = UndoStack::instance();
2556 RedoStack *redo = RedoStack::instance(); 2556 RedoStack *redo = RedoStack::instance();
2557 2557
2558 if ( undo->isEmpty() ) 2558 if ( undo->isEmpty() )
2559 mActionUndo->setText( i18n( "Undo" ) ); 2559 mActionUndo->setText( i18n( "Undo" ) );
2560 else 2560 else
2561 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2561 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2562 2562
2563 mActionUndo->setEnabled( !undo->isEmpty() ); 2563 mActionUndo->setEnabled( !undo->isEmpty() );
2564 2564
2565 if ( !redo->top() ) 2565 if ( !redo->top() )
2566 mActionRedo->setText( i18n( "Redo" ) ); 2566 mActionRedo->setText( i18n( "Redo" ) );
2567 else 2567 else
2568 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2568 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2569 2569
2570 mActionRedo->setEnabled( !redo->isEmpty() ); 2570 mActionRedo->setEnabled( !redo->isEmpty() );
2571} 2571}
2572 2572
2573void KABCore::configureKeyBindings() 2573void KABCore::configureKeyBindings()
2574{ 2574{
2575#ifndef KAB_EMBEDDED 2575#ifndef KAB_EMBEDDED
2576 KKeyDialog::configure( actionCollection(), true ); 2576 KKeyDialog::configure( actionCollection(), true );
2577#else //KAB_EMBEDDED 2577#else //KAB_EMBEDDED
2578 qDebug("KABCore::configureKeyBindings() not implemented"); 2578 qDebug("KABCore::configureKeyBindings() not implemented");
2579#endif //KAB_EMBEDDED 2579#endif //KAB_EMBEDDED
2580} 2580}
2581 2581
2582#ifdef KAB_EMBEDDED 2582#ifdef KAB_EMBEDDED
2583void KABCore::configureResources() 2583void KABCore::configureResources()
2584{ 2584{
2585 KRES::KCMKResources dlg( this, "" , 0 ); 2585 KRES::KCMKResources dlg( this, "" , 0 );
2586 2586
2587 if ( !dlg.exec() ) 2587 if ( !dlg.exec() )
2588 return; 2588 return;
2589 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2589 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2590} 2590}
2591#endif //KAB_EMBEDDED 2591#endif //KAB_EMBEDDED
2592 2592
2593 2593
2594/* this method will be called through the QCop interface from Ko/Pi to select addresses 2594/* this method will be called through the QCop interface from Ko/Pi to select addresses
2595 * for the attendees list of an event. 2595 * for the attendees list of an event.
2596 */ 2596 */
2597void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2597void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2598{ 2598{
2599 qDebug("KABCore::requestForNameEmailUidList "); 2599 qDebug("KABCore::requestForNameEmailUidList ");
2600 bool ok = false; 2600 bool ok = false;
2601 mEmailSourceChannel = sourceChannel; 2601 mEmailSourceChannel = sourceChannel;
2602 mEmailSourceUID = uid; 2602 mEmailSourceUID = uid;
2603 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); 2603 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) );
2604 //callContactdialog(); 2604 //callContactdialog();
2605#if 0 2605#if 0
2606 int wid = uid.toInt( &ok ); 2606 int wid = uid.toInt( &ok );
2607 qDebug("UID %s ", uid.latin1()); 2607 qDebug("UID %s ", uid.latin1());
2608 if ( ok ) { 2608 if ( ok ) {
2609 if ( wid != QApplication::desktop()->width() ) { 2609 if ( wid != QApplication::desktop()->width() ) {
2610 qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); 2610 qDebug("KA/Pi: Request from different desktop geometry. Resizing ...");
2611 message( i18n("Resizing, please wait...") ); 2611 message( i18n("Resizing, please wait...") );
2612 mMainWindow->showMinimized(); 2612 mMainWindow->showMinimized();
2613 /* 2613 /*
2614 { 2614 {
2615 QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); 2615 QCopEnvelope e("QPE/Application/kapi", "callContactdialog()");
2616 } 2616 }
2617 */ 2617 */
2618 QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) ); 2618 QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) );
2619 return; 2619 return;
2620 } 2620 }
2621 2621
2622 } else { 2622 } else {
2623 qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); 2623 qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid ");
2624 } 2624 }
2625 callContactdialog(); 2625 callContactdialog();
2626 //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); 2626 //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()");
2627#endif 2627#endif
2628} 2628}
2629void KABCore::resizeAndCallContactdialog() 2629void KABCore::resizeAndCallContactdialog()
2630{ 2630{
2631 updateMainWindow(); 2631 updateMainWindow();
2632 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); 2632 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) );
2633} 2633}
2634 2634
2635void KABCore::doRingSync() 2635void KABCore::doRingSync()
2636{ 2636{
2637 topLevelWidget()->raise(); 2637 topLevelWidget()->raise();
2638 syncManager->multiSync( false ); 2638 syncManager->multiSync( false );
2639} 2639}
2640void KABCore::callContactdialog() 2640void KABCore::callContactdialog()
2641{ 2641{
2642 static bool running = false; 2642 static bool running = false;
2643 if (running) return; 2643 if (running) return;
2644 running = true; 2644 running = true;
2645 QStringList nameList; 2645 QStringList nameList;
2646 QStringList emailList; 2646 QStringList emailList;
2647 QStringList uidList; 2647 QStringList uidList;
2648 qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() ); 2648 qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() );
2649 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2649 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2650 uint i=0; 2650 uint i=0;
2651 for (i=0; i < list.count(); i++) 2651 for (i=0; i < list.count(); i++)
2652 { 2652 {
2653 nameList.append(list[i].realName()); 2653 nameList.append(list[i].realName());
2654 emailList.append(list[i].preferredEmail()); 2654 emailList.append(list[i].preferredEmail());
2655 uidList.append(list[i].uid()); 2655 uidList.append(list[i].uid());
2656 } 2656 }
2657 QString uid = mEmailSourceUID; 2657 QString uid = mEmailSourceUID;
2658 //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); 2658 //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1());
2659 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList); 2659 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList);
2660 running = false; 2660 running = false;
2661} 2661}
2662/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2662/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2663 * to put them into the calendar. 2663 * to put them into the calendar.
2664 */ 2664 */
2665void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2665void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2666{ 2666{
2667 // qDebug("KABCore::requestForBirthdayList"); 2667 // qDebug("KABCore::requestForBirthdayList");
2668 QStringList birthdayList; 2668 QStringList birthdayList;
2669 QStringList anniversaryList; 2669 QStringList anniversaryList;
2670 QStringList realNameList; 2670 QStringList realNameList;
2671 QStringList preferredEmailList; 2671 QStringList preferredEmailList;
2672 QStringList assembledNameList; 2672 QStringList assembledNameList;
2673 QStringList uidList; 2673 QStringList uidList;
2674 2674
2675 KABC::AddressBook::Iterator it; 2675 KABC::AddressBook::Iterator it;
2676 2676
2677 int count = 0; 2677 int count = 0;
2678 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2678 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2679 ++count; 2679 ++count;
2680 } 2680 }
2681 QProgressBar bar(count,0 ); 2681 QProgressBar bar(count,0 );
2682 int w = 300; 2682 int w = 300;
2683 if ( QApplication::desktop()->width() < 320 ) 2683 if ( QApplication::desktop()->width() < 320 )
2684 w = 220; 2684 w = 220;
2685 int h = bar.sizeHint().height() ; 2685 int h = bar.sizeHint().height() ;
2686 int dw = QApplication::desktop()->width(); 2686 int dw = QApplication::desktop()->width();
2687 int dh = QApplication::desktop()->height(); 2687 int dh = QApplication::desktop()->height();
2688 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2688 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2689 bar.show(); 2689 bar.show();
2690 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2690 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2691 qApp->processEvents(); 2691 qApp->processEvents();
2692 2692
2693 QDate bday; 2693 QDate bday;
2694 QString anni; 2694 QString anni;
2695 QString formattedbday; 2695 QString formattedbday;
2696 2696
2697 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2697 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2698 { 2698 {
2699 if ( ! bar.isVisible() ) 2699 if ( ! bar.isVisible() )
2700 return; 2700 return;
2701 bar.setProgress( count++ ); 2701 bar.setProgress( count++ );
2702 qApp->processEvents(); 2702 qApp->processEvents();
2703 bday = (*it).birthday().date(); 2703 bday = (*it).birthday().date();
2704 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2704 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2705 2705
2706 if ( bday.isValid() || !anni.isEmpty()) 2706 if ( bday.isValid() || !anni.isEmpty())
2707 { 2707 {
2708 if (bday.isValid()) 2708 if (bday.isValid())
2709 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2709 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2710 else 2710 else
2711 formattedbday = "NOTVALID"; 2711 formattedbday = "NOTVALID";
2712 if (anni.isEmpty()) 2712 if (anni.isEmpty())
2713 anni = "INVALID"; 2713 anni = "INVALID";
2714 2714
2715 birthdayList.append(formattedbday); 2715 birthdayList.append(formattedbday);
2716 anniversaryList.append(anni); //should be ISODate 2716 anniversaryList.append(anni); //should be ISODate
2717 realNameList.append((*it).realName()); 2717 realNameList.append((*it).realName());
2718 preferredEmailList.append((*it).preferredEmail()); 2718 preferredEmailList.append((*it).preferredEmail());
2719 assembledNameList.append((*it).realName()); 2719 assembledNameList.append((*it).realName());
2720 uidList.append((*it).uid()); 2720 uidList.append((*it).uid());
2721 2721
2722 //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() ); 2722 //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() );
2723 } 2723 }
2724 } 2724 }
2725 2725
2726 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2726 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2727 2727
2728} 2728}
2729 2729
2730/* this method will be called through the QCop interface from other apps to show details of a contact. 2730/* this method will be called through the QCop interface from other apps to show details of a contact.
2731 */ 2731 */
2732void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2732void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2733{ 2733{
2734 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2734 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2735 2735
2736 QString foundUid = QString::null; 2736 QString foundUid = QString::null;
2737 if ( ! uid.isEmpty() ) { 2737 if ( ! uid.isEmpty() ) {
2738 Addressee adrr = mAddressBook->findByUid( uid ); 2738 Addressee adrr = mAddressBook->findByUid( uid );
2739 if ( !adrr.isEmpty() ) { 2739 if ( !adrr.isEmpty() ) {
2740 foundUid = uid; 2740 foundUid = uid;
2741 } 2741 }
2742 if ( email == "sendbacklist" ) { 2742 if ( email == "sendbacklist" ) {
2743 //qDebug("ssssssssssssssssssssssend "); 2743 //qDebug("ssssssssssssssssssssssend ");
2744 QStringList nameList; 2744 QStringList nameList;
2745 QStringList emailList; 2745 QStringList emailList;
2746 QStringList uidList; 2746 QStringList uidList;
2747 nameList.append(adrr.realName()); 2747 nameList.append(adrr.realName());
2748 emailList = adrr.emails(); 2748 emailList = adrr.emails();
2749 uidList.append( adrr.preferredEmail()); 2749 uidList.append( adrr.preferredEmail());
2750 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2750 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2751 return; 2751 return;
2752 } 2752 }
2753 2753
2754 } 2754 }
2755 2755
2756 if ( email == "sendbacklist" ) 2756 if ( email == "sendbacklist" )
2757 return; 2757 return;
2758 if (foundUid.isEmpty()) 2758 if (foundUid.isEmpty())
2759 { 2759 {
2760 //find the uid of the person first 2760 //find the uid of the person first
2761 Addressee::List namelist; 2761 Addressee::List namelist;
2762 Addressee::List emaillist; 2762 Addressee::List emaillist;
2763 2763
2764 if (!name.isEmpty()) 2764 if (!name.isEmpty())
2765 namelist = mAddressBook->findByName( name ); 2765 namelist = mAddressBook->findByName( name );
2766 2766
2767 if (!email.isEmpty()) 2767 if (!email.isEmpty())
2768 emaillist = mAddressBook->findByEmail( email ); 2768 emaillist = mAddressBook->findByEmail( email );
2769 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2769 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2770 //check if we have a match in Namelist and Emaillist 2770 //check if we have a match in Namelist and Emaillist
2771 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2771 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2772 foundUid = emaillist[0].uid(); 2772 foundUid = emaillist[0].uid();
2773 } 2773 }
2774 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2774 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2775 foundUid = namelist[0].uid(); 2775 foundUid = namelist[0].uid();
2776 else 2776 else
2777 { 2777 {
2778 for (int i = 0; i < namelist.count(); i++) 2778 for (int i = 0; i < namelist.count(); i++)
2779 { 2779 {
2780 for (int j = 0; j < emaillist.count(); j++) 2780 for (int j = 0; j < emaillist.count(); j++)
2781 { 2781 {
2782 if (namelist[i] == emaillist[j]) 2782 if (namelist[i] == emaillist[j])
2783 { 2783 {
2784 foundUid = namelist[i].uid(); 2784 foundUid = namelist[i].uid();
2785 } 2785 }
2786 } 2786 }
2787 } 2787 }
2788 } 2788 }
2789 } 2789 }
2790 else 2790 else
2791 { 2791 {
2792 foundUid = uid; 2792 foundUid = uid;
2793 } 2793 }
2794 2794
2795 if (!foundUid.isEmpty()) 2795 if (!foundUid.isEmpty())
2796 { 2796 {
2797 2797
2798 // raise Ka/Pi if it is in the background 2798 // raise Ka/Pi if it is in the background
2799#ifndef DESKTOP_VERSION 2799#ifndef DESKTOP_VERSION
2800#ifndef KORG_NODCOP 2800#ifndef KORG_NODCOP
2801 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2801 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2802#endif 2802#endif
2803#endif 2803#endif
2804 2804
2805 mMainWindow->showMaximized(); 2805 mMainWindow->showMaximized();
2806 mMainWindow-> raise(); 2806 mMainWindow-> raise();
2807 2807
2808 mViewManager->setSelected( "", false); 2808 mViewManager->setSelected( "", false);
2809 mViewManager->refreshView( "" ); 2809 mViewManager->refreshView( "" );
2810 mViewManager->setSelected( foundUid, true ); 2810 mViewManager->setSelected( foundUid, true );
2811 mViewManager->refreshView( foundUid ); 2811 mViewManager->refreshView( foundUid );
2812 2812
2813 if ( !mMultipleViewsAtOnce ) 2813 if ( !mMultipleViewsAtOnce )
2814 { 2814 {
2815 setDetailsVisible( true ); 2815 setDetailsVisible( true );
2816 mActionDetails->setChecked(true); 2816 mActionDetails->setChecked(true);
2817 } 2817 }
2818 } 2818 }
2819} 2819}
2820void KABCore::storagehowto() 2820void KABCore::storagehowto()
2821{ 2821{
2822 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 2822 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
2823} 2823}
2824void KABCore::whatsnew() 2824void KABCore::whatsnew()
2825{ 2825{
2826 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2826 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2827} 2827}
2828void KABCore::synchowto() 2828void KABCore::synchowto()
2829{ 2829{
2830 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2830 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2831} 2831}
2832void KABCore::kdesynchowto() 2832void KABCore::kdesynchowto()
2833{ 2833{
2834 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2834 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2835} 2835}
2836void KABCore::multisynchowto() 2836void KABCore::multisynchowto()
2837{ 2837{
2838 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2838 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2839} 2839}
2840void KABCore::faq() 2840void KABCore::faq()
2841{ 2841{
2842 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2842 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2843} 2843}
2844 2844
2845#include <libkcal/syncdefines.h> 2845#include <libkcal/syncdefines.h>
2846 2846
2847KABC::Addressee KABCore::getLastSyncAddressee() 2847KABC::Addressee KABCore::getLastSyncAddressee()
2848{ 2848{
2849 Addressee lse; 2849 Addressee lse;
2850 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2850 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2851 2851
2852 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2852 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2853 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2853 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2854 if (lse.isEmpty()) { 2854 if (lse.isEmpty()) {
2855 qDebug("KA: Creating new last-syncAddressee "); 2855 qDebug("KA: Creating new last-syncAddressee ");
2856 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2856 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2857 QString sum = ""; 2857 QString sum = "";
2858 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2858 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2859 sum = "E: "; 2859 sum = "E: ";
2860 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2860 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2861 lse.setRevision( mLastAddressbookSync ); 2861 lse.setRevision( mLastAddressbookSync );
2862 lse.setCategories( i18n("SyncEvent") ); 2862 lse.setCategories( i18n("SyncEvent") );
2863 mAddressBook->insertAddressee( lse ); 2863 mAddressBook->insertAddressee( lse );
2864 } 2864 }
2865 return lse; 2865 return lse;
2866} 2866}
2867int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2867int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2868{ 2868{
2869 2869
2870 //void setZaurusId(int id); 2870 //void setZaurusId(int id);
2871 // int zaurusId() const; 2871 // int zaurusId() const;
2872 // void setZaurusUid(int id); 2872 // void setZaurusUid(int id);
2873 // int zaurusUid() const; 2873 // int zaurusUid() const;
2874 // void setZaurusStat(int id); 2874 // void setZaurusStat(int id);
2875 // int zaurusStat() const; 2875 // int zaurusStat() const;
2876 // 0 equal 2876 // 0 equal
2877 // 1 take local 2877 // 1 take local
2878 // 2 take remote 2878 // 2 take remote
2879 // 3 cancel 2879 // 3 cancel
2880 QDateTime lastSync = mLastAddressbookSync; 2880 QDateTime lastSync = mLastAddressbookSync;
2881 QDateTime localMod = local->revision(); 2881 QDateTime localMod = local->revision();
2882 QDateTime remoteMod = remote->revision(); 2882 QDateTime remoteMod = remote->revision();
2883 2883
2884 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2884 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2885 2885
2886 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2886 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2887 bool remCh, locCh; 2887 bool remCh, locCh;
2888 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2888 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2889 //if ( remCh ) 2889 //if ( remCh )
2890 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2890 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2891 locCh = ( localMod > mLastAddressbookSync ); 2891 locCh = ( localMod > mLastAddressbookSync );
2892 //qDebug("cahnged rem %d loc %d",remCh, locCh ); 2892 //qDebug("cahnged rem %d loc %d",remCh, locCh );
2893 if ( !remCh && ! locCh ) { 2893 if ( !remCh && ! locCh ) {
2894 //qDebug("both not changed "); 2894 //qDebug("both not changed ");
2895 lastSync = localMod.addDays(1); 2895 lastSync = localMod.addDays(1);
2896 if ( mode <= SYNC_PREF_ASK ) 2896 if ( mode <= SYNC_PREF_ASK )
2897 return 0; 2897 return 0;
2898 } else { 2898 } else {
2899 if ( locCh ) { 2899 if ( locCh ) {
2900 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2900 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2901 lastSync = localMod.addDays( -1 ); 2901 lastSync = localMod.addDays( -1 );
2902 if ( !remCh ) 2902 if ( !remCh )
2903 remoteMod =( lastSync.addDays( -1 ) ); 2903 remoteMod =( lastSync.addDays( -1 ) );
2904 } else { 2904 } else {
2905 //qDebug(" not loc changed "); 2905 //qDebug(" not loc changed ");
2906 lastSync = localMod.addDays( 1 ); 2906 lastSync = localMod.addDays( 1 );
2907 if ( remCh ) { 2907 if ( remCh ) {
2908 //qDebug("rem changed "); 2908 //qDebug("rem changed ");
2909 remoteMod =( lastSync.addDays( 1 ) ); 2909 remoteMod =( lastSync.addDays( 1 ) );
2910 } 2910 }
2911 2911
2912 } 2912 }
2913 } 2913 }
2914 full = true; 2914 full = true;
2915 if ( mode < SYNC_PREF_ASK ) 2915 if ( mode < SYNC_PREF_ASK )
2916 mode = SYNC_PREF_ASK; 2916 mode = SYNC_PREF_ASK;
2917 } else { 2917 } else {
2918 if ( localMod == remoteMod ) 2918 if ( localMod == remoteMod )
2919 return 0; 2919 return 0;
2920 2920
2921 } 2921 }
2922 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2922 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2923 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2923 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2924 //full = true; //debug only 2924 //full = true; //debug only
2925 if ( full ) { 2925 if ( full ) {
2926 bool equ = ( (*local) == (*remote) ); 2926 bool equ = ( (*local) == (*remote) );
2927 if ( equ ) { 2927 if ( equ ) {
2928 //qDebug("equal "); 2928 //qDebug("equal ");
2929 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2929 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2930 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2930 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2931 } 2931 }
2932 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2932 if ( mode < SYNC_PREF_FORCE_LOCAL )
2933 return 0; 2933 return 0;
2934 2934
2935 }//else //debug only 2935 }//else //debug only
2936 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2936 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2937 } 2937 }
2938 int result; 2938 int result;
2939 bool localIsNew; 2939 bool localIsNew;
2940 //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() ); 2940 //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() );
2941 2941
2942 if ( full && mode < SYNC_PREF_NEWEST ) 2942 if ( full && mode < SYNC_PREF_NEWEST )
2943 mode = SYNC_PREF_ASK; 2943 mode = SYNC_PREF_ASK;
2944 2944
2945 switch( mode ) { 2945 switch( mode ) {
2946 case SYNC_PREF_LOCAL: 2946 case SYNC_PREF_LOCAL:
2947 if ( lastSync > remoteMod ) 2947 if ( lastSync > remoteMod )
2948 return 1; 2948 return 1;
2949 if ( lastSync > localMod ) 2949 if ( lastSync > localMod )
2950 return 2; 2950 return 2;
2951 return 1; 2951 return 1;
2952 break; 2952 break;
2953 case SYNC_PREF_REMOTE: 2953 case SYNC_PREF_REMOTE:
2954 if ( lastSync > localMod ) 2954 if ( lastSync > localMod )
2955 return 2; 2955 return 2;
2956 if ( lastSync > remoteMod ) 2956 if ( lastSync > remoteMod )
2957 return 1; 2957 return 1;
2958 return 2; 2958 return 2;
2959 break; 2959 break;
2960 case SYNC_PREF_NEWEST: 2960 case SYNC_PREF_NEWEST:
2961 if ( localMod > remoteMod ) 2961 if ( localMod > remoteMod )
2962 return 1; 2962 return 1;
2963 else 2963 else
2964 return 2; 2964 return 2;
2965 break; 2965 break;
2966 case SYNC_PREF_ASK: 2966 case SYNC_PREF_ASK:
2967 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2967 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2968 if ( lastSync > remoteMod && lastSync > localMod) 2968 if ( lastSync > remoteMod && lastSync > localMod)
2969 return 0; 2969 return 0;
2970 if ( lastSync > remoteMod ) 2970 if ( lastSync > remoteMod )
2971 return 1; 2971 return 1;
2972 if ( lastSync > localMod ) { 2972 if ( lastSync > localMod ) {
2973 return 2; 2973 return 2;
2974 } 2974 }
2975 localIsNew = localMod >= remoteMod; 2975 localIsNew = localMod >= remoteMod;
2976 //qDebug("conflict! ************************************** "); 2976 //qDebug("conflict! ************************************** ");
2977 { 2977 {
2978 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2978 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2979 result = acd.executeD(localIsNew); 2979 result = acd.executeD(localIsNew);
2980 return result; 2980 return result;
2981 } 2981 }
2982 break; 2982 break;
2983 case SYNC_PREF_FORCE_LOCAL: 2983 case SYNC_PREF_FORCE_LOCAL:
2984 return 1; 2984 return 1;
2985 break; 2985 break;
2986 case SYNC_PREF_FORCE_REMOTE: 2986 case SYNC_PREF_FORCE_REMOTE:
2987 return 2; 2987 return 2;
2988 break; 2988 break;
2989 2989
2990 default: 2990 default:
2991 // SYNC_PREF_TAKE_BOTH not implemented 2991 // SYNC_PREF_TAKE_BOTH not implemented
2992 break; 2992 break;
2993 } 2993 }
2994 return 0; 2994 return 0;
2995} 2995}
2996 2996
2997 2997
2998bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2998bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2999{ 2999{
3000 bool syncOK = true; 3000 bool syncOK = true;
3001 int addedAddressee = 0; 3001 int addedAddressee = 0;
3002 int addedAddresseeR = 0; 3002 int addedAddresseeR = 0;
3003 int deletedAddresseeR = 0; 3003 int deletedAddresseeR = 0;
3004 int deletedAddresseeL = 0; 3004 int deletedAddresseeL = 0;
3005 int changedLocal = 0; 3005 int changedLocal = 0;
3006 int changedRemote = 0; 3006 int changedRemote = 0;
3007 int filteredIN = 0; 3007 int filteredIN = 0;
3008 int filteredOUT = 0; 3008 int filteredOUT = 0;
3009 3009
3010 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 3010 QString mCurrentSyncName = syncManager->getCurrentSyncName();
3011 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3011 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3012 3012
3013 //QPtrList<Addressee> el = local->rawAddressees(); 3013 //QPtrList<Addressee> el = local->rawAddressees();
3014 Addressee addresseeR; 3014 Addressee addresseeR;
3015 QString uid; 3015 QString uid;
3016 int take; 3016 int take;
3017 Addressee addresseeL; 3017 Addressee addresseeL;
3018 Addressee addresseeRSync; 3018 Addressee addresseeRSync;
3019 Addressee addresseeLSync; 3019 Addressee addresseeLSync;
3020 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 3020 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
3021 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 3021 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
3022 bool fullDateRange = false; 3022 bool fullDateRange = false;
3023 local->resetTempSyncStat(); 3023 local->resetTempSyncStat();
3024 mLastAddressbookSync = QDateTime::currentDateTime(); 3024 mLastAddressbookSync = QDateTime::currentDateTime();
3025 if ( syncManager->syncWithDesktop() ) { 3025 if ( syncManager->syncWithDesktop() ) {
3026 // remote->removeSyncInfo( QString());//remove all info 3026 // remote->removeSyncInfo( QString());//remove all info
3027 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 3027 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
3028 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 3028 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
3029 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 3029 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
3030 } else { 3030 } else {
3031 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime "); 3031 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime ");
3032 } 3032 }
3033 } 3033 }
3034 QDateTime modifiedCalendar = mLastAddressbookSync; 3034 QDateTime modifiedCalendar = mLastAddressbookSync;
3035 addresseeLSync = getLastSyncAddressee(); 3035 addresseeLSync = getLastSyncAddressee();
3036 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1()); 3036 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1());
3037 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 3037 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
3038 if ( !addresseeR.isEmpty() ) { 3038 if ( !addresseeR.isEmpty() ) {
3039 addresseeRSync = addresseeR; 3039 addresseeRSync = addresseeR;
3040 remote->removeAddressee(addresseeR ); 3040 remote->removeAddressee(addresseeR );
3041 3041
3042 } else { 3042 } else {
3043 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3043 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3044 addresseeRSync = addresseeLSync ; 3044 addresseeRSync = addresseeLSync ;
3045 } else { 3045 } else {
3046 //qDebug("FULLDATE 1"); 3046 //qDebug("FULLDATE 1");
3047 fullDateRange = true; 3047 fullDateRange = true;
3048 Addressee newAdd; 3048 Addressee newAdd;
3049 addresseeRSync = newAdd; 3049 addresseeRSync = newAdd;
3050 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 3050 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
3051 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 3051 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
3052 addresseeRSync.setRevision( mLastAddressbookSync ); 3052 addresseeRSync.setRevision( mLastAddressbookSync );
3053 addresseeRSync.setCategories( i18n("SyncAddressee") ); 3053 addresseeRSync.setCategories( i18n("SyncAddressee") );
3054 } 3054 }
3055 } 3055 }
3056 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 3056 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
3057 // qDebug("FULLDATE 2"); 3057 // qDebug("FULLDATE 2");
3058 fullDateRange = true; 3058 fullDateRange = true;
3059 } 3059 }
3060 if ( ! fullDateRange ) { 3060 if ( ! fullDateRange ) {
3061 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 3061 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
3062 3062
3063 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 3063 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
3064 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 3064 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
3065 fullDateRange = true; 3065 fullDateRange = true;
3066 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 3066 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
3067 } 3067 }
3068 } 3068 }
3069 // fullDateRange = true; // debug only! 3069 // fullDateRange = true; // debug only!
3070 if ( fullDateRange ) 3070 if ( fullDateRange )
3071 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 3071 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
3072 else 3072 else
3073 mLastAddressbookSync = addresseeLSync.revision(); 3073 mLastAddressbookSync = addresseeLSync.revision();
3074 // for resyncing if own file has changed 3074 // for resyncing if own file has changed
3075 // PENDING fixme later when implemented 3075 // PENDING fixme later when implemented
3076#if 0 3076#if 0
3077 if ( mCurrentSyncDevice == "deleteaftersync" ) { 3077 if ( mCurrentSyncDevice == "deleteaftersync" ) {
3078 mLastAddressbookSync = loadedFileVersion; 3078 mLastAddressbookSync = loadedFileVersion;
3079 qDebug("setting mLastAddressbookSync "); 3079 qDebug("setting mLastAddressbookSync ");
3080 } 3080 }
3081#endif 3081#endif
3082 3082
3083 3083
3084 // ********** setting filters **************** 3084 // ********** setting filters ****************
3085 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); 3085 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB );
3086 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); 3086 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB );
3087 3087
3088 //qDebug("*************************** "); 3088 //qDebug("*************************** ");
3089 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 3089 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
3090 QStringList er = remote->uidList(); 3090 QStringList er = remote->uidList();
3091 Addressee inR ;//= er.first(); 3091 Addressee inR ;//= er.first();
3092 Addressee inL; 3092 Addressee inL;
3093 3093
3094 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 3094 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
3095 3095
3096 int modulo = (er.count()/10)+1; 3096 int modulo = (er.count()/10)+1;
3097 int incCounter = 0; 3097 int incCounter = 0;
3098 while ( incCounter < er.count()) { 3098 while ( incCounter < er.count()) {
3099 if (syncManager->isProgressBarCanceled()) 3099 if (syncManager->isProgressBarCanceled())
3100 return false; 3100 return false;
3101 if ( incCounter % modulo == 0 ) 3101 if ( incCounter % modulo == 0 )
3102 syncManager->showProgressBar(incCounter); 3102 syncManager->showProgressBar(incCounter);
3103 3103
3104 uid = er[ incCounter ]; 3104 uid = er[ incCounter ];
3105 bool skipIncidence = false; 3105 bool skipIncidence = false;
3106 if ( uid.left(19) == QString("last-syncAddressee-") ) 3106 if ( uid.left(19) == QString("last-syncAddressee-") )
3107 skipIncidence = true; 3107 skipIncidence = true;
3108 QString idS,OidS; 3108 QString idS,OidS;
3109 qApp->processEvents(); 3109 qApp->processEvents();
3110 if ( !skipIncidence ) { 3110 if ( !skipIncidence ) {
3111 inL = local->findByUid( uid ); 3111 inL = local->findByUid( uid );
3112 inR = remote->findByUid( uid ); 3112 inR = remote->findByUid( uid );
3113 //inL.setResource( 0 ); 3113 //inL.setResource( 0 );
3114 //inR.setResource( 0 ); 3114 //inR.setResource( 0 );
3115 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 3115 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
3116 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3116 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3117 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 3117 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
3118 //qDebug("take %d %s ", take, inL.summary().latin1()); 3118 //qDebug("take %d %s ", take, inL.summary().latin1());
3119 if ( take == 3 ) 3119 if ( take == 3 )
3120 return false; 3120 return false;
3121 if ( take == 1 ) {// take local ********************** 3121 if ( take == 1 ) {// take local **********************
3122 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3122 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3123 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3123 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3124 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3124 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3125 local->insertAddressee( inL, false ); 3125 local->insertAddressee( inL, false );
3126 idS = inR.externalUID(); 3126 idS = inR.externalUID();
3127 OidS = inR.originalExternalUID(); 3127 OidS = inR.originalExternalUID();
3128 } 3128 }
3129 else 3129 else
3130 idS = inR.IDStr(); 3130 idS = inR.IDStr();
3131 remote->removeAddressee( inR ); 3131 remote->removeAddressee( inR );
3132 inR = inL; 3132 inR = inL;
3133 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 3133 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
3134 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3134 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3135 inR.setOriginalExternalUID( OidS ); 3135 inR.setOriginalExternalUID( OidS );
3136 inR.setExternalUID( idS ); 3136 inR.setExternalUID( idS );
3137 if ( syncManager->syncWithDesktop() ) { 3137 if ( syncManager->syncWithDesktop() ) {
3138 inR.setIDStr("changed" ); 3138 inR.setIDStr("changed" );
3139 } 3139 }
3140 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 3140 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
3141 } else { 3141 } else {
3142 inR.setIDStr( idS ); 3142 inR.setIDStr( idS );
3143 } 3143 }
3144 inR.setResource( 0 ); 3144 inR.setResource( 0 );
3145 remote->insertAddressee( inR , false); 3145 remote->insertAddressee( inR , false);
3146 ++changedRemote; 3146 ++changedRemote;
3147 } else { // take == 2 take remote ********************** 3147 } else { // take == 2 take remote **********************
3148 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3148 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3149 if ( inR.revision().date().year() < 2004 ) 3149 if ( inR.revision().date().year() < 2004 )
3150 inR.setRevision( modifiedCalendar ); 3150 inR.setRevision( modifiedCalendar );
3151 } 3151 }
3152 idS = inL.IDStr(); 3152 idS = inL.IDStr();
3153 local->removeAddressee( inL ); 3153 local->removeAddressee( inL );
3154 inL = inR; 3154 inL = inR;
3155 inL.setIDStr( idS ); 3155 inL.setIDStr( idS );
3156 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3156 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3157 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3157 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3158 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3158 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3159 } 3159 }
3160 inL.setResource( 0 ); 3160 inL.setResource( 0 );
3161 local->insertAddressee( inL , false ); 3161 local->insertAddressee( inL , false );
3162 ++changedLocal; 3162 ++changedLocal;
3163 } 3163 }
3164 } 3164 }
3165 } 3165 }
3166 } else { // no conflict ********** add or delete remote 3166 } else { // no conflict ********** add or delete remote
3167 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { 3167 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
3168 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3168 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3169 QString des = addresseeLSync.note(); 3169 QString des = addresseeLSync.note();
3170 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 3170 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
3171 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 3171 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
3172 remote->insertAddressee( inR, false ); 3172 remote->insertAddressee( inR, false );
3173 ++deletedAddresseeR; 3173 ++deletedAddresseeR;
3174 } else { 3174 } else {
3175 inR.setRevision( modifiedCalendar ); 3175 inR.setRevision( modifiedCalendar );
3176 remote->insertAddressee( inR, false ); 3176 remote->insertAddressee( inR, false );
3177 inL = inR; 3177 inL = inR;
3178 inL.setIDStr( ":" ); 3178 inL.setIDStr( ":" );
3179 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3179 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3180 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3180 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3181 inL.setResource( 0 ); 3181 inL.setResource( 0 );
3182 local->insertAddressee( inL , false); 3182 local->insertAddressee( inL , false);
3183 ++addedAddressee; 3183 ++addedAddressee;
3184 } 3184 }
3185 } else { 3185 } else {
3186 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 3186 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
3187 inR.setRevision( modifiedCalendar ); 3187 inR.setRevision( modifiedCalendar );
3188 remote->insertAddressee( inR, false ); 3188 remote->insertAddressee( inR, false );
3189 inR.setResource( 0 ); 3189 inR.setResource( 0 );
3190 local->insertAddressee( inR, false ); 3190 local->insertAddressee( inR, false );
3191 ++addedAddressee; 3191 ++addedAddressee;
3192 } else { 3192 } else {
3193 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 3193 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
3194 remote->removeAddressee( inR ); 3194 remote->removeAddressee( inR );
3195 ++deletedAddresseeR; 3195 ++deletedAddresseeR;
3196 } 3196 }
3197 } 3197 }
3198 } else { 3198 } else {
3199 ++filteredIN; 3199 ++filteredIN;
3200 } 3200 }
3201 } 3201 }
3202 } 3202 }
3203 ++incCounter; 3203 ++incCounter;
3204 } 3204 }
3205 er.clear(); 3205 er.clear();
3206 QStringList el = local->uidList(); 3206 QStringList el = local->uidList();
3207 modulo = (el.count()/10)+1; 3207 modulo = (el.count()/10)+1;
3208 3208
3209 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3209 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3210 incCounter = 0; 3210 incCounter = 0;
3211 while ( incCounter < el.count()) { 3211 while ( incCounter < el.count()) {
3212 qApp->processEvents(); 3212 qApp->processEvents();
3213 if (syncManager->isProgressBarCanceled()) 3213 if (syncManager->isProgressBarCanceled())
3214 return false; 3214 return false;
3215 if ( incCounter % modulo == 0 ) 3215 if ( incCounter % modulo == 0 )
3216 syncManager->showProgressBar(incCounter); 3216 syncManager->showProgressBar(incCounter);
3217 uid = el[ incCounter ]; 3217 uid = el[ incCounter ];
3218 bool skipIncidence = false; 3218 bool skipIncidence = false;
3219 if ( uid.left(19) == QString("last-syncAddressee-") ) 3219 if ( uid.left(19) == QString("last-syncAddressee-") )
3220 skipIncidence = true; 3220 skipIncidence = true;
3221 if ( !skipIncidence ) { 3221 if ( !skipIncidence ) {
3222 inL = local->findByUid( uid ); 3222 inL = local->findByUid( uid );
3223 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3223 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3224 inR = remote->findByUid( uid ); 3224 inR = remote->findByUid( uid );
3225 if ( inR.isEmpty() ){ 3225 if ( inR.isEmpty() ){
3226 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { 3226 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) {
3227 // no conflict ********** add or delete local 3227 // no conflict ********** add or delete local
3228 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3228 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3229 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3229 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
3230 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3230 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3231 local->removeAddressee( inL ); 3231 local->removeAddressee( inL );
3232 ++deletedAddresseeL; 3232 ++deletedAddresseeL;
3233 } else { 3233 } else {
3234 if ( ! syncManager->mWriteBackExistingOnly ) { 3234 if ( ! syncManager->mWriteBackExistingOnly ) {
3235 inL.removeID(mCurrentSyncDevice ); 3235 inL.removeID(mCurrentSyncDevice );
3236 ++addedAddresseeR; 3236 ++addedAddresseeR;
3237 inL.setRevision( modifiedCalendar ); 3237 inL.setRevision( modifiedCalendar );
3238 local->insertAddressee( inL, false ); 3238 local->insertAddressee( inL, false );
3239 inR = inL; 3239 inR = inL;
3240 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3240 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
3241 inR.setResource( 0 ); 3241 inR.setResource( 0 );
3242 remote->insertAddressee( inR, false ); 3242 remote->insertAddressee( inR, false );
3243 } 3243 }
3244 } 3244 }
3245 } else { 3245 } else {
3246 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3246 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
3247 //qDebug("data %s ", inL.revision().toString().latin1()); 3247 //qDebug("data %s ", inL.revision().toString().latin1());
3248 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3248 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3249 local->removeAddressee( inL ); 3249 local->removeAddressee( inL );
3250 ++deletedAddresseeL; 3250 ++deletedAddresseeL;
3251 } else { 3251 } else {
3252 if ( ! syncManager->mWriteBackExistingOnly ) { 3252 if ( ! syncManager->mWriteBackExistingOnly ) {
3253 ++addedAddresseeR; 3253 ++addedAddresseeR;
3254 inL.setRevision( modifiedCalendar ); 3254 inL.setRevision( modifiedCalendar );
3255 local->insertAddressee( inL, false ); 3255 local->insertAddressee( inL, false );
3256 inR = inL; 3256 inR = inL;
3257 inR.setIDStr( ":" ); 3257 inR.setIDStr( ":" );
3258 inR.setResource( 0 ); 3258 inR.setResource( 0 );
3259 remote->insertAddressee( inR, false ); 3259 remote->insertAddressee( inR, false );
3260 } 3260 }
3261 } 3261 }
3262 } 3262 }
3263 } else { 3263 } else {
3264 ++filteredOUT; 3264 ++filteredOUT;
3265 } 3265 }
3266 } 3266 }
3267 } 3267 }
3268 } 3268 }
3269 ++incCounter; 3269 ++incCounter;
3270 } 3270 }
3271 el.clear(); 3271 el.clear();
3272 syncManager->hideProgressBar(); 3272 syncManager->hideProgressBar();
3273 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3273 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
3274 // get rid of micro seconds 3274 // get rid of micro seconds
3275 QTime t = mLastAddressbookSync.time(); 3275 QTime t = mLastAddressbookSync.time();
3276 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3276 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3277 addresseeLSync.setRevision( mLastAddressbookSync ); 3277 addresseeLSync.setRevision( mLastAddressbookSync );
3278 addresseeRSync.setRevision( mLastAddressbookSync ); 3278 addresseeRSync.setRevision( mLastAddressbookSync );
3279 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3279 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
3280 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3280 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
3281 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3281 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
3282 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3282 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
3283 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3283 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
3284 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3284 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
3285 addresseeRSync.setNote( "" ) ; 3285 addresseeRSync.setNote( "" ) ;
3286 addresseeLSync.setNote( "" ); 3286 addresseeLSync.setNote( "" );
3287 3287
3288 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3288 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
3289 remote->insertAddressee( addresseeRSync, false ); 3289 remote->insertAddressee( addresseeRSync, false );
3290 local->insertAddressee( addresseeLSync, false ); 3290 local->insertAddressee( addresseeLSync, false );
3291 QString mes; 3291 QString mes;
3292 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 ); 3292 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 );
3293 qDebug( mes ); 3293 qDebug( mes );
3294 mes = i18n("Local addressbook changed!\n") +mes; 3294 mes = i18n("Local addressbook changed!\n") +mes;
3295 if ( syncManager->mShowSyncSummary ) { 3295 if ( syncManager->mShowSyncSummary ) {
3296 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 3296 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
3297 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 3297 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
3298 qDebug("KA: WB cancelled "); 3298 qDebug("KA: WB cancelled ");
3299 syncManager->mWriteBackFile = false; 3299 syncManager->mWriteBackFile = false;
3300 return syncOK; 3300 return syncOK;
3301 } 3301 }
3302 } 3302 }
3303 return syncOK; 3303 return syncOK;
3304} 3304}
3305 3305
3306 3306
3307//this is a overwritten callbackmethods from the syncinterface 3307//this is a overwritten callbackmethods from the syncinterface
3308bool KABCore::sync(KSyncManager* manager, QString filename, int mode,QString resource) 3308bool KABCore::sync(KSyncManager* manager, QString filename, int mode,QString resource)
3309{ 3309{
3310 3310
3311 //pending prepare addresseeview for output 3311 //pending prepare addresseeview for output
3312 //pending detect, if remote file has REV field. if not switch to external sync 3312 //pending detect, if remote file has REV field. if not switch to external sync
3313 mGlobalSyncMode = SYNC_MODE_NORMAL; 3313 mGlobalSyncMode = SYNC_MODE_NORMAL;
3314 if ( manager != syncManager ) 3314 if ( manager != syncManager )
3315 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3315 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3316 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3316 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3317 3317
3318 AddressBook abLocal(filename,"syncContact"); 3318 AddressBook abLocal(filename,"syncContact");
3319 bool syncOK = false; 3319 bool syncOK = false;
3320 if ( abLocal.load() ) { 3320 if ( abLocal.load() ) {
3321 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); 3321 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode );
3322 bool external = false; 3322 bool external = false;
3323 bool isXML = false; 3323 bool isXML = false;
3324 if ( filename.right(4) == ".xml") { 3324 if ( filename.right(4) == ".xml") {
3325 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3325 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3326 isXML = true; 3326 isXML = true;
3327 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3327 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3328 } else { 3328 } else {
3329 external = !manager->mIsKapiFile; 3329 external = !manager->mIsKapiFile;
3330 if ( external ) { 3330 if ( external ) {
3331 qDebug("KA: Sync::Setting vcf mode to external "); 3331 qDebug("KA: Sync::Setting vcf mode to external ");
3332 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3332 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3333 AddressBook::Iterator it; 3333 AddressBook::Iterator it;
3334 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3334 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3335 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3335 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3336 (*it).computeCsum( mCurrentSyncDevice ); 3336 (*it).computeCsum( mCurrentSyncDevice );
3337 } 3337 }
3338 } 3338 }
3339 } 3339 }
3340 //AddressBook::Iterator it; 3340 //AddressBook::Iterator it;
3341 //QStringList vcards; 3341 //QStringList vcards;
3342 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3342 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3343 // qDebug("Name %s ", (*it).familyName().latin1()); 3343 // qDebug("Name %s ", (*it).familyName().latin1());
3344 //} 3344 //}
3345 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3345 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3346 syncManager->hideProgressBar(); 3346 syncManager->hideProgressBar();
3347 if ( syncOK ) { 3347 if ( syncOK ) {
3348 if ( syncManager->mWriteBackFile ) 3348 if ( syncManager->mWriteBackFile )
3349 { 3349 {
3350 if ( external ) 3350 if ( external )
3351 abLocal.removeSyncAddressees( !isXML); 3351 abLocal.removeSyncAddressees( !isXML);
3352 qDebug("KA: Sync::Saving remote AB "); 3352 qDebug("KA: Sync::Saving remote AB ");
3353 if ( ! abLocal.saveAB()) 3353 if ( ! abLocal.saveAB())
3354 qDebug("KA: sync::Error writing back AB to file "); 3354 qDebug("KA: sync::Error writing back AB to file ");
3355 if ( external ) { 3355 if ( external ) {
3356 // afterwrite processing 3356 // afterwrite processing
3357 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3357 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3358 } 3358 }
3359 } 3359 }
3360 } 3360 }
3361 setModified(); 3361 setModified();
3362 3362
3363 } 3363 }
3364 abLocal.removeResources(); 3364 abLocal.removeResources();
3365 if ( syncOK ) 3365 if ( syncOK )
3366 mViewManager->refreshView(); 3366 mViewManager->refreshView();
3367 return syncOK; 3367 return syncOK;
3368 3368
3369} 3369}
3370void KABCore::removeSyncInfo( QString syncProfile) 3370void KABCore::removeSyncInfo( QString syncProfile)
3371{ 3371{
3372 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3372 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3373 mAddressBook->removeSyncInfo( syncProfile ); 3373 mAddressBook->removeSyncInfo( syncProfile );
3374 setModified(); 3374 setModified();
3375} 3375}
3376 3376
3377 3377
3378//this is a overwritten callbackmethods from the syncinterface 3378//this is a overwritten callbackmethods from the syncinterface
3379bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3379bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3380{ 3380{
3381 if ( resource == "phone" ) 3381 if ( resource == "phone" )
3382 return syncPhone(); 3382 return syncPhone();
3383 disableBR( true ); 3383 disableBR( true );
3384 if ( manager != syncManager ) 3384 if ( manager != syncManager )
3385 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3385 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3386 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3386 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3387 3387
3388 AddressBook abLocal( resource,"syncContact"); 3388 AddressBook abLocal( resource,"syncContact");
3389 bool syncOK = false; 3389 bool syncOK = false;
3390 message(i18n("Loading DTM address data..."), false); 3390 message(i18n("Loading DTM address data..."), false);
3391 if ( abLocal.load() ) { 3391 if ( abLocal.load() ) {
3392 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3392 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3393 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3393 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3394 message(i18n("Sync preprocessing..."),false); 3394 message(i18n("Sync preprocessing..."),false);
3395 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3395 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3396 message(i18n("Synchronizing..."),false); 3396 message(i18n("Synchronizing..."),false);
3397 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3397 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3398 syncManager->hideProgressBar(); 3398 syncManager->hideProgressBar();
3399 if ( syncOK ) { 3399 if ( syncOK ) {
3400 if ( syncManager->mWriteBackFile ) { 3400 if ( syncManager->mWriteBackFile ) {
3401 abLocal.removeSyncAddressees( false ); 3401 abLocal.removeSyncAddressees( false );
3402 message(i18n("Saving DTM address data..."),false); 3402 message(i18n("Saving DTM address data..."),false);
3403 abLocal.saveAB(); 3403 abLocal.saveAB();
3404 message(i18n("Sync postprocessing..."),false); 3404 message(i18n("Sync postprocessing..."),false);
3405 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3405 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3406 } 3406 }
3407 } else 3407 } else
3408 message( i18n("Sync cancelled or failed.") ); 3408 message( i18n("Sync cancelled or failed.") );
3409 setModified(); 3409 setModified();
3410 } 3410 }
3411 abLocal.removeResources(); 3411 abLocal.removeResources();
3412 if ( syncOK ) { 3412 if ( syncOK ) {
3413 mViewManager->refreshView(); 3413 mViewManager->refreshView();
3414 message(i18n("DTM syncing finished.")); 3414 message(i18n("DTM syncing finished."));
3415 } 3415 }
3416 disableBR( false ); 3416 disableBR( false );
3417 return syncOK; 3417 return syncOK;
3418 3418
3419} 3419}
3420void KABCore::message( QString m, bool startTimer) 3420void KABCore::message( QString m, bool startTimer)
3421{ 3421{
3422 topLevelWidget()->setCaption( m ); 3422 topLevelWidget()->setCaption( m );
3423 qApp->processEvents(); 3423 qApp->processEvents();
3424 if ( startTimer ) 3424 if ( startTimer )
3425 mMessageTimer->start( 15000, true ); 3425 mMessageTimer->start( 15000, true );
3426 else 3426 else
3427 mMessageTimer->stop(); 3427 mMessageTimer->stop();
3428} 3428}
3429bool KABCore::syncPhone() 3429bool KABCore::syncPhone()
3430{ 3430{
3431 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3431 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3432 QString fileName = getPhoneFile(); 3432 QString fileName = getPhoneFile();
3433 if ( !PhoneAccess::readFromPhone( fileName) ) { 3433 if ( !PhoneAccess::readFromPhone( fileName) ) {
3434 message(i18n("Phone access failed!")); 3434 message(i18n("Phone access failed!"));
3435 return false; 3435 return false;
3436 } 3436 }
3437 AddressBook abLocal( fileName,"syncContact"); 3437 AddressBook abLocal( fileName,"syncContact");
3438 bool syncOK = false; 3438 bool syncOK = false;
3439 { 3439 {
3440 abLocal.importFromFile( fileName ); 3440 abLocal.importFromFile( fileName );
3441 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3441 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3442 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3442 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3443 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3443 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3444 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3444 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3445 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3445 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3446 syncManager->hideProgressBar(); 3446 syncManager->hideProgressBar();
3447 if ( syncOK ) { 3447 if ( syncOK ) {
3448 if ( syncManager->mWriteBackFile ) { 3448 if ( syncManager->mWriteBackFile ) {
3449 abLocal.removeSyncAddressees( true ); 3449 abLocal.removeSyncAddressees( true );
3450 abLocal.saveABphone( fileName ); 3450 abLocal.saveABphone( fileName );
3451 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3451 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3452 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3452 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3453 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3453 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3454 } 3454 }
3455 } 3455 }
3456 setModified(); 3456 setModified();
3457 } 3457 }
3458 abLocal.removeResources(); 3458 abLocal.removeResources();
3459 if ( syncOK ) 3459 if ( syncOK )
3460 mViewManager->refreshView(); 3460 mViewManager->refreshView();
3461 return syncOK; 3461 return syncOK;
3462} 3462}
3463void KABCore::getFile( bool success ) 3463void KABCore::getFile( bool success ,const QString & resource)
3464{ 3464{
3465 if ( ! success ) { 3465 if ( ! success ) {
3466 message( i18n("Error receiving file. Nothing changed!") ); 3466 message( i18n("Error receiving file. Nothing changed!") );
3467 return; 3467 return;
3468 } 3468 }
3469 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3469 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ,resource);
3470 if ( count ) 3470 if ( count )
3471 setModified( true ); 3471 setModified( true );
3472 message( i18n("Pi-Sync successful!") ); 3472 message( i18n("Pi-Sync successful!") );
3473 mViewManager->refreshView(); 3473 mViewManager->refreshView();
3474} 3474}
3475void KABCore::syncFileRequest(const QString & resource) 3475void KABCore::syncFileRequest(const QString & resource)
3476{ 3476{
3477 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3477 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3478 syncManager->slotSyncMenu( 999 ); 3478 syncManager->slotSyncMenu( 999 );
3479 } 3479 }
3480 3480
3481 if ( resource == "ALL" ) { 3481 if ( resource == "ALL" ) {
3482 mAddressBook->export2File( sentSyncFile() ); 3482 mAddressBook->export2File( sentSyncFile() );
3483 } 3483 }
3484 else 3484 else
3485 mAddressBook->export2File( sentSyncFile(), resource); 3485 mAddressBook->export2File( sentSyncFile(), resource);
3486} 3486}
3487QString KABCore::sentSyncFile() 3487QString KABCore::sentSyncFile()
3488{ 3488{
3489#ifdef DESKTOP_VERSION 3489#ifdef DESKTOP_VERSION
3490 return locateLocal( "tmp", "copysyncab.vcf" ); 3490 return locateLocal( "tmp", "copysyncab.vcf" );
3491#else 3491#else
3492 return QString( "/tmp/copysyncab.vcf" ); 3492 return QString( "/tmp/copysyncab.vcf" );
3493#endif 3493#endif
3494} 3494}
3495 3495
3496void KABCore::setCaptionBack() 3496void KABCore::setCaptionBack()
3497{ 3497{
3498 mMessageTimer->stop(); 3498 mMessageTimer->stop();
3499 topLevelWidget()->setCaption( i18n("KA/Pi") ); 3499 topLevelWidget()->setCaption( i18n("KA/Pi") );
3500} 3500}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 2d1505f..e69cb60 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -1,535 +1,535 @@
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
41namespace KABC { 41namespace KABC {
42class AddressBook; 42class AddressBook;
43} 43}
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46class KAboutData; 46class KAboutData;
47class KConfig; 47class KConfig;
48 48
49class KAddressBookService; 49class KAddressBookService;
50class LDAPSearchDialog; 50class LDAPSearchDialog;
51#else //KAB_EMBEDDED 51#else //KAB_EMBEDDED
52class KAddressBookMain; 52class KAddressBookMain;
53//US class QAction; 53//US class QAction;
54#endif //KAB_EMBEDDED 54#endif //KAB_EMBEDDED
55class KCMultiDialog; 55class KCMultiDialog;
56class KXMLGUIClient; 56class KXMLGUIClient;
57class ExtensionManager; 57class ExtensionManager;
58class XXPortManager; 58class XXPortManager;
59class JumpButtonBar; 59class JumpButtonBar;
60class IncSearchWidget; 60class IncSearchWidget;
61class KDGanttMinimizeSplitter; 61class KDGanttMinimizeSplitter;
62class KAction; 62class KAction;
63class KActionCollection; 63class KActionCollection;
64class KToggleAction; 64class KToggleAction;
65class KSyncProfile; 65class KSyncProfile;
66 66
67class QAction; 67class QAction;
68class QMenuBar; 68class QMenuBar;
69class QSplitter; 69class QSplitter;
70class ViewContainer; 70class ViewContainer;
71class ViewManager; 71class ViewManager;
72class AddresseeEditorDialog; 72class AddresseeEditorDialog;
73class Ir; 73class Ir;
74 74
75class KABCore : public QWidget, public KSyncInterface 75class 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 storagehowto() ; 152 void storagehowto() ;
153 void multisynchowto() ; 153 void multisynchowto() ;
154 void kdesynchowto() ; 154 void kdesynchowto() ;
155 void writeToPhone(); 155 void writeToPhone();
156 156
157 /** 157 /**
158 Is called whenever a contact is selected in the view. 158 Is called whenever a contact is selected in the view.
159 */ 159 */
160 void setContactSelected( const QString &uid ); 160 void setContactSelected( const QString &uid );
161 161
162 /** 162 /**
163 Opens the preferred mail composer with all selected contacts as 163 Opens the preferred mail composer with all selected contacts as
164 arguments. 164 arguments.
165 */ 165 */
166 void sendMail(); 166 void sendMail();
167 167
168 /** 168 /**
169 Opens the preferred mail composer with the given contacts as 169 Opens the preferred mail composer with the given contacts as
170 arguments. 170 arguments.
171 */ 171 */
172 void sendMail( const QString& email ); 172 void sendMail( const QString& email );
173 173
174 174
175 void mailVCard(); 175 void mailVCard();
176 void mailVCard(const QStringList& uids); 176 void mailVCard(const QStringList& uids);
177 177
178 /** 178 /**
179 Beams the "WhoAmI contact. 179 Beams the "WhoAmI contact.
180 */ 180 */
181 void beamMySelf(); 181 void beamMySelf();
182 182
183 void beamVCard(); 183 void beamVCard();
184 void export2phone(); 184 void export2phone();
185 void beamVCard(const QStringList& uids); 185 void beamVCard(const QStringList& uids);
186 void beamDone( Ir *ir ); 186 void beamDone( Ir *ir );
187 187
188 188
189 /** 189 /**
190 Starts the preferred web browser with the given URL as argument. 190 Starts the preferred web browser with the given URL as argument.
191 */ 191 */
192 void browse( const QString& url ); 192 void browse( const QString& url );
193 193
194 /** 194 /**
195 Select all contacts in the view. 195 Select all contacts in the view.
196 */ 196 */
197 void selectAllContacts(); 197 void selectAllContacts();
198 198
199 /** 199 /**
200 Deletes all selected contacts from the address book. 200 Deletes all selected contacts from the address book.
201 */ 201 */
202 void deleteContacts(); 202 void deleteContacts();
203 203
204 /** 204 /**
205 Deletes given contacts from the address book. 205 Deletes given contacts from the address book.
206 206
207 @param uids The uids of the contacts, which shall be deleted. 207 @param uids The uids of the contacts, which shall be deleted.
208 */ 208 */
209 void deleteContacts( const QStringList &uids ); 209 void deleteContacts( const QStringList &uids );
210 210
211 /** 211 /**
212 Copys the selected contacts into clipboard for later pasting. 212 Copys the selected contacts into clipboard for later pasting.
213 */ 213 */
214 void copyContacts(); 214 void copyContacts();
215 215
216 /** 216 /**
217 Cuts the selected contacts and stores them for later pasting. 217 Cuts the selected contacts and stores them for later pasting.
218 */ 218 */
219 void cutContacts(); 219 void cutContacts();
220 220
221 /** 221 /**
222 Paste contacts from clipboard into the address book. 222 Paste contacts from clipboard into the address book.
223 */ 223 */
224 void pasteContacts(); 224 void pasteContacts();
225 225
226 /** 226 /**
227 Paste given contacts into the address book. 227 Paste given contacts into the address book.
228 228
229 @param list The list of addressee, which shall be pasted. 229 @param list The list of addressee, which shall be pasted.
230 */ 230 */
231 void pasteContacts( KABC::Addressee::List &list ); 231 void pasteContacts( KABC::Addressee::List &list );
232 232
233 /** 233 /**
234 Sets the whoAmI contact, that is used by many other programs to 234 Sets the whoAmI contact, that is used by many other programs to
235 get personal information about the current user. 235 get personal information about the current user.
236 */ 236 */
237 void setWhoAmI(); 237 void setWhoAmI();
238 238
239 /** 239 /**
240 Displays the category dialog and applies the result to all 240 Displays the category dialog and applies the result to all
241 selected contacts. 241 selected contacts.
242 */ 242 */
243 void setCategories(); 243 void setCategories();
244 void manageCategories(); 244 void manageCategories();
245 void editCategories(); 245 void editCategories();
246 246
247 /** 247 /**
248 Sets the field list of the Incremental Search Widget. 248 Sets the field list of the Incremental Search Widget.
249 */ 249 */
250 void setSearchFields( const KABC::Field::List &fields ); 250 void setSearchFields( const KABC::Field::List &fields );
251 251
252 /** 252 /**
253 Search with the current search field for a contact, that matches 253 Search with the current search field for a contact, that matches
254 the given text, and selects it in the view. 254 the given text, and selects it in the view.
255 */ 255 */
256 void incrementalSearch( const QString& text ); 256 void incrementalSearch( const QString& text );
257 void incrementalSearchJump( const QString& text ); 257 void incrementalSearchJump( const QString& text );
258 258
259 /** 259 /**
260 Marks the address book as modified. 260 Marks the address book as modified.
261 */ 261 */
262 void setModified(); 262 void setModified();
263 /** 263 /**
264 Marks the address book as modified without refreshing the view. 264 Marks the address book as modified without refreshing the view.
265 */ 265 */
266 void setModifiedWOrefresh(); 266 void setModifiedWOrefresh();
267 267
268 /** 268 /**
269 Marks the address book as modified concerning the argument. 269 Marks the address book as modified concerning the argument.
270 */ 270 */
271 void setModified( bool modified ); 271 void setModified( bool modified );
272 272
273 /** 273 /**
274 Returns whether the address book is modified. 274 Returns whether the address book is modified.
275 */ 275 */
276 bool modified() const; 276 bool modified() const;
277 277
278 /** 278 /**
279 Called whenever an contact is modified in the contact editor 279 Called whenever an contact is modified in the contact editor
280 dialog or the quick edit. 280 dialog or the quick edit.
281 */ 281 */
282 void contactModified( const KABC::Addressee &addr ); 282 void contactModified( const KABC::Addressee &addr );
283 void addrModified( const KABC::Addressee &addr, bool updateDetails = true ); 283 void addrModified( const KABC::Addressee &addr, bool updateDetails = true );
284 284
285 /** 285 /**
286 DCOP METHODS. 286 DCOP METHODS.
287 */ 287 */
288 void addEmail( QString addr ); 288 void addEmail( QString addr );
289 void importVCard( const KURL& url, bool showPreview ); 289 void importVCard( const KURL& url, bool showPreview );
290 void importVCard( const QString& vCard, bool showPreview ); 290 void importVCard( const QString& vCard, bool showPreview );
291 void newContact(); 291 void newContact();
292 QString getNameByPhone( const QString& phone ); 292 QString getNameByPhone( const QString& phone );
293 /** 293 /**
294 END DCOP METHODS 294 END DCOP METHODS
295 */ 295 */
296 296
297 /** 297 /**
298 Saves the contents of the AddressBook back to disk. 298 Saves the contents of the AddressBook back to disk.
299 */ 299 */
300 void save(); 300 void save();
301 301
302 /** 302 /**
303 Undos the last command using the undo stack. 303 Undos the last command using the undo stack.
304 */ 304 */
305 void undo(); 305 void undo();
306 306
307 /** 307 /**
308 Redos the last command that was undone, using the redo stack. 308 Redos the last command that was undone, using the redo stack.
309 */ 309 */
310 void redo(); 310 void redo();
311 311
312 /** 312 /**
313 Shows the edit dialog for the given uid. If the uid is QString::null, 313 Shows the edit dialog for the given uid. If the uid is QString::null,
314 the method will try to find a selected addressee in the view. 314 the method will try to find a selected addressee in the view.
315 */ 315 */
316 void editContact( const QString &uid /*US = QString::null*/ ); 316 void editContact( const QString &uid /*US = QString::null*/ );
317//US added a second method without defaultparameter 317//US added a second method without defaultparameter
318 void editContact2(); 318 void editContact2();
319 319
320 /** 320 /**
321 Shows or edits the detail view for the given uid. If the uid is QString::null, 321 Shows or edits the detail view for the given uid. If the uid is QString::null,
322 the method will try to find a selected addressee in the view. 322 the method will try to find a selected addressee in the view.
323 */ 323 */
324 void executeContact( const QString &uid /*US = QString::null*/ ); 324 void executeContact( const QString &uid /*US = QString::null*/ );
325 325
326 /** 326 /**
327 Launches the configuration dialog. 327 Launches the configuration dialog.
328 */ 328 */
329 void openConfigDialog(); 329 void openConfigDialog();
330 void openConfigGlobalDialog(); 330 void openConfigGlobalDialog();
331 331
332 /** 332 /**
333 Launches the ldap search dialog. 333 Launches the ldap search dialog.
334 */ 334 */
335 void openLDAPDialog(); 335 void openLDAPDialog();
336 336
337 /** 337 /**
338 Creates a KAddressBookPrinter, which will display the print 338 Creates a KAddressBookPrinter, which will display the print
339 dialog and do the printing. 339 dialog and do the printing.
340 */ 340 */
341 void print(); 341 void print();
342 342
343 /** 343 /**
344 Registers a new GUI client, so plugins can register its actions. 344 Registers a new GUI client, so plugins can register its actions.
345 */ 345 */
346 void addGUIClient( KXMLGUIClient *client ); 346 void addGUIClient( KXMLGUIClient *client );
347 347
348 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); 348 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
349 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 349 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
350 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); 350 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid);
351 351
352 352
353 signals: 353 signals:
354 void contactSelected( const QString &name ); 354 void contactSelected( const QString &name );
355 void contactSelected( const QPixmap &pixmap ); 355 void contactSelected( const QPixmap &pixmap );
356 public slots: 356 public slots:
357 void loadDataAfterStart(); 357 void loadDataAfterStart();
358 void recieve(QString cmsg ); 358 void recieve(QString cmsg );
359 void getFile( bool success ); 359 void getFile( bool success,const QString & );
360 void syncFileRequest(const QString &); 360 void syncFileRequest(const QString &);
361 void setDetailsVisible( bool visible ); 361 void setDetailsVisible( bool visible );
362 void setDetailsToState(); 362 void setDetailsToState();
363 363
364 void saveSettings(); 364 void saveSettings();
365 365
366 private slots: 366 private slots:
367 void updateToolBar(); 367 void updateToolBar();
368 void updateMainWindow(); 368 void updateMainWindow();
369 void receive( const QCString& cmsg, const QByteArray& data ); 369 void receive( const QCString& cmsg, const QByteArray& data );
370 void receiveStart( const QCString& cmsg, const QByteArray& data ); 370 void receiveStart( const QCString& cmsg, const QByteArray& data );
371 void toggleBeamReceive( ); 371 void toggleBeamReceive( );
372 void disableBR(bool); 372 void disableBR(bool);
373 void setJumpButtonBarVisible( bool visible ); 373 void setJumpButtonBarVisible( bool visible );
374 void setJumpButtonBar( bool visible ); 374 void setJumpButtonBar( bool visible );
375 void setCaptionBack(); 375 void setCaptionBack();
376 void resizeAndCallContactdialog(); 376 void resizeAndCallContactdialog();
377 void callContactdialog(); 377 void callContactdialog();
378 void doRingSync(); 378 void doRingSync();
379 379
380 void importFromOL(); 380 void importFromOL();
381 void extensionModified( const KABC::Addressee::List &list ); 381 void extensionModified( const KABC::Addressee::List &list );
382 void extensionChanged( int id ); 382 void extensionChanged( int id );
383 void clipboardDataChanged(); 383 void clipboardDataChanged();
384 void updateActionMenu(); 384 void updateActionMenu();
385 void configureKeyBindings(); 385 void configureKeyBindings();
386 void removeVoice(); 386 void removeVoice();
387 void setFormattedName(); 387 void setFormattedName();
388#ifdef KAB_EMBEDDED 388#ifdef KAB_EMBEDDED
389 void configureResources(); 389 void configureResources();
390#endif //KAB_EMBEDDED 390#endif //KAB_EMBEDDED
391 391
392 void slotEditorDestroyed( const QString &uid ); 392 void slotEditorDestroyed( const QString &uid );
393 void configurationChanged(); 393 void configurationChanged();
394 void addressBookChanged(); 394 void addressBookChanged();
395 395
396 private: 396 private:
397 QCString mCStringMess; 397 QCString mCStringMess;
398 QByteArray mByteData; 398 QByteArray mByteData;
399 QString mEmailSourceChannel; 399 QString mEmailSourceChannel;
400 QString mEmailSourceUID; 400 QString mEmailSourceUID;
401 void resizeEvent(QResizeEvent* e ); 401 void resizeEvent(QResizeEvent* e );
402 bool mBRdisabled; 402 bool mBRdisabled;
403#ifndef DESKTOP_VERSION 403#ifndef DESKTOP_VERSION
404 QCopChannel* infrared; 404 QCopChannel* infrared;
405#endif 405#endif
406 QTimer *mMessageTimer; 406 QTimer *mMessageTimer;
407 void initGUI(); 407 void initGUI();
408 void initActions(); 408 void initActions();
409 QString getPhoneFile(); 409 QString getPhoneFile();
410 410
411 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 411 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
412 const char *name = 0 ); 412 const char *name = 0 );
413 413
414 KXMLGUIClient *mGUIClient; 414 KXMLGUIClient *mGUIClient;
415 415
416 KABC::AddressBook *mAddressBook; 416 KABC::AddressBook *mAddressBook;
417 417
418 ViewManager *mViewManager; 418 ViewManager *mViewManager;
419 // QSplitter *mDetailsSplitter; 419 // QSplitter *mDetailsSplitter;
420 KDGanttMinimizeSplitter *mExtensionBarSplitter; 420 KDGanttMinimizeSplitter *mExtensionBarSplitter;
421 ViewContainer *mDetails; 421 ViewContainer *mDetails;
422 KDGanttMinimizeSplitter* mMiniSplitter; 422 KDGanttMinimizeSplitter* mMiniSplitter;
423 XXPortManager *mXXPortManager; 423 XXPortManager *mXXPortManager;
424 JumpButtonBar *mJumpButtonBar; 424 JumpButtonBar *mJumpButtonBar;
425 IncSearchWidget *mIncSearchWidget; 425 IncSearchWidget *mIncSearchWidget;
426 ExtensionManager *mExtensionManager; 426 ExtensionManager *mExtensionManager;
427 427
428 KCMultiDialog *mConfigureDialog; 428 KCMultiDialog *mConfigureDialog;
429 429
430#ifndef KAB_EMBEDDED 430#ifndef KAB_EMBEDDED
431 LDAPSearchDialog *mLdapSearchDialog; 431 LDAPSearchDialog *mLdapSearchDialog;
432#endif //KAB_EMBEDDED 432#endif //KAB_EMBEDDED
433 // QDict<AddresseeEditorDialog> mEditorDict; 433 // QDict<AddresseeEditorDialog> mEditorDict;
434 AddresseeEditorDialog *mEditorDialog; 434 AddresseeEditorDialog *mEditorDialog;
435 bool mReadWrite; 435 bool mReadWrite;
436 bool mModified; 436 bool mModified;
437 bool mIsPart; 437 bool mIsPart;
438 bool mMultipleViewsAtOnce; 438 bool mMultipleViewsAtOnce;
439 439
440 440
441 //US file menu 441 //US file menu
442 KAction *mActionMail; 442 KAction *mActionMail;
443 KAction *mActionBeam; 443 KAction *mActionBeam;
444 KToggleAction *mActionBR; 444 KToggleAction *mActionBR;
445 KAction *mActionExport2phone; 445 KAction *mActionExport2phone;
446 KAction* mActionPrint; 446 KAction* mActionPrint;
447 KAction* mActionPrintDetails; 447 KAction* mActionPrintDetails;
448 KAction* mActionNewContact; 448 KAction* mActionNewContact;
449 KAction *mActionSave; 449 KAction *mActionSave;
450 KAction *mActionEditAddressee; 450 KAction *mActionEditAddressee;
451 KAction *mActionMailVCard; 451 KAction *mActionMailVCard;
452 KAction *mActionBeamVCard; 452 KAction *mActionBeamVCard;
453 453
454 KAction *mActionQuit; 454 KAction *mActionQuit;
455 455
456 //US edit menu 456 //US edit menu
457 KAction *mActionCopy; 457 KAction *mActionCopy;
458 KAction *mActionCut; 458 KAction *mActionCut;
459 KAction *mActionPaste; 459 KAction *mActionPaste;
460 KAction *mActionSelectAll; 460 KAction *mActionSelectAll;
461 KAction *mActionUndo; 461 KAction *mActionUndo;
462 KAction *mActionRedo; 462 KAction *mActionRedo;
463 KAction *mActionDelete; 463 KAction *mActionDelete;
464 464
465 //US settings menu 465 //US settings menu
466 KAction *mActionConfigResources; 466 KAction *mActionConfigResources;
467 KAction *mActionConfigGlobal; 467 KAction *mActionConfigGlobal;
468 KAction *mActionConfigKAddressbook; 468 KAction *mActionConfigKAddressbook;
469 KAction *mActionConfigShortcuts; 469 KAction *mActionConfigShortcuts;
470 KAction *mActionConfigureToolbars; 470 KAction *mActionConfigureToolbars;
471 KAction *mActionKeyBindings; 471 KAction *mActionKeyBindings;
472 KToggleAction *mActionJumpBar; 472 KToggleAction *mActionJumpBar;
473 KToggleAction *mActionDetails; 473 KToggleAction *mActionDetails;
474 KAction *mActionWhoAmI; 474 KAction *mActionWhoAmI;
475 KAction *mActionCategories; 475 KAction *mActionCategories;
476 KAction *mActionEditCategories; 476 KAction *mActionEditCategories;
477 KAction *mActionManageCategories; 477 KAction *mActionManageCategories;
478 KAction *mActionAboutKAddressbook; 478 KAction *mActionAboutKAddressbook;
479 KAction *mActionLicence; 479 KAction *mActionLicence;
480 KAction *mActionFaq; 480 KAction *mActionFaq;
481 KAction *mActionWN; 481 KAction *mActionWN;
482 KAction *mActionSyncHowto; 482 KAction *mActionSyncHowto;
483 KAction *mActionStorageHowto; 483 KAction *mActionStorageHowto;
484 KAction *mActionKdeSyncHowto; 484 KAction *mActionKdeSyncHowto;
485 KAction *mActionMultiSyncHowto; 485 KAction *mActionMultiSyncHowto;
486 486
487 KAction *mActionDeleteView; 487 KAction *mActionDeleteView;
488 488
489 QPopupMenu *viewMenu; 489 QPopupMenu *viewMenu;
490 QPopupMenu *filterMenu; 490 QPopupMenu *filterMenu;
491 QPopupMenu *settingsMenu; 491 QPopupMenu *settingsMenu;
492 QPopupMenu *changeMenu; 492 QPopupMenu *changeMenu;
493 QPopupMenu *beamMenu; 493 QPopupMenu *beamMenu;
494//US QAction *mActionSave; 494//US QAction *mActionSave;
495 QPopupMenu *ImportMenu; 495 QPopupMenu *ImportMenu;
496 QPopupMenu *ExportMenu; 496 QPopupMenu *ExportMenu;
497 //LR additional methods 497 //LR additional methods
498 KAction *mActionRemoveVoice; 498 KAction *mActionRemoveVoice;
499 KAction *mActionSetFormattedName; 499 KAction *mActionSetFormattedName;
500 KAction * mActionImportOL; 500 KAction * mActionImportOL;
501 501
502#ifndef KAB_EMBEDDED 502#ifndef KAB_EMBEDDED
503 KAddressBookService *mAddressBookService; 503 KAddressBookService *mAddressBookService;
504#endif //KAB_EMBEDDED 504#endif //KAB_EMBEDDED
505 505
506 class KABCorePrivate; 506 class KABCorePrivate;
507 KABCorePrivate *d; 507 KABCorePrivate *d;
508 //US bool mBlockSaveFlag; 508 //US bool mBlockSaveFlag;
509 509
510#ifdef KAB_EMBEDDED 510#ifdef KAB_EMBEDDED
511 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 511 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
512#endif //KAB_EMBEDDED 512#endif //KAB_EMBEDDED
513 513
514 //this are the overwritten callbackmethods from the syncinterface 514 //this are the overwritten callbackmethods from the syncinterface
515 virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource); 515 virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource);
516 virtual bool syncExternal(KSyncManager* manager, QString resource); 516 virtual bool syncExternal(KSyncManager* manager, QString resource);
517 virtual void removeSyncInfo( QString syncProfile); 517 virtual void removeSyncInfo( QString syncProfile);
518 bool syncPhone(); 518 bool syncPhone();
519 void message( QString m , bool startTimer = true); 519 void message( QString m , bool startTimer = true);
520 520
521 // LR ******************************* 521 // LR *******************************
522 // sync stuff! 522 // sync stuff!
523 QString sentSyncFile(); 523 QString sentSyncFile();
524 QPopupMenu *syncMenu; 524 QPopupMenu *syncMenu;
525 KSyncManager* syncManager; 525 KSyncManager* syncManager;
526 int mGlobalSyncMode; 526 int mGlobalSyncMode;
527 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 527 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
528 KABC::Addressee getLastSyncAddressee(); 528 KABC::Addressee getLastSyncAddressee();
529 QDateTime mLastAddressbookSync; 529 QDateTime mLastAddressbookSync;
530 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); 530 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
531 // ********************* 531 // *********************
532 532
533}; 533};
534 534
535#endif 535#endif
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index e615cbe..7197b30 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,1469 +1,1469 @@
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#include <qapplication.h> 52#include <qapplication.h>
53 53
54#include <klocale.h> 54#include <klocale.h>
55#include <kglobal.h> 55#include <kglobal.h>
56#include <kconfig.h> 56#include <kconfig.h>
57#include <kfiledialog.h> 57#include <kfiledialog.h>
58 58
59QDateTime KSyncManager::mRequestedSyncEvent; 59QDateTime KSyncManager::mRequestedSyncEvent;
60 60
61 61
62KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 62KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
63 : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) 63 : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu)
64{ 64{
65 mServerSocket = 0; 65 mServerSocket = 0;
66 bar = new QProgressBar ( 1, 0 ); 66 bar = new QProgressBar ( 1, 0 );
67 bar->setCaption (""); 67 bar->setCaption ("");
68 mWriteBackInPast = 2; 68 mWriteBackInPast = 2;
69 69
70 70
71} 71}
72 72
73KSyncManager::~KSyncManager() 73KSyncManager::~KSyncManager()
74{ 74{
75 delete bar; 75 delete bar;
76} 76}
77 77
78void KSyncManager::setDefaultFileName( QString s) 78void KSyncManager::setDefaultFileName( QString s)
79{ 79{
80 mDefFileName = s ; 80 mDefFileName = s ;
81 if ( mPrefs->mPassiveSyncAutoStart ) 81 if ( mPrefs->mPassiveSyncAutoStart )
82 enableQuick( false ); 82 enableQuick( false );
83} 83}
84 84
85void KSyncManager::fillSyncMenu() 85void KSyncManager::fillSyncMenu()
86{ 86{
87 if ( mSyncMenu->count() ) 87 if ( mSyncMenu->count() )
88 mSyncMenu->clear(); 88 mSyncMenu->clear();
89 89
90 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 90 mSyncMenu->insertItem( i18n("Configure..."), 0 );
91 mSyncMenu->insertSeparator(); 91 mSyncMenu->insertSeparator();
92 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); 92 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu );
93 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); 93 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 );
94 clearMenu->insertItem( i18n("For all profiles"), 1 ); 94 clearMenu->insertItem( i18n("For all profiles"), 1 );
95 clearMenu->insertSeparator(); 95 clearMenu->insertSeparator();
96 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); 96 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) );
97 mSyncMenu->insertSeparator(); 97 mSyncMenu->insertSeparator();
98 if ( mServerSocket == 0 ) { 98 if ( mServerSocket == 0 ) {
99 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 99 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
100 } else { 100 } else {
101 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 101 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
102 } 102 }
103 mSyncMenu->insertSeparator(); 103 mSyncMenu->insertSeparator();
104 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 104 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
105 mSyncMenu->insertSeparator(); 105 mSyncMenu->insertSeparator();
106 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 106 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
107 config.setGroup("General"); 107 config.setGroup("General");
108 QStringList prof = config.readListEntry("SyncProfileNames"); 108 QStringList prof = config.readListEntry("SyncProfileNames");
109 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 109 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
110 if ( prof.count() < 2 ) { 110 if ( prof.count() < 2 ) {
111 prof.clear(); 111 prof.clear();
112 QString externalName; 112 QString externalName;
113#ifdef DESKTOP_VERSION 113#ifdef DESKTOP_VERSION
114#ifdef _WIN32_ 114#ifdef _WIN32_
115 externalName = "OutLook(not_implemented)"; 115 externalName = "OutLook(not_implemented)";
116#else 116#else
117 externalName = "KDE_Desktop"; 117 externalName = "KDE_Desktop";
118#endif 118#endif
119#else 119#else
120 externalName = "Sharp_DTM"; 120 externalName = "Sharp_DTM";
121#endif 121#endif
122 prof << externalName; 122 prof << externalName;
123 prof << i18n("Local_file"); 123 prof << i18n("Local_file");
124 prof << i18n("Last_file"); 124 prof << i18n("Last_file");
125 KSyncProfile* temp = new KSyncProfile (); 125 KSyncProfile* temp = new KSyncProfile ();
126 temp->setName( prof[0] ); 126 temp->setName( prof[0] );
127 temp->writeConfig(&config); 127 temp->writeConfig(&config);
128 temp->setName( prof[1] ); 128 temp->setName( prof[1] );
129 temp->writeConfig(&config); 129 temp->writeConfig(&config);
130 temp->setName( prof[2] ); 130 temp->setName( prof[2] );
131 temp->writeConfig(&config); 131 temp->writeConfig(&config);
132 config.setGroup("General"); 132 config.setGroup("General");
133 config.writeEntry("SyncProfileNames",prof); 133 config.writeEntry("SyncProfileNames",prof);
134 config.writeEntry("ExternSyncProfiles",externalName); 134 config.writeEntry("ExternSyncProfiles",externalName);
135 config.sync(); 135 config.sync();
136 delete temp; 136 delete temp;
137 } 137 }
138 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 138 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
139 mSyncProfileNames = prof; 139 mSyncProfileNames = prof;
140 unsigned int i; 140 unsigned int i;
141 for ( i = 0; i < prof.count(); ++i ) { 141 for ( i = 0; i < prof.count(); ++i ) {
142 QString insertText = prof[i]; 142 QString insertText = prof[i];
143 if ( i == 0 ) { 143 if ( i == 0 ) {
144#ifdef DESKTOP_VERSION 144#ifdef DESKTOP_VERSION
145#ifdef _WIN32_ 145#ifdef _WIN32_
146 insertText = "OutLook(not_implemented)"; 146 insertText = "OutLook(not_implemented)";
147#else 147#else
148 insertText = "KDE_Desktop"; 148 insertText = "KDE_Desktop";
149#endif 149#endif
150#else 150#else
151 insertText = "Sharp_DTM"; 151 insertText = "Sharp_DTM";
152#endif 152#endif
153 } 153 }
154 mSyncMenu->insertItem( insertText, 1000+i ); 154 mSyncMenu->insertItem( insertText, 1000+i );
155 clearMenu->insertItem( insertText, 1000+i ); 155 clearMenu->insertItem( insertText, 1000+i );
156 if ( i == 2 ) 156 if ( i == 2 )
157 mSyncMenu->insertSeparator(); 157 mSyncMenu->insertSeparator();
158 } 158 }
159 QDir app_dir; 159 QDir app_dir;
160 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 160 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
161 if ( mTargetApp == PWMPI) { 161 if ( mTargetApp == PWMPI) {
162 mSyncMenu->removeItem( 1000 ); 162 mSyncMenu->removeItem( 1000 );
163 clearMenu->removeItem( 1000 ); 163 clearMenu->removeItem( 1000 );
164 } 164 }
165#ifndef DESKTOP_VERSION 165#ifndef DESKTOP_VERSION
166 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 166 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
167 mSyncMenu->removeItem( 1000 ); 167 mSyncMenu->removeItem( 1000 );
168 clearMenu->removeItem( 1000 ); 168 clearMenu->removeItem( 1000 );
169 } 169 }
170#endif 170#endif
171 mSyncMenu->removeItem( 1002 ); 171 mSyncMenu->removeItem( 1002 );
172 clearMenu->removeItem( 1002 ); 172 clearMenu->removeItem( 1002 );
173} 173}
174void KSyncManager::slotClearMenu( int action ) 174void KSyncManager::slotClearMenu( int action )
175{ 175{
176 QString syncDevice; 176 QString syncDevice;
177 if ( action > 999 ) { 177 if ( action > 999 ) {
178 syncDevice = mSyncProfileNames[action - 1000] ; 178 syncDevice = mSyncProfileNames[action - 1000] ;
179 } 179 }
180 180
181 181
182 182
183 int result = 0; 183 int result = 0;
184 QString sd; 184 QString sd;
185 if ( syncDevice.isEmpty() ) 185 if ( syncDevice.isEmpty() )
186 sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); 186 sd = i18n("Do you want to\nclear all sync info\nof all profiles?");
187 else 187 else
188 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); 188 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice );
189 189
190 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, 190 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0,
191 0, 1 ); 191 0, 1 );
192 if ( result ) 192 if ( result )
193 return; 193 return;
194 mImplementation->removeSyncInfo( syncDevice ); 194 mImplementation->removeSyncInfo( syncDevice );
195} 195}
196void KSyncManager::slotSyncMenu( int action ) 196void KSyncManager::slotSyncMenu( int action )
197{ 197{
198 qDebug("KSM::syncaction %d ", action); 198 qDebug("KSM::syncaction %d ", action);
199 mCurrentResourceLocal = ""; 199 mCurrentResourceLocal = "";
200 emit multiResourceSyncStart( false ); 200 emit multiResourceSyncStart( false );
201 if ( action == 5000 ) 201 if ( action == 5000 )
202 return; 202 return;
203 mSyncWithDesktop = false; 203 mSyncWithDesktop = false;
204 if ( action == 0 ) { 204 if ( action == 0 ) {
205 205
206 // seems to be a Qt2 event handling bug 206 // seems to be a Qt2 event handling bug
207 // syncmenu.clear causes a segfault at first time 207 // syncmenu.clear causes a segfault at first time
208 // when we call it after the main event loop, it is ok 208 // when we call it after the main event loop, it is ok
209 // same behaviour when calling OM/Pi via QCOP for the first time 209 // same behaviour when calling OM/Pi via QCOP for the first time
210 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 210 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
211 //confSync(); 211 //confSync();
212 212
213 return; 213 return;
214 } 214 }
215 if ( action == 1 ) { 215 if ( action == 1 ) {
216 multiSync( true ); 216 multiSync( true );
217 return; 217 return;
218 } 218 }
219 if ( action == 2 ) { 219 if ( action == 2 ) {
220 enableQuick(); 220 enableQuick();
221 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 221 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
222 return; 222 return;
223 } 223 }
224 if ( action == 3 ) { 224 if ( action == 3 ) {
225 delete mServerSocket; 225 delete mServerSocket;
226 mServerSocket = 0; 226 mServerSocket = 0;
227 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 227 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
228 return; 228 return;
229 } 229 }
230 230
231 if (blockSave()) 231 if (blockSave())
232 return; 232 return;
233 233
234 setBlockSave(true); 234 setBlockSave(true);
235 bool silent = false; 235 bool silent = false;
236 if ( action == 999 ) { 236 if ( action == 999 ) {
237 //special mode for silent syncing 237 //special mode for silent syncing
238 action = 1000; 238 action = 1000;
239 silent = true; 239 silent = true;
240 } 240 }
241 241
242 mCurrentSyncProfile = action - 1000 ; 242 mCurrentSyncProfile = action - 1000 ;
243 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 243 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
244 mCurrentSyncName = mLocalMachineName ; 244 mCurrentSyncName = mLocalMachineName ;
245 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 245 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
246 KSyncProfile* temp = new KSyncProfile (); 246 KSyncProfile* temp = new KSyncProfile ();
247 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 247 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
248 temp->readConfig(&config); 248 temp->readConfig(&config);
249 if (silent) { 249 if (silent) {
250 mAskForPreferences = false; 250 mAskForPreferences = false;
251 mShowSyncSummary = false; 251 mShowSyncSummary = false;
252 mWriteBackFile = true; 252 mWriteBackFile = true;
253 mSyncAlgoPrefs = 2;// take newest 253 mSyncAlgoPrefs = 2;// take newest
254 } 254 }
255 else { 255 else {
256 mAskForPreferences = temp->getAskForPreferences(); 256 mAskForPreferences = temp->getAskForPreferences();
257 mShowSyncSummary = temp->getShowSummaryAfterSync(); 257 mShowSyncSummary = temp->getShowSummaryAfterSync();
258 mWriteBackFile = temp->getWriteBackFile(); 258 mWriteBackFile = temp->getWriteBackFile();
259 mSyncAlgoPrefs = temp->getSyncPrefs(); 259 mSyncAlgoPrefs = temp->getSyncPrefs();
260 } 260 }
261 mWriteBackExistingOnly = temp->getWriteBackExisting(); 261 mWriteBackExistingOnly = temp->getWriteBackExisting();
262 mIsKapiFile = temp->getIsKapiFile(); 262 mIsKapiFile = temp->getIsKapiFile();
263 mWriteBackInFuture = 0; 263 mWriteBackInFuture = 0;
264 if ( temp->getWriteBackFuture() ) { 264 if ( temp->getWriteBackFuture() ) {
265 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 265 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
266 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 266 mWriteBackInPast = temp->getWriteBackPastWeeks( );
267 } 267 }
268 mFilterInCal = temp->getFilterInCal(); 268 mFilterInCal = temp->getFilterInCal();
269 mFilterOutCal = temp->getFilterOutCal(); 269 mFilterOutCal = temp->getFilterOutCal();
270 mFilterInAB = temp->getFilterInAB(); 270 mFilterInAB = temp->getFilterInAB();
271 mFilterOutAB = temp->getFilterOutAB(); 271 mFilterOutAB = temp->getFilterOutAB();
272 272
273 if ( action == 1000 ) { 273 if ( action == 1000 ) {
274 mIsKapiFile = false; 274 mIsKapiFile = false;
275#ifdef DESKTOP_VERSION 275#ifdef DESKTOP_VERSION
276 syncKDE(); 276 syncKDE();
277#else 277#else
278 syncSharp(); 278 syncSharp();
279#endif 279#endif
280 280
281 } else if ( action == 1001 ) { 281 } else if ( action == 1001 ) {
282 syncLocalFile(); 282 syncLocalFile();
283 283
284 } else if ( action == 1002 ) { 284 } else if ( action == 1002 ) {
285 mWriteBackFile = false; 285 mWriteBackFile = false;
286 mAskForPreferences = false; 286 mAskForPreferences = false;
287 mShowSyncSummary = false; 287 mShowSyncSummary = false;
288 mSyncAlgoPrefs = 3; 288 mSyncAlgoPrefs = 3;
289 quickSyncLocalFile(); 289 quickSyncLocalFile();
290 290
291 } else if ( action >= 1003 ) { 291 } else if ( action >= 1003 ) {
292 if ( temp->getIsLocalFileSync() ) { 292 if ( temp->getIsLocalFileSync() ) {
293 switch(mTargetApp) 293 switch(mTargetApp)
294 { 294 {
295 case (KAPI): 295 case (KAPI):
296 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 296 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
297 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 297 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
298 break; 298 break;
299 case (KOPI): 299 case (KOPI):
300 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 300 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
301 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 301 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
302 break; 302 break;
303 case (PWMPI): 303 case (PWMPI):
304 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 304 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
305 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 305 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
306 break; 306 break;
307 default: 307 default:
308 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 308 qDebug("KSM::slotSyncMenu: invalid apptype selected");
309 break; 309 break;
310 310
311 } 311 }
312 } else { 312 } else {
313 if ( temp->getIsPhoneSync() ) { 313 if ( temp->getIsPhoneSync() ) {
314 mPhoneDevice = temp->getPhoneDevice( ) ; 314 mPhoneDevice = temp->getPhoneDevice( ) ;
315 mPhoneConnection = temp->getPhoneConnection( ); 315 mPhoneConnection = temp->getPhoneConnection( );
316 mPhoneModel = temp->getPhoneModel( ); 316 mPhoneModel = temp->getPhoneModel( );
317 syncPhone(); 317 syncPhone();
318 } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) { 318 } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) {
319 mSpecificResources.clear(); 319 mSpecificResources.clear();
320 if ( mTargetApp == KAPI ) { 320 if ( mTargetApp == KAPI ) {
321 if ( temp->getIsPiSyncSpec() ) 321 if ( temp->getIsPiSyncSpec() )
322 mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true ); 322 mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true );
323 mPassWordPiSync = temp->getRemotePwAB(); 323 mPassWordPiSync = temp->getRemotePwAB();
324 mActiveSyncPort = temp->getRemotePortAB(); 324 mActiveSyncPort = temp->getRemotePortAB();
325 mActiveSyncIP = temp->getRemoteIPAB(); 325 mActiveSyncIP = temp->getRemoteIPAB();
326 } else if ( mTargetApp == KOPI ) { 326 } else if ( mTargetApp == KOPI ) {
327 if ( temp->getIsPiSyncSpec() ) 327 if ( temp->getIsPiSyncSpec() )
328 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); 328 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true );
329 mPassWordPiSync = temp->getRemotePw(); 329 mPassWordPiSync = temp->getRemotePw();
330 mActiveSyncPort = temp->getRemotePort(); 330 mActiveSyncPort = temp->getRemotePort();
331 mActiveSyncIP = temp->getRemoteIP(); 331 mActiveSyncIP = temp->getRemoteIP();
332 } else { 332 } else {
333 mPassWordPiSync = temp->getRemotePwPWM(); 333 mPassWordPiSync = temp->getRemotePwPWM();
334 mActiveSyncPort = temp->getRemotePortPWM(); 334 mActiveSyncPort = temp->getRemotePortPWM();
335 mActiveSyncIP = temp->getRemoteIPPWM(); 335 mActiveSyncIP = temp->getRemoteIPPWM();
336 } 336 }
337 syncPi(); 337 syncPi();
338 while ( !mPisyncFinished ) { 338 while ( !mPisyncFinished ) {
339 //qDebug("waiting "); 339 //qDebug("waiting ");
340 qApp->processEvents(); 340 qApp->processEvents();
341 } 341 }
342 } else 342 } else
343 syncRemote( temp ); 343 syncRemote( temp );
344 344
345 } 345 }
346 } 346 }
347 delete temp; 347 delete temp;
348 setBlockSave(false); 348 setBlockSave(false);
349} 349}
350 350
351void KSyncManager::enableQuick( bool ask ) 351void KSyncManager::enableQuick( bool ask )
352{ 352{
353 bool autoStart; 353 bool autoStart;
354 bool changed = false; 354 bool changed = false;
355 if ( ask ) { 355 if ( ask ) {
356 QDialog dia ( 0, "input-dialog", true ); 356 QDialog dia ( 0, "input-dialog", true );
357 QLineEdit lab ( &dia ); 357 QLineEdit lab ( &dia );
358 QVBoxLayout lay( &dia ); 358 QVBoxLayout lay( &dia );
359 lab.setText( mPrefs->mPassiveSyncPort ); 359 lab.setText( mPrefs->mPassiveSyncPort );
360 lay.setMargin(7); 360 lay.setMargin(7);
361 lay.setSpacing(7); 361 lay.setSpacing(7);
362 int po = 9197+mTargetApp; 362 int po = 9197+mTargetApp;
363 QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); 363 QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia );
364 lay.addWidget( &label); 364 lay.addWidget( &label);
365 lay.addWidget( &lab); 365 lay.addWidget( &lab);
366 366
367 QLineEdit lepw ( &dia ); 367 QLineEdit lepw ( &dia );
368 lepw.setText( mPrefs->mPassiveSyncPw ); 368 lepw.setText( mPrefs->mPassiveSyncPw );
369 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 369 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
370 lay.addWidget( &label2); 370 lay.addWidget( &label2);
371 lay.addWidget( &lepw); 371 lay.addWidget( &lepw);
372 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); 372 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia );
373 lay.addWidget( &autostart); 373 lay.addWidget( &autostart);
374 autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); 374 autostart.setChecked( mPrefs->mPassiveSyncAutoStart );
375#ifdef DESKTOP_VERSION 375#ifdef DESKTOP_VERSION
376#ifdef _WIN32_ 376#ifdef _WIN32_
377 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); 377 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia );
378 syncdesktop.hide();// not implemented! 378 syncdesktop.hide();// not implemented!
379#else 379#else
380 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); 380 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia );
381#endif 381#endif
382 lay.addWidget( &syncdesktop); 382 lay.addWidget( &syncdesktop);
383#else 383#else
384 mPrefs->mPassiveSyncWithDesktop = false; 384 mPrefs->mPassiveSyncWithDesktop = false;
385 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); 385 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
386 syncdesktop.hide(); 386 syncdesktop.hide();
387#endif 387#endif
388 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); 388 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
389 389
390 QPushButton pb ( "OK", &dia); 390 QPushButton pb ( "OK", &dia);
391 lay.addWidget( &pb ); 391 lay.addWidget( &pb );
392 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 392 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
393 dia.resize( 230,120 ); 393 dia.resize( 230,120 );
394 dia.setCaption( i18n("Enter port for Pi-Sync") ); 394 dia.setCaption( i18n("Enter port for Pi-Sync") );
395 dia.show(); 395 dia.show();
396#ifndef DESKTOP_VERSION 396#ifndef DESKTOP_VERSION
397 int dw = QApplication::desktop()->width(); 397 int dw = QApplication::desktop()->width();
398 int dh = QApplication::desktop()->height(); 398 int dh = QApplication::desktop()->height();
399 dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); 399 dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 );
400#endif 400#endif
401 if ( ! dia.exec() ) 401 if ( ! dia.exec() )
402 return; 402 return;
403 dia.hide(); 403 dia.hide();
404 qApp->processEvents(); 404 qApp->processEvents();
405 if ( mPrefs->mPassiveSyncPw != lepw.text() ) { 405 if ( mPrefs->mPassiveSyncPw != lepw.text() ) {
406 changed = true; 406 changed = true;
407 mPrefs->mPassiveSyncPw = lepw.text(); 407 mPrefs->mPassiveSyncPw = lepw.text();
408 } 408 }
409 if ( mPrefs->mPassiveSyncPort != lab.text() ) { 409 if ( mPrefs->mPassiveSyncPort != lab.text() ) {
410 mPrefs->mPassiveSyncPort = lab.text(); 410 mPrefs->mPassiveSyncPort = lab.text();
411 changed = true; 411 changed = true;
412 } 412 }
413 autoStart = autostart.isChecked(); 413 autoStart = autostart.isChecked();
414 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { 414 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) {
415 changed = true; 415 changed = true;
416 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); 416 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked();
417 } 417 }
418 } 418 }
419 else 419 else
420 autoStart = mPrefs->mPassiveSyncAutoStart; 420 autoStart = mPrefs->mPassiveSyncAutoStart;
421 if ( autoStart != mPrefs->mPassiveSyncAutoStart ) 421 if ( autoStart != mPrefs->mPassiveSyncAutoStart )
422 changed = true; 422 changed = true;
423 bool ok; 423 bool ok;
424 mPrefs->mPassiveSyncAutoStart = false; 424 mPrefs->mPassiveSyncAutoStart = false;
425 Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); 425 Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok);
426 if ( ! ok || port_t > 65535 ) { 426 if ( ! ok || port_t > 65535 ) {
427 KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); 427 KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error"));
428 return; 428 return;
429 } 429 }
430 Q_UINT16 port = port_t; 430 Q_UINT16 port = port_t;
431 //qDebug("port %d ", port); 431 //qDebug("port %d ", port);
432 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 432 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
433 mServerSocket->setFileName( defaultFileName() );//bbb 433 mServerSocket->setFileName( defaultFileName() );//bbb
434 if ( !mServerSocket->ok() ) { 434 if ( !mServerSocket->ok() ) {
435 QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); 435 QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) );
436 delete mServerSocket; 436 delete mServerSocket;
437 mServerSocket = 0; 437 mServerSocket = 0;
438 return; 438 return;
439 } 439 }
440 mPrefs->mPassiveSyncAutoStart = autoStart; 440 mPrefs->mPassiveSyncAutoStart = autoStart;
441 if ( changed ) { 441 if ( changed ) {
442 mPrefs->writeConfig(); 442 mPrefs->writeConfig();
443 } 443 }
444 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 444 //connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
445 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 445 //connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
446 connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) ); 446 connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) );
447 connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) ); 447 connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) );
448} 448}
449void KSyncManager::displayErrorPort() 449void KSyncManager::displayErrorPort()
450{ 450{
451 KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); 451 KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error"));
452} 452}
453void KSyncManager::syncLocalFile() 453void KSyncManager::syncLocalFile()
454{ 454{
455 455
456 QString fn =mPrefs->mLastSyncedLocalFile; 456 QString fn =mPrefs->mLastSyncedLocalFile;
457 QString ext; 457 QString ext;
458 458
459 switch(mTargetApp) 459 switch(mTargetApp)
460 { 460 {
461 case (KAPI): 461 case (KAPI):
462 ext = "(*.vcf)"; 462 ext = "(*.vcf)";
463 break; 463 break;
464 case (KOPI): 464 case (KOPI):
465 ext = "(*.ics/*.vcs)"; 465 ext = "(*.ics/*.vcs)";
466 break; 466 break;
467 case (PWMPI): 467 case (PWMPI):
468 ext = "(*.pwm)"; 468 ext = "(*.pwm)";
469 break; 469 break;
470 default: 470 default:
471 qDebug("KSM::syncLocalFile: invalid apptype selected"); 471 qDebug("KSM::syncLocalFile: invalid apptype selected");
472 break; 472 break;
473 473
474 } 474 }
475 475
476 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 476 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
477 if ( fn == "" ) 477 if ( fn == "" )
478 return; 478 return;
479 if ( syncWithFile( fn, false ) ) { 479 if ( syncWithFile( fn, false ) ) {
480 qDebug("KSM::syncLocalFile() successful "); 480 qDebug("KSM::syncLocalFile() successful ");
481 } 481 }
482 482
483} 483}
484 484
485bool KSyncManager::syncWithFile( QString fn , bool quick ) 485bool KSyncManager::syncWithFile( QString fn , bool quick )
486{ 486{
487 bool ret = false; 487 bool ret = false;
488 QFileInfo info; 488 QFileInfo info;
489 info.setFile( fn ); 489 info.setFile( fn );
490 QString mess; 490 QString mess;
491 if ( !info. exists() ) { 491 if ( !info. exists() ) {
492 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 492 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
493 QMessageBox::warning( mParent, i18n("Warning!"), 493 QMessageBox::warning( mParent, i18n("Warning!"),
494 mess ); 494 mess );
495 return ret; 495 return ret;
496 } 496 }
497 int result = 0; 497 int result = 0;
498 if ( !quick ) { 498 if ( !quick ) {
499 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 499 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
500 result = QMessageBox::warning( mParent, i18n("Warning!"), 500 result = QMessageBox::warning( mParent, i18n("Warning!"),
501 mess, 501 mess,
502 i18n("Sync"), i18n("Cancel"), 0, 502 i18n("Sync"), i18n("Cancel"), 0,
503 0, 1 ); 503 0, 1 );
504 if ( result ) 504 if ( result )
505 return false; 505 return false;
506 } 506 }
507 if ( mAskForPreferences ) 507 if ( mAskForPreferences )
508 if ( !edit_sync_options()) { 508 if ( !edit_sync_options()) {
509 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 509 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
510 return false; 510 return false;
511 } 511 }
512 if ( result == 0 ) { 512 if ( result == 0 ) {
513 //qDebug("Now sycing ... "); 513 //qDebug("Now sycing ... ");
514 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) ) 514 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) )
515 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 515 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
516 else 516 else
517 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 517 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
518 if ( ! quick ) 518 if ( ! quick )
519 mPrefs->mLastSyncedLocalFile = fn; 519 mPrefs->mLastSyncedLocalFile = fn;
520 } 520 }
521 return ret; 521 return ret;
522} 522}
523 523
524void KSyncManager::quickSyncLocalFile() 524void KSyncManager::quickSyncLocalFile()
525{ 525{
526 526
527 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { 527 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
528 qDebug("KSM::quick syncLocalFile() successful "); 528 qDebug("KSM::quick syncLocalFile() successful ");
529 529
530 } 530 }
531} 531}
532 532
533void KSyncManager::multiSync( bool askforPrefs ) 533void KSyncManager::multiSync( bool askforPrefs )
534{ 534{
535 if (blockSave()) 535 if (blockSave())
536 return; 536 return;
537 setBlockSave(true); 537 setBlockSave(true);
538 mCurrentResourceLocal = ""; 538 mCurrentResourceLocal = "";
539 if ( askforPrefs ) { 539 if ( askforPrefs ) {
540 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 540 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
541 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 541 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
542 question, 542 question,
543 i18n("Yes"), i18n("No"), 543 i18n("Yes"), i18n("No"),
544 0, 0 ) != 0 ) { 544 0, 0 ) != 0 ) {
545 setBlockSave(false); 545 setBlockSave(false);
546 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 546 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
547 return; 547 return;
548 } 548 }
549 } 549 }
550 mCurrentSyncDevice = i18n("Multiple profiles") ; 550 mCurrentSyncDevice = i18n("Multiple profiles") ;
551 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 551 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
552 if ( askforPrefs ) { 552 if ( askforPrefs ) {
553 if ( !edit_sync_options()) { 553 if ( !edit_sync_options()) {
554 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); 554 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") );
555 return; 555 return;
556 } 556 }
557 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; 557 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
558 } 558 }
559 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 559 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
560 qApp->processEvents(); 560 qApp->processEvents();
561 int num = ringSync() ; 561 int num = ringSync() ;
562 if ( num > 1 ) 562 if ( num > 1 )
563 ringSync(); 563 ringSync();
564 setBlockSave(false); 564 setBlockSave(false);
565 if ( num ) 565 if ( num )
566 emit save(); 566 emit save();
567 if ( num ) 567 if ( num )
568 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); 568 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
569 else 569 else
570 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 570 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
571 return; 571 return;
572} 572}
573 573
574int KSyncManager::ringSync() 574int KSyncManager::ringSync()
575{ 575{
576 emit multiResourceSyncStart( false ); 576 emit multiResourceSyncStart( false );
577 int syncedProfiles = 0; 577 int syncedProfiles = 0;
578 unsigned int i; 578 unsigned int i;
579 QTime timer; 579 QTime timer;
580 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 580 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
581 QStringList syncProfileNames = mSyncProfileNames; 581 QStringList syncProfileNames = mSyncProfileNames;
582 KSyncProfile* temp = new KSyncProfile (); 582 KSyncProfile* temp = new KSyncProfile ();
583 mAskForPreferences = false; 583 mAskForPreferences = false;
584 mCurrentResourceLocal = ""; 584 mCurrentResourceLocal = "";
585 for ( i = 0; i < syncProfileNames.count(); ++i ) { 585 for ( i = 0; i < syncProfileNames.count(); ++i ) {
586 mCurrentSyncProfile = i; 586 mCurrentSyncProfile = i;
587 temp->setName(syncProfileNames[mCurrentSyncProfile]); 587 temp->setName(syncProfileNames[mCurrentSyncProfile]);
588 temp->readConfig(&config); 588 temp->readConfig(&config);
589 589
590 bool includeInRingSync = false; 590 bool includeInRingSync = false;
591 switch(mTargetApp) 591 switch(mTargetApp)
592 { 592 {
593 case (KAPI): 593 case (KAPI):
594 includeInRingSync = temp->getIncludeInRingSyncAB(); 594 includeInRingSync = temp->getIncludeInRingSyncAB();
595 break; 595 break;
596 case (KOPI): 596 case (KOPI):
597 includeInRingSync = temp->getIncludeInRingSync(); 597 includeInRingSync = temp->getIncludeInRingSync();
598 break; 598 break;
599 case (PWMPI): 599 case (PWMPI):
600 includeInRingSync = temp->getIncludeInRingSyncPWM(); 600 includeInRingSync = temp->getIncludeInRingSyncPWM();
601 break; 601 break;
602 default: 602 default:
603 qDebug("KSM::ringSync: invalid apptype selected"); 603 qDebug("KSM::ringSync: invalid apptype selected");
604 break; 604 break;
605 605
606 } 606 }
607 607
608 608
609 if ( includeInRingSync && ( i < 1 || i > 2 )) { 609 if ( includeInRingSync && ( i < 1 || i > 2 )) {
610 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 610 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
611 ++syncedProfiles; 611 ++syncedProfiles;
612 mSyncWithDesktop = false; 612 mSyncWithDesktop = false;
613 // mAskForPreferences = temp->getAskForPreferences(); 613 // mAskForPreferences = temp->getAskForPreferences();
614 mWriteBackFile = temp->getWriteBackFile(); 614 mWriteBackFile = temp->getWriteBackFile();
615 mWriteBackExistingOnly = temp->getWriteBackExisting(); 615 mWriteBackExistingOnly = temp->getWriteBackExisting();
616 mIsKapiFile = temp->getIsKapiFile(); 616 mIsKapiFile = temp->getIsKapiFile();
617 mWriteBackInFuture = 0; 617 mWriteBackInFuture = 0;
618 if ( temp->getWriteBackFuture() ) { 618 if ( temp->getWriteBackFuture() ) {
619 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 619 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
620 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 620 mWriteBackInPast = temp->getWriteBackPastWeeks( );
621 } 621 }
622 mFilterInCal = temp->getFilterInCal(); 622 mFilterInCal = temp->getFilterInCal();
623 mFilterOutCal = temp->getFilterOutCal(); 623 mFilterOutCal = temp->getFilterOutCal();
624 mFilterInAB = temp->getFilterInAB(); 624 mFilterInAB = temp->getFilterInAB();
625 mFilterOutAB = temp->getFilterOutAB(); 625 mFilterOutAB = temp->getFilterOutAB();
626 mShowSyncSummary = false; 626 mShowSyncSummary = false;
627 mCurrentSyncDevice = syncProfileNames[i] ; 627 mCurrentSyncDevice = syncProfileNames[i] ;
628 mCurrentSyncName = mLocalMachineName; 628 mCurrentSyncName = mLocalMachineName;
629 if ( i == 0 ) { 629 if ( i == 0 ) {
630 mIsKapiFile = false; 630 mIsKapiFile = false;
631#ifdef DESKTOP_VERSION 631#ifdef DESKTOP_VERSION
632 syncKDE(); 632 syncKDE();
633#else 633#else
634 syncSharp(); 634 syncSharp();
635#endif 635#endif
636 } else { 636 } else {
637 if ( temp->getIsLocalFileSync() ) { 637 if ( temp->getIsLocalFileSync() ) {
638 switch(mTargetApp) 638 switch(mTargetApp)
639 { 639 {
640 case (KAPI): 640 case (KAPI):
641 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 641 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
642 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 642 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
643 break; 643 break;
644 case (KOPI): 644 case (KOPI):
645 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 645 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
646 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 646 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
647 break; 647 break;
648 case (PWMPI): 648 case (PWMPI):
649 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 649 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
650 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 650 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
651 break; 651 break;
652 default: 652 default:
653 qDebug("KSM: invalid apptype selected"); 653 qDebug("KSM: invalid apptype selected");
654 break; 654 break;
655 } 655 }
656 } else { 656 } else {
657 if ( temp->getIsPhoneSync() ) { 657 if ( temp->getIsPhoneSync() ) {
658 mPhoneDevice = temp->getPhoneDevice( ) ; 658 mPhoneDevice = temp->getPhoneDevice( ) ;
659 mPhoneConnection = temp->getPhoneConnection( ); 659 mPhoneConnection = temp->getPhoneConnection( );
660 mPhoneModel = temp->getPhoneModel( ); 660 mPhoneModel = temp->getPhoneModel( );
661 syncPhone(); 661 syncPhone();
662 } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) { 662 } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) {
663 mSpecificResources.clear(); 663 mSpecificResources.clear();
664 if ( mTargetApp == KAPI ) { 664 if ( mTargetApp == KAPI ) {
665 if ( temp->getIsPiSyncSpec() ) 665 if ( temp->getIsPiSyncSpec() )
666 mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true ); 666 mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true );
667 mPassWordPiSync = temp->getRemotePwAB(); 667 mPassWordPiSync = temp->getRemotePwAB();
668 mActiveSyncPort = temp->getRemotePortAB(); 668 mActiveSyncPort = temp->getRemotePortAB();
669 mActiveSyncIP = temp->getRemoteIPAB(); 669 mActiveSyncIP = temp->getRemoteIPAB();
670 } else if ( mTargetApp == KOPI ) { 670 } else if ( mTargetApp == KOPI ) {
671 if ( temp->getIsPiSyncSpec() ) 671 if ( temp->getIsPiSyncSpec() )
672 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); 672 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true );
673 mPassWordPiSync = temp->getRemotePw(); 673 mPassWordPiSync = temp->getRemotePw();
674 mActiveSyncPort = temp->getRemotePort(); 674 mActiveSyncPort = temp->getRemotePort();
675 mActiveSyncIP = temp->getRemoteIP(); 675 mActiveSyncIP = temp->getRemoteIP();
676 } else { 676 } else {
677 mPassWordPiSync = temp->getRemotePwPWM(); 677 mPassWordPiSync = temp->getRemotePwPWM();
678 mActiveSyncPort = temp->getRemotePortPWM(); 678 mActiveSyncPort = temp->getRemotePortPWM();
679 mActiveSyncIP = temp->getRemoteIPPWM(); 679 mActiveSyncIP = temp->getRemoteIPPWM();
680 } 680 }
681 syncPi(); 681 syncPi();
682 while ( !mPisyncFinished ) { 682 while ( !mPisyncFinished ) {
683 //qDebug("waiting "); 683 //qDebug("waiting ");
684 qApp->processEvents(); 684 qApp->processEvents();
685 } 685 }
686 timer.start(); 686 timer.start();
687 while ( timer.elapsed () < 2000 ) { 687 while ( timer.elapsed () < 2000 ) {
688 qApp->processEvents(); 688 qApp->processEvents();
689 } 689 }
690 } else 690 } else
691 syncRemote( temp, false ); 691 syncRemote( temp, false );
692 692
693 } 693 }
694 } 694 }
695 timer.start(); 695 timer.start();
696 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 696 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
697 while ( timer.elapsed () < 2000 ) { 697 while ( timer.elapsed () < 2000 ) {
698 qApp->processEvents(); 698 qApp->processEvents();
699#ifndef _WIN32_ 699#ifndef _WIN32_
700 sleep (1); 700 sleep (1);
701#endif 701#endif
702 } 702 }
703 703
704 } 704 }
705 705
706 } 706 }
707 delete temp; 707 delete temp;
708 return syncedProfiles; 708 return syncedProfiles;
709} 709}
710 710
711void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 711void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
712{ 712{
713 QString question; 713 QString question;
714 if ( ask ) { 714 if ( ask ) {
715 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 715 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
716 if ( QMessageBox::information( mParent, i18n("Sync"), 716 if ( QMessageBox::information( mParent, i18n("Sync"),
717 question, 717 question,
718 i18n("Yes"), i18n("No"), 718 i18n("Yes"), i18n("No"),
719 0, 0 ) != 0 ) 719 0, 0 ) != 0 )
720 return; 720 return;
721 } 721 }
722 722
723 QString preCommand; 723 QString preCommand;
724 QString localTempFile; 724 QString localTempFile;
725 QString postCommand; 725 QString postCommand;
726 726
727 switch(mTargetApp) 727 switch(mTargetApp)
728 { 728 {
729 case (KAPI): 729 case (KAPI):
730 preCommand = prof->getPreSyncCommandAB(); 730 preCommand = prof->getPreSyncCommandAB();
731 postCommand = prof->getPostSyncCommandAB(); 731 postCommand = prof->getPostSyncCommandAB();
732 localTempFile = prof->getLocalTempFileAB(); 732 localTempFile = prof->getLocalTempFileAB();
733 break; 733 break;
734 case (KOPI): 734 case (KOPI):
735 preCommand = prof->getPreSyncCommand(); 735 preCommand = prof->getPreSyncCommand();
736 postCommand = prof->getPostSyncCommand(); 736 postCommand = prof->getPostSyncCommand();
737 localTempFile = prof->getLocalTempFile(); 737 localTempFile = prof->getLocalTempFile();
738 break; 738 break;
739 case (PWMPI): 739 case (PWMPI):
740 preCommand = prof->getPreSyncCommandPWM(); 740 preCommand = prof->getPreSyncCommandPWM();
741 postCommand = prof->getPostSyncCommandPWM(); 741 postCommand = prof->getPostSyncCommandPWM();
742 localTempFile = prof->getLocalTempFilePWM(); 742 localTempFile = prof->getLocalTempFilePWM();
743 break; 743 break;
744 default: 744 default:
745 qDebug("KSM::syncRemote: invalid apptype selected"); 745 qDebug("KSM::syncRemote: invalid apptype selected");
746 break; 746 break;
747 } 747 }
748 748
749 749
750 int fi; 750 int fi;
751 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 751 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
752 QString pwd = getPassword(); 752 QString pwd = getPassword();
753 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 753 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
754 754
755 } 755 }
756 int maxlen = 30; 756 int maxlen = 30;
757 if ( QApplication::desktop()->width() > 320 ) 757 if ( QApplication::desktop()->width() > 320 )
758 maxlen += 25; 758 maxlen += 25;
759 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 759 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
760 int result = system ( preCommand ); 760 int result = system ( preCommand );
761 // 0 : okay 761 // 0 : okay
762 // 256: no such file or dir 762 // 256: no such file or dir
763 // 763 //
764 qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); 764 qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result );
765 if ( result != 0 ) { 765 if ( result != 0 ) {
766 unsigned int len = maxlen; 766 unsigned int len = maxlen;
767 while ( len < preCommand.length() ) { 767 while ( len < preCommand.length() ) {
768 preCommand.insert( len , "\n" ); 768 preCommand.insert( len , "\n" );
769 len += maxlen +2; 769 len += maxlen +2;
770 } 770 }
771 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) ; 771 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) ;
772 QMessageBox::information( mParent, i18n("Sync - ERROR"), 772 QMessageBox::information( mParent, i18n("Sync - ERROR"),
773 question, 773 question,
774 i18n("Okay!")) ; 774 i18n("Okay!")) ;
775 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 775 mParent->topLevelWidget()->setCaption ("KDE-Pim");
776 return; 776 return;
777 } 777 }
778 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 778 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
779 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 779 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
780 780
781 if ( syncWithFile( localTempFile, true ) ) { 781 if ( syncWithFile( localTempFile, true ) ) {
782 782
783 if ( mWriteBackFile ) { 783 if ( mWriteBackFile ) {
784 int fi; 784 int fi;
785 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 785 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
786 QString pwd = getPassword(); 786 QString pwd = getPassword();
787 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 787 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
788 788
789 } 789 }
790 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 790 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
791 result = system ( postCommand ); 791 result = system ( postCommand );
792 qDebug("KSM::Sync:Writing back file result: %d ", result); 792 qDebug("KSM::Sync:Writing back file result: %d ", result);
793 if ( result != 0 ) { 793 if ( result != 0 ) {
794 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 794 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
795 return; 795 return;
796 } else { 796 } else {
797 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 797 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
798 } 798 }
799 } 799 }
800 } 800 }
801 return; 801 return;
802} 802}
803bool KSyncManager::edit_pisync_options() 803bool KSyncManager::edit_pisync_options()
804{ 804{
805 QDialog dia( mParent, "dia", true ); 805 QDialog dia( mParent, "dia", true );
806 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 806 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
807 QVBoxLayout lay ( &dia ); 807 QVBoxLayout lay ( &dia );
808 lay.setSpacing( 5 ); 808 lay.setSpacing( 5 );
809 lay.setMargin( 3 ); 809 lay.setMargin( 3 );
810 QLabel lab1 ( i18n("Password for remote access:"), &dia); 810 QLabel lab1 ( i18n("Password for remote access:"), &dia);
811 lay.addWidget( &lab1 ); 811 lay.addWidget( &lab1 );
812 QLineEdit le1 (&dia ); 812 QLineEdit le1 (&dia );
813 lay.addWidget( &le1 ); 813 lay.addWidget( &le1 );
814 QLabel lab2 ( i18n("Remote IP address:"), &dia); 814 QLabel lab2 ( i18n("Remote IP address:"), &dia);
815 lay.addWidget( &lab2 ); 815 lay.addWidget( &lab2 );
816 QLineEdit le2 (&dia ); 816 QLineEdit le2 (&dia );
817 lay.addWidget( &le2 ); 817 lay.addWidget( &le2 );
818 QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia); 818 QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia);
819 lay.addWidget( &lab3 ); 819 lay.addWidget( &lab3 );
820 QLineEdit le3 (&dia ); 820 QLineEdit le3 (&dia );
821 lay.addWidget( &le3 ); 821 lay.addWidget( &le3 );
822 QPushButton pb ( "OK", &dia); 822 QPushButton pb ( "OK", &dia);
823 lay.addWidget( &pb ); 823 lay.addWidget( &pb );
824 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 824 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
825 le1.setText( mPassWordPiSync ); 825 le1.setText( mPassWordPiSync );
826 le2.setText( mActiveSyncIP ); 826 le2.setText( mActiveSyncIP );
827 le3.setText( mActiveSyncPort ); 827 le3.setText( mActiveSyncPort );
828 if ( dia.exec() ) { 828 if ( dia.exec() ) {
829 mPassWordPiSync = le1.text(); 829 mPassWordPiSync = le1.text();
830 mActiveSyncPort = le3.text(); 830 mActiveSyncPort = le3.text();
831 mActiveSyncIP = le2.text(); 831 mActiveSyncIP = le2.text();
832 return true; 832 return true;
833 } 833 }
834 return false; 834 return false;
835} 835}
836bool KSyncManager::edit_sync_options() 836bool KSyncManager::edit_sync_options()
837{ 837{
838 838
839 QDialog dia( mParent, "dia", true ); 839 QDialog dia( mParent, "dia", true );
840 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 840 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
841 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 841 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
842 QVBoxLayout lay ( &dia ); 842 QVBoxLayout lay ( &dia );
843 lay.setSpacing( 2 ); 843 lay.setSpacing( 2 );
844 lay.setMargin( 3 ); 844 lay.setMargin( 3 );
845 lay.addWidget(&gr); 845 lay.addWidget(&gr);
846 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 846 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
847 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 847 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
848 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 848 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
849 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 849 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
850 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 850 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
851 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 851 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
852 //QRadioButton both( i18n("Take both on conflict"), &gr ); 852 //QRadioButton both( i18n("Take both on conflict"), &gr );
853 QPushButton pb ( "OK", &dia); 853 QPushButton pb ( "OK", &dia);
854 lay.addWidget( &pb ); 854 lay.addWidget( &pb );
855 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 855 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
856 switch ( mSyncAlgoPrefs ) { 856 switch ( mSyncAlgoPrefs ) {
857 case 0: 857 case 0:
858 loc.setChecked( true); 858 loc.setChecked( true);
859 break; 859 break;
860 case 1: 860 case 1:
861 rem.setChecked( true ); 861 rem.setChecked( true );
862 break; 862 break;
863 case 2: 863 case 2:
864 newest.setChecked( true); 864 newest.setChecked( true);
865 break; 865 break;
866 case 3: 866 case 3:
867 ask.setChecked( true); 867 ask.setChecked( true);
868 break; 868 break;
869 case 4: 869 case 4:
870 f_loc.setChecked( true); 870 f_loc.setChecked( true);
871 break; 871 break;
872 case 5: 872 case 5:
873 f_rem.setChecked( true); 873 f_rem.setChecked( true);
874 break; 874 break;
875 case 6: 875 case 6:
876 // both.setChecked( true); 876 // both.setChecked( true);
877 break; 877 break;
878 default: 878 default:
879 break; 879 break;
880 } 880 }
881 if ( dia.exec() ) { 881 if ( dia.exec() ) {
882 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 882 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
883 return true; 883 return true;
884 } 884 }
885 return false; 885 return false;
886} 886}
887 887
888QString KSyncManager::getPassword( ) 888QString KSyncManager::getPassword( )
889{ 889{
890 QString retfile = ""; 890 QString retfile = "";
891 QDialog dia ( mParent, "input-dialog", true ); 891 QDialog dia ( mParent, "input-dialog", true );
892 QLineEdit lab ( &dia ); 892 QLineEdit lab ( &dia );
893 lab.setEchoMode( QLineEdit::Password ); 893 lab.setEchoMode( QLineEdit::Password );
894 QVBoxLayout lay( &dia ); 894 QVBoxLayout lay( &dia );
895 lay.setMargin(7); 895 lay.setMargin(7);
896 lay.setSpacing(7); 896 lay.setSpacing(7);
897 lay.addWidget( &lab); 897 lay.addWidget( &lab);
898 dia.setFixedSize( 230,50 ); 898 dia.setFixedSize( 230,50 );
899 dia.setCaption( i18n("Enter password") ); 899 dia.setCaption( i18n("Enter password") );
900 QPushButton pb ( "OK", &dia); 900 QPushButton pb ( "OK", &dia);
901 lay.addWidget( &pb ); 901 lay.addWidget( &pb );
902 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 902 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
903 dia.show(); 903 dia.show();
904 int res = dia.exec(); 904 int res = dia.exec();
905 if ( res ) 905 if ( res )
906 retfile = lab.text(); 906 retfile = lab.text();
907 dia.hide(); 907 dia.hide();
908 qApp->processEvents(); 908 qApp->processEvents();
909 return retfile; 909 return retfile;
910 910
911} 911}
912 912
913 913
914void KSyncManager::confSync() 914void KSyncManager::confSync()
915{ 915{
916 static KSyncPrefsDialog* sp = 0; 916 static KSyncPrefsDialog* sp = 0;
917 if ( ! sp ) { 917 if ( ! sp ) {
918 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 918 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
919 } 919 }
920 sp->usrReadConfig(); 920 sp->usrReadConfig();
921#ifndef DESKTOP_VERSION 921#ifndef DESKTOP_VERSION
922 sp->showMaximized(); 922 sp->showMaximized();
923#else 923#else
924 sp->show(); 924 sp->show();
925#endif 925#endif
926 sp->exec(); 926 sp->exec();
927 QStringList oldSyncProfileNames = mSyncProfileNames; 927 QStringList oldSyncProfileNames = mSyncProfileNames;
928 mSyncProfileNames = sp->getSyncProfileNames(); 928 mSyncProfileNames = sp->getSyncProfileNames();
929 mLocalMachineName = sp->getLocalMachineName (); 929 mLocalMachineName = sp->getLocalMachineName ();
930 uint ii; 930 uint ii;
931 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { 931 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) {
932 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) 932 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) )
933 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); 933 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] );
934 } 934 }
935 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 935 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
936} 936}
937void KSyncManager::syncKDE() 937void KSyncManager::syncKDE()
938{ 938{
939 mSyncWithDesktop = true; 939 mSyncWithDesktop = true;
940 emit save(); 940 emit save();
941 switch(mTargetApp) 941 switch(mTargetApp)
942 { 942 {
943 case (KAPI): 943 case (KAPI):
944 { 944 {
945#ifdef DESKTOP_VERSION 945#ifdef DESKTOP_VERSION
946 QString command = "kdeabdump33"; 946 QString command = "kdeabdump33";
947 QString commandfile = "kdeabdump33"; 947 QString commandfile = "kdeabdump33";
948 QString commandpath = qApp->applicationDirPath () + "/"; 948 QString commandpath = qApp->applicationDirPath () + "/";
949#else 949#else
950 QString command = "kdeabdump33"; 950 QString command = "kdeabdump33";
951 QString commandfile = "kdeabdump33"; 951 QString commandfile = "kdeabdump33";
952 QString commandpath = QDir::homeDirPath ()+"/"; 952 QString commandpath = QDir::homeDirPath ()+"/";
953#endif 953#endif
954 if ( ! QFile::exists ( commandpath+commandfile ) ) 954 if ( ! QFile::exists ( commandpath+commandfile ) )
955 command = commandfile; 955 command = commandfile;
956 else 956 else
957 command = commandpath+commandfile; 957 command = commandpath+commandfile;
958 958
959 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; 959 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf";
960 int result = system ( command.latin1()); 960 int result = system ( command.latin1());
961 qDebug("AB dump 33 command call result: %d ", result); 961 qDebug("AB dump 33 command call result: %d ", result);
962 if ( result != 0 ) { 962 if ( result != 0 ) {
963 qDebug("Calling AB dump version 33 failed. Trying 34... "); 963 qDebug("Calling AB dump version 33 failed. Trying 34... ");
964 commandfile = "kdeabdump34"; 964 commandfile = "kdeabdump34";
965 if ( ! QFile::exists ( commandpath+commandfile ) ) 965 if ( ! QFile::exists ( commandpath+commandfile ) )
966 command = commandfile; 966 command = commandfile;
967 else 967 else
968 command = commandpath+commandfile; 968 command = commandpath+commandfile;
969 result = system ( command.latin1()); 969 result = system ( command.latin1());
970 qDebug("AB dump 34 command call result: %d ", result); 970 qDebug("AB dump 34 command call result: %d ", result);
971 if ( result != 0 ) { 971 if ( result != 0 ) {
972 KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); 972 KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath ));
973 return; 973 return;
974 } 974 }
975 } 975 }
976 if ( syncWithFile( fileName,true ) ) { 976 if ( syncWithFile( fileName,true ) ) {
977 if ( mWriteBackFile ) { 977 if ( mWriteBackFile ) {
978 command += " --read"; 978 command += " --read";
979 system ( command.latin1()); 979 system ( command.latin1());
980 } 980 }
981 } 981 }
982 982
983 } 983 }
984 break; 984 break;
985 case (KOPI): 985 case (KOPI):
986 { 986 {
987#ifdef DESKTOP_VERSION 987#ifdef DESKTOP_VERSION
988 QString command = "kdecaldump33"; 988 QString command = "kdecaldump33";
989 QString commandfile = "kdecaldump33"; 989 QString commandfile = "kdecaldump33";
990 QString commandpath = qApp->applicationDirPath () + "/"; 990 QString commandpath = qApp->applicationDirPath () + "/";
991#else 991#else
992 QString command = "kdecaldump33"; 992 QString command = "kdecaldump33";
993 QString commandfile = "kdecaldump33"; 993 QString commandfile = "kdecaldump33";
994 QString commandpath = QDir::homeDirPath ()+"/"; 994 QString commandpath = QDir::homeDirPath ()+"/";
995#endif 995#endif
996 if ( ! QFile::exists ( commandpath+commandfile ) ) 996 if ( ! QFile::exists ( commandpath+commandfile ) )
997 command = commandfile; 997 command = commandfile;
998 else 998 else
999 command = commandpath+commandfile; 999 command = commandpath+commandfile;
1000 1000
1001 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; 1001 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
1002 int result = system ( command.latin1()); 1002 int result = system ( command.latin1());
1003 qDebug("Cal dump 33 command call result result: %d ", result); 1003 qDebug("Cal dump 33 command call result result: %d ", result);
1004 if ( result != 0 ) { 1004 if ( result != 0 ) {
1005 qDebug("Calling CAL dump version 33 failed. Trying 34... "); 1005 qDebug("Calling CAL dump version 33 failed. Trying 34... ");
1006 commandfile = "kdecaldump34"; 1006 commandfile = "kdecaldump34";
1007 if ( ! QFile::exists ( commandpath+commandfile ) ) 1007 if ( ! QFile::exists ( commandpath+commandfile ) )
1008 command = commandfile; 1008 command = commandfile;
1009 else 1009 else
1010 command = commandpath+commandfile; 1010 command = commandpath+commandfile;
1011 result = system ( command.latin1()); 1011 result = system ( command.latin1());
1012 qDebug("Cal dump 34 command call result result: %d ", result); 1012 qDebug("Cal dump 34 command call result result: %d ", result);
1013 if ( result != 0 ) { 1013 if ( result != 0 ) {
1014 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); 1014 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath ));
1015 return; 1015 return;
1016 } 1016 }
1017 } 1017 }
1018 if ( syncWithFile( fileName,true ) ) { 1018 if ( syncWithFile( fileName,true ) ) {
1019 if ( mWriteBackFile ) { 1019 if ( mWriteBackFile ) {
1020 command += " --read"; 1020 command += " --read";
1021 system ( command.latin1()); 1021 system ( command.latin1());
1022 } 1022 }
1023 } 1023 }
1024 1024
1025 } 1025 }
1026 break; 1026 break;
1027 case (PWMPI): 1027 case (PWMPI):
1028 1028
1029 break; 1029 break;
1030 default: 1030 default:
1031 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 1031 qDebug("KSM::slotSyncMenu: invalid apptype selected");
1032 break; 1032 break;
1033 1033
1034 } 1034 }
1035} 1035}
1036 1036
1037void KSyncManager::syncSharp() 1037void KSyncManager::syncSharp()
1038{ 1038{
1039 1039
1040 if ( ! syncExternalApplication("sharp") ) 1040 if ( ! syncExternalApplication("sharp") )
1041 qDebug("KSM::ERROR sync sharp "); 1041 qDebug("KSM::ERROR sync sharp ");
1042} 1042}
1043 1043
1044bool KSyncManager::syncExternalApplication(QString resource) 1044bool KSyncManager::syncExternalApplication(QString resource)
1045{ 1045{
1046 1046
1047 emit save(); 1047 emit save();
1048 1048
1049 if ( mAskForPreferences ) 1049 if ( mAskForPreferences )
1050 if ( !edit_sync_options()) { 1050 if ( !edit_sync_options()) {
1051 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1051 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1052 return false; 1052 return false;
1053 } 1053 }
1054 1054
1055 qDebug("KSM::Sync extern %s", resource.latin1()); 1055 qDebug("KSM::Sync extern %s", resource.latin1());
1056 1056
1057 bool syncOK = mImplementation->syncExternal(this, resource); 1057 bool syncOK = mImplementation->syncExternal(this, resource);
1058 1058
1059 return syncOK; 1059 return syncOK;
1060 1060
1061} 1061}
1062 1062
1063void KSyncManager::syncPhone() 1063void KSyncManager::syncPhone()
1064{ 1064{
1065 1065
1066 syncExternalApplication("phone"); 1066 syncExternalApplication("phone");
1067 1067
1068} 1068}
1069 1069
1070void KSyncManager::showProgressBar(int percentage, QString caption, int total) 1070void KSyncManager::showProgressBar(int percentage, QString caption, int total)
1071{ 1071{
1072 if (!bar->isVisible()) 1072 if (!bar->isVisible())
1073 { 1073 {
1074 int w = 300; 1074 int w = 300;
1075 if ( QApplication::desktop()->width() < 320 ) 1075 if ( QApplication::desktop()->width() < 320 )
1076 w = 220; 1076 w = 220;
1077 int h = bar->sizeHint().height() ; 1077 int h = bar->sizeHint().height() ;
1078 int dw = QApplication::desktop()->width(); 1078 int dw = QApplication::desktop()->width();
1079 int dh = QApplication::desktop()->height(); 1079 int dh = QApplication::desktop()->height();
1080 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1080 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1081 bar->setCaption (caption); 1081 bar->setCaption (caption);
1082 bar->setTotalSteps ( total ) ; 1082 bar->setTotalSteps ( total ) ;
1083 bar->show(); 1083 bar->show();
1084 } 1084 }
1085 bar->raise(); 1085 bar->raise();
1086 bar->setProgress( percentage ); 1086 bar->setProgress( percentage );
1087 qApp->processEvents(); 1087 qApp->processEvents();
1088} 1088}
1089 1089
1090void KSyncManager::hideProgressBar() 1090void KSyncManager::hideProgressBar()
1091{ 1091{
1092 bar->hide(); 1092 bar->hide();
1093 qApp->processEvents(); 1093 qApp->processEvents();
1094} 1094}
1095 1095
1096bool KSyncManager::isProgressBarCanceled() 1096bool KSyncManager::isProgressBarCanceled()
1097{ 1097{
1098 return !bar->isVisible(); 1098 return !bar->isVisible();
1099} 1099}
1100 1100
1101QString KSyncManager::syncFileName() 1101QString KSyncManager::syncFileName()
1102{ 1102{
1103 1103
1104 QString fn = "tempfile"; 1104 QString fn = "tempfile";
1105 switch(mTargetApp) 1105 switch(mTargetApp)
1106 { 1106 {
1107 case (KAPI): 1107 case (KAPI):
1108 fn = "tempsyncab.vcf"; 1108 fn = "tempsyncab.vcf";
1109 break; 1109 break;
1110 case (KOPI): 1110 case (KOPI):
1111 fn = "tempsynccal.ics"; 1111 fn = "tempsynccal.ics";
1112 break; 1112 break;
1113 case (PWMPI): 1113 case (PWMPI):
1114 fn = "tempsyncpw.pwm"; 1114 fn = "tempsyncpw.pwm";
1115 break; 1115 break;
1116 default: 1116 default:
1117 break; 1117 break;
1118 } 1118 }
1119#ifdef DESKTOP_VERSION 1119#ifdef DESKTOP_VERSION
1120 return locateLocal( "tmp", fn ); 1120 return locateLocal( "tmp", fn );
1121#else 1121#else
1122 return (QString( "/tmp/" )+ fn ); 1122 return (QString( "/tmp/" )+ fn );
1123#endif 1123#endif
1124} 1124}
1125 1125
1126void KSyncManager::syncPi() 1126void KSyncManager::syncPi()
1127{ 1127{
1128 mIsKapiFile = true; 1128 mIsKapiFile = true;
1129 mPisyncFinished = false; 1129 mPisyncFinished = false;
1130 qApp->processEvents(); 1130 qApp->processEvents();
1131 if ( mAskForPreferences ) 1131 if ( mAskForPreferences )
1132 if ( !edit_pisync_options()) { 1132 if ( !edit_pisync_options()) {
1133 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1133 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1134 mPisyncFinished = true; 1134 mPisyncFinished = true;
1135 return; 1135 return;
1136 } 1136 }
1137 bool ok; 1137 bool ok;
1138 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 1138 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
1139 if ( ! ok ) { 1139 if ( ! ok ) {
1140 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1140 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
1141 mPisyncFinished = true; 1141 mPisyncFinished = true;
1142 return; 1142 return;
1143 } 1143 }
1144 mCurrentResourceLocal = ""; 1144 mCurrentResourceLocal = "";
1145 mCurrentResourceRemote = ""; 1145 mCurrentResourceRemote = "";
1146 if ( mSpecificResources.count() ) { 1146 if ( mSpecificResources.count() ) {
1147 uint lastSyncRes = mSpecificResources.count()/2; 1147 uint lastSyncRes = mSpecificResources.count()/2;
1148 int ccc = mSpecificResources.count()-1; 1148 int ccc = mSpecificResources.count()-1;
1149 while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) { 1149 while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) {
1150 --ccc; 1150 --ccc;
1151 --lastSyncRes; 1151 --lastSyncRes;
1152 //qDebug ( "KSM: sync pi %d",ccc ); 1152 //qDebug ( "KSM: sync pi %d",ccc );
1153 } 1153 }
1154 uint startLocal = 0; 1154 uint startLocal = 0;
1155 uint startRemote = mSpecificResources.count()/2; 1155 uint startRemote = mSpecificResources.count()/2;
1156 emit multiResourceSyncStart( true ); 1156 emit multiResourceSyncStart( true );
1157 while ( startLocal < mSpecificResources.count()/2 ) { 1157 while ( startLocal < mSpecificResources.count()/2 ) {
1158 if ( startLocal+1 >= lastSyncRes ) 1158 if ( startLocal+1 >= lastSyncRes )
1159 emit multiResourceSyncStart( false ); 1159 emit multiResourceSyncStart( false );
1160 mPisyncFinished = false; 1160 mPisyncFinished = false;
1161 mCurrentResourceLocal = mSpecificResources[ startLocal ]; 1161 mCurrentResourceLocal = mSpecificResources[ startLocal ];
1162 mCurrentResourceRemote = mSpecificResources[ startRemote ]; 1162 mCurrentResourceRemote = mSpecificResources[ startRemote ];
1163 //qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); 1163 //qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() );
1164 if ( !mCurrentResourceRemote.isEmpty() ) { 1164 if ( !mCurrentResourceRemote.isEmpty() ) {
1165 qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); 1165 qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() );
1166 1166
1167 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); 1167 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1168 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1168 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1169 commandSocket->readFile( syncFileName() ); 1169 commandSocket->readFile( syncFileName() );
1170 mParent->topLevelWidget()->setCaption( i18n("Syncing %1 <-> %2").arg( mCurrentResourceLocal ).arg( mCurrentResourceRemote ) ); 1170 mParent->topLevelWidget()->setCaption( i18n("Syncing %1 <-> %2").arg( mCurrentResourceLocal ).arg( mCurrentResourceRemote ) );
1171 while ( !mPisyncFinished ) { 1171 while ( !mPisyncFinished ) {
1172 //qDebug("waiting "); 1172 //qDebug("waiting ");
1173 qApp->processEvents(); 1173 qApp->processEvents();
1174 } 1174 }
1175 if ( startLocal+1 < mSpecificResources.count()/2 ) { 1175 if ( startLocal+1 < mSpecificResources.count()/2 ) {
1176 mParent->topLevelWidget()->setCaption( i18n("Waiting a second before syncing next resource...") ); 1176 mParent->topLevelWidget()->setCaption( i18n("Waiting a second before syncing next resource...") );
1177 QTime timer; 1177 QTime timer;
1178 timer.start(); 1178 timer.start();
1179 while ( timer.elapsed () < 1000 ) { 1179 while ( timer.elapsed () < 1000 ) {
1180 qApp->processEvents(); 1180 qApp->processEvents();
1181 } 1181 }
1182 } 1182 }
1183 } 1183 }
1184 ++startRemote; 1184 ++startRemote;
1185 ++startLocal; 1185 ++startLocal;
1186 mAskForPreferences = false; 1186 mAskForPreferences = false;
1187 } 1187 }
1188 mPisyncFinished = true; 1188 mPisyncFinished = true;
1189 } else { 1189 } else {
1190 KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); 1190 KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1191 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1191 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1192 commandSocket->readFile( syncFileName() ); 1192 commandSocket->readFile( syncFileName() );
1193 } 1193 }
1194} 1194}
1195 1195
1196void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 1196void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1197{ 1197{
1198 //enum { success, errorW, errorR, quiet }; 1198 //enum { success, errorW, errorR, quiet };
1199 1199
1200 1200
1201 1201
1202 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || 1202 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW ||
1203 state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { 1203 state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) {
1204 if ( state == KCommandSocket::errorPW ) 1204 if ( state == KCommandSocket::errorPW )
1205 mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); 1205 mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") );
1206 else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) 1206 else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO )
1207 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 1207 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
1208 else if ( state == KCommandSocket::errorCA ) 1208 else if ( state == KCommandSocket::errorCA )
1209 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); 1209 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") );
1210 else if ( state == KCommandSocket::errorFI ) 1210 else if ( state == KCommandSocket::errorFI )
1211 mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); 1211 mParent->topLevelWidget()->setCaption( i18n("File error on remote.") );
1212 else if ( state == KCommandSocket::errorED ) 1212 else if ( state == KCommandSocket::errorED )
1213 mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); 1213 mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") );
1214 else if ( state == KCommandSocket::errorUN ) 1214 else if ( state == KCommandSocket::errorUN )
1215 mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); 1215 mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") );
1216 delete s; 1216 delete s;
1217 if ( state == KCommandSocket::errorR ) { 1217 if ( state == KCommandSocket::errorR ) {
1218 KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); 1218 KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget());
1219 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1219 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1220 commandSocket->sendStop(); 1220 commandSocket->sendStop();
1221 } 1221 }
1222 mPisyncFinished = true; 1222 mPisyncFinished = true;
1223 return; 1223 return;
1224 1224
1225 } else if ( state == KCommandSocket::errorW ) { 1225 } else if ( state == KCommandSocket::errorW ) {
1226 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 1226 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
1227 mPisyncFinished = true; 1227 mPisyncFinished = true;
1228 1228
1229 } else if ( state == KCommandSocket::successR ) { 1229 } else if ( state == KCommandSocket::successR ) {
1230 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1230 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
1231 1231
1232 } else if ( state == KCommandSocket::successW ) { 1232 } else if ( state == KCommandSocket::successW ) {
1233 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); 1233 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
1234 mPisyncFinished = true; 1234 mPisyncFinished = true;
1235 } else if ( state == KCommandSocket::quiet ){ 1235 } else if ( state == KCommandSocket::quiet ){
1236 qDebug("KSS: quiet "); 1236 qDebug("KSS: quiet ");
1237 mPisyncFinished = true; 1237 mPisyncFinished = true;
1238 } else { 1238 } else {
1239 qDebug("KSS: Error: unknown state: %d ", state); 1239 qDebug("KSS: Error: unknown state: %d ", state);
1240 mPisyncFinished = true; 1240 mPisyncFinished = true;
1241 } 1241 }
1242 1242
1243 delete s; 1243 delete s;
1244} 1244}
1245 1245
1246void KSyncManager::readFileFromSocket() 1246void KSyncManager::readFileFromSocket()
1247{ 1247{
1248 QString fileName = syncFileName(); 1248 QString fileName = syncFileName();
1249 bool syncOK = true; 1249 bool syncOK = true;
1250 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 1250 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
1251 if ( ! syncWithFile( fileName , true ) ) { 1251 if ( ! syncWithFile( fileName , true ) ) {
1252 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 1252 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
1253 syncOK = false; 1253 syncOK = false;
1254 } 1254 }
1255 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote,mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); 1255 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote,mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() );
1256 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1256 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1257 if ( mWriteBackFile && syncOK ) { 1257 if ( mWriteBackFile && syncOK ) {
1258 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); 1258 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") );
1259 commandSocket->writeFile( fileName ); 1259 commandSocket->writeFile( fileName );
1260 } 1260 }
1261 else { 1261 else {
1262 commandSocket->sendStop(); 1262 commandSocket->sendStop();
1263 if ( syncOK ) 1263 if ( syncOK )
1264 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1264 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1265 mPisyncFinished = true; 1265 mPisyncFinished = true;
1266 } 1266 }
1267} 1267}
1268 1268
1269KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 1269KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
1270{ 1270{
1271 mPendingConnect = 0; 1271 mPendingConnect = 0;
1272 mPassWord = pw; 1272 mPassWord = pw;
1273 mSocket = 0; 1273 mSocket = 0;
1274 mSyncActionDialog = 0; 1274 mSyncActionDialog = 0;
1275 blockRC = false; 1275 blockRC = false;
1276 mErrorMessage = 0; 1276 mErrorMessage = 0;
1277} 1277}
1278void KServerSocket::waitForSocketFinish() 1278void KServerSocket::waitForSocketFinish()
1279{ 1279{
1280 if ( mSocket ) { 1280 if ( mSocket ) {
1281 //qDebug("KSS:: waiting for finish operation"); 1281 //qDebug("KSS:: waiting for finish operation");
1282 QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); 1282 QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish()));
1283 return; 1283 return;
1284 } 1284 }
1285 mSocket = new QSocket( this ); 1285 mSocket = new QSocket( this );
1286 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1286 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1287 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1287 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1288 mSocket->setSocket( mPendingConnect ); 1288 mSocket->setSocket( mPendingConnect );
1289 mPendingConnect = 0; 1289 mPendingConnect = 0;
1290} 1290}
1291void KServerSocket::newConnection ( int socket ) 1291void KServerSocket::newConnection ( int socket )
1292{ 1292{
1293 // qDebug("KServerSocket:New connection %d ", socket); 1293 // qDebug("KServerSocket:New connection %d ", socket);
1294 if ( mPendingConnect ) { 1294 if ( mPendingConnect ) {
1295 qDebug("KSS::Error : new Connection"); 1295 qDebug("KSS::Error : new Connection");
1296 return; 1296 return;
1297 } 1297 }
1298 if ( mSocket ) { 1298 if ( mSocket ) {
1299 mPendingConnect = socket; 1299 mPendingConnect = socket;
1300 QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); 1300 QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish()));
1301 return; 1301 return;
1302 qDebug("KSS::newConnection Socket deleted! "); 1302 qDebug("KSS::newConnection Socket deleted! ");
1303 delete mSocket; 1303 delete mSocket;
1304 mSocket = 0; 1304 mSocket = 0;
1305 } 1305 }
1306 mPendingConnect = 0; 1306 mPendingConnect = 0;
1307 mSocket = new QSocket( this ); 1307 mSocket = new QSocket( this );
1308 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1308 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1309 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1309 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1310 mSocket->setSocket( socket ); 1310 mSocket->setSocket( socket );
1311} 1311}
1312 1312
1313void KServerSocket::discardClient() 1313void KServerSocket::discardClient()
1314{ 1314{
1315 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1315 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1316} 1316}
1317void KServerSocket::deleteSocket() 1317void KServerSocket::deleteSocket()
1318{ 1318{
1319 //qDebug("KSS::deleteSocket"); 1319 //qDebug("KSS::deleteSocket");
1320 if ( mSocket ) { 1320 if ( mSocket ) {
1321 delete mSocket; 1321 delete mSocket;
1322 mSocket = 0; 1322 mSocket = 0;
1323 } 1323 }
1324 if ( mErrorMessage ) 1324 if ( mErrorMessage )
1325 QTimer::singleShot( 10, this , SLOT ( displayErrorMessage())); 1325 QTimer::singleShot( 10, this , SLOT ( displayErrorMessage()));
1326} 1326}
1327void KServerSocket::readClient() 1327void KServerSocket::readClient()
1328{ 1328{
1329 if ( blockRC ) 1329 if ( blockRC )
1330 return; 1330 return;
1331 if ( mSocket == 0 ) { 1331 if ( mSocket == 0 ) {
1332 qDebug("ERROR::KSS::readClient(): mSocket == 0 "); 1332 qDebug("ERROR::KSS::readClient(): mSocket == 0 ");
1333 return; 1333 return;
1334 } 1334 }
1335 if ( mErrorMessage ) { 1335 if ( mErrorMessage ) {
1336 mErrorMessage = 999; 1336 mErrorMessage = 999;
1337 error_connect("ERROR_ED\r\n\r\n"); 1337 error_connect("ERROR_ED\r\n\r\n");
1338 return; 1338 return;
1339 } 1339 }
1340 mResource = ""; 1340 mResource = "";
1341 mErrorMessage = 0; 1341 mErrorMessage = 0;
1342 //qDebug("KServerSocket::readClient()"); 1342 //qDebug("KServerSocket::readClient()");
1343 if ( mSocket->canReadLine() ) { 1343 if ( mSocket->canReadLine() ) {
1344 QString line = mSocket->readLine(); 1344 QString line = mSocket->readLine();
1345 //qDebug("KServerSocket readline: %s ", line.latin1()); 1345 //qDebug("KServerSocket readline: %s ", line.latin1());
1346 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 1346 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
1347 if ( tokens[0] == "GET" ) { 1347 if ( tokens[0] == "GET" ) {
1348 if ( tokens[1] == mPassWord ) { 1348 if ( tokens[1] == mPassWord ) {
1349 //emit sendFile( mSocket ); 1349 //emit sendFile( mSocket );
1350 bool ok = false; 1350 bool ok = false;
1351 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); 1351 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok);
1352 if ( ok ) { 1352 if ( ok ) {
1353 KSyncManager::mRequestedSyncEvent = dt; 1353 KSyncManager::mRequestedSyncEvent = dt;
1354 } 1354 }
1355 else 1355 else
1356 KSyncManager::mRequestedSyncEvent = QDateTime(); 1356 KSyncManager::mRequestedSyncEvent = QDateTime();
1357 mResource =tokens[3]; 1357 mResource =tokens[3];
1358 send_file(); 1358 send_file();
1359 } 1359 }
1360 else { 1360 else {
1361 mErrorMessage = 1; 1361 mErrorMessage = 1;
1362 error_connect("ERROR_PW\r\n\r\n"); 1362 error_connect("ERROR_PW\r\n\r\n");
1363 } 1363 }
1364 } 1364 }
1365 if ( tokens[0] == "PUT" ) { 1365 if ( tokens[0] == "PUT" ) {
1366 if ( tokens[1] == mPassWord ) { 1366 if ( tokens[1] == mPassWord ) {
1367 //emit getFile( mSocket ); 1367 //emit getFile( mSocket );
1368 blockRC = true; 1368 blockRC = true;
1369 mResource =tokens[2]; 1369 mResource =tokens[2];
1370 get_file(); 1370 get_file();
1371 } 1371 }
1372 else { 1372 else {
1373 mErrorMessage = 2; 1373 mErrorMessage = 2;
1374 error_connect("ERROR_PW\r\n\r\n"); 1374 error_connect("ERROR_PW\r\n\r\n");
1375 end_connect(); 1375 end_connect();
1376 } 1376 }
1377 } 1377 }
1378 if ( tokens[0] == "STOP" ) { 1378 if ( tokens[0] == "STOP" ) {
1379 //emit endConnect(); 1379 //emit endConnect();
1380 end_connect(); 1380 end_connect();
1381 } 1381 }
1382 } 1382 }
1383} 1383}
1384void KServerSocket::displayErrorMessage() 1384void KServerSocket::displayErrorMessage()
1385{ 1385{
1386 if ( mErrorMessage == 1 ) { 1386 if ( mErrorMessage == 1 ) {
1387 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error")); 1387 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error"));
1388 mErrorMessage = 0; 1388 mErrorMessage = 0;
1389 } 1389 }
1390 else if ( mErrorMessage == 2 ) { 1390 else if ( mErrorMessage == 2 ) {
1391 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); 1391 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error"));
1392 mErrorMessage = 0; 1392 mErrorMessage = 0;
1393 } 1393 }
1394} 1394}
1395void KServerSocket::error_connect( QString errmess ) 1395void KServerSocket::error_connect( QString errmess )
1396{ 1396{
1397 QTextStream os( mSocket ); 1397 QTextStream os( mSocket );
1398 os.setEncoding( QTextStream::Latin1 ); 1398 os.setEncoding( QTextStream::Latin1 );
1399 os << errmess ; 1399 os << errmess ;
1400 mSocket->close(); 1400 mSocket->close();
1401 if ( mSocket->state() == QSocket::Idle ) { 1401 if ( mSocket->state() == QSocket::Idle ) {
1402 QTimer::singleShot( 0, this , SLOT ( discardClient())); 1402 QTimer::singleShot( 0, this , SLOT ( discardClient()));
1403 } 1403 }
1404} 1404}
1405void KServerSocket::end_connect() 1405void KServerSocket::end_connect()
1406{ 1406{
1407 delete mSyncActionDialog; 1407 delete mSyncActionDialog;
1408 mSyncActionDialog = 0; 1408 mSyncActionDialog = 0;
1409} 1409}
1410void KServerSocket::send_file() 1410void KServerSocket::send_file()
1411{ 1411{
1412 //qDebug("MainWindow::sendFile(QSocket* s) "); 1412 //qDebug("MainWindow::sendFile(QSocket* s) ");
1413 if ( mSyncActionDialog ) 1413 if ( mSyncActionDialog )
1414 delete mSyncActionDialog; 1414 delete mSyncActionDialog;
1415 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 1415 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
1416 mSyncActionDialog->setCaption(i18n("Received sync request")); 1416 mSyncActionDialog->setCaption(i18n("Received sync request"));
1417 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 1417 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
1418 label->setAlignment ( Qt::AlignHCenter ); 1418 label->setAlignment ( Qt::AlignHCenter );
1419 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1419 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
1420 lay->addWidget( label); 1420 lay->addWidget( label);
1421 lay->setMargin(7); 1421 lay->setMargin(7);
1422 lay->setSpacing(7); 1422 lay->setSpacing(7);
1423 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1423 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1424 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); 1424 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent );
1425 //secs = 333; 1425 //secs = 333;
1426 if ( secs < 0 ) 1426 if ( secs < 0 )
1427 secs = secs * (-1); 1427 secs = secs * (-1);
1428 if ( secs > 30 ) 1428 if ( secs > 30 )
1429 //if ( true ) 1429 //if ( true )
1430 { 1430 {
1431 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); 1431 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs );
1432 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1432 QLabel* label = new QLabel( warning, mSyncActionDialog );
1433 label->setAlignment ( Qt::AlignHCenter ); 1433 label->setAlignment ( Qt::AlignHCenter );
1434 lay->addWidget( label); 1434 lay->addWidget( label);
1435 if ( secs > 180 ) 1435 if ( secs > 180 )
1436 { 1436 {
1437 if ( secs > 300 ) { 1437 if ( secs > 300 ) {
1438 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { 1438 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) {
1439 qDebug("KSS::Sync cancelled ,cs"); 1439 qDebug("KSS::Sync cancelled ,cs");
1440 mErrorMessage = 0; 1440 mErrorMessage = 0;
1441 end_connect(); 1441 end_connect();
1442 error_connect("ERROR_CA\r\n\r\n"); 1442 error_connect("ERROR_CA\r\n\r\n");
1443 return ; 1443 return ;
1444 } 1444 }
1445 } 1445 }
1446 QFont f = label->font(); 1446 QFont f = label->font();
1447 f.setPointSize ( f.pointSize() *2 ); 1447 f.setPointSize ( f.pointSize() *2 );
1448 f. setBold (true ); 1448 f. setBold (true );
1449 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1449 QLabel* label = new QLabel( warning, mSyncActionDialog );
1450 label->setFont( f ); 1450 label->setFont( f );
1451 warning = i18n("ADJUST\nYOUR\nCLOCKS!"); 1451 warning = i18n("ADJUST\nYOUR\nCLOCKS!");
1452 label->setText( warning ); 1452 label->setText( warning );
1453 label->setAlignment ( Qt::AlignHCenter ); 1453 label->setAlignment ( Qt::AlignHCenter );
1454 lay->addWidget( label); 1454 lay->addWidget( label);
1455 mSyncActionDialog->setFixedSize( 230, 300); 1455 mSyncActionDialog->setFixedSize( 230, 300);
1456 } else { 1456 } else {
1457 mSyncActionDialog->setFixedSize( 230, 200); 1457 mSyncActionDialog->setFixedSize( 230, 200);
1458 } 1458 }
1459 } else { 1459 } else {
1460 mSyncActionDialog->setFixedSize( 230, 120); 1460 mSyncActionDialog->setFixedSize( 230, 120);
1461 } 1461 }
1462 } else 1462 } else
1463 mSyncActionDialog->setFixedSize( 230, 120); 1463 mSyncActionDialog->setFixedSize( 230, 120);
1464 mSyncActionDialog->show(); 1464 mSyncActionDialog->show();
1465 mSyncActionDialog->raise(); 1465 mSyncActionDialog->raise();
1466 emit request_file(mResource); 1466 emit request_file(mResource);
1467 //emit request_file(); 1467 //emit request_file();
1468 qApp->processEvents(); 1468 qApp->processEvents();
1469 QString fileName = mFileName; 1469 QString fileName = mFileName;