summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp70
-rw-r--r--kabc/addressbook.h5
-rw-r--r--kaddressbook/kabcore.cpp20
-rw-r--r--kaddressbook/kabcore.h2
-rw-r--r--kaddressbook/xxport/vcard_xxport.cpp1
-rw-r--r--libkdepim/ksyncmanager.cpp5
-rw-r--r--libkdepim/ksyncmanager.h5
7 files changed, 90 insertions, 18 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 5fb49eb..295cf03 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -1,868 +1,926 @@
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>
42#include <qfile.h>
41 43
42#include <kglobal.h> 44#include <kglobal.h>
43#include <klocale.h> 45#include <klocale.h>>
46#include <kmessagebox.h>
44#include <kdebug.h> 47#include <kdebug.h>
45#include <libkcal/syncdefines.h> 48#include <libkcal/syncdefines.h>
46#include "addressbook.h" 49#include "addressbook.h"
47#include "resource.h" 50#include "resource.h"
51#include "vcardconverter.h"
52#include "vcardparser/vcardtool.h"
48 53
49//US #include "addressbook.moc" 54//US #include "addressbook.moc"
50 55
51using namespace KABC; 56using namespace KABC;
52 57
53struct AddressBook::AddressBookData 58struct AddressBook::AddressBookData
54{ 59{
55 Addressee::List mAddressees; 60 Addressee::List mAddressees;
56 Addressee::List mRemovedAddressees; 61 Addressee::List mRemovedAddressees;
57 Field::List mAllFields; 62 Field::List mAllFields;
58 KConfig *mConfig; 63 KConfig *mConfig;
59 KRES::Manager<Resource> *mManager; 64 KRES::Manager<Resource> *mManager;
60//US ErrorHandler *mErrorHandler; 65//US ErrorHandler *mErrorHandler;
61}; 66};
62 67
63struct AddressBook::Iterator::IteratorData 68struct AddressBook::Iterator::IteratorData
64{ 69{
65 Addressee::List::Iterator mIt; 70 Addressee::List::Iterator mIt;
66}; 71};
67 72
68struct AddressBook::ConstIterator::ConstIteratorData 73struct AddressBook::ConstIterator::ConstIteratorData
69{ 74{
70 Addressee::List::ConstIterator mIt; 75 Addressee::List::ConstIterator mIt;
71}; 76};
72 77
73AddressBook::Iterator::Iterator() 78AddressBook::Iterator::Iterator()
74{ 79{
75 d = new IteratorData; 80 d = new IteratorData;
76} 81}
77 82
78AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) 83AddressBook::Iterator::Iterator( const AddressBook::Iterator &i )
79{ 84{
80 d = new IteratorData; 85 d = new IteratorData;
81 d->mIt = i.d->mIt; 86 d->mIt = i.d->mIt;
82} 87}
83 88
84AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) 89AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i )
85{ 90{
86 if( this == &i ) return *this; // guard against self assignment 91 if( this == &i ) return *this; // guard against self assignment
87 delete d; // delete the old data the Iterator was completely constructed before 92 delete d; // delete the old data the Iterator was completely constructed before
88 d = new IteratorData; 93 d = new IteratorData;
89 d->mIt = i.d->mIt; 94 d->mIt = i.d->mIt;
90 return *this; 95 return *this;
91} 96}
92 97
93AddressBook::Iterator::~Iterator() 98AddressBook::Iterator::~Iterator()
94{ 99{
95 delete d; 100 delete d;
96} 101}
97 102
98const Addressee &AddressBook::Iterator::operator*() const 103const Addressee &AddressBook::Iterator::operator*() const
99{ 104{
100 return *(d->mIt); 105 return *(d->mIt);
101} 106}
102 107
103Addressee &AddressBook::Iterator::operator*() 108Addressee &AddressBook::Iterator::operator*()
104{ 109{
105 return *(d->mIt); 110 return *(d->mIt);
106} 111}
107 112
108Addressee *AddressBook::Iterator::operator->() 113Addressee *AddressBook::Iterator::operator->()
109{ 114{
110 return &(*(d->mIt)); 115 return &(*(d->mIt));
111} 116}
112 117
113AddressBook::Iterator &AddressBook::Iterator::operator++() 118AddressBook::Iterator &AddressBook::Iterator::operator++()
114{ 119{
115 (d->mIt)++; 120 (d->mIt)++;
116 return *this; 121 return *this;
117} 122}
118 123
119AddressBook::Iterator &AddressBook::Iterator::operator++(int) 124AddressBook::Iterator &AddressBook::Iterator::operator++(int)
120{ 125{
121 (d->mIt)++; 126 (d->mIt)++;
122 return *this; 127 return *this;
123} 128}
124 129
125AddressBook::Iterator &AddressBook::Iterator::operator--() 130AddressBook::Iterator &AddressBook::Iterator::operator--()
126{ 131{
127 (d->mIt)--; 132 (d->mIt)--;
128 return *this; 133 return *this;
129} 134}
130 135
131AddressBook::Iterator &AddressBook::Iterator::operator--(int) 136AddressBook::Iterator &AddressBook::Iterator::operator--(int)
132{ 137{
133 (d->mIt)--; 138 (d->mIt)--;
134 return *this; 139 return *this;
135} 140}
136 141
137bool AddressBook::Iterator::operator==( const Iterator &it ) 142bool AddressBook::Iterator::operator==( const Iterator &it )
138{ 143{
139 return ( d->mIt == it.d->mIt ); 144 return ( d->mIt == it.d->mIt );
140} 145}
141 146
142bool AddressBook::Iterator::operator!=( const Iterator &it ) 147bool AddressBook::Iterator::operator!=( const Iterator &it )
143{ 148{
144 return ( d->mIt != it.d->mIt ); 149 return ( d->mIt != it.d->mIt );
145} 150}
146 151
147 152
148AddressBook::ConstIterator::ConstIterator() 153AddressBook::ConstIterator::ConstIterator()
149{ 154{
150 d = new ConstIteratorData; 155 d = new ConstIteratorData;
151} 156}
152 157
153AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) 158AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i )
154{ 159{
155 d = new ConstIteratorData; 160 d = new ConstIteratorData;
156 d->mIt = i.d->mIt; 161 d->mIt = i.d->mIt;
157} 162}
158 163
159AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) 164AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i )
160{ 165{
161 if( this == &i ) return *this; // guard for self assignment 166 if( this == &i ) return *this; // guard for self assignment
162 delete d; // delete the old data because the Iterator was really constructed before 167 delete d; // delete the old data because the Iterator was really constructed before
163 d = new ConstIteratorData; 168 d = new ConstIteratorData;
164 d->mIt = i.d->mIt; 169 d->mIt = i.d->mIt;
165 return *this; 170 return *this;
166} 171}
167 172
168AddressBook::ConstIterator::~ConstIterator() 173AddressBook::ConstIterator::~ConstIterator()
169{ 174{
170 delete d; 175 delete d;
171} 176}
172 177
173const Addressee &AddressBook::ConstIterator::operator*() const 178const Addressee &AddressBook::ConstIterator::operator*() const
174{ 179{
175 return *(d->mIt); 180 return *(d->mIt);
176} 181}
177 182
178const Addressee* AddressBook::ConstIterator::operator->() const 183const Addressee* AddressBook::ConstIterator::operator->() const
179{ 184{
180 return &(*(d->mIt)); 185 return &(*(d->mIt));
181} 186}
182 187
183AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() 188AddressBook::ConstIterator &AddressBook::ConstIterator::operator++()
184{ 189{
185 (d->mIt)++; 190 (d->mIt)++;
186 return *this; 191 return *this;
187} 192}
188 193
189AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) 194AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int)
190{ 195{
191 (d->mIt)++; 196 (d->mIt)++;
192 return *this; 197 return *this;
193} 198}
194 199
195AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() 200AddressBook::ConstIterator &AddressBook::ConstIterator::operator--()
196{ 201{
197 (d->mIt)--; 202 (d->mIt)--;
198 return *this; 203 return *this;
199} 204}
200 205
201AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) 206AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int)
202{ 207{
203 (d->mIt)--; 208 (d->mIt)--;
204 return *this; 209 return *this;
205} 210}
206 211
207bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) 212bool AddressBook::ConstIterator::operator==( const ConstIterator &it )
208{ 213{
209 return ( d->mIt == it.d->mIt ); 214 return ( d->mIt == it.d->mIt );
210} 215}
211 216
212bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) 217bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
213{ 218{
214 return ( d->mIt != it.d->mIt ); 219 return ( d->mIt != it.d->mIt );
215} 220}
216 221
217 222
218AddressBook::AddressBook() 223AddressBook::AddressBook()
219{ 224{
220 init(0, "contact"); 225 init(0, "contact");
221} 226}
222 227
223AddressBook::AddressBook( const QString &config ) 228AddressBook::AddressBook( const QString &config )
224{ 229{
225 init(config, "contact"); 230 init(config, "contact");
226} 231}
227 232
228AddressBook::AddressBook( const QString &config, const QString &family ) 233AddressBook::AddressBook( const QString &config, const QString &family )
229{ 234{
230 init(config, family); 235 init(config, family);
231 236
232} 237}
233 238
234// the default family is "contact" 239// the default family is "contact"
235void AddressBook::init(const QString &config, const QString &family ) 240void AddressBook::init(const QString &config, const QString &family )
236{ 241{
237 blockLSEchange = false; 242 blockLSEchange = false;
238 d = new AddressBookData; 243 d = new AddressBookData;
239 QString fami = family; 244 QString fami = family;
240 if (config != 0) { 245 if (config != 0) {
241 if ( family == "syncContact" ) { 246 if ( family == "syncContact" ) {
242 qDebug("creating sync config "); 247 qDebug("creating sync config ");
243 fami = "contact"; 248 fami = "contact";
244 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); 249 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") );
245 con->setGroup( "General" ); 250 con->setGroup( "General" );
246 con->writeEntry( "ResourceKeys", QString("sync") ); 251 con->writeEntry( "ResourceKeys", QString("sync") );
247 con->writeEntry( "Standard", QString("sync") ); 252 con->writeEntry( "Standard", QString("sync") );
248 con->setGroup( "Resource_sync" ); 253 con->setGroup( "Resource_sync" );
249 con->writeEntry( "FileName", config ); 254 con->writeEntry( "FileName", config );
250 con->writeEntry( "FileFormat", QString("vcard") ); 255 con->writeEntry( "FileFormat", QString("vcard") );
251 con->writeEntry( "ResourceIdentifier", QString("sync") ); 256 con->writeEntry( "ResourceIdentifier", QString("sync") );
252 con->writeEntry( "ResourceName", QString("sync_res") ); 257 con->writeEntry( "ResourceName", QString("sync_res") );
253 if ( config.right(4) == ".xml" ) 258 if ( config.right(4) == ".xml" )
254 con->writeEntry( "ResourceType", QString("qtopia") ); 259 con->writeEntry( "ResourceType", QString("qtopia") );
255 else if ( config == "sharp" ) { 260 else if ( config == "sharp" ) {
256 con->writeEntry( "ResourceType", QString("sharp") ); 261 con->writeEntry( "ResourceType", QString("sharp") );
257 } else { 262 } else {
258 con->writeEntry( "ResourceType", QString("file") ); 263 con->writeEntry( "ResourceType", QString("file") );
259 } 264 }
260 //con->sync(); 265 //con->sync();
261 d->mConfig = con; 266 d->mConfig = con;
262 } 267 }
263 else 268 else
264 d->mConfig = new KConfig( locateLocal("config", config) ); 269 d->mConfig = new KConfig( locateLocal("config", config) );
265// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 270// qDebug("AddressBook::init 1 config=%s",config.latin1() );
266 } 271 }
267 else { 272 else {
268 d->mConfig = 0; 273 d->mConfig = 0;
269// qDebug("AddressBook::init 1 config=0"); 274// qDebug("AddressBook::init 1 config=0");
270 } 275 }
271 276
272//US d->mErrorHandler = 0; 277//US d->mErrorHandler = 0;
273 d->mManager = new KRES::Manager<Resource>( fami, false ); 278 d->mManager = new KRES::Manager<Resource>( fami, false );
274 d->mManager->readConfig( d->mConfig ); 279 d->mManager->readConfig( d->mConfig );
275 if ( family == "syncContact" ) { 280 if ( family == "syncContact" ) {
276 KRES::Manager<Resource> *manager = d->mManager; 281 KRES::Manager<Resource> *manager = d->mManager;
277 KRES::Manager<Resource>::ActiveIterator it; 282 KRES::Manager<Resource>::ActiveIterator it;
278 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 283 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
279 (*it)->setAddressBook( this ); 284 (*it)->setAddressBook( this );
280 if ( !(*it)->open() ) 285 if ( !(*it)->open() )
281 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); 286 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
282 } 287 }
283 Resource *res = standardResource(); 288 Resource *res = standardResource();
284 if ( !res ) { 289 if ( !res ) {
285 qDebug("ERROR: no standard resource"); 290 qDebug("ERROR: no standard resource");
286 res = manager->createResource( "file" ); 291 res = manager->createResource( "file" );
287 if ( res ) 292 if ( res )
288 { 293 {
289 addResource( res ); 294 addResource( res );
290 } 295 }
291 else 296 else
292 qDebug(" No resource available!!!"); 297 qDebug(" No resource available!!!");
293 } 298 }
294 setStandardResource( res ); 299 setStandardResource( res );
295 manager->writeConfig(); 300 manager->writeConfig();
296 } 301 }
297 addCustomField( i18n( "Department" ), KABC::Field::Organization, 302 addCustomField( i18n( "Department" ), KABC::Field::Organization,
298 "X-Department", "KADDRESSBOOK" ); 303 "X-Department", "KADDRESSBOOK" );
299 addCustomField( i18n( "Profession" ), KABC::Field::Organization, 304 addCustomField( i18n( "Profession" ), KABC::Field::Organization,
300 "X-Profession", "KADDRESSBOOK" ); 305 "X-Profession", "KADDRESSBOOK" );
301 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 306 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
302 "X-AssistantsName", "KADDRESSBOOK" ); 307 "X-AssistantsName", "KADDRESSBOOK" );
303 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 308 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
304 "X-ManagersName", "KADDRESSBOOK" ); 309 "X-ManagersName", "KADDRESSBOOK" );
305 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 310 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
306 "X-SpousesName", "KADDRESSBOOK" ); 311 "X-SpousesName", "KADDRESSBOOK" );
307 addCustomField( i18n( "Office" ), KABC::Field::Personal, 312 addCustomField( i18n( "Office" ), KABC::Field::Personal,
308 "X-Office", "KADDRESSBOOK" ); 313 "X-Office", "KADDRESSBOOK" );
309 addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 314 addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
310 "X-IMAddress", "KADDRESSBOOK" ); 315 "X-IMAddress", "KADDRESSBOOK" );
311 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 316 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
312 "X-Anniversary", "KADDRESSBOOK" ); 317 "X-Anniversary", "KADDRESSBOOK" );
313 318
314 //US added this field to become compatible with Opie/qtopia addressbook 319 //US added this field to become compatible with Opie/qtopia addressbook
315 // values can be "female" or "male" or "". An empty field represents undefined. 320 // values can be "female" or "male" or "". An empty field represents undefined.
316 addCustomField( i18n( "Gender" ), KABC::Field::Personal, 321 addCustomField( i18n( "Gender" ), KABC::Field::Personal,
317 "X-Gender", "KADDRESSBOOK" ); 322 "X-Gender", "KADDRESSBOOK" );
318 addCustomField( i18n( "Children" ), KABC::Field::Personal, 323 addCustomField( i18n( "Children" ), KABC::Field::Personal,
319 "X-Children", "KADDRESSBOOK" ); 324 "X-Children", "KADDRESSBOOK" );
320 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 325 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
321 "X-FreeBusyUrl", "KADDRESSBOOK" ); 326 "X-FreeBusyUrl", "KADDRESSBOOK" );
322 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, 327 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal,
323 "X-ExternalID", "KADDRESSBOOK" ); 328 "X-ExternalID", "KADDRESSBOOK" );
324} 329}
325 330
326AddressBook::~AddressBook() 331AddressBook::~AddressBook()
327{ 332{
328 delete d->mConfig; d->mConfig = 0; 333 delete d->mConfig; d->mConfig = 0;
329 delete d->mManager; d->mManager = 0; 334 delete d->mManager; d->mManager = 0;
330//US delete d->mErrorHandler; d->mErrorHandler = 0; 335//US delete d->mErrorHandler; d->mErrorHandler = 0;
331 delete d; d = 0; 336 delete d; d = 0;
332} 337}
333 338
334bool AddressBook::load() 339bool AddressBook::load()
335{ 340{
336 341
337 342
338 clear(); 343 clear();
339 344
340 KRES::Manager<Resource>::ActiveIterator it; 345 KRES::Manager<Resource>::ActiveIterator it;
341 bool ok = true; 346 bool ok = true;
342 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
343 if ( !(*it)->load() ) { 348 if ( !(*it)->load() ) {
344 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); 349 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
345 ok = false; 350 ok = false;
346 } 351 }
347 352
348 // mark all addressees as unchanged 353 // mark all addressees as unchanged
349 Addressee::List::Iterator addrIt; 354 Addressee::List::Iterator addrIt;
350 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { 355 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) {
351 (*addrIt).setChanged( false ); 356 (*addrIt).setChanged( false );
352 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); 357 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" );
353 if ( !id.isEmpty() ) { 358 if ( !id.isEmpty() ) {
354 //qDebug("setId aa %s ", id.latin1()); 359 //qDebug("setId aa %s ", id.latin1());
355 (*addrIt).setIDStr(id ); 360 (*addrIt).setIDStr(id );
356 } 361 }
357 } 362 }
358 blockLSEchange = true; 363 blockLSEchange = true;
359 return ok; 364 return ok;
360} 365}
361 366
362bool AddressBook::save( Ticket *ticket ) 367bool AddressBook::save( Ticket *ticket )
363{ 368{
364 kdDebug(5700) << "AddressBook::save()"<< endl; 369 kdDebug(5700) << "AddressBook::save()"<< endl;
365 370
366 if ( ticket->resource() ) { 371 if ( ticket->resource() ) {
367 deleteRemovedAddressees(); 372 deleteRemovedAddressees();
368 return ticket->resource()->save( ticket ); 373 return ticket->resource()->save( ticket );
369 } 374 }
370 375
371 return false; 376 return false;
372} 377}
378void AddressBook::export2File( QString fileName )
379{
380
381 QFile outFile( fileName );
382 if ( !outFile.open( IO_WriteOnly ) ) {
383 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
384 KMessageBox::error( 0, text.arg( fileName ) );
385 return ;
386 }
387 QTextStream t( &outFile );
388 t.setEncoding( QTextStream::UnicodeUTF8 );
389 Iterator it;
390 KABC::VCardConverter::Version version;
391 version = KABC::VCardConverter::v3_0;
392 for ( it = begin(); it != end(); ++it ) {
393 if ( !(*it).IDStr().isEmpty() ) {
394 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() );
395 }
396 KABC::VCardConverter converter;
397 QString vcard;
398 //Resource *resource() const;
399 converter.addresseeToVCard( *it, vcard, version );
400 t << vcard << "\r\n";
401 }
402 outFile.close();
403}
404void AddressBook::importFromFile( QString fileName )
405{
406
407 KABC::Addressee::List list;
408 QFile file( fileName );
409
410 file.open( IO_ReadOnly );
411 QByteArray rawData = file.readAll();
412 file.close();
413
414 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
415 KABC::VCardTool tool;
416 list = tool.parseVCards( data );
417
418 KABC::Addressee::List::Iterator it;
419 for ( it = list.begin(); it != list.end(); ++it ) {
420 (*it).setResource( 0 );
421 insertAddressee( (*it), false, true );
422 }
423
424}
425
373bool AddressBook::saveAB() 426bool AddressBook::saveAB()
374{ 427{
375 bool ok = true; 428 bool ok = true;
376 429
377 deleteRemovedAddressees(); 430 deleteRemovedAddressees();
378 Iterator ait; 431 Iterator ait;
379 for ( ait = begin(); ait != end(); ++ait ) { 432 for ( ait = begin(); ait != end(); ++ait ) {
380 if ( !(*ait).IDStr().isEmpty() ) { 433 if ( !(*ait).IDStr().isEmpty() ) {
381 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 434 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
382 } 435 }
383 } 436 }
384 KRES::Manager<Resource>::ActiveIterator it; 437 KRES::Manager<Resource>::ActiveIterator it;
385 KRES::Manager<Resource> *manager = d->mManager; 438 KRES::Manager<Resource> *manager = d->mManager;
386 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 439 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
387 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 440 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
388 Ticket *ticket = requestSaveTicket( *it ); 441 Ticket *ticket = requestSaveTicket( *it );
389// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 442// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
390 if ( !ticket ) { 443 if ( !ticket ) {
391 error( i18n( "Unable to save to resource '%1'. It is locked." ) 444 error( i18n( "Unable to save to resource '%1'. It is locked." )
392 .arg( (*it)->resourceName() ) ); 445 .arg( (*it)->resourceName() ) );
393 return false; 446 return false;
394 } 447 }
395 448
396 //if ( !save( ticket ) ) 449 //if ( !save( ticket ) )
397 if ( ticket->resource() ) { 450 if ( ticket->resource() ) {
398 if ( ! ticket->resource()->save( ticket ) ) 451 if ( ! ticket->resource()->save( ticket ) )
399 ok = false; 452 ok = false;
400 } else 453 } else
401 ok = false; 454 ok = false;
402 455
403 } 456 }
404 } 457 }
405 return ok; 458 return ok;
406} 459}
407 460
408AddressBook::Iterator AddressBook::begin() 461AddressBook::Iterator AddressBook::begin()
409{ 462{
410 Iterator it = Iterator(); 463 Iterator it = Iterator();
411 it.d->mIt = d->mAddressees.begin(); 464 it.d->mIt = d->mAddressees.begin();
412 return it; 465 return it;
413} 466}
414 467
415AddressBook::ConstIterator AddressBook::begin() const 468AddressBook::ConstIterator AddressBook::begin() const
416{ 469{
417 ConstIterator it = ConstIterator(); 470 ConstIterator it = ConstIterator();
418 it.d->mIt = d->mAddressees.begin(); 471 it.d->mIt = d->mAddressees.begin();
419 return it; 472 return it;
420} 473}
421 474
422AddressBook::Iterator AddressBook::end() 475AddressBook::Iterator AddressBook::end()
423{ 476{
424 Iterator it = Iterator(); 477 Iterator it = Iterator();
425 it.d->mIt = d->mAddressees.end(); 478 it.d->mIt = d->mAddressees.end();
426 return it; 479 return it;
427} 480}
428 481
429AddressBook::ConstIterator AddressBook::end() const 482AddressBook::ConstIterator AddressBook::end() const
430{ 483{
431 ConstIterator it = ConstIterator(); 484 ConstIterator it = ConstIterator();
432 it.d->mIt = d->mAddressees.end(); 485 it.d->mIt = d->mAddressees.end();
433 return it; 486 return it;
434} 487}
435 488
436void AddressBook::clear() 489void AddressBook::clear()
437{ 490{
438 d->mAddressees.clear(); 491 d->mAddressees.clear();
439} 492}
440 493
441Ticket *AddressBook::requestSaveTicket( Resource *resource ) 494Ticket *AddressBook::requestSaveTicket( Resource *resource )
442{ 495{
443 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 496 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
444 497
445 if ( !resource ) 498 if ( !resource )
446 { 499 {
447 qDebug("AddressBook::requestSaveTicket no resource" ); 500 qDebug("AddressBook::requestSaveTicket no resource" );
448 resource = standardResource(); 501 resource = standardResource();
449 } 502 }
450 503
451 KRES::Manager<Resource>::ActiveIterator it; 504 KRES::Manager<Resource>::ActiveIterator it;
452 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 505 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
453 if ( (*it) == resource ) { 506 if ( (*it) == resource ) {
454 if ( (*it)->readOnly() || !(*it)->isOpen() ) 507 if ( (*it)->readOnly() || !(*it)->isOpen() )
455 return 0; 508 return 0;
456 else 509 else
457 return (*it)->requestSaveTicket(); 510 return (*it)->requestSaveTicket();
458 } 511 }
459 } 512 }
460 513
461 return 0; 514 return 0;
462} 515}
463 516
464void AddressBook::insertAddressee( const Addressee &a, bool setRev ) 517void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource )
465{ 518{
466 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { 519 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) {
467 //qDebug("block insert "); 520 //qDebug("block insert ");
468 return; 521 return;
469 } 522 }
470 //qDebug("inserting.... %s ",a.uid().latin1() ); 523 //qDebug("inserting.... %s ",a.uid().latin1() );
471 bool found = false; 524 bool found = false;
472 Addressee::List::Iterator it; 525 Addressee::List::Iterator it;
473 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 526 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
474 if ( a.uid() == (*it).uid() ) { 527 if ( a.uid() == (*it).uid() ) {
475 528
476 bool changed = false; 529 bool changed = false;
477 Addressee addr = a; 530 Addressee addr = a;
478 if ( addr != (*it) ) 531 if ( addr != (*it) )
479 changed = true; 532 changed = true;
480 533
481 (*it) = a; 534 if ( takeResource ) {
482 if ( (*it).resource() == 0 ) 535 Resource * res = (*it).resource();
483 (*it).setResource( standardResource() ); 536 (*it) = a;
484 537 (*it).setResource( res );
538 } else {
539 (*it) = a;
540 if ( (*it).resource() == 0 )
541 (*it).setResource( standardResource() );
542 }
485 if ( changed ) { 543 if ( changed ) {
486 if ( setRev ) { 544 if ( setRev ) {
487 545
488 // get rid of micro seconds 546 // get rid of micro seconds
489 QDateTime dt = QDateTime::currentDateTime(); 547 QDateTime dt = QDateTime::currentDateTime();
490 QTime t = dt.time(); 548 QTime t = dt.time();
491 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 549 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
492 (*it).setRevision( dt ); 550 (*it).setRevision( dt );
493 } 551 }
494 (*it).setChanged( true ); 552 (*it).setChanged( true );
495 } 553 }
496 554
497 found = true; 555 found = true;
498 } else { 556 } else {
499 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 557 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
500 QString name = (*it).uid().mid( 19 ); 558 QString name = (*it).uid().mid( 19 );
501 Addressee b = a; 559 Addressee b = a;
502 QString id = b.getID( name ); 560 QString id = b.getID( name );
503 if ( ! id.isEmpty() ) { 561 if ( ! id.isEmpty() ) {
504 QString des = (*it).note(); 562 QString des = (*it).note();
505 int startN; 563 int startN;
506 if( (startN = des.find( id ) ) >= 0 ) { 564 if( (startN = des.find( id ) ) >= 0 ) {
507 int endN = des.find( ",", startN+1 ); 565 int endN = des.find( ",", startN+1 );
508 des = des.left( startN ) + des.mid( endN+1 ); 566 des = des.left( startN ) + des.mid( endN+1 );
509 (*it).setNote( des ); 567 (*it).setNote( des );
510 } 568 }
511 } 569 }
512 } 570 }
513 } 571 }
514 } 572 }
515 if ( found ) 573 if ( found )
516 return; 574 return;
517 d->mAddressees.append( a ); 575 d->mAddressees.append( a );
518 Addressee& addr = d->mAddressees.last(); 576 Addressee& addr = d->mAddressees.last();
519 if ( addr.resource() == 0 ) 577 if ( addr.resource() == 0 )
520 addr.setResource( standardResource() ); 578 addr.setResource( standardResource() );
521 579
522 addr.setChanged( true ); 580 addr.setChanged( true );
523} 581}
524 582
525void AddressBook::removeAddressee( const Addressee &a ) 583void AddressBook::removeAddressee( const Addressee &a )
526{ 584{
527 Iterator it; 585 Iterator it;
528 Iterator it2; 586 Iterator it2;
529 bool found = false; 587 bool found = false;
530 for ( it = begin(); it != end(); ++it ) { 588 for ( it = begin(); it != end(); ++it ) {
531 if ( a.uid() == (*it).uid() ) { 589 if ( a.uid() == (*it).uid() ) {
532 found = true; 590 found = true;
533 it2 = it; 591 it2 = it;
534 } else { 592 } else {
535 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 593 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
536 QString name = (*it).uid().mid( 19 ); 594 QString name = (*it).uid().mid( 19 );
537 Addressee b = a; 595 Addressee b = a;
538 QString id = b.getID( name ); 596 QString id = b.getID( name );
539 if ( ! id.isEmpty() ) { 597 if ( ! id.isEmpty() ) {
540 QString des = (*it).note(); 598 QString des = (*it).note();
541 if( des.find( id ) < 0 ) { 599 if( des.find( id ) < 0 ) {
542 des += id + ","; 600 des += id + ",";
543 (*it).setNote( des ); 601 (*it).setNote( des );
544 } 602 }
545 } 603 }
546 } 604 }
547 605
548 } 606 }
549 } 607 }
550 608
551 if ( found ) 609 if ( found )
552 removeAddressee( it2 ); 610 removeAddressee( it2 );
553 611
554} 612}
555 613
556void AddressBook::removeSyncAddressees( bool removeDeleted ) 614void AddressBook::removeSyncAddressees( bool removeDeleted )
557{ 615{
558 Iterator it = begin(); 616 Iterator it = begin();
559 Iterator it2 ; 617 Iterator it2 ;
560 QDateTime dt ( QDate( 2004,1,1) ); 618 QDateTime dt ( QDate( 2004,1,1) );
561 while ( it != end() ) { 619 while ( it != end() ) {
562 (*it).setRevision( dt ); 620 (*it).setRevision( dt );
563 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 621 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
564 (*it).setIDStr(""); 622 (*it).setIDStr("");
565 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { 623 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) {
566 it2 = it; 624 it2 = it;
567 //qDebug("removing %s ",(*it).uid().latin1() ); 625 //qDebug("removing %s ",(*it).uid().latin1() );
568 ++it; 626 ++it;
569 removeAddressee( it2 ); 627 removeAddressee( it2 );
570 } else { 628 } else {
571 //qDebug("skipping %s ",(*it).uid().latin1() ); 629 //qDebug("skipping %s ",(*it).uid().latin1() );
572 ++it; 630 ++it;
573 } 631 }
574 } 632 }
575 deleteRemovedAddressees(); 633 deleteRemovedAddressees();
576} 634}
577 635
578void AddressBook::removeAddressee( const Iterator &it ) 636void AddressBook::removeAddressee( const Iterator &it )
579{ 637{
580 d->mRemovedAddressees.append( (*it) ); 638 d->mRemovedAddressees.append( (*it) );
581 d->mAddressees.remove( it.d->mIt ); 639 d->mAddressees.remove( it.d->mIt );
582} 640}
583 641
584AddressBook::Iterator AddressBook::find( const Addressee &a ) 642AddressBook::Iterator AddressBook::find( const Addressee &a )
585{ 643{
586 Iterator it; 644 Iterator it;
587 for ( it = begin(); it != end(); ++it ) { 645 for ( it = begin(); it != end(); ++it ) {
588 if ( a.uid() == (*it).uid() ) { 646 if ( a.uid() == (*it).uid() ) {
589 return it; 647 return it;
590 } 648 }
591 } 649 }
592 return end(); 650 return end();
593} 651}
594 652
595Addressee AddressBook::findByUid( const QString &uid ) 653Addressee AddressBook::findByUid( const QString &uid )
596{ 654{
597 Iterator it; 655 Iterator it;
598 for ( it = begin(); it != end(); ++it ) { 656 for ( it = begin(); it != end(); ++it ) {
599 if ( uid == (*it).uid() ) { 657 if ( uid == (*it).uid() ) {
600 return *it; 658 return *it;
601 } 659 }
602 } 660 }
603 return Addressee(); 661 return Addressee();
604} 662}
605void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) 663void AddressBook::preExternSync( AddressBook* aBook, const QString& csd )
606{ 664{
607 //qDebug("AddressBook::preExternSync "); 665 //qDebug("AddressBook::preExternSync ");
608 AddressBook::Iterator it; 666 AddressBook::Iterator it;
609 for ( it = begin(); it != end(); ++it ) { 667 for ( it = begin(); it != end(); ++it ) {
610 (*it).setID( csd, (*it).externalUID() ); 668 (*it).setID( csd, (*it).externalUID() );
611 (*it).computeCsum( csd ); 669 (*it).computeCsum( csd );
612 } 670 }
613 mergeAB( aBook ,csd ); 671 mergeAB( aBook ,csd );
614} 672}
615void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) 673void AddressBook::postExternSync( AddressBook* aBook , const QString& csd)
616{ 674{
617 //qDebug("AddressBook::postExternSync "); 675 //qDebug("AddressBook::postExternSync ");
618 AddressBook::Iterator it; 676 AddressBook::Iterator it;
619 for ( it = begin(); it != end(); ++it ) { 677 for ( it = begin(); it != end(); ++it ) {
620 // qDebug("check uid %s ", (*it).uid().latin1() ); 678 // qDebug("check uid %s ", (*it).uid().latin1() );
621 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || 679 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
622 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { 680 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) {
623 Addressee ad = aBook->findByUid( ( (*it).uid() )); 681 Addressee ad = aBook->findByUid( ( (*it).uid() ));
624 if ( ad.isEmpty() ) { 682 if ( ad.isEmpty() ) {
625 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); 683 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1());
626 } else { 684 } else {
627 (*it).computeCsum( csd ); 685 (*it).computeCsum( csd );
628 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) 686 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
629 ad.setID( csd, (*it).externalUID() ); 687 ad.setID( csd, (*it).externalUID() );
630 ad.setCsum( csd, (*it).getCsum( csd ) ); 688 ad.setCsum( csd, (*it).getCsum( csd ) );
631 aBook->insertAddressee( ad ); 689 aBook->insertAddressee( ad );
632 } 690 }
633 } 691 }
634 } 692 }
635} 693}
636 694
637bool AddressBook::containsExternalUid( const QString& uid ) 695bool AddressBook::containsExternalUid( const QString& uid )
638{ 696{
639 Iterator it; 697 Iterator it;
640 for ( it = begin(); it != end(); ++it ) { 698 for ( it = begin(); it != end(); ++it ) {
641 if ( uid == (*it).externalUID( ) ) 699 if ( uid == (*it).externalUID( ) )
642 return true; 700 return true;
643 } 701 }
644 return false; 702 return false;
645} 703}
646Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) 704Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile )
647{ 705{
648 Iterator it; 706 Iterator it;
649 for ( it = begin(); it != end(); ++it ) { 707 for ( it = begin(); it != end(); ++it ) {
650 if ( uid == (*it).getID( profile ) ) 708 if ( uid == (*it).getID( profile ) )
651 return (*it); 709 return (*it);
652 } 710 }
653 return Addressee(); 711 return Addressee();
654} 712}
655void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) 713void AddressBook::mergeAB( AddressBook *aBook, const QString& profile )
656{ 714{
657 Iterator it; 715 Iterator it;
658 Addressee ad; 716 Addressee ad;
659 for ( it = begin(); it != end(); ++it ) { 717 for ( it = begin(); it != end(); ++it ) {
660 ad = aBook->findByExternUid( (*it).externalUID(), profile ); 718 ad = aBook->findByExternUid( (*it).externalUID(), profile );
661 if ( !ad.isEmpty() ) { 719 if ( !ad.isEmpty() ) {
662 (*it).mergeContact( ad ); 720 (*it).mergeContact( ad );
663 } 721 }
664 } 722 }
665#if 0 723#if 0
666 // test only 724 // test only
667 for ( it = begin(); it != end(); ++it ) { 725 for ( it = begin(); it != end(); ++it ) {
668 726
669 qDebug("uid %s ", (*it).uid().latin1()); 727 qDebug("uid %s ", (*it).uid().latin1());
670 } 728 }
671#endif 729#endif
672} 730}
673 731
674#if 0 732#if 0
675Addressee::List AddressBook::getExternLastSyncAddressees() 733Addressee::List AddressBook::getExternLastSyncAddressees()
676{ 734{
677 Addressee::List results; 735 Addressee::List results;
678 736
679 Iterator it; 737 Iterator it;
680 for ( it = begin(); it != end(); ++it ) { 738 for ( it = begin(); it != end(); ++it ) {
681 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { 739 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) {
682 if ( (*it).familyName().left(4) == "!E: " ) 740 if ( (*it).familyName().left(4) == "!E: " )
683 results.append( *it ); 741 results.append( *it );
684 } 742 }
685 } 743 }
686 744
687 return results; 745 return results;
688} 746}
689#endif 747#endif
690void AddressBook::resetTempSyncStat() 748void AddressBook::resetTempSyncStat()
691{ 749{
692 Iterator it; 750 Iterator it;
693 for ( it = begin(); it != end(); ++it ) { 751 for ( it = begin(); it != end(); ++it ) {
694 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); 752 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
695 } 753 }
696 754
697} 755}
698 756
699QStringList AddressBook:: uidList() 757QStringList AddressBook:: uidList()
700{ 758{
701 QStringList results; 759 QStringList results;
702 Iterator it; 760 Iterator it;
703 for ( it = begin(); it != end(); ++it ) { 761 for ( it = begin(); it != end(); ++it ) {
704 results.append( (*it).uid() ); 762 results.append( (*it).uid() );
705 } 763 }
706 return results; 764 return results;
707} 765}
708 766
709 767
710Addressee::List AddressBook::allAddressees() 768Addressee::List AddressBook::allAddressees()
711{ 769{
712 return d->mAddressees; 770 return d->mAddressees;
713 771
714} 772}
715 773
716Addressee::List AddressBook::findByName( const QString &name ) 774Addressee::List AddressBook::findByName( const QString &name )
717{ 775{
718 Addressee::List results; 776 Addressee::List results;
719 777
720 Iterator it; 778 Iterator it;
721 for ( it = begin(); it != end(); ++it ) { 779 for ( it = begin(); it != end(); ++it ) {
722 if ( name == (*it).realName() ) { 780 if ( name == (*it).realName() ) {
723 results.append( *it ); 781 results.append( *it );
724 } 782 }
725 } 783 }
726 784
727 return results; 785 return results;
728} 786}
729 787
730Addressee::List AddressBook::findByEmail( const QString &email ) 788Addressee::List AddressBook::findByEmail( const QString &email )
731{ 789{
732 Addressee::List results; 790 Addressee::List results;
733 QStringList mailList; 791 QStringList mailList;
734 792
735 Iterator it; 793 Iterator it;
736 for ( it = begin(); it != end(); ++it ) { 794 for ( it = begin(); it != end(); ++it ) {
737 mailList = (*it).emails(); 795 mailList = (*it).emails();
738 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { 796 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
739 if ( email == (*ite) ) { 797 if ( email == (*ite) ) {
740 results.append( *it ); 798 results.append( *it );
741 } 799 }
742 } 800 }
743 } 801 }
744 802
745 return results; 803 return results;
746} 804}
747 805
748Addressee::List AddressBook::findByCategory( const QString &category ) 806Addressee::List AddressBook::findByCategory( const QString &category )
749{ 807{
750 Addressee::List results; 808 Addressee::List results;
751 809
752 Iterator it; 810 Iterator it;
753 for ( it = begin(); it != end(); ++it ) { 811 for ( it = begin(); it != end(); ++it ) {
754 if ( (*it).hasCategory( category) ) { 812 if ( (*it).hasCategory( category) ) {
755 results.append( *it ); 813 results.append( *it );
756 } 814 }
757 } 815 }
758 816
759 return results; 817 return results;
760} 818}
761 819
762void AddressBook::dump() const 820void AddressBook::dump() const
763{ 821{
764 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; 822 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl;
765 823
766 ConstIterator it; 824 ConstIterator it;
767 for( it = begin(); it != end(); ++it ) { 825 for( it = begin(); it != end(); ++it ) {
768 (*it).dump(); 826 (*it).dump();
769 } 827 }
770 828
771 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; 829 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl;
772} 830}
773 831
774QString AddressBook::identifier() 832QString AddressBook::identifier()
775{ 833{
776 QStringList identifier; 834 QStringList identifier;
777 835
778 836
779 KRES::Manager<Resource>::ActiveIterator it; 837 KRES::Manager<Resource>::ActiveIterator it;
780 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 838 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
781 if ( !(*it)->identifier().isEmpty() ) 839 if ( !(*it)->identifier().isEmpty() )
782 identifier.append( (*it)->identifier() ); 840 identifier.append( (*it)->identifier() );
783 } 841 }
784 842
785 return identifier.join( ":" ); 843 return identifier.join( ":" );
786} 844}
787 845
788Field::List AddressBook::fields( int category ) 846Field::List AddressBook::fields( int category )
789{ 847{
790 if ( d->mAllFields.isEmpty() ) { 848 if ( d->mAllFields.isEmpty() ) {
791 d->mAllFields = Field::allFields(); 849 d->mAllFields = Field::allFields();
792 } 850 }
793 851
794 if ( category == Field::All ) return d->mAllFields; 852 if ( category == Field::All ) return d->mAllFields;
795 853
796 Field::List result; 854 Field::List result;
797 Field::List::ConstIterator it; 855 Field::List::ConstIterator it;
798 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { 856 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) {
799 if ( (*it)->category() & category ) result.append( *it ); 857 if ( (*it)->category() & category ) result.append( *it );
800 } 858 }
801 859
802 return result; 860 return result;
803} 861}
804 862
805bool AddressBook::addCustomField( const QString &label, int category, 863bool AddressBook::addCustomField( const QString &label, int category,
806 const QString &key, const QString &app ) 864 const QString &key, const QString &app )
807{ 865{
808 if ( d->mAllFields.isEmpty() ) { 866 if ( d->mAllFields.isEmpty() ) {
809 d->mAllFields = Field::allFields(); 867 d->mAllFields = Field::allFields();
810 } 868 }
811//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; 869//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app;
812 QString a = app.isNull() ? KGlobal::getAppName() : app; 870 QString a = app.isNull() ? KGlobal::getAppName() : app;
813 871
814 QString k = key.isNull() ? label : key; 872 QString k = key.isNull() ? label : key;
815 873
816 Field *field = Field::createCustomField( label, category, k, a ); 874 Field *field = Field::createCustomField( label, category, k, a );
817 875
818 if ( !field ) return false; 876 if ( !field ) return false;
819 877
820 d->mAllFields.append( field ); 878 d->mAllFields.append( field );
821 879
822 return true; 880 return true;
823} 881}
824 882
825QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) 883QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab )
826{ 884{
827 if (!ab.d) return s; 885 if (!ab.d) return s;
828 886
829 return s << ab.d->mAddressees; 887 return s << ab.d->mAddressees;
830} 888}
831 889
832QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) 890QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab )
833{ 891{
834 if (!ab.d) return s; 892 if (!ab.d) return s;
835 893
836 s >> ab.d->mAddressees; 894 s >> ab.d->mAddressees;
837 895
838 return s; 896 return s;
839} 897}
840 898
841bool AddressBook::addResource( Resource *resource ) 899bool AddressBook::addResource( Resource *resource )
842{ 900{
843 if ( !resource->open() ) { 901 if ( !resource->open() ) {
844 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; 902 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl;
845 return false; 903 return false;
846 } 904 }
847 905
848 resource->setAddressBook( this ); 906 resource->setAddressBook( this );
849 907
850 d->mManager->add( resource ); 908 d->mManager->add( resource );
851 return true; 909 return true;
852} 910}
853 911
854bool AddressBook::removeResource( Resource *resource ) 912bool AddressBook::removeResource( Resource *resource )
855{ 913{
856 resource->close(); 914 resource->close();
857 915
858 if ( resource == standardResource() ) 916 if ( resource == standardResource() )
859 d->mManager->setStandardResource( 0 ); 917 d->mManager->setStandardResource( 0 );
860 918
861 resource->setAddressBook( 0 ); 919 resource->setAddressBook( 0 );
862 920
863 d->mManager->remove( resource ); 921 d->mManager->remove( resource );
864 return true; 922 return true;
865} 923}
866 924
867QPtrList<Resource> AddressBook::resources() 925QPtrList<Resource> AddressBook::resources()
868{ 926{
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 8f62f0d..3603ec1 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -1,340 +1,341 @@
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 145 void export2File( QString fileName );
146 void importFromFile( QString fileName );
146 /** 147 /**
147 Returns a iterator for first entry of address book. 148 Returns a iterator for first entry of address book.
148 */ 149 */
149 Iterator begin(); 150 Iterator begin();
150 151
151 /** 152 /**
152 Returns a const iterator for first entry of address book. 153 Returns a const iterator for first entry of address book.
153 */ 154 */
154 ConstIterator begin() const; 155 ConstIterator begin() const;
155 156
156 /** 157 /**
157 Returns a iterator for first entry of address book. 158 Returns a iterator for first entry of address book.
158 */ 159 */
159 Iterator end(); 160 Iterator end();
160 161
161 /** 162 /**
162 Returns a const iterator for first entry of address book. 163 Returns a const iterator for first entry of address book.
163 */ 164 */
164 ConstIterator end() const; 165 ConstIterator end() const;
165 166
166 /** 167 /**
167 Removes all entries from address book. 168 Removes all entries from address book.
168 */ 169 */
169 void clear(); 170 void clear();
170 171
171 /** 172 /**
172 Insert an Addressee object into address book. If an object with the same 173 Insert an Addressee object into address book. If an object with the same
173 unique id already exists in the address book it it replaced by the new 174 unique id already exists in the address book it it replaced by the new
174 one. If not the new object is appended to the address book. 175 one. If not the new object is appended to the address book.
175 */ 176 */
176 void insertAddressee( const Addressee &, bool setRev = true ); 177 void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false);
177 178
178 /** 179 /**
179 Removes entry from the address book. 180 Removes entry from the address book.
180 */ 181 */
181 void removeAddressee( const Addressee & ); 182 void removeAddressee( const Addressee & );
182 183
183 /** 184 /**
184 This is like @ref removeAddressee() just above, with the difference that 185 This is like @ref removeAddressee() just above, with the difference that
185 the first element is a iterator, returned by @ref begin(). 186 the first element is a iterator, returned by @ref begin().
186 */ 187 */
187 void removeAddressee( const Iterator & ); 188 void removeAddressee( const Iterator & );
188 189
189 /** 190 /**
190 Find the specified entry in address book. Returns end(), if the entry 191 Find the specified entry in address book. Returns end(), if the entry
191 couldn't be found. 192 couldn't be found.
192 */ 193 */
193 Iterator find( const Addressee & ); 194 Iterator find( const Addressee & );
194 195
195 /** 196 /**
196 Find the entry specified by an unique id. Returns an empty Addressee 197 Find the entry specified by an unique id. Returns an empty Addressee
197 object, if the address book does not contain an entry with this id. 198 object, if the address book does not contain an entry with this id.
198 */ 199 */
199 Addressee findByUid( const QString & ); 200 Addressee findByUid( const QString & );
200 201
201 202
202 /** 203 /**
203 Returns a list of all addressees in the address book. This list can 204 Returns a list of all addressees in the address book. This list can
204 be sorted with @ref KABC::AddresseeList for example. 205 be sorted with @ref KABC::AddresseeList for example.
205 */ 206 */
206 Addressee::List allAddressees(); 207 Addressee::List allAddressees();
207 208
208 /** 209 /**
209 Find all entries with the specified name in the address book. Returns 210 Find all entries with the specified name in the address book. Returns
210 an empty list, if no entries could be found. 211 an empty list, if no entries could be found.
211 */ 212 */
212 Addressee::List findByName( const QString & ); 213 Addressee::List findByName( const QString & );
213 214
214 /** 215 /**
215 Find all entries with the specified email address in the address book. 216 Find all entries with the specified email address in the address book.
216 Returns an empty list, if no entries could be found. 217 Returns an empty list, if no entries could be found.
217 */ 218 */
218 Addressee::List findByEmail( const QString & ); 219 Addressee::List findByEmail( const QString & );
219 220
220 /** 221 /**
221 Find all entries wich have the specified category in the address book. 222 Find all entries wich have the specified category in the address book.
222 Returns an empty list, if no entries could be found. 223 Returns an empty list, if no entries could be found.
223 */ 224 */
224 Addressee::List findByCategory( const QString & ); 225 Addressee::List findByCategory( const QString & );
225 226
226 /** 227 /**
227 Return a string identifying this addressbook. 228 Return a string identifying this addressbook.
228 */ 229 */
229 virtual QString identifier(); 230 virtual QString identifier();
230 231
231 /** 232 /**
232 Used for debug output. 233 Used for debug output.
233 */ 234 */
234 void dump() const; 235 void dump() const;
235 236
236 void emitAddressBookLocked() { emit addressBookLocked( this ); } 237 void emitAddressBookLocked() { emit addressBookLocked( this ); }
237 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } 238 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); }
238 void emitAddressBookChanged() { emit addressBookChanged( this ); } 239 void emitAddressBookChanged() { emit addressBookChanged( this ); }
239 240
240 /** 241 /**
241 Return list of all Fields known to the address book which are associated 242 Return list of all Fields known to the address book which are associated
242 with the given field category. 243 with the given field category.
243 */ 244 */
244 Field::List fields( int category = Field::All ); 245 Field::List fields( int category = Field::All );
245 246
246 /** 247 /**
247 Add custom field to address book. 248 Add custom field to address book.
248 249
249 @param label User visible label of the field. 250 @param label User visible label of the field.
250 @param category Ored list of field categories. 251 @param category Ored list of field categories.
251 @param key Identifier used as key for reading and writing the field. 252 @param key Identifier used as key for reading and writing the field.
252 @param app String used as application key for reading and writing 253 @param app String used as application key for reading and writing
253 the field. 254 the field.
254 */ 255 */
255 bool addCustomField( const QString &label, int category = Field::All, 256 bool addCustomField( const QString &label, int category = Field::All,
256 const QString &key = QString::null, 257 const QString &key = QString::null,
257 const QString &app = QString::null ); 258 const QString &app = QString::null );
258 259
259 260
260 /** 261 /**
261 Add address book resource. 262 Add address book resource.
262 */ 263 */
263 bool addResource( Resource * ); 264 bool addResource( Resource * );
264 265
265 /** 266 /**
266 Remove address book resource. 267 Remove address book resource.
267 */ 268 */
268 bool removeResource( Resource * ); 269 bool removeResource( Resource * );
269 270
270 /** 271 /**
271 Return pointer list of all resources. 272 Return pointer list of all resources.
272 */ 273 */
273 QPtrList<Resource> resources(); 274 QPtrList<Resource> resources();
274 275
275 /** 276 /**
276 Set the @p ErrorHandler, that is used by @ref error() to 277 Set the @p ErrorHandler, that is used by @ref error() to
277 provide gui-independend error messages. 278 provide gui-independend error messages.
278 */ 279 */
279 void setErrorHandler( ErrorHandler * ); 280 void setErrorHandler( ErrorHandler * );
280 281
281 /** 282 /**
282 Shows gui independend error messages. 283 Shows gui independend error messages.
283 */ 284 */
284 void error( const QString& ); 285 void error( const QString& );
285 286
286 /** 287 /**
287 Query all resources to clean up their lock files 288 Query all resources to clean up their lock files
288 */ 289 */
289 void cleanUp(); 290 void cleanUp();
290 291
291 // sync stuff 292 // sync stuff
292 //Addressee::List getExternLastSyncAddressees(); 293 //Addressee::List getExternLastSyncAddressees();
293 void resetTempSyncStat(); 294 void resetTempSyncStat();
294 QStringList uidList(); 295 QStringList uidList();
295 void removeSyncAddressees( bool removeDeleted = false ); 296 void removeSyncAddressees( bool removeDeleted = false );
296 void mergeAB( AddressBook *aBook, const QString& profile ); 297 void mergeAB( AddressBook *aBook, const QString& profile );
297 Addressee findByExternUid( const QString& uid , const QString& profile ); 298 Addressee findByExternUid( const QString& uid , const QString& profile );
298 bool containsExternalUid( const QString& uid ); 299 bool containsExternalUid( const QString& uid );
299 300
300 void preExternSync( AddressBook* aBook, const QString& csd ); 301 void preExternSync( AddressBook* aBook, const QString& csd );
301 void postExternSync( AddressBook* aBook, const QString& csd ); 302 void postExternSync( AddressBook* aBook, const QString& csd );
302 signals: 303 signals:
303 /** 304 /**
304 Emitted, when the address book has changed on disk. 305 Emitted, when the address book has changed on disk.
305 */ 306 */
306 void addressBookChanged( AddressBook * ); 307 void addressBookChanged( AddressBook * );
307 308
308 /** 309 /**
309 Emitted, when the address book has been locked for writing. 310 Emitted, when the address book has been locked for writing.
310 */ 311 */
311 void addressBookLocked( AddressBook * ); 312 void addressBookLocked( AddressBook * );
312 313
313 /** 314 /**
314 Emitted, when the address book has been unlocked. 315 Emitted, when the address book has been unlocked.
315 */ 316 */
316 void addressBookUnlocked( AddressBook * ); 317 void addressBookUnlocked( AddressBook * );
317 318
318 protected: 319 protected:
319 void deleteRemovedAddressees(); 320 void deleteRemovedAddressees();
320 void setStandardResource( Resource * ); 321 void setStandardResource( Resource * );
321 Resource *standardResource(); 322 Resource *standardResource();
322 KRES::Manager<Resource> *resourceManager(); 323 KRES::Manager<Resource> *resourceManager();
323 324
324 void init(const QString &config, const QString &family); 325 void init(const QString &config, const QString &family);
325 326
326 private: 327 private:
327//US QPtrList<Resource> mDummy; // Remove in KDE 4 328//US QPtrList<Resource> mDummy; // Remove in KDE 4
328 329
329 330
330 struct AddressBookData; 331 struct AddressBookData;
331 AddressBookData *d; 332 AddressBookData *d;
332 bool blockLSEchange; 333 bool blockLSEchange;
333}; 334};
334 335
335QDataStream &operator<<( QDataStream &, const AddressBook & ); 336QDataStream &operator<<( QDataStream &, const AddressBook & );
336QDataStream &operator>>( QDataStream &, AddressBook & ); 337QDataStream &operator>>( QDataStream &, AddressBook & );
337 338
338} 339}
339 340
340#endif 341#endif
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 83fede4..6404410 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1302,771 +1302,771 @@ void KABCore::setDetailsToState()
1302void KABCore::setDetailsVisible( bool visible ) 1302void KABCore::setDetailsVisible( bool visible )
1303{ 1303{
1304 if (visible && mDetails->isHidden()) 1304 if (visible && mDetails->isHidden())
1305 { 1305 {
1306 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1306 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1307 if ( addrList.count() > 0 ) 1307 if ( addrList.count() > 0 )
1308 mDetails->setAddressee( addrList[ 0 ] ); 1308 mDetails->setAddressee( addrList[ 0 ] );
1309 } 1309 }
1310 1310
1311 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1311 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1312 // the listview and the detailview. We do that by changing the splitbar size. 1312 // the listview and the detailview. We do that by changing the splitbar size.
1313 if (mMultipleViewsAtOnce) 1313 if (mMultipleViewsAtOnce)
1314 { 1314 {
1315 if ( visible ) 1315 if ( visible )
1316 mDetails->show(); 1316 mDetails->show();
1317 else 1317 else
1318 mDetails->hide(); 1318 mDetails->hide();
1319 } 1319 }
1320 else 1320 else
1321 { 1321 {
1322 if ( visible ) { 1322 if ( visible ) {
1323 mViewManager->hide(); 1323 mViewManager->hide();
1324 mDetails->show(); 1324 mDetails->show();
1325 } 1325 }
1326 else { 1326 else {
1327 mViewManager->show(); 1327 mViewManager->show();
1328 mDetails->hide(); 1328 mDetails->hide();
1329 } 1329 }
1330 setJumpButtonBarVisible( !visible ); 1330 setJumpButtonBarVisible( !visible );
1331 } 1331 }
1332 1332
1333} 1333}
1334 1334
1335void KABCore::extensionChanged( int id ) 1335void KABCore::extensionChanged( int id )
1336{ 1336{
1337 //change the details view only for non desktop systems 1337 //change the details view only for non desktop systems
1338#ifndef DESKTOP_VERSION 1338#ifndef DESKTOP_VERSION
1339 1339
1340 if (id == 0) 1340 if (id == 0)
1341 { 1341 {
1342 //the user disabled the extension. 1342 //the user disabled the extension.
1343 1343
1344 if (mMultipleViewsAtOnce) 1344 if (mMultipleViewsAtOnce)
1345 { // enable detailsview again 1345 { // enable detailsview again
1346 setDetailsVisible( true ); 1346 setDetailsVisible( true );
1347 mActionDetails->setChecked( true ); 1347 mActionDetails->setChecked( true );
1348 } 1348 }
1349 else 1349 else
1350 { //go back to the listview 1350 { //go back to the listview
1351 setDetailsVisible( false ); 1351 setDetailsVisible( false );
1352 mActionDetails->setChecked( false ); 1352 mActionDetails->setChecked( false );
1353 mActionDetails->setEnabled(true); 1353 mActionDetails->setEnabled(true);
1354 } 1354 }
1355 1355
1356 } 1356 }
1357 else 1357 else
1358 { 1358 {
1359 //the user enabled the extension. 1359 //the user enabled the extension.
1360 setDetailsVisible( false ); 1360 setDetailsVisible( false );
1361 mActionDetails->setChecked( false ); 1361 mActionDetails->setChecked( false );
1362 1362
1363 if (!mMultipleViewsAtOnce) 1363 if (!mMultipleViewsAtOnce)
1364 { 1364 {
1365 mActionDetails->setEnabled(false); 1365 mActionDetails->setEnabled(false);
1366 } 1366 }
1367 1367
1368 mExtensionManager->setSelectionChanged(); 1368 mExtensionManager->setSelectionChanged();
1369 1369
1370 } 1370 }
1371 1371
1372#endif// DESKTOP_VERSION 1372#endif// DESKTOP_VERSION
1373 1373
1374} 1374}
1375 1375
1376 1376
1377void KABCore::extensionModified( const KABC::Addressee::List &list ) 1377void KABCore::extensionModified( const KABC::Addressee::List &list )
1378{ 1378{
1379 1379
1380 if ( list.count() != 0 ) { 1380 if ( list.count() != 0 ) {
1381 KABC::Addressee::List::ConstIterator it; 1381 KABC::Addressee::List::ConstIterator it;
1382 for ( it = list.begin(); it != list.end(); ++it ) 1382 for ( it = list.begin(); it != list.end(); ++it )
1383 mAddressBook->insertAddressee( *it ); 1383 mAddressBook->insertAddressee( *it );
1384 if ( list.count() > 1 ) 1384 if ( list.count() > 1 )
1385 setModified(); 1385 setModified();
1386 else 1386 else
1387 setModifiedWOrefresh(); 1387 setModifiedWOrefresh();
1388 } 1388 }
1389 if ( list.count() == 0 ) 1389 if ( list.count() == 0 )
1390 mViewManager->refreshView(); 1390 mViewManager->refreshView();
1391 else 1391 else
1392 mViewManager->refreshView( list[ 0 ].uid() ); 1392 mViewManager->refreshView( list[ 0 ].uid() );
1393 1393
1394 1394
1395 1395
1396} 1396}
1397 1397
1398QString KABCore::getNameByPhone( const QString &phone ) 1398QString KABCore::getNameByPhone( const QString &phone )
1399{ 1399{
1400#ifndef KAB_EMBEDDED 1400#ifndef KAB_EMBEDDED
1401 QRegExp r( "[/*/-/ ]" ); 1401 QRegExp r( "[/*/-/ ]" );
1402 QString localPhone( phone ); 1402 QString localPhone( phone );
1403 1403
1404 bool found = false; 1404 bool found = false;
1405 QString ownerName = ""; 1405 QString ownerName = "";
1406 KABC::AddressBook::Iterator iter; 1406 KABC::AddressBook::Iterator iter;
1407 KABC::PhoneNumber::List::Iterator phoneIter; 1407 KABC::PhoneNumber::List::Iterator phoneIter;
1408 KABC::PhoneNumber::List phoneList; 1408 KABC::PhoneNumber::List phoneList;
1409 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1409 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1410 phoneList = (*iter).phoneNumbers(); 1410 phoneList = (*iter).phoneNumbers();
1411 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1411 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1412 ++phoneIter) { 1412 ++phoneIter) {
1413 // Get rid of separator chars so just the numbers are compared. 1413 // Get rid of separator chars so just the numbers are compared.
1414 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1414 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1415 ownerName = (*iter).formattedName(); 1415 ownerName = (*iter).formattedName();
1416 found = true; 1416 found = true;
1417 } 1417 }
1418 } 1418 }
1419 } 1419 }
1420 1420
1421 return ownerName; 1421 return ownerName;
1422#else //KAB_EMBEDDED 1422#else //KAB_EMBEDDED
1423 qDebug("KABCore::getNameByPhone finsih method"); 1423 qDebug("KABCore::getNameByPhone finsih method");
1424 return ""; 1424 return "";
1425#endif //KAB_EMBEDDED 1425#endif //KAB_EMBEDDED
1426 1426
1427} 1427}
1428 1428
1429void KABCore::openConfigDialog() 1429void KABCore::openConfigDialog()
1430{ 1430{
1431 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1431 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1432 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1432 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1433 ConfigureDialog->addModule(kabcfg ); 1433 ConfigureDialog->addModule(kabcfg );
1434 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1434 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1435 ConfigureDialog->addModule(kdelibcfg ); 1435 ConfigureDialog->addModule(kdelibcfg );
1436 1436
1437 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1437 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1438 this, SLOT( configurationChanged() ) ); 1438 this, SLOT( configurationChanged() ) );
1439 connect( ConfigureDialog, SIGNAL( okClicked() ), 1439 connect( ConfigureDialog, SIGNAL( okClicked() ),
1440 this, SLOT( configurationChanged() ) ); 1440 this, SLOT( configurationChanged() ) );
1441 saveSettings(); 1441 saveSettings();
1442#ifndef DESKTOP_VERSION 1442#ifndef DESKTOP_VERSION
1443 ConfigureDialog->showMaximized(); 1443 ConfigureDialog->showMaximized();
1444#endif 1444#endif
1445 if ( ConfigureDialog->exec() ) 1445 if ( ConfigureDialog->exec() )
1446 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1446 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1447 delete ConfigureDialog; 1447 delete ConfigureDialog;
1448} 1448}
1449 1449
1450void KABCore::openLDAPDialog() 1450void KABCore::openLDAPDialog()
1451{ 1451{
1452#ifndef KAB_EMBEDDED 1452#ifndef KAB_EMBEDDED
1453 if ( !mLdapSearchDialog ) { 1453 if ( !mLdapSearchDialog ) {
1454 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1454 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1455 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1455 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1456 SLOT( refreshView() ) ); 1456 SLOT( refreshView() ) );
1457 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1457 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1458 SLOT( setModified() ) ); 1458 SLOT( setModified() ) );
1459 } else 1459 } else
1460 mLdapSearchDialog->restoreSettings(); 1460 mLdapSearchDialog->restoreSettings();
1461 1461
1462 if ( mLdapSearchDialog->isOK() ) 1462 if ( mLdapSearchDialog->isOK() )
1463 mLdapSearchDialog->exec(); 1463 mLdapSearchDialog->exec();
1464#else //KAB_EMBEDDED 1464#else //KAB_EMBEDDED
1465 qDebug("KABCore::openLDAPDialog() finsih method"); 1465 qDebug("KABCore::openLDAPDialog() finsih method");
1466#endif //KAB_EMBEDDED 1466#endif //KAB_EMBEDDED
1467} 1467}
1468 1468
1469void KABCore::print() 1469void KABCore::print()
1470{ 1470{
1471#ifndef KAB_EMBEDDED 1471#ifndef KAB_EMBEDDED
1472 KPrinter printer; 1472 KPrinter printer;
1473 if ( !printer.setup( this ) ) 1473 if ( !printer.setup( this ) )
1474 return; 1474 return;
1475 1475
1476 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1476 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1477 mViewManager->selectedUids(), this ); 1477 mViewManager->selectedUids(), this );
1478 1478
1479 wizard.exec(); 1479 wizard.exec();
1480#else //KAB_EMBEDDED 1480#else //KAB_EMBEDDED
1481 qDebug("KABCore::print() finsih method"); 1481 qDebug("KABCore::print() finsih method");
1482#endif //KAB_EMBEDDED 1482#endif //KAB_EMBEDDED
1483 1483
1484} 1484}
1485 1485
1486 1486
1487void KABCore::addGUIClient( KXMLGUIClient *client ) 1487void KABCore::addGUIClient( KXMLGUIClient *client )
1488{ 1488{
1489 if ( mGUIClient ) 1489 if ( mGUIClient )
1490 mGUIClient->insertChildClient( client ); 1490 mGUIClient->insertChildClient( client );
1491 else 1491 else
1492 KMessageBox::error( this, "no KXMLGUICLient"); 1492 KMessageBox::error( this, "no KXMLGUICLient");
1493} 1493}
1494 1494
1495 1495
1496void KABCore::configurationChanged() 1496void KABCore::configurationChanged()
1497{ 1497{
1498 mExtensionManager->reconfigure(); 1498 mExtensionManager->reconfigure();
1499} 1499}
1500 1500
1501void KABCore::addressBookChanged() 1501void KABCore::addressBookChanged()
1502{ 1502{
1503/*US 1503/*US
1504 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1504 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1505 while ( it.current() ) { 1505 while ( it.current() ) {
1506 if ( it.current()->dirty() ) { 1506 if ( it.current()->dirty() ) {
1507 QString text = i18n( "Data has been changed externally. Unsaved " 1507 QString text = i18n( "Data has been changed externally. Unsaved "
1508 "changes will be lost." ); 1508 "changes will be lost." );
1509 KMessageBox::information( this, text ); 1509 KMessageBox::information( this, text );
1510 } 1510 }
1511 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1511 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1512 ++it; 1512 ++it;
1513 } 1513 }
1514*/ 1514*/
1515 if (mEditorDialog) 1515 if (mEditorDialog)
1516 { 1516 {
1517 if (mEditorDialog->dirty()) 1517 if (mEditorDialog->dirty())
1518 { 1518 {
1519 QString text = i18n( "Data has been changed externally. Unsaved " 1519 QString text = i18n( "Data has been changed externally. Unsaved "
1520 "changes will be lost." ); 1520 "changes will be lost." );
1521 KMessageBox::information( this, text ); 1521 KMessageBox::information( this, text );
1522 } 1522 }
1523 QString currentuid = mEditorDialog->addressee().uid(); 1523 QString currentuid = mEditorDialog->addressee().uid();
1524 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1524 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1525 } 1525 }
1526 mViewManager->refreshView(); 1526 mViewManager->refreshView();
1527// mDetails->refreshView(); 1527// mDetails->refreshView();
1528 1528
1529 1529
1530} 1530}
1531 1531
1532AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1532AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1533 const char *name ) 1533 const char *name )
1534{ 1534{
1535 1535
1536 if ( mEditorDialog == 0 ) { 1536 if ( mEditorDialog == 0 ) {
1537 mEditorDialog = new AddresseeEditorDialog( this, parent, 1537 mEditorDialog = new AddresseeEditorDialog( this, parent,
1538 name ? name : "editorDialog" ); 1538 name ? name : "editorDialog" );
1539 1539
1540 1540
1541 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1541 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1542 SLOT( contactModified( const KABC::Addressee& ) ) ); 1542 SLOT( contactModified( const KABC::Addressee& ) ) );
1543 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1543 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1544 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1544 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1545 } 1545 }
1546 1546
1547 return mEditorDialog; 1547 return mEditorDialog;
1548} 1548}
1549 1549
1550void KABCore::slotEditorDestroyed( const QString &uid ) 1550void KABCore::slotEditorDestroyed( const QString &uid )
1551{ 1551{
1552 //mEditorDict.remove( uid ); 1552 //mEditorDict.remove( uid );
1553} 1553}
1554 1554
1555void KABCore::initGUI() 1555void KABCore::initGUI()
1556{ 1556{
1557#ifndef KAB_EMBEDDED 1557#ifndef KAB_EMBEDDED
1558 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1558 QHBoxLayout *topLayout = new QHBoxLayout( this );
1559 topLayout->setSpacing( KDialogBase::spacingHint() ); 1559 topLayout->setSpacing( KDialogBase::spacingHint() );
1560 1560
1561 mExtensionBarSplitter = new QSplitter( this ); 1561 mExtensionBarSplitter = new QSplitter( this );
1562 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1562 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1563 1563
1564 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1564 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1565 1565
1566 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1566 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1567 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1567 mIncSearchWidget = new IncSearchWidget( viewSpace );
1568 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1568 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1569 SLOT( incrementalSearch( const QString& ) ) ); 1569 SLOT( incrementalSearch( const QString& ) ) );
1570 1570
1571 mViewManager = new ViewManager( this, viewSpace ); 1571 mViewManager = new ViewManager( this, viewSpace );
1572 viewSpace->setStretchFactor( mViewManager, 1 ); 1572 viewSpace->setStretchFactor( mViewManager, 1 );
1573 1573
1574 mDetails = new ViewContainer( mDetailsSplitter ); 1574 mDetails = new ViewContainer( mDetailsSplitter );
1575 1575
1576 mJumpButtonBar = new JumpButtonBar( this, this ); 1576 mJumpButtonBar = new JumpButtonBar( this, this );
1577 1577
1578 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1578 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1579 1579
1580 topLayout->addWidget( mExtensionBarSplitter ); 1580 topLayout->addWidget( mExtensionBarSplitter );
1581 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1581 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1582 topLayout->addWidget( mJumpButtonBar ); 1582 topLayout->addWidget( mJumpButtonBar );
1583 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1583 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1584 1584
1585 mXXPortManager = new XXPortManager( this, this ); 1585 mXXPortManager = new XXPortManager( this, this );
1586 1586
1587#else //KAB_EMBEDDED 1587#else //KAB_EMBEDDED
1588 //US initialize viewMenu before settingup viewmanager. 1588 //US initialize viewMenu before settingup viewmanager.
1589 // Viewmanager needs this menu to plugin submenues. 1589 // Viewmanager needs this menu to plugin submenues.
1590 viewMenu = new QPopupMenu( this ); 1590 viewMenu = new QPopupMenu( this );
1591 settingsMenu = new QPopupMenu( this ); 1591 settingsMenu = new QPopupMenu( this );
1592 //filterMenu = new QPopupMenu( this ); 1592 //filterMenu = new QPopupMenu( this );
1593 ImportMenu = new QPopupMenu( this ); 1593 ImportMenu = new QPopupMenu( this );
1594 ExportMenu = new QPopupMenu( this ); 1594 ExportMenu = new QPopupMenu( this );
1595 syncMenu = new QPopupMenu( this ); 1595 syncMenu = new QPopupMenu( this );
1596 changeMenu= new QPopupMenu( this ); 1596 changeMenu= new QPopupMenu( this );
1597 1597
1598//US since we have no splitter for the embedded system, setup 1598//US since we have no splitter for the embedded system, setup
1599// a layout with two frames. One left and one right. 1599// a layout with two frames. One left and one right.
1600 1600
1601 QBoxLayout *topLayout; 1601 QBoxLayout *topLayout;
1602 1602
1603 // = new QHBoxLayout( this ); 1603 // = new QHBoxLayout( this );
1604// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1604// QBoxLayout *topLayout = (QBoxLayout*)layout();
1605 1605
1606// QWidget *mainBox = new QWidget( this ); 1606// QWidget *mainBox = new QWidget( this );
1607// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1607// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1608 1608
1609#ifdef DESKTOP_VERSION 1609#ifdef DESKTOP_VERSION
1610 topLayout = new QHBoxLayout( this ); 1610 topLayout = new QHBoxLayout( this );
1611 1611
1612 1612
1613 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1613 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1614 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1614 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1615 1615
1616 topLayout->addWidget(mMiniSplitter ); 1616 topLayout->addWidget(mMiniSplitter );
1617 1617
1618 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1618 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1619 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1619 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1620 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1620 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1621 mDetails = new ViewContainer( mMiniSplitter ); 1621 mDetails = new ViewContainer( mMiniSplitter );
1622 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1622 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1623#else 1623#else
1624 if ( QApplication::desktop()->width() > 480 ) { 1624 if ( QApplication::desktop()->width() > 480 ) {
1625 topLayout = new QHBoxLayout( this ); 1625 topLayout = new QHBoxLayout( this );
1626 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1626 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1627 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1627 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1628 } else { 1628 } else {
1629 1629
1630 topLayout = new QHBoxLayout( this ); 1630 topLayout = new QHBoxLayout( this );
1631 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1631 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1632 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1632 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1633 } 1633 }
1634 1634
1635 topLayout->addWidget(mMiniSplitter ); 1635 topLayout->addWidget(mMiniSplitter );
1636 mViewManager = new ViewManager( this, mMiniSplitter ); 1636 mViewManager = new ViewManager( this, mMiniSplitter );
1637 mDetails = new ViewContainer( mMiniSplitter ); 1637 mDetails = new ViewContainer( mMiniSplitter );
1638 1638
1639 1639
1640 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1640 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1641#endif 1641#endif
1642 //eh->hide(); 1642 //eh->hide();
1643 // topLayout->addWidget(mExtensionManager ); 1643 // topLayout->addWidget(mExtensionManager );
1644 1644
1645 1645
1646/*US 1646/*US
1647#ifndef KAB_NOSPLITTER 1647#ifndef KAB_NOSPLITTER
1648 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1648 QHBoxLayout *topLayout = new QHBoxLayout( this );
1649//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1649//US topLayout->setSpacing( KDialogBase::spacingHint() );
1650 topLayout->setSpacing( 10 ); 1650 topLayout->setSpacing( 10 );
1651 1651
1652 mDetailsSplitter = new QSplitter( this ); 1652 mDetailsSplitter = new QSplitter( this );
1653 1653
1654 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1654 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1655 1655
1656 mViewManager = new ViewManager( this, viewSpace ); 1656 mViewManager = new ViewManager( this, viewSpace );
1657 viewSpace->setStretchFactor( mViewManager, 1 ); 1657 viewSpace->setStretchFactor( mViewManager, 1 );
1658 1658
1659 mDetails = new ViewContainer( mDetailsSplitter ); 1659 mDetails = new ViewContainer( mDetailsSplitter );
1660 1660
1661 topLayout->addWidget( mDetailsSplitter ); 1661 topLayout->addWidget( mDetailsSplitter );
1662 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1662 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1663#else //KAB_NOSPLITTER 1663#else //KAB_NOSPLITTER
1664 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1664 QHBoxLayout *topLayout = new QHBoxLayout( this );
1665//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1665//US topLayout->setSpacing( KDialogBase::spacingHint() );
1666 topLayout->setSpacing( 10 ); 1666 topLayout->setSpacing( 10 );
1667 1667
1668// mDetailsSplitter = new QSplitter( this ); 1668// mDetailsSplitter = new QSplitter( this );
1669 1669
1670 QVBox *viewSpace = new QVBox( this ); 1670 QVBox *viewSpace = new QVBox( this );
1671 1671
1672 mViewManager = new ViewManager( this, viewSpace ); 1672 mViewManager = new ViewManager( this, viewSpace );
1673 viewSpace->setStretchFactor( mViewManager, 1 ); 1673 viewSpace->setStretchFactor( mViewManager, 1 );
1674 1674
1675 mDetails = new ViewContainer( this ); 1675 mDetails = new ViewContainer( this );
1676 1676
1677 topLayout->addWidget( viewSpace ); 1677 topLayout->addWidget( viewSpace );
1678// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1678// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1679 topLayout->addWidget( mDetails ); 1679 topLayout->addWidget( mDetails );
1680#endif //KAB_NOSPLITTER 1680#endif //KAB_NOSPLITTER
1681*/ 1681*/
1682 1682
1683 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1683 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1684 syncManager->setBlockSave(false); 1684 syncManager->setBlockSave(false);
1685 1685
1686 connect(syncManager , SIGNAL( save() ), this, SLOT( save() ) ); 1686 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1687 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1687 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1688 syncManager->setDefaultFileName(locateLocal( "apps","kabc/std.vcf") ); 1688 syncManager->setDefaultFileName( sentSyncFile());
1689 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1689 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1690 1690
1691#endif //KAB_EMBEDDED 1691#endif //KAB_EMBEDDED
1692 initActions(); 1692 initActions();
1693 1693
1694#ifdef KAB_EMBEDDED 1694#ifdef KAB_EMBEDDED
1695 addActionsManually(); 1695 addActionsManually();
1696 //US make sure the export and import menues are initialized before creating the xxPortManager. 1696 //US make sure the export and import menues are initialized before creating the xxPortManager.
1697 mXXPortManager = new XXPortManager( this, this ); 1697 mXXPortManager = new XXPortManager( this, this );
1698 1698
1699 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1699 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1700 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1700 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1701 // mActionQuit->plug ( mMainWindow->toolBar()); 1701 // mActionQuit->plug ( mMainWindow->toolBar());
1702 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1702 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1703 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1703 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1704 // mIncSearchWidget->hide(); 1704 // mIncSearchWidget->hide();
1705 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1705 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1706 SLOT( incrementalSearch( const QString& ) ) ); 1706 SLOT( incrementalSearch( const QString& ) ) );
1707 1707
1708 1708
1709 mJumpButtonBar = new JumpButtonBar( this, this ); 1709 mJumpButtonBar = new JumpButtonBar( this, this );
1710 1710
1711 topLayout->addWidget( mJumpButtonBar ); 1711 topLayout->addWidget( mJumpButtonBar );
1712//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1712//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1713 1713
1714// mMainWindow->getIconToolBar()->raise(); 1714// mMainWindow->getIconToolBar()->raise();
1715 1715
1716#endif //KAB_EMBEDDED 1716#endif //KAB_EMBEDDED
1717 1717
1718} 1718}
1719void KABCore::initActions() 1719void KABCore::initActions()
1720{ 1720{
1721//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1721//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1722 1722
1723#ifndef KAB_EMBEDDED 1723#ifndef KAB_EMBEDDED
1724 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1724 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1725 SLOT( clipboardDataChanged() ) ); 1725 SLOT( clipboardDataChanged() ) );
1726#endif //KAB_EMBEDDED 1726#endif //KAB_EMBEDDED
1727 1727
1728 // file menu 1728 // file menu
1729 if ( mIsPart ) { 1729 if ( mIsPart ) {
1730 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1730 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1731 SLOT( sendMail() ), actionCollection(), 1731 SLOT( sendMail() ), actionCollection(),
1732 "kaddressbook_mail" ); 1732 "kaddressbook_mail" );
1733 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1733 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1734 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1734 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1735 1735
1736 } else { 1736 } else {
1737 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1737 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1738 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1738 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1739 } 1739 }
1740 1740
1741 1741
1742 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1742 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1743 SLOT( save() ), actionCollection(), "file_sync" ); 1743 SLOT( save() ), actionCollection(), "file_sync" );
1744 1744
1745 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1745 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1746 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1746 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1747 1747
1748 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1748 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1749 this, SLOT( mailVCard() ), 1749 this, SLOT( mailVCard() ),
1750 actionCollection(), "file_mail_vcard"); 1750 actionCollection(), "file_mail_vcard");
1751 1751
1752 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, 1752 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this,
1753 SLOT( export2phone() ), actionCollection(), 1753 SLOT( export2phone() ), actionCollection(),
1754 "kaddressbook_ex2phone" ); 1754 "kaddressbook_ex2phone" );
1755 1755
1756 mActionBeamVCard = 0; 1756 mActionBeamVCard = 0;
1757 mActionBeam = 0; 1757 mActionBeam = 0;
1758 1758
1759#ifndef DESKTOP_VERSION 1759#ifndef DESKTOP_VERSION
1760 if ( Ir::supported() ) { 1760 if ( Ir::supported() ) {
1761 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1761 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1762 SLOT( beamVCard() ), actionCollection(), 1762 SLOT( beamVCard() ), actionCollection(),
1763 "kaddressbook_beam_vcard" ); 1763 "kaddressbook_beam_vcard" );
1764 1764
1765 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1765 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1766 SLOT( beamMySelf() ), actionCollection(), 1766 SLOT( beamMySelf() ), actionCollection(),
1767 "kaddressbook_beam_myself" ); 1767 "kaddressbook_beam_myself" );
1768 } 1768 }
1769#endif 1769#endif
1770 1770
1771 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1771 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1772 this, SLOT( editContact2() ), 1772 this, SLOT( editContact2() ),
1773 actionCollection(), "file_properties" ); 1773 actionCollection(), "file_properties" );
1774 1774
1775#ifdef KAB_EMBEDDED 1775#ifdef KAB_EMBEDDED
1776 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1776 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1777 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1777 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1778 mMainWindow, SLOT( exit() ), 1778 mMainWindow, SLOT( exit() ),
1779 actionCollection(), "quit" ); 1779 actionCollection(), "quit" );
1780#endif //KAB_EMBEDDED 1780#endif //KAB_EMBEDDED
1781 1781
1782 // edit menu 1782 // edit menu
1783 if ( mIsPart ) { 1783 if ( mIsPart ) {
1784 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1784 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1785 SLOT( copyContacts() ), actionCollection(), 1785 SLOT( copyContacts() ), actionCollection(),
1786 "kaddressbook_copy" ); 1786 "kaddressbook_copy" );
1787 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1787 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1788 SLOT( cutContacts() ), actionCollection(), 1788 SLOT( cutContacts() ), actionCollection(),
1789 "kaddressbook_cut" ); 1789 "kaddressbook_cut" );
1790 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1790 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1791 SLOT( pasteContacts() ), actionCollection(), 1791 SLOT( pasteContacts() ), actionCollection(),
1792 "kaddressbook_paste" ); 1792 "kaddressbook_paste" );
1793 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1793 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1794 SLOT( selectAllContacts() ), actionCollection(), 1794 SLOT( selectAllContacts() ), actionCollection(),
1795 "kaddressbook_select_all" ); 1795 "kaddressbook_select_all" );
1796 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1796 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1797 SLOT( undo() ), actionCollection(), 1797 SLOT( undo() ), actionCollection(),
1798 "kaddressbook_undo" ); 1798 "kaddressbook_undo" );
1799 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1799 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1800 this, SLOT( redo() ), actionCollection(), 1800 this, SLOT( redo() ), actionCollection(),
1801 "kaddressbook_redo" ); 1801 "kaddressbook_redo" );
1802 } else { 1802 } else {
1803 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1803 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1804 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1804 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1805 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1805 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1806 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1806 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1807 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1807 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1808 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1808 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1809 } 1809 }
1810 1810
1811 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1811 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1812 Key_Delete, this, SLOT( deleteContacts() ), 1812 Key_Delete, this, SLOT( deleteContacts() ),
1813 actionCollection(), "edit_delete" ); 1813 actionCollection(), "edit_delete" );
1814 1814
1815 mActionUndo->setEnabled( false ); 1815 mActionUndo->setEnabled( false );
1816 mActionRedo->setEnabled( false ); 1816 mActionRedo->setEnabled( false );
1817 1817
1818 // settings menu 1818 // settings menu
1819#ifdef KAB_EMBEDDED 1819#ifdef KAB_EMBEDDED
1820//US special menuentry to configure the addressbook resources. On KDE 1820//US special menuentry to configure the addressbook resources. On KDE
1821// you do that through the control center !!! 1821// you do that through the control center !!!
1822 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1822 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1823 SLOT( configureResources() ), actionCollection(), 1823 SLOT( configureResources() ), actionCollection(),
1824 "kaddressbook_configure_resources" ); 1824 "kaddressbook_configure_resources" );
1825#endif //KAB_EMBEDDED 1825#endif //KAB_EMBEDDED
1826 1826
1827 if ( mIsPart ) { 1827 if ( mIsPart ) {
1828 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1828 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1829 SLOT( openConfigDialog() ), actionCollection(), 1829 SLOT( openConfigDialog() ), actionCollection(),
1830 "kaddressbook_configure" ); 1830 "kaddressbook_configure" );
1831 1831
1832 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1832 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1833 this, SLOT( configureKeyBindings() ), actionCollection(), 1833 this, SLOT( configureKeyBindings() ), actionCollection(),
1834 "kaddressbook_configure_shortcuts" ); 1834 "kaddressbook_configure_shortcuts" );
1835#ifdef KAB_EMBEDDED 1835#ifdef KAB_EMBEDDED
1836 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1836 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1837 mActionConfigureToolbars->setEnabled( false ); 1837 mActionConfigureToolbars->setEnabled( false );
1838#endif //KAB_EMBEDDED 1838#endif //KAB_EMBEDDED
1839 1839
1840 } else { 1840 } else {
1841 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1841 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1842 1842
1843 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1843 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1844 } 1844 }
1845 1845
1846 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1846 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1847 actionCollection(), "options_show_jump_bar" ); 1847 actionCollection(), "options_show_jump_bar" );
1848 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1848 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1849 1849
1850 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1850 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1851 actionCollection(), "options_show_details" ); 1851 actionCollection(), "options_show_details" );
1852 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1852 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1853 1853
1854 // misc 1854 // misc
1855 // only enable LDAP lookup if we can handle the protocol 1855 // only enable LDAP lookup if we can handle the protocol
1856#ifndef KAB_EMBEDDED 1856#ifndef KAB_EMBEDDED
1857 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1857 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1858 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1858 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1859 this, SLOT( openLDAPDialog() ), actionCollection(), 1859 this, SLOT( openLDAPDialog() ), actionCollection(),
1860 "ldap_lookup" ); 1860 "ldap_lookup" );
1861 } 1861 }
1862#else //KAB_EMBEDDED 1862#else //KAB_EMBEDDED
1863 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1863 //qDebug("KABCore::initActions() LDAP has to be implemented");
1864#endif //KAB_EMBEDDED 1864#endif //KAB_EMBEDDED
1865 1865
1866 1866
1867 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1867 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1868 SLOT( setWhoAmI() ), actionCollection(), 1868 SLOT( setWhoAmI() ), actionCollection(),
1869 "set_personal" ); 1869 "set_personal" );
1870 1870
1871 1871
1872 1872
1873 1873
1874 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1874 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1875 SLOT( setCategories() ), actionCollection(), 1875 SLOT( setCategories() ), actionCollection(),
1876 "edit_set_categories" ); 1876 "edit_set_categories" );
1877 1877
1878 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1878 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1879 SLOT( removeVoice() ), actionCollection(), 1879 SLOT( removeVoice() ), actionCollection(),
1880 "remove_voice" ); 1880 "remove_voice" );
1881 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 1881 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
1882 SLOT( importFromOL() ), actionCollection(), 1882 SLOT( importFromOL() ), actionCollection(),
1883 "import_OL" ); 1883 "import_OL" );
1884#ifdef KAB_EMBEDDED 1884#ifdef KAB_EMBEDDED
1885 mActionLicence = new KAction( i18n( "Licence" ), 0, 1885 mActionLicence = new KAction( i18n( "Licence" ), 0,
1886 this, SLOT( showLicence() ), actionCollection(), 1886 this, SLOT( showLicence() ), actionCollection(),
1887 "licence_about_data" ); 1887 "licence_about_data" );
1888 mActionFaq = new KAction( i18n( "Faq" ), 0, 1888 mActionFaq = new KAction( i18n( "Faq" ), 0,
1889 this, SLOT( faq() ), actionCollection(), 1889 this, SLOT( faq() ), actionCollection(),
1890 "faq_about_data" ); 1890 "faq_about_data" );
1891 1891
1892 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1892 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1893 this, SLOT( createAboutData() ), actionCollection(), 1893 this, SLOT( createAboutData() ), actionCollection(),
1894 "kaddressbook_about_data" ); 1894 "kaddressbook_about_data" );
1895#endif //KAB_EMBEDDED 1895#endif //KAB_EMBEDDED
1896 1896
1897 clipboardDataChanged(); 1897 clipboardDataChanged();
1898 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1898 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1899 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1899 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1900} 1900}
1901 1901
1902//US we need this function, to plug all actions into the correct menues. 1902//US we need this function, to plug all actions into the correct menues.
1903// KDE uses a XML format to plug the actions, but we work her without this overhead. 1903// KDE uses a XML format to plug the actions, but we work her without this overhead.
1904void KABCore::addActionsManually() 1904void KABCore::addActionsManually()
1905{ 1905{
1906//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1906//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1907 1907
1908#ifdef KAB_EMBEDDED 1908#ifdef KAB_EMBEDDED
1909 QPopupMenu *fileMenu = new QPopupMenu( this ); 1909 QPopupMenu *fileMenu = new QPopupMenu( this );
1910 QPopupMenu *editMenu = new QPopupMenu( this ); 1910 QPopupMenu *editMenu = new QPopupMenu( this );
1911 QPopupMenu *helpMenu = new QPopupMenu( this ); 1911 QPopupMenu *helpMenu = new QPopupMenu( this );
1912 1912
1913 KToolBar* tb = mMainWindow->toolBar(); 1913 KToolBar* tb = mMainWindow->toolBar();
1914 1914
1915#ifdef DESKTOP_VERSION 1915#ifdef DESKTOP_VERSION
1916 QMenuBar* mb = mMainWindow->menuBar(); 1916 QMenuBar* mb = mMainWindow->menuBar();
1917 1917
1918 //US setup menubar. 1918 //US setup menubar.
1919 //Disable the following block if you do not want to have a menubar. 1919 //Disable the following block if you do not want to have a menubar.
1920 mb->insertItem( "&File", fileMenu ); 1920 mb->insertItem( "&File", fileMenu );
1921 mb->insertItem( "&Edit", editMenu ); 1921 mb->insertItem( "&Edit", editMenu );
1922 mb->insertItem( "&View", viewMenu ); 1922 mb->insertItem( "&View", viewMenu );
1923 mb->insertItem( "&Settings", settingsMenu ); 1923 mb->insertItem( "&Settings", settingsMenu );
1924 mb->insertItem( i18n("Synchronize"), syncMenu ); 1924 mb->insertItem( i18n("Synchronize"), syncMenu );
1925 mb->insertItem( "&Change selected", changeMenu ); 1925 mb->insertItem( "&Change selected", changeMenu );
1926 mb->insertItem( "&Help", helpMenu ); 1926 mb->insertItem( "&Help", helpMenu );
1927 mIncSearchWidget = new IncSearchWidget( tb ); 1927 mIncSearchWidget = new IncSearchWidget( tb );
1928 // tb->insertWidget(-1, 0, mIncSearchWidget); 1928 // tb->insertWidget(-1, 0, mIncSearchWidget);
1929 1929
1930#else 1930#else
1931 //US setup toolbar 1931 //US setup toolbar
1932 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 1932 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
1933 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1933 QPopupMenu *popupBarTB = new QPopupMenu( this );
1934 menuBarTB->insertItem( "ME", popupBarTB); 1934 menuBarTB->insertItem( "ME", popupBarTB);
1935 tb->insertWidget(-1, 0, menuBarTB); 1935 tb->insertWidget(-1, 0, menuBarTB);
1936 mIncSearchWidget = new IncSearchWidget( tb ); 1936 mIncSearchWidget = new IncSearchWidget( tb );
1937 1937
1938 tb->enableMoving(false); 1938 tb->enableMoving(false);
1939 popupBarTB->insertItem( "&File", fileMenu ); 1939 popupBarTB->insertItem( "&File", fileMenu );
1940 popupBarTB->insertItem( "&Edit", editMenu ); 1940 popupBarTB->insertItem( "&Edit", editMenu );
1941 popupBarTB->insertItem( "&View", viewMenu ); 1941 popupBarTB->insertItem( "&View", viewMenu );
1942 popupBarTB->insertItem( "&Settings", settingsMenu ); 1942 popupBarTB->insertItem( "&Settings", settingsMenu );
1943 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 1943 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
1944 mViewManager->getFilterAction()->plug ( popupBarTB); 1944 mViewManager->getFilterAction()->plug ( popupBarTB);
1945 popupBarTB->insertItem( "&Change selected", changeMenu ); 1945 popupBarTB->insertItem( "&Change selected", changeMenu );
1946 popupBarTB->insertItem( "&Help", helpMenu ); 1946 popupBarTB->insertItem( "&Help", helpMenu );
1947 if (QApplication::desktop()->width() > 320 ) { 1947 if (QApplication::desktop()->width() > 320 ) {
1948 // mViewManager->getFilterAction()->plug ( tb); 1948 // mViewManager->getFilterAction()->plug ( tb);
1949 } 1949 }
1950#endif 1950#endif
1951 // mActionQuit->plug ( mMainWindow->toolBar()); 1951 // mActionQuit->plug ( mMainWindow->toolBar());
1952 1952
1953 1953
1954 1954
1955 //US Now connect the actions with the menue entries. 1955 //US Now connect the actions with the menue entries.
1956 mActionPrint->plug( fileMenu ); 1956 mActionPrint->plug( fileMenu );
1957 mActionMail->plug( fileMenu ); 1957 mActionMail->plug( fileMenu );
1958 fileMenu->insertSeparator(); 1958 fileMenu->insertSeparator();
1959 1959
1960 mActionNewContact->plug( fileMenu ); 1960 mActionNewContact->plug( fileMenu );
1961 mActionNewContact->plug( tb ); 1961 mActionNewContact->plug( tb );
1962 1962
1963 mActionEditAddressee->plug( fileMenu ); 1963 mActionEditAddressee->plug( fileMenu );
1964 if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 1964 if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
1965 (!KABPrefs::instance()->mMultipleViewsAtOnce )) 1965 (!KABPrefs::instance()->mMultipleViewsAtOnce ))
1966 mActionEditAddressee->plug( tb ); 1966 mActionEditAddressee->plug( tb );
1967 1967
1968 fileMenu->insertSeparator(); 1968 fileMenu->insertSeparator();
1969 mActionSave->plug( fileMenu ); 1969 mActionSave->plug( fileMenu );
1970 fileMenu->insertItem( "&Import", ImportMenu ); 1970 fileMenu->insertItem( "&Import", ImportMenu );
1971 fileMenu->insertItem( "&Export", ExportMenu ); 1971 fileMenu->insertItem( "&Export", ExportMenu );
1972 fileMenu->insertSeparator(); 1972 fileMenu->insertSeparator();
1973 mActionMailVCard->plug( fileMenu ); 1973 mActionMailVCard->plug( fileMenu );
1974#ifndef DESKTOP_VERSION 1974#ifndef DESKTOP_VERSION
1975 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 1975 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1976 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 1976 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
1977#endif 1977#endif
1978 fileMenu->insertSeparator(); 1978 fileMenu->insertSeparator();
1979 mActionQuit->plug( fileMenu ); 1979 mActionQuit->plug( fileMenu );
1980#ifdef _WIN32_ 1980#ifdef _WIN32_
1981 mActionImportOL->plug( ImportMenu ); 1981 mActionImportOL->plug( ImportMenu );
1982#endif 1982#endif
1983 // edit menu 1983 // edit menu
1984 mActionUndo->plug( editMenu ); 1984 mActionUndo->plug( editMenu );
1985 mActionRedo->plug( editMenu ); 1985 mActionRedo->plug( editMenu );
1986 editMenu->insertSeparator(); 1986 editMenu->insertSeparator();
1987 mActionCut->plug( editMenu ); 1987 mActionCut->plug( editMenu );
1988 mActionCopy->plug( editMenu ); 1988 mActionCopy->plug( editMenu );
1989 mActionPaste->plug( editMenu ); 1989 mActionPaste->plug( editMenu );
1990 mActionDelete->plug( editMenu ); 1990 mActionDelete->plug( editMenu );
1991 editMenu->insertSeparator(); 1991 editMenu->insertSeparator();
1992 mActionSelectAll->plug( editMenu ); 1992 mActionSelectAll->plug( editMenu );
1993 1993
1994 mActionRemoveVoice->plug( changeMenu ); 1994 mActionRemoveVoice->plug( changeMenu );
1995 // settings menu 1995 // settings menu
1996//US special menuentry to configure the addressbook resources. On KDE 1996//US special menuentry to configure the addressbook resources. On KDE
1997// you do that through the control center !!! 1997// you do that through the control center !!!
1998 mActionConfigResources->plug( settingsMenu ); 1998 mActionConfigResources->plug( settingsMenu );
1999 settingsMenu->insertSeparator(); 1999 settingsMenu->insertSeparator();
2000 2000
2001 mActionConfigKAddressbook->plug( settingsMenu ); 2001 mActionConfigKAddressbook->plug( settingsMenu );
2002 2002
2003 if ( mIsPart ) { 2003 if ( mIsPart ) {
2004 mActionConfigShortcuts->plug( settingsMenu ); 2004 mActionConfigShortcuts->plug( settingsMenu );
2005 mActionConfigureToolbars->plug( settingsMenu ); 2005 mActionConfigureToolbars->plug( settingsMenu );
2006 2006
2007 } else { 2007 } else {
2008 mActionKeyBindings->plug( settingsMenu ); 2008 mActionKeyBindings->plug( settingsMenu );
2009 } 2009 }
2010 2010
2011 settingsMenu->insertSeparator(); 2011 settingsMenu->insertSeparator();
2012 2012
2013 mActionJumpBar->plug( settingsMenu ); 2013 mActionJumpBar->plug( settingsMenu );
2014 mActionDetails->plug( settingsMenu ); 2014 mActionDetails->plug( settingsMenu );
2015 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2015 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2016 mActionDetails->plug( tb ); 2016 mActionDetails->plug( tb );
2017 settingsMenu->insertSeparator(); 2017 settingsMenu->insertSeparator();
2018 2018
2019 mActionWhoAmI->plug( settingsMenu ); 2019 mActionWhoAmI->plug( settingsMenu );
2020 mActionCategories->plug( settingsMenu ); 2020 mActionCategories->plug( settingsMenu );
2021 2021
2022 mActionLicence->plug( helpMenu ); 2022 mActionLicence->plug( helpMenu );
2023 mActionFaq->plug( helpMenu ); 2023 mActionFaq->plug( helpMenu );
2024 mActionAboutKAddressbook->plug( helpMenu ); 2024 mActionAboutKAddressbook->plug( helpMenu );
2025 2025
2026 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2026 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2027 2027
2028 mActionSave->plug( tb ); 2028 mActionSave->plug( tb );
2029 mViewManager->getFilterAction()->plug ( tb); 2029 mViewManager->getFilterAction()->plug ( tb);
2030 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 2030 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
2031 mActionUndo->plug( tb ); 2031 mActionUndo->plug( tb );
2032 mActionDelete->plug( tb ); 2032 mActionDelete->plug( tb );
2033 mActionRedo->plug( tb ); 2033 mActionRedo->plug( tb );
2034 } 2034 }
2035 } 2035 }
2036 //mActionQuit->plug ( tb ); 2036 //mActionQuit->plug ( tb );
2037 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2037 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2038 2038
2039 //US link the searchwidget first to this. 2039 //US link the searchwidget first to this.
2040 // The real linkage to the toolbar happens later. 2040 // The real linkage to the toolbar happens later.
2041//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2041//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2042//US tb->insertItem( mIncSearchWidget ); 2042//US tb->insertItem( mIncSearchWidget );
2043/*US 2043/*US
2044 mIncSearchWidget = new IncSearchWidget( tb ); 2044 mIncSearchWidget = new IncSearchWidget( tb );
2045 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2045 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2046 SLOT( incrementalSearch( const QString& ) ) ); 2046 SLOT( incrementalSearch( const QString& ) ) );
2047 2047
2048 mJumpButtonBar = new JumpButtonBar( this, this ); 2048 mJumpButtonBar = new JumpButtonBar( this, this );
2049 2049
2050//US topLayout->addWidget( mJumpButtonBar ); 2050//US topLayout->addWidget( mJumpButtonBar );
2051 this->layout()->add( mJumpButtonBar ); 2051 this->layout()->add( mJumpButtonBar );
2052*/ 2052*/
2053 2053
2054#endif //KAB_EMBEDDED 2054#endif //KAB_EMBEDDED
2055 2055
2056 mActionExport2phone->plug( ExportMenu ); 2056 mActionExport2phone->plug( ExportMenu );
2057 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2057 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2058 syncManager->fillSyncMenu(); 2058 syncManager->fillSyncMenu();
2059 2059
2060} 2060}
2061void KABCore::showLicence() 2061void KABCore::showLicence()
2062{ 2062{
2063 KApplication::showLicence(); 2063 KApplication::showLicence();
2064} 2064}
2065void KABCore::removeVoice() 2065void KABCore::removeVoice()
2066{ 2066{
2067 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2067 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2068 return; 2068 return;
2069 KABC::Addressee::List list = mViewManager->selectedAddressees(); 2069 KABC::Addressee::List list = mViewManager->selectedAddressees();
2070 KABC::Addressee::List::Iterator it; 2070 KABC::Addressee::List::Iterator it;
2071 for ( it = list.begin(); it != list.end(); ++it ) { 2071 for ( it = list.begin(); it != list.end(); ++it ) {
2072 PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); 2072 PhoneNumber::List phoneNumbers = (*it).phoneNumbers();
@@ -2481,391 +2481,401 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2481 int addedAddresseeR = 0; 2481 int addedAddresseeR = 0;
2482 int deletedAddresseeR = 0; 2482 int deletedAddresseeR = 0;
2483 int deletedAddresseeL = 0; 2483 int deletedAddresseeL = 0;
2484 int changedLocal = 0; 2484 int changedLocal = 0;
2485 int changedRemote = 0; 2485 int changedRemote = 0;
2486 2486
2487 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2487 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2488 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2488 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2489 2489
2490 //QPtrList<Addressee> el = local->rawAddressees(); 2490 //QPtrList<Addressee> el = local->rawAddressees();
2491 Addressee addresseeR; 2491 Addressee addresseeR;
2492 QString uid; 2492 QString uid;
2493 int take; 2493 int take;
2494 Addressee addresseeL; 2494 Addressee addresseeL;
2495 Addressee addresseeRSync; 2495 Addressee addresseeRSync;
2496 Addressee addresseeLSync; 2496 Addressee addresseeLSync;
2497 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2497 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2498 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2498 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2499 bool fullDateRange = false; 2499 bool fullDateRange = false;
2500 local->resetTempSyncStat(); 2500 local->resetTempSyncStat();
2501 mLastAddressbookSync = QDateTime::currentDateTime(); 2501 mLastAddressbookSync = QDateTime::currentDateTime();
2502 QDateTime modifiedCalendar = mLastAddressbookSync;; 2502 QDateTime modifiedCalendar = mLastAddressbookSync;;
2503 addresseeLSync = getLastSyncAddressee(); 2503 addresseeLSync = getLastSyncAddressee();
2504 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2504 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2505 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2505 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2506 if ( !addresseeR.isEmpty() ) { 2506 if ( !addresseeR.isEmpty() ) {
2507 addresseeRSync = addresseeR; 2507 addresseeRSync = addresseeR;
2508 remote->removeAddressee(addresseeR ); 2508 remote->removeAddressee(addresseeR );
2509 2509
2510 } else { 2510 } else {
2511 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2511 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2512 addresseeRSync = addresseeLSync ; 2512 addresseeRSync = addresseeLSync ;
2513 } else { 2513 } else {
2514 qDebug("FULLDATE 1"); 2514 qDebug("FULLDATE 1");
2515 fullDateRange = true; 2515 fullDateRange = true;
2516 Addressee newAdd; 2516 Addressee newAdd;
2517 addresseeRSync = newAdd; 2517 addresseeRSync = newAdd;
2518 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2518 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2519 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2519 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2520 addresseeRSync.setRevision( mLastAddressbookSync ); 2520 addresseeRSync.setRevision( mLastAddressbookSync );
2521 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2521 addresseeRSync.setCategories( i18n("SyncAddressee") );
2522 } 2522 }
2523 } 2523 }
2524 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2524 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2525 qDebug("FULLDATE 2"); 2525 qDebug("FULLDATE 2");
2526 fullDateRange = true; 2526 fullDateRange = true;
2527 } 2527 }
2528 if ( ! fullDateRange ) { 2528 if ( ! fullDateRange ) {
2529 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2529 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2530 2530
2531 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2531 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2532 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2532 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2533 fullDateRange = true; 2533 fullDateRange = true;
2534 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2534 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2535 } 2535 }
2536 } 2536 }
2537 // fullDateRange = true; // debug only! 2537 // fullDateRange = true; // debug only!
2538 if ( fullDateRange ) 2538 if ( fullDateRange )
2539 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2539 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2540 else 2540 else
2541 mLastAddressbookSync = addresseeLSync.revision(); 2541 mLastAddressbookSync = addresseeLSync.revision();
2542 // for resyncing if own file has changed 2542 // for resyncing if own file has changed
2543 // PENDING fixme later when implemented 2543 // PENDING fixme later when implemented
2544#if 0 2544#if 0
2545 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2545 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2546 mLastAddressbookSync = loadedFileVersion; 2546 mLastAddressbookSync = loadedFileVersion;
2547 qDebug("setting mLastAddressbookSync "); 2547 qDebug("setting mLastAddressbookSync ");
2548 } 2548 }
2549#endif 2549#endif
2550 2550
2551 //qDebug("*************************** "); 2551 //qDebug("*************************** ");
2552 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2552 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2553 QStringList er = remote->uidList(); 2553 QStringList er = remote->uidList();
2554 Addressee inR ;//= er.first(); 2554 Addressee inR ;//= er.first();
2555 Addressee inL; 2555 Addressee inL;
2556 2556
2557 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2557 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2558 2558
2559 int modulo = (er.count()/10)+1; 2559 int modulo = (er.count()/10)+1;
2560 int incCounter = 0; 2560 int incCounter = 0;
2561 while ( incCounter < er.count()) { 2561 while ( incCounter < er.count()) {
2562 if (syncManager->isProgressBarCanceled()) 2562 if (syncManager->isProgressBarCanceled())
2563 return false; 2563 return false;
2564 if ( incCounter % modulo == 0 ) 2564 if ( incCounter % modulo == 0 )
2565 syncManager->showProgressBar(incCounter); 2565 syncManager->showProgressBar(incCounter);
2566 2566
2567 uid = er[ incCounter ]; 2567 uid = er[ incCounter ];
2568 bool skipIncidence = false; 2568 bool skipIncidence = false;
2569 if ( uid.left(19) == QString("last-syncAddressee-") ) 2569 if ( uid.left(19) == QString("last-syncAddressee-") )
2570 skipIncidence = true; 2570 skipIncidence = true;
2571 QString idS,OidS; 2571 QString idS,OidS;
2572 qApp->processEvents(); 2572 qApp->processEvents();
2573 if ( !skipIncidence ) { 2573 if ( !skipIncidence ) {
2574 inL = local->findByUid( uid ); 2574 inL = local->findByUid( uid );
2575 inR = remote->findByUid( uid ); 2575 inR = remote->findByUid( uid );
2576 //inL.setResource( 0 ); 2576 //inL.setResource( 0 );
2577 //inR.setResource( 0 ); 2577 //inR.setResource( 0 );
2578 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2578 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2579 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { 2579 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
2580 //qDebug("take %d %s ", take, inL.summary().latin1()); 2580 //qDebug("take %d %s ", take, inL.summary().latin1());
2581 if ( take == 3 ) 2581 if ( take == 3 )
2582 return false; 2582 return false;
2583 if ( take == 1 ) {// take local 2583 if ( take == 1 ) {// take local
2584 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2584 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2585 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2585 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2586 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2586 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2587 local->insertAddressee( inL, false ); 2587 local->insertAddressee( inL, false );
2588 idS = inR.externalUID(); 2588 idS = inR.externalUID();
2589 OidS = inR.originalExternalUID(); 2589 OidS = inR.originalExternalUID();
2590 } 2590 }
2591 else 2591 else
2592 idS = inR.IDStr(); 2592 idS = inR.IDStr();
2593 remote->removeAddressee( inR ); 2593 remote->removeAddressee( inR );
2594 inR = inL; 2594 inR = inL;
2595 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2595 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2596 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2596 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2597 inR.setOriginalExternalUID( OidS ); 2597 inR.setOriginalExternalUID( OidS );
2598 inR.setExternalUID( idS ); 2598 inR.setExternalUID( idS );
2599 } else { 2599 } else {
2600 inR.setIDStr( idS ); 2600 inR.setIDStr( idS );
2601 } 2601 }
2602 inR.setResource( 0 ); 2602 inR.setResource( 0 );
2603 remote->insertAddressee( inR , false); 2603 remote->insertAddressee( inR , false);
2604 ++changedRemote; 2604 ++changedRemote;
2605 } else { // take == 2 take remote 2605 } else { // take == 2 take remote
2606 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2606 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2607 if ( inR.revision().date().year() < 2004 ) 2607 if ( inR.revision().date().year() < 2004 )
2608 inR.setRevision( modifiedCalendar ); 2608 inR.setRevision( modifiedCalendar );
2609 } 2609 }
2610 idS = inL.IDStr(); 2610 idS = inL.IDStr();
2611 local->removeAddressee( inL ); 2611 local->removeAddressee( inL );
2612 inL = inR; 2612 inL = inR;
2613 inL.setIDStr( idS ); 2613 inL.setIDStr( idS );
2614 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2614 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2615 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2615 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2616 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2616 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2617 } 2617 }
2618 inL.setResource( 0 ); 2618 inL.setResource( 0 );
2619 local->insertAddressee( inL , false ); 2619 local->insertAddressee( inL , false );
2620 ++changedLocal; 2620 ++changedLocal;
2621 } 2621 }
2622 } 2622 }
2623 } else { // no conflict 2623 } else { // no conflict
2624 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2624 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2625 QString des = addresseeLSync.note(); 2625 QString des = addresseeLSync.note();
2626 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2626 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2627 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2627 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2628 remote->insertAddressee( inR, false ); 2628 remote->insertAddressee( inR, false );
2629 ++deletedAddresseeR; 2629 ++deletedAddresseeR;
2630 } else { 2630 } else {
2631 inR.setRevision( modifiedCalendar ); 2631 inR.setRevision( modifiedCalendar );
2632 remote->insertAddressee( inR, false ); 2632 remote->insertAddressee( inR, false );
2633 inL = inR; 2633 inL = inR;
2634 inL.setResource( 0 ); 2634 inL.setResource( 0 );
2635 local->insertAddressee( inL , false); 2635 local->insertAddressee( inL , false);
2636 ++addedAddressee; 2636 ++addedAddressee;
2637 } 2637 }
2638 } else { 2638 } else {
2639 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2639 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2640 inR.setRevision( modifiedCalendar ); 2640 inR.setRevision( modifiedCalendar );
2641 remote->insertAddressee( inR, false ); 2641 remote->insertAddressee( inR, false );
2642 inR.setResource( 0 ); 2642 inR.setResource( 0 );
2643 local->insertAddressee( inR, false ); 2643 local->insertAddressee( inR, false );
2644 ++addedAddressee; 2644 ++addedAddressee;
2645 } else { 2645 } else {
2646 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2646 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2647 remote->removeAddressee( inR ); 2647 remote->removeAddressee( inR );
2648 ++deletedAddresseeR; 2648 ++deletedAddresseeR;
2649 } 2649 }
2650 } 2650 }
2651 } 2651 }
2652 } 2652 }
2653 ++incCounter; 2653 ++incCounter;
2654 } 2654 }
2655 er.clear(); 2655 er.clear();
2656 QStringList el = local->uidList(); 2656 QStringList el = local->uidList();
2657 modulo = (el.count()/10)+1; 2657 modulo = (el.count()/10)+1;
2658 2658
2659 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2659 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2660 incCounter = 0; 2660 incCounter = 0;
2661 while ( incCounter < el.count()) { 2661 while ( incCounter < el.count()) {
2662 qApp->processEvents(); 2662 qApp->processEvents();
2663 if (syncManager->isProgressBarCanceled()) 2663 if (syncManager->isProgressBarCanceled())
2664 return false; 2664 return false;
2665 if ( incCounter % modulo == 0 ) 2665 if ( incCounter % modulo == 0 )
2666 syncManager->showProgressBar(incCounter); 2666 syncManager->showProgressBar(incCounter);
2667 uid = el[ incCounter ]; 2667 uid = el[ incCounter ];
2668 bool skipIncidence = false; 2668 bool skipIncidence = false;
2669 if ( uid.left(19) == QString("last-syncAddressee-") ) 2669 if ( uid.left(19) == QString("last-syncAddressee-") )
2670 skipIncidence = true; 2670 skipIncidence = true;
2671 if ( !skipIncidence ) { 2671 if ( !skipIncidence ) {
2672 inL = local->findByUid( uid ); 2672 inL = local->findByUid( uid );
2673 inR = remote->findByUid( uid ); 2673 inR = remote->findByUid( uid );
2674 if ( inR.isEmpty() ) { 2674 if ( inR.isEmpty() ) {
2675 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2675 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2676 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2676 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2677 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2677 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2678 local->removeAddressee( inL ); 2678 local->removeAddressee( inL );
2679 ++deletedAddresseeL; 2679 ++deletedAddresseeL;
2680 } else { 2680 } else {
2681 if ( ! syncManager->mWriteBackExistingOnly ) { 2681 if ( ! syncManager->mWriteBackExistingOnly ) {
2682 inL.removeID(mCurrentSyncDevice ); 2682 inL.removeID(mCurrentSyncDevice );
2683 ++addedAddresseeR; 2683 ++addedAddresseeR;
2684 inL.setRevision( modifiedCalendar ); 2684 inL.setRevision( modifiedCalendar );
2685 local->insertAddressee( inL, false ); 2685 local->insertAddressee( inL, false );
2686 inR = inL; 2686 inR = inL;
2687 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2687 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2688 inR.setResource( 0 ); 2688 inR.setResource( 0 );
2689 remote->insertAddressee( inR, false ); 2689 remote->insertAddressee( inR, false );
2690 } 2690 }
2691 } 2691 }
2692 } else { 2692 } else {
2693 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2693 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2694 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2694 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2695 local->removeAddressee( inL ); 2695 local->removeAddressee( inL );
2696 ++deletedAddresseeL; 2696 ++deletedAddresseeL;
2697 } else { 2697 } else {
2698 if ( ! syncManager->mWriteBackExistingOnly ) { 2698 if ( ! syncManager->mWriteBackExistingOnly ) {
2699 ++addedAddresseeR; 2699 ++addedAddresseeR;
2700 inL.setRevision( modifiedCalendar ); 2700 inL.setRevision( modifiedCalendar );
2701 local->insertAddressee( inL, false ); 2701 local->insertAddressee( inL, false );
2702 inR = inL; 2702 inR = inL;
2703 inR.setResource( 0 ); 2703 inR.setResource( 0 );
2704 remote->insertAddressee( inR, false ); 2704 remote->insertAddressee( inR, false );
2705 } 2705 }
2706 } 2706 }
2707 } 2707 }
2708 } 2708 }
2709 } 2709 }
2710 ++incCounter; 2710 ++incCounter;
2711 } 2711 }
2712 el.clear(); 2712 el.clear();
2713 syncManager->hideProgressBar(); 2713 syncManager->hideProgressBar();
2714 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2714 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2715 // get rid of micro seconds 2715 // get rid of micro seconds
2716 QTime t = mLastAddressbookSync.time(); 2716 QTime t = mLastAddressbookSync.time();
2717 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2717 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2718 addresseeLSync.setRevision( mLastAddressbookSync ); 2718 addresseeLSync.setRevision( mLastAddressbookSync );
2719 addresseeRSync.setRevision( mLastAddressbookSync ); 2719 addresseeRSync.setRevision( mLastAddressbookSync );
2720 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2720 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2721 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2721 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2722 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2722 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2723 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2723 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2724 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2724 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2725 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2725 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2726 addresseeRSync.setNote( "" ) ; 2726 addresseeRSync.setNote( "" ) ;
2727 addresseeLSync.setNote( "" ); 2727 addresseeLSync.setNote( "" );
2728 2728
2729 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2729 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2730 remote->insertAddressee( addresseeRSync, false ); 2730 remote->insertAddressee( addresseeRSync, false );
2731 local->insertAddressee( addresseeLSync, false ); 2731 local->insertAddressee( addresseeLSync, false );
2732 QString mes; 2732 QString mes;
2733 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2733 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2734 if ( syncManager->mShowSyncSummary ) { 2734 if ( syncManager->mShowSyncSummary ) {
2735 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2735 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2736 } 2736 }
2737 qDebug( mes ); 2737 qDebug( mes );
2738 return syncOK; 2738 return syncOK;
2739} 2739}
2740 2740
2741 2741
2742//this is a overwritten callbackmethods from the syncinterface 2742//this is a overwritten callbackmethods from the syncinterface
2743bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2743bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2744{ 2744{
2745 2745
2746 //pending prepare addresseeview for output 2746 //pending prepare addresseeview for output
2747 //pending detect, if remote file has REV field. if not switch to external sync 2747 //pending detect, if remote file has REV field. if not switch to external sync
2748 mGlobalSyncMode = SYNC_MODE_NORMAL; 2748 mGlobalSyncMode = SYNC_MODE_NORMAL;
2749 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2749 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2750 2750
2751 AddressBook abLocal(filename,"syncContact"); 2751 AddressBook abLocal(filename,"syncContact");
2752 bool syncOK = false; 2752 bool syncOK = false;
2753 if ( abLocal.load() ) { 2753 if ( abLocal.load() ) {
2754 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2754 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2755 bool external = false; 2755 bool external = false;
2756 bool isXML = false; 2756 bool isXML = false;
2757 if ( filename.right(4) == ".xml") { 2757 if ( filename.right(4) == ".xml") {
2758 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2758 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2759 isXML = true; 2759 isXML = true;
2760 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2760 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2761 } else { 2761 } else {
2762 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2762 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2763 if ( ! lse.isEmpty() ) { 2763 if ( ! lse.isEmpty() ) {
2764 if ( lse.familyName().left(4) == "!E: " ) 2764 if ( lse.familyName().left(4) == "!E: " )
2765 external = true; 2765 external = true;
2766 } else { 2766 } else {
2767 bool found = false; 2767 bool found = false;
2768 AddressBook::Iterator it; 2768 AddressBook::Iterator it;
2769 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2769 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2770 if ( (*it).revision().date().year() > 2003 ) { 2770 if ( (*it).revision().date().year() > 2003 ) {
2771 found = true; 2771 found = true;
2772 break; 2772 break;
2773 } 2773 }
2774 } 2774 }
2775 external = ! found; 2775 external = ! found;
2776 } 2776 }
2777 2777
2778 if ( external ) { 2778 if ( external ) {
2779 qDebug("Setting vcf mode to external "); 2779 qDebug("Setting vcf mode to external ");
2780 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2780 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2781 AddressBook::Iterator it; 2781 AddressBook::Iterator it;
2782 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2782 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2783 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2783 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2784 (*it).computeCsum( mCurrentSyncDevice ); 2784 (*it).computeCsum( mCurrentSyncDevice );
2785 } 2785 }
2786 } 2786 }
2787 } 2787 }
2788 //AddressBook::Iterator it; 2788 //AddressBook::Iterator it;
2789 //QStringList vcards; 2789 //QStringList vcards;
2790 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2790 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2791 // qDebug("Name %s ", (*it).familyName().latin1()); 2791 // qDebug("Name %s ", (*it).familyName().latin1());
2792 //} 2792 //}
2793 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2793 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2794 if ( syncOK ) { 2794 if ( syncOK ) {
2795 if ( syncManager->mWriteBackFile ) 2795 if ( syncManager->mWriteBackFile )
2796 { 2796 {
2797 if ( external ) 2797 if ( external )
2798 abLocal.removeSyncAddressees( !isXML); 2798 abLocal.removeSyncAddressees( !isXML);
2799 qDebug("Saving remote AB "); 2799 qDebug("Saving remote AB ");
2800 abLocal.saveAB(); 2800 abLocal.saveAB();
2801 if ( isXML ) { 2801 if ( isXML ) {
2802 // afterwrite processing 2802 // afterwrite processing
2803 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2803 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2804 } 2804 }
2805 } 2805 }
2806 } 2806 }
2807 setModified(); 2807 setModified();
2808 2808
2809 } 2809 }
2810 if ( syncOK ) 2810 if ( syncOK )
2811 mViewManager->refreshView(); 2811 mViewManager->refreshView();
2812 return syncOK; 2812 return syncOK;
2813#if 0 2813#if 0
2814 2814
2815 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 2815 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
2816 getEventViewerDialog()->setSyncMode( true ); 2816 getEventViewerDialog()->setSyncMode( true );
2817 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 2817 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
2818 getEventViewerDialog()->setSyncMode( false ); 2818 getEventViewerDialog()->setSyncMode( false );
2819 if ( syncOK ) { 2819 if ( syncOK ) {
2820 if ( KOPrefs::instance()->mWriteBackFile ) 2820 if ( KOPrefs::instance()->mWriteBackFile )
2821 { 2821 {
2822 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2822 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2823 storage->save(); 2823 storage->save();
2824 } 2824 }
2825 } 2825 }
2826 setModified(); 2826 setModified();
2827 } 2827 }
2828 2828
2829#endif 2829#endif
2830} 2830}
2831 2831
2832 2832
2833//this is a overwritten callbackmethods from the syncinterface 2833//this is a overwritten callbackmethods from the syncinterface
2834bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2834bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2835{ 2835{
2836 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2836 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2837 2837
2838 AddressBook abLocal( resource,"syncContact"); 2838 AddressBook abLocal( resource,"syncContact");
2839 bool syncOK = false; 2839 bool syncOK = false;
2840 if ( abLocal.load() ) { 2840 if ( abLocal.load() ) {
2841 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2841 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2842 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2842 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2843 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2843 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2844 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2844 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2845 if ( syncOK ) { 2845 if ( syncOK ) {
2846 if ( syncManager->mWriteBackFile ) { 2846 if ( syncManager->mWriteBackFile ) {
2847 abLocal.saveAB(); 2847 abLocal.saveAB();
2848 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2848 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2849 } 2849 }
2850 } 2850 }
2851 setModified(); 2851 setModified();
2852 } 2852 }
2853 if ( syncOK ) 2853 if ( syncOK )
2854 mViewManager->refreshView(); 2854 mViewManager->refreshView();
2855 return syncOK; 2855 return syncOK;
2856 2856
2857} 2857}
2858 2858
2859void KABCore::getFile( bool success ) 2859void KABCore::getFile( bool success )
2860{ 2860{
2861 if ( ! success ) { 2861 if ( ! success ) {
2862 setCaption( i18n("Error receiving file. Nothing changed!") ); 2862 setCaption( i18n("Error receiving file. Nothing changed!") );
2863 return; 2863 return;
2864 } 2864 }
2865 //mView->watchSavedFile(); 2865 mAddressBook->importFromFile( sentSyncFile() );
2866 //mView->openCalendar( defaultFileName() );
2867 // pending: reload received file!
2868 setCaption( i18n("Pi-Sync successful!") ); 2866 setCaption( i18n("Pi-Sync successful!") );
2869} 2867}
2868void KABCore::syncFileRequest()
2869{
2870 mAddressBook->export2File( sentSyncFile() );
2871}
2872QString KABCore::sentSyncFile()
2873{
2874#ifdef _WIN32_
2875 return locateLocal( "tmp", "syncab.ics" );
2876#else
2877 return QString( "/tmp/kapitempfile.vcf" );
2878#endif
2879}
2870 2880
2871 2881
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 355e828..987369d 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -1,479 +1,481 @@
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 32
33#include <qwidget.h> 33#include <qwidget.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <ksyncmanager.h> 35#include <ksyncmanager.h>
36 36
37namespace KABC { 37namespace KABC {
38class AddressBook; 38class AddressBook;
39} 39}
40 40
41#ifndef KAB_EMBEDDED 41#ifndef KAB_EMBEDDED
42class KAboutData; 42class KAboutData;
43class KConfig; 43class KConfig;
44 44
45class KAddressBookService; 45class KAddressBookService;
46class LDAPSearchDialog; 46class LDAPSearchDialog;
47#else //KAB_EMBEDDED 47#else //KAB_EMBEDDED
48class KAddressBookMain; 48class KAddressBookMain;
49//US class QAction; 49//US class QAction;
50#endif //KAB_EMBEDDED 50#endif //KAB_EMBEDDED
51class KCMultiDialog; 51class KCMultiDialog;
52class KXMLGUIClient; 52class KXMLGUIClient;
53class ExtensionManager; 53class ExtensionManager;
54class XXPortManager; 54class XXPortManager;
55class JumpButtonBar; 55class JumpButtonBar;
56class IncSearchWidget; 56class IncSearchWidget;
57class KDGanttMinimizeSplitter; 57class KDGanttMinimizeSplitter;
58class KAction; 58class KAction;
59class KActionCollection; 59class KActionCollection;
60class KToggleAction; 60class KToggleAction;
61class KSyncProfile; 61class KSyncProfile;
62 62
63class QAction; 63class QAction;
64class QMenuBar; 64class QMenuBar;
65class QSplitter; 65class QSplitter;
66class ViewContainer; 66class ViewContainer;
67class ViewManager; 67class ViewManager;
68class AddresseeEditorDialog; 68class AddresseeEditorDialog;
69class Ir; 69class Ir;
70 70
71class KABCore : public QWidget, public KSyncInterface 71class KABCore : public QWidget, public KSyncInterface
72{ 72{
73 Q_OBJECT 73 Q_OBJECT
74 74
75 public: 75 public:
76 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); 76 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 );
77 77
78 78
79 ~KABCore(); 79 ~KABCore();
80 80
81 81
82#ifdef KAB_EMBEDDED 82#ifdef KAB_EMBEDDED
83 //US added functionality 83 //US added functionality
84 QPopupMenu* getViewMenu() {return viewMenu;} 84 QPopupMenu* getViewMenu() {return viewMenu;}
85 QPopupMenu* getFilterMenu() {return filterMenu;} 85 QPopupMenu* getFilterMenu() {return filterMenu;}
86 QPopupMenu* getSettingsMenu() {return settingsMenu;} 86 QPopupMenu* getSettingsMenu() {return settingsMenu;}
87 void addActionsManually(); 87 void addActionsManually();
88#endif //KAB_EMBEDDED 88#endif //KAB_EMBEDDED
89 /** 89 /**
90 Restores the global settings. 90 Restores the global settings.
91 */ 91 */
92 void restoreSettings(); 92 void restoreSettings();
93 93
94 /** 94 /**
95 Saves the global settings. 95 Saves the global settings.
96 */ 96 */
97 void saveSettings(); 97 void saveSettings();
98 98
99 /** 99 /**
100 Returns a pointer to the StdAddressBook of the application. 100 Returns a pointer to the StdAddressBook of the application.
101 */ 101 */
102 KABC::AddressBook *addressBook() const; 102 KABC::AddressBook *addressBook() const;
103 103
104 /** 104 /**
105 Returns a pointer to the KConfig object of the application. 105 Returns a pointer to the KConfig object of the application.
106 */ 106 */
107 static KConfig *config(); 107 static KConfig *config();
108 108
109 /** 109 /**
110 Returns a pointer to the global KActionCollection object. So 110 Returns a pointer to the global KActionCollection object. So
111 other classes can register their actions easily. 111 other classes can register their actions easily.
112 */ 112 */
113 KActionCollection *actionCollection() const; 113 KActionCollection *actionCollection() const;
114 114
115 /** 115 /**
116 Returns the current search field of the Incremental Search Widget. 116 Returns the current search field of the Incremental Search Widget.
117 */ 117 */
118 KABC::Field *currentSearchField() const; 118 KABC::Field *currentSearchField() const;
119 119
120 /** 120 /**
121 Returns the uid list of the currently selected contacts. 121 Returns the uid list of the currently selected contacts.
122 */ 122 */
123 QStringList selectedUIDs() const; 123 QStringList selectedUIDs() const;
124 124
125 /** 125 /**
126 Displays the ResourceSelectDialog and returns the selected 126 Displays the ResourceSelectDialog and returns the selected
127 resource or a null pointer if no resource was selected by 127 resource or a null pointer if no resource was selected by
128 the user. 128 the user.
129 */ 129 */
130 KABC::Resource *requestResource( QWidget *parent ); 130 KABC::Resource *requestResource( QWidget *parent );
131 131
132#ifndef KAB_EMBEDDED 132#ifndef KAB_EMBEDDED
133 static KAboutData *createAboutData(); 133 static KAboutData *createAboutData();
134#endif //KAB_EMBEDDED 134#endif //KAB_EMBEDDED
135 135
136#ifdef KAB_EMBEDDED 136#ifdef KAB_EMBEDDED
137 inline QPopupMenu* getImportMenu() { return ImportMenu;} 137 inline QPopupMenu* getImportMenu() { return ImportMenu;}
138 inline QPopupMenu* getExportMenu() { return ExportMenu;} 138 inline QPopupMenu* getExportMenu() { return ExportMenu;}
139#endif //KAB_EMBEDDED 139#endif //KAB_EMBEDDED
140 140
141 public slots: 141 public slots:
142#ifdef KAB_EMBEDDED 142#ifdef KAB_EMBEDDED
143 void createAboutData(); 143 void createAboutData();
144#endif //KAB_EMBEDDED 144#endif //KAB_EMBEDDED
145 145
146 void statusMessage(QString, int time = 0 ); 146 void statusMessage(QString, int time = 0 );
147 void showLicence(); 147 void showLicence();
148 void faq(); 148 void faq();
149 149
150 /** 150 /**
151 Is called whenever a contact is selected in the view. 151 Is called whenever a contact is selected in the view.
152 */ 152 */
153 void setContactSelected( const QString &uid ); 153 void setContactSelected( const QString &uid );
154 154
155 /** 155 /**
156 Opens the preferred mail composer with all selected contacts as 156 Opens the preferred mail composer with all selected contacts as
157 arguments. 157 arguments.
158 */ 158 */
159 void sendMail(); 159 void sendMail();
160 160
161 /** 161 /**
162 Opens the preferred mail composer with the given contacts as 162 Opens the preferred mail composer with the given contacts as
163 arguments. 163 arguments.
164 */ 164 */
165 void sendMail( const QString& email ); 165 void sendMail( const QString& email );
166 166
167 167
168 void mailVCard(); 168 void mailVCard();
169 void mailVCard(const QStringList& uids); 169 void mailVCard(const QStringList& uids);
170 170
171 /** 171 /**
172 Beams the "WhoAmI contact. 172 Beams the "WhoAmI contact.
173 */ 173 */
174 void beamMySelf(); 174 void beamMySelf();
175 175
176 void beamVCard(); 176 void beamVCard();
177 void export2phone(); 177 void export2phone();
178 void beamVCard(const QStringList& uids); 178 void beamVCard(const QStringList& uids);
179 void beamDone( Ir *ir ); 179 void beamDone( Ir *ir );
180 180
181 181
182 /** 182 /**
183 Starts the preferred web browser with the given URL as argument. 183 Starts the preferred web browser with the given URL as argument.
184 */ 184 */
185 void browse( const QString& url ); 185 void browse( const QString& url );
186 186
187 /** 187 /**
188 Select all contacts in the view. 188 Select all contacts in the view.
189 */ 189 */
190 void selectAllContacts(); 190 void selectAllContacts();
191 191
192 /** 192 /**
193 Deletes all selected contacts from the address book. 193 Deletes all selected contacts from the address book.
194 */ 194 */
195 void deleteContacts(); 195 void deleteContacts();
196 196
197 /** 197 /**
198 Deletes given contacts from the address book. 198 Deletes given contacts from the address book.
199 199
200 @param uids The uids of the contacts, which shall be deleted. 200 @param uids The uids of the contacts, which shall be deleted.
201 */ 201 */
202 void deleteContacts( const QStringList &uids ); 202 void deleteContacts( const QStringList &uids );
203 203
204 /** 204 /**
205 Copys the selected contacts into clipboard for later pasting. 205 Copys the selected contacts into clipboard for later pasting.
206 */ 206 */
207 void copyContacts(); 207 void copyContacts();
208 208
209 /** 209 /**
210 Cuts the selected contacts and stores them for later pasting. 210 Cuts the selected contacts and stores them for later pasting.
211 */ 211 */
212 void cutContacts(); 212 void cutContacts();
213 213
214 /** 214 /**
215 Paste contacts from clipboard into the address book. 215 Paste contacts from clipboard into the address book.
216 */ 216 */
217 void pasteContacts(); 217 void pasteContacts();
218 218
219 /** 219 /**
220 Paste given contacts into the address book. 220 Paste given contacts into the address book.
221 221
222 @param list The list of addressee, which shall be pasted. 222 @param list The list of addressee, which shall be pasted.
223 */ 223 */
224 void pasteContacts( KABC::Addressee::List &list ); 224 void pasteContacts( KABC::Addressee::List &list );
225 225
226 /** 226 /**
227 Sets the whoAmI contact, that is used by many other programs to 227 Sets the whoAmI contact, that is used by many other programs to
228 get personal information about the current user. 228 get personal information about the current user.
229 */ 229 */
230 void setWhoAmI(); 230 void setWhoAmI();
231 231
232 /** 232 /**
233 Displays the category dialog and applies the result to all 233 Displays the category dialog and applies the result to all
234 selected contacts. 234 selected contacts.
235 */ 235 */
236 void setCategories(); 236 void setCategories();
237 237
238 /** 238 /**
239 Sets the field list of the Incremental Search Widget. 239 Sets the field list of the Incremental Search Widget.
240 */ 240 */
241 void setSearchFields( const KABC::Field::List &fields ); 241 void setSearchFields( const KABC::Field::List &fields );
242 242
243 /** 243 /**
244 Search with the current search field for a contact, that matches 244 Search with the current search field for a contact, that matches
245 the given text, and selects it in the view. 245 the given text, and selects it in the view.
246 */ 246 */
247 void incrementalSearch( const QString& text ); 247 void incrementalSearch( const QString& text );
248 248
249 /** 249 /**
250 Marks the address book as modified. 250 Marks the address book as modified.
251 */ 251 */
252 void setModified(); 252 void setModified();
253 /** 253 /**
254 Marks the address book as modified without refreshing the view. 254 Marks the address book as modified without refreshing the view.
255 */ 255 */
256 void setModifiedWOrefresh(); 256 void setModifiedWOrefresh();
257 257
258 /** 258 /**
259 Marks the address book as modified concerning the argument. 259 Marks the address book as modified concerning the argument.
260 */ 260 */
261 void setModified( bool modified ); 261 void setModified( bool modified );
262 262
263 /** 263 /**
264 Returns whether the address book is modified. 264 Returns whether the address book is modified.
265 */ 265 */
266 bool modified() const; 266 bool modified() const;
267 267
268 /** 268 /**
269 Called whenever an contact is modified in the contact editor 269 Called whenever an contact is modified in the contact editor
270 dialog or the quick edit. 270 dialog or the quick edit.
271 */ 271 */
272 void contactModified( const KABC::Addressee &addr ); 272 void contactModified( const KABC::Addressee &addr );
273 273
274 /** 274 /**
275 DCOP METHODS. 275 DCOP METHODS.
276 */ 276 */
277 void addEmail( QString addr ); 277 void addEmail( QString addr );
278 void importVCard( const KURL& url, bool showPreview ); 278 void importVCard( const KURL& url, bool showPreview );
279 void importVCard( const QString& vCard, bool showPreview ); 279 void importVCard( const QString& vCard, bool showPreview );
280 void newContact(); 280 void newContact();
281 QString getNameByPhone( const QString& phone ); 281 QString getNameByPhone( const QString& phone );
282 /** 282 /**
283 END DCOP METHODS 283 END DCOP METHODS
284 */ 284 */
285 285
286 /** 286 /**
287 Saves the contents of the AddressBook back to disk. 287 Saves the contents of the AddressBook back to disk.
288 */ 288 */
289 void save(); 289 void save();
290 290
291 /** 291 /**
292 Undos the last command using the undo stack. 292 Undos the last command using the undo stack.
293 */ 293 */
294 void undo(); 294 void undo();
295 295
296 /** 296 /**
297 Redos the last command that was undone, using the redo stack. 297 Redos the last command that was undone, using the redo stack.
298 */ 298 */
299 void redo(); 299 void redo();
300 300
301 /** 301 /**
302 Shows the edit dialog for the given uid. If the uid is QString::null, 302 Shows the edit dialog for the given uid. If the uid is QString::null,
303 the method will try to find a selected addressee in the view. 303 the method will try to find a selected addressee in the view.
304 */ 304 */
305 void editContact( const QString &uid /*US = QString::null*/ ); 305 void editContact( const QString &uid /*US = QString::null*/ );
306//US added a second method without defaultparameter 306//US added a second method without defaultparameter
307 void editContact2(); 307 void editContact2();
308 308
309 /** 309 /**
310 Shows or edits the detail view for the given uid. If the uid is QString::null, 310 Shows or edits the detail view for the given uid. If the uid is QString::null,
311 the method will try to find a selected addressee in the view. 311 the method will try to find a selected addressee in the view.
312 */ 312 */
313 void executeContact( const QString &uid /*US = QString::null*/ ); 313 void executeContact( const QString &uid /*US = QString::null*/ );
314 314
315 /** 315 /**
316 Launches the configuration dialog. 316 Launches the configuration dialog.
317 */ 317 */
318 void openConfigDialog(); 318 void openConfigDialog();
319 319
320 /** 320 /**
321 Launches the ldap search dialog. 321 Launches the ldap search dialog.
322 */ 322 */
323 void openLDAPDialog(); 323 void openLDAPDialog();
324 324
325 /** 325 /**
326 Creates a KAddressBookPrinter, which will display the print 326 Creates a KAddressBookPrinter, which will display the print
327 dialog and do the printing. 327 dialog and do the printing.
328 */ 328 */
329 void print(); 329 void print();
330 330
331 /** 331 /**
332 Registers a new GUI client, so plugins can register its actions. 332 Registers a new GUI client, so plugins can register its actions.
333 */ 333 */
334 void addGUIClient( KXMLGUIClient *client ); 334 void addGUIClient( KXMLGUIClient *client );
335 335
336 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); 336 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
337 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 337 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
338 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); 338 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid);
339 339
340 340
341 signals: 341 signals:
342 void contactSelected( const QString &name ); 342 void contactSelected( const QString &name );
343 void contactSelected( const QPixmap &pixmap ); 343 void contactSelected( const QPixmap &pixmap );
344 public slots: 344 public slots:
345 void getFile( bool success ); 345 void getFile( bool success );
346 void syncFileRequest();
346 void setDetailsVisible( bool visible ); 347 void setDetailsVisible( bool visible );
347 void setDetailsToState(); 348 void setDetailsToState();
348 // void slotSyncMenu( int ); 349 // void slotSyncMenu( int );
349 private slots: 350 private slots:
350 void setJumpButtonBarVisible( bool visible ); 351 void setJumpButtonBarVisible( bool visible );
351 void importFromOL(); 352 void importFromOL();
352 void extensionModified( const KABC::Addressee::List &list ); 353 void extensionModified( const KABC::Addressee::List &list );
353 void extensionChanged( int id ); 354 void extensionChanged( int id );
354 void clipboardDataChanged(); 355 void clipboardDataChanged();
355 void updateActionMenu(); 356 void updateActionMenu();
356 void configureKeyBindings(); 357 void configureKeyBindings();
357 void removeVoice(); 358 void removeVoice();
358#ifdef KAB_EMBEDDED 359#ifdef KAB_EMBEDDED
359 void configureResources(); 360 void configureResources();
360#endif //KAB_EMBEDDED 361#endif //KAB_EMBEDDED
361 362
362 void slotEditorDestroyed( const QString &uid ); 363 void slotEditorDestroyed( const QString &uid );
363 void configurationChanged(); 364 void configurationChanged();
364 void addressBookChanged(); 365 void addressBookChanged();
365 366
366 private: 367 private:
367 void initGUI(); 368 void initGUI();
368 void initActions(); 369 void initActions();
369 370
370 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 371 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
371 const char *name = 0 ); 372 const char *name = 0 );
372 373
373 KXMLGUIClient *mGUIClient; 374 KXMLGUIClient *mGUIClient;
374 375
375 KABC::AddressBook *mAddressBook; 376 KABC::AddressBook *mAddressBook;
376 377
377 ViewManager *mViewManager; 378 ViewManager *mViewManager;
378 // QSplitter *mDetailsSplitter; 379 // QSplitter *mDetailsSplitter;
379 KDGanttMinimizeSplitter *mExtensionBarSplitter; 380 KDGanttMinimizeSplitter *mExtensionBarSplitter;
380 ViewContainer *mDetails; 381 ViewContainer *mDetails;
381 KDGanttMinimizeSplitter* mMiniSplitter; 382 KDGanttMinimizeSplitter* mMiniSplitter;
382 XXPortManager *mXXPortManager; 383 XXPortManager *mXXPortManager;
383 JumpButtonBar *mJumpButtonBar; 384 JumpButtonBar *mJumpButtonBar;
384 IncSearchWidget *mIncSearchWidget; 385 IncSearchWidget *mIncSearchWidget;
385 ExtensionManager *mExtensionManager; 386 ExtensionManager *mExtensionManager;
386 387
387 KCMultiDialog *mConfigureDialog; 388 KCMultiDialog *mConfigureDialog;
388 389
389#ifndef KAB_EMBEDDED 390#ifndef KAB_EMBEDDED
390 LDAPSearchDialog *mLdapSearchDialog; 391 LDAPSearchDialog *mLdapSearchDialog;
391#endif //KAB_EMBEDDED 392#endif //KAB_EMBEDDED
392 // QDict<AddresseeEditorDialog> mEditorDict; 393 // QDict<AddresseeEditorDialog> mEditorDict;
393 AddresseeEditorDialog *mEditorDialog; 394 AddresseeEditorDialog *mEditorDialog;
394 bool mReadWrite; 395 bool mReadWrite;
395 bool mModified; 396 bool mModified;
396 bool mIsPart; 397 bool mIsPart;
397 bool mMultipleViewsAtOnce; 398 bool mMultipleViewsAtOnce;
398 399
399 400
400 //US file menu 401 //US file menu
401 KAction *mActionMail; 402 KAction *mActionMail;
402 KAction *mActionBeam; 403 KAction *mActionBeam;
403 KAction *mActionExport2phone; 404 KAction *mActionExport2phone;
404 KAction* mActionPrint; 405 KAction* mActionPrint;
405 KAction* mActionNewContact; 406 KAction* mActionNewContact;
406 KAction *mActionSave; 407 KAction *mActionSave;
407 KAction *mActionEditAddressee; 408 KAction *mActionEditAddressee;
408 KAction *mActionMailVCard; 409 KAction *mActionMailVCard;
409 KAction *mActionBeamVCard; 410 KAction *mActionBeamVCard;
410 411
411 KAction *mActionQuit; 412 KAction *mActionQuit;
412 413
413 //US edit menu 414 //US edit menu
414 KAction *mActionCopy; 415 KAction *mActionCopy;
415 KAction *mActionCut; 416 KAction *mActionCut;
416 KAction *mActionPaste; 417 KAction *mActionPaste;
417 KAction *mActionSelectAll; 418 KAction *mActionSelectAll;
418 KAction *mActionUndo; 419 KAction *mActionUndo;
419 KAction *mActionRedo; 420 KAction *mActionRedo;
420 KAction *mActionDelete; 421 KAction *mActionDelete;
421 422
422 //US settings menu 423 //US settings menu
423 KAction *mActionConfigResources; 424 KAction *mActionConfigResources;
424 KAction *mActionConfigKAddressbook; 425 KAction *mActionConfigKAddressbook;
425 KAction *mActionConfigShortcuts; 426 KAction *mActionConfigShortcuts;
426 KAction *mActionConfigureToolbars; 427 KAction *mActionConfigureToolbars;
427 KAction *mActionKeyBindings; 428 KAction *mActionKeyBindings;
428 KToggleAction *mActionJumpBar; 429 KToggleAction *mActionJumpBar;
429 KToggleAction *mActionDetails; 430 KToggleAction *mActionDetails;
430 KAction *mActionWhoAmI; 431 KAction *mActionWhoAmI;
431 KAction *mActionCategories; 432 KAction *mActionCategories;
432 KAction *mActionAboutKAddressbook; 433 KAction *mActionAboutKAddressbook;
433 KAction *mActionLicence; 434 KAction *mActionLicence;
434 KAction *mActionFaq; 435 KAction *mActionFaq;
435 436
436 KAction *mActionDeleteView; 437 KAction *mActionDeleteView;
437 438
438 QPopupMenu *viewMenu; 439 QPopupMenu *viewMenu;
439 QPopupMenu *filterMenu; 440 QPopupMenu *filterMenu;
440 QPopupMenu *settingsMenu; 441 QPopupMenu *settingsMenu;
441 QPopupMenu *changeMenu; 442 QPopupMenu *changeMenu;
442//US QAction *mActionSave; 443//US QAction *mActionSave;
443 QPopupMenu *ImportMenu; 444 QPopupMenu *ImportMenu;
444 QPopupMenu *ExportMenu; 445 QPopupMenu *ExportMenu;
445 //LR additional methods 446 //LR additional methods
446 KAction *mActionRemoveVoice; 447 KAction *mActionRemoveVoice;
447 KAction * mActionImportOL; 448 KAction * mActionImportOL;
448 449
449#ifndef KAB_EMBEDDED 450#ifndef KAB_EMBEDDED
450 KAddressBookService *mAddressBookService; 451 KAddressBookService *mAddressBookService;
451#endif //KAB_EMBEDDED 452#endif //KAB_EMBEDDED
452 453
453 class KABCorePrivate; 454 class KABCorePrivate;
454 KABCorePrivate *d; 455 KABCorePrivate *d;
455 //US bool mBlockSaveFlag; 456 //US bool mBlockSaveFlag;
456 457
457#ifdef KAB_EMBEDDED 458#ifdef KAB_EMBEDDED
458 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 459 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
459#endif //KAB_EMBEDDED 460#endif //KAB_EMBEDDED
460 461
461 //this are the overwritten callbackmethods from the syncinterface 462 //this are the overwritten callbackmethods from the syncinterface
462 virtual bool sync(KSyncManager* manager, QString filename, int mode); 463 virtual bool sync(KSyncManager* manager, QString filename, int mode);
463 virtual bool syncExternal(KSyncManager* manager, QString resource); 464 virtual bool syncExternal(KSyncManager* manager, QString resource);
464 465
465 466
466 // LR ******************************* 467 // LR *******************************
467 // sync stuff! 468 // sync stuff!
469 QString sentSyncFile();
468 QPopupMenu *syncMenu; 470 QPopupMenu *syncMenu;
469 KSyncManager* syncManager; 471 KSyncManager* syncManager;
470 int mGlobalSyncMode; 472 int mGlobalSyncMode;
471 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 473 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
472 KABC::Addressee getLastSyncAddressee(); 474 KABC::Addressee getLastSyncAddressee();
473 QDateTime mLastAddressbookSync; 475 QDateTime mLastAddressbookSync;
474 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); 476 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
475 // ********************* 477 // *********************
476 478
477}; 479};
478 480
479#endif 481#endif
diff --git a/kaddressbook/xxport/vcard_xxport.cpp b/kaddressbook/xxport/vcard_xxport.cpp
index acf6419..3079d42 100644
--- a/kaddressbook/xxport/vcard_xxport.cpp
+++ b/kaddressbook/xxport/vcard_xxport.cpp
@@ -1,256 +1,257 @@
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/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <qfile.h> 31#include <qfile.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33 33
34#include <kabc/vcardconverter.h> 34#include <kabc/vcardconverter.h>
35#include <kabc/vcardparser/vcardtool.h> 35#include <kabc/vcardparser/vcardtool.h>
36#include <kfiledialog.h> 36#include <kfiledialog.h>
37#ifndef KAB_EMBEDDED 37#ifndef KAB_EMBEDDED
38#include <kio/netaccess.h> 38#include <kio/netaccess.h>
39#endif //KAB_EMBEDDED 39#endif //KAB_EMBEDDED
40 40
41#include <klocale.h> 41#include <klocale.h>
42#include <kmessagebox.h> 42#include <kmessagebox.h>
43#include <ktempfile.h> 43#include <ktempfile.h>
44#include <kurl.h> 44#include <kurl.h>
45 45
46#include "xxportmanager.h" 46#include "xxportmanager.h"
47 47
48#include "vcard_xxport.h" 48#include "vcard_xxport.h"
49 49
50#ifndef KAB_EMBEDDED 50#ifndef KAB_EMBEDDED
51 51
52class VCardXXPortFactory : public XXPortFactory 52class VCardXXPortFactory : public XXPortFactory
53{ 53{
54 public: 54 public:
55 XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) 55 XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name )
56 { 56 {
57 return new VCardXXPort( ab, parent, name ); 57 return new VCardXXPort( ab, parent, name );
58 } 58 }
59}; 59};
60#endif //KAB_EMBEDDED 60#endif //KAB_EMBEDDED
61 61
62 62
63extern "C" 63extern "C"
64{ 64{
65#ifndef KAB_EMBEDDED 65#ifndef KAB_EMBEDDED
66 void *init_libkaddrbk_vcard_xxport() 66 void *init_libkaddrbk_vcard_xxport()
67#else //KAB_EMBEDDED 67#else //KAB_EMBEDDED
68 void *init_microkaddrbk_vcard_xxport() 68 void *init_microkaddrbk_vcard_xxport()
69#endif //KAB_EMBEDDED 69#endif //KAB_EMBEDDED
70 { 70 {
71 return ( new VCardXXPortFactory() ); 71 return ( new VCardXXPortFactory() );
72 } 72 }
73} 73}
74 74
75 75
76VCardXXPort::VCardXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name ) 76VCardXXPort::VCardXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name )
77 : XXPortObject( ab, parent, name ) 77 : XXPortObject( ab, parent, name )
78{ 78{
79 createImportAction( i18n( "Import vCard..." ) ); 79 createImportAction( i18n( "Import vCard..." ) );
80//US KABC::VCardConverter does not support the export of 2.1 addressbooks. 80//US KABC::VCardConverter does not support the export of 2.1 addressbooks.
81//US createExportAction( i18n( "Export vCard 2.1..." ), "v21" ); 81//US createExportAction( i18n( "Export vCard 2.1..." ), "v21" );
82 createExportAction( i18n( "Export vCard 3.0..." ), "v30" ); 82 createExportAction( i18n( "Export vCard 3.0..." ), "v30" );
83} 83}
84 84
85bool VCardXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data ) 85bool VCardXXPort::exportContacts( const KABC::AddresseeList &list, const QString &data )
86{ 86{
87 QString name; 87 QString name;
88 88
89 if ( list.count() == 1 ) 89 if ( list.count() == 1 )
90 name = list[ 0 ].givenName() + "_" + list[ 0 ].familyName() + ".vcf"; 90 name = list[ 0 ].givenName() + "_" + list[ 0 ].familyName() + ".vcf";
91 else 91 else
92 name = "addressbook.vcf"; 92 name = "addressbook.vcf";
93 93
94#ifndef KAB_EMBEDDED 94#ifndef KAB_EMBEDDED
95 QString fileName = KFileDialog::getSaveFileName( name ); 95 QString fileName = KFileDialog::getSaveFileName( name );
96#else //KAB_EMBEDDED 96#else //KAB_EMBEDDED
97 QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); 97 QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() );
98#endif //KAB_EMBEDDED 98#endif //KAB_EMBEDDED
99 99
100 if ( fileName.isEmpty() ) 100 if ( fileName.isEmpty() )
101 return false; 101 return false;
102 102
103 QFile outFile( fileName ); 103 QFile outFile( fileName );
104 if ( !outFile.open( IO_WriteOnly ) ) { 104 if ( !outFile.open( IO_WriteOnly ) ) {
105 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); 105 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
106 KMessageBox::error( parentWidget(), text.arg( fileName ) ); 106 KMessageBox::error( parentWidget(), text.arg( fileName ) );
107 return false; 107 return false;
108 } 108 }
109 109
110 QTextStream t( &outFile ); 110 QTextStream t( &outFile );
111 t.setEncoding( QTextStream::UnicodeUTF8 ); 111 t.setEncoding( QTextStream::UnicodeUTF8 );
112 112
113 KABC::Addressee::List::ConstIterator it; 113 KABC::Addressee::List::ConstIterator it;
114 for ( it = list.begin(); it != list.end(); ++it ) { 114 for ( it = list.begin(); it != list.end(); ++it ) {
115 KABC::VCardConverter converter; 115 KABC::VCardConverter converter;
116 QString vcard; 116 QString vcard;
117 117
118 KABC::VCardConverter::Version version; 118 KABC::VCardConverter::Version version;
119 if ( data == "v21" ) 119 if ( data == "v21" )
120 version = KABC::VCardConverter::v2_1; 120 version = KABC::VCardConverter::v2_1;
121 else 121 else
122 version = KABC::VCardConverter::v3_0; 122 version = KABC::VCardConverter::v3_0;
123 123
124 version = KABC::VCardConverter::v2_1;
124 converter.addresseeToVCard( *it, vcard, version ); 125 converter.addresseeToVCard( *it, vcard, version );
125 t << vcard << "\r\n\r\n"; 126 t << vcard << "\r\n\r\n";
126 } 127 }
127 128
128 outFile.close(); 129 outFile.close();
129 130
130 return true; 131 return true;
131} 132}
132 133
133KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const 134KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const
134{ 135{
135 QString fileName; 136 QString fileName;
136 KABC::AddresseeList addrList; 137 KABC::AddresseeList addrList;
137 KURL url; 138 KURL url;
138 139
139#ifndef KAB_EMBEDDED 140#ifndef KAB_EMBEDDED
140 if ( !XXPortManager::importData.isEmpty() ) 141 if ( !XXPortManager::importData.isEmpty() )
141 addrList = parseVCard( XXPortManager::importData ); 142 addrList = parseVCard( XXPortManager::importData );
142 else { 143 else {
143 if ( XXPortManager::importURL.isEmpty() ) 144 if ( XXPortManager::importURL.isEmpty() )
144 { 145 {
145 url = KFileDialog::getLoadFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); 146 url = KFileDialog::getLoadFileName( QString::null, i18n("Select vCard to Import"), parentWidget() );
146 } 147 }
147 else 148 else
148 url = XXPortManager::importURL; 149 url = XXPortManager::importURL;
149 150
150 if ( url.isEmpty() ) 151 if ( url.isEmpty() )
151 return addrList; 152 return addrList;
152 153
153 QString caption( i18n( "vCard Import Failed" ) ); 154 QString caption( i18n( "vCard Import Failed" ) );
154 if ( KIO::NetAccess::download( url, fileName ) ) { 155 if ( KIO::NetAccess::download( url, fileName ) ) {
155 QFile file( fileName ); 156 QFile file( fileName );
156 157
157 file.open( IO_ReadOnly ); 158 file.open( IO_ReadOnly );
158 QByteArray rawData = file.readAll(); 159 QByteArray rawData = file.readAll();
159 file.close(); 160 file.close();
160 161
161 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 162 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
162 addrList = parseVCard( data ); 163 addrList = parseVCard( data );
163 164
164 if ( !url.isLocalFile() ) 165 if ( !url.isLocalFile() )
165 KIO::NetAccess::removeTempFile( fileName ); 166 KIO::NetAccess::removeTempFile( fileName );
166 167
167 } else { 168 } else {
168 QString text = i18n( "<qt>Unable to access <b>%1</b>.</qt>" ); 169 QString text = i18n( "<qt>Unable to access <b>%1</b>.</qt>" );
169 KMessageBox::error( parentWidget(), text.arg( url.url() ), caption ); 170 KMessageBox::error( parentWidget(), text.arg( url.url() ), caption );
170 } 171 }
171 172
172 } 173 }
173 174
174 175
175#else //KAB_EMBEDDED 176#else //KAB_EMBEDDED
176 177
177 178
178 if ( !XXPortManager::importData.isEmpty() ) 179 if ( !XXPortManager::importData.isEmpty() )
179 addrList = parseVCard( XXPortManager::importData ); 180 addrList = parseVCard( XXPortManager::importData );
180 else { 181 else {
181 if ( XXPortManager::importURL.isEmpty() ) 182 if ( XXPortManager::importURL.isEmpty() )
182 { 183 {
183 fileName = KFileDialog::getOpenFileName( QString::null, i18n("Select vCard to Import"), parentWidget() ); 184 fileName = KFileDialog::getOpenFileName( QString::null, i18n("Select vCard to Import"), parentWidget() );
184 if ( fileName.isEmpty() ) 185 if ( fileName.isEmpty() )
185 return addrList; 186 return addrList;
186 187
187 } 188 }
188 else 189 else
189 { 190 {
190//US url = XXPortManager::importURL; 191//US url = XXPortManager::importURL;
191 qDebug("VCardXXPort::importContacts Urls at the moment not supported"); 192 qDebug("VCardXXPort::importContacts Urls at the moment not supported");
192 if ( url.isEmpty() ) 193 if ( url.isEmpty() )
193 return addrList; 194 return addrList;
194 195
195 } 196 }
196 197
197 198
198 QFile file( fileName ); 199 QFile file( fileName );
199 200
200 file.open( IO_ReadOnly ); 201 file.open( IO_ReadOnly );
201 QByteArray rawData = file.readAll(); 202 QByteArray rawData = file.readAll();
202 file.close(); 203 file.close();
203 204
204 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 205 QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
205 addrList = parseVCard( data ); 206 addrList = parseVCard( data );
206 207
207 } 208 }
208#endif //KAB_EMBEDDED 209#endif //KAB_EMBEDDED
209 210
210 return addrList; 211 return addrList;
211} 212}
212 213
213KABC::AddresseeList VCardXXPort::parseVCard( const QString &data ) const 214KABC::AddresseeList VCardXXPort::parseVCard( const QString &data ) const
214{ 215{
215 216
216 KABC::VCardTool tool; 217 KABC::VCardTool tool;
217 KABC::AddresseeList addrList; 218 KABC::AddresseeList addrList;
218 addrList = tool.parseVCards( data ); 219 addrList = tool.parseVCards( data );
219 // LR : I switched to the code, which is in current cvs HEAD 220 // LR : I switched to the code, which is in current cvs HEAD
220 /* 221 /*
221 uint numVCards = data.contains( "BEGIN:VCARD", false ); 222 uint numVCards = data.contains( "BEGIN:VCARD", false );
222 QStringList dataList = QStringList::split( "\r\n\r\n", data ); 223 QStringList dataList = QStringList::split( "\r\n\r\n", data );
223 224
224 for ( uint i = 0; i < numVCards && i < dataList.count(); ++i ) { 225 for ( uint i = 0; i < numVCards && i < dataList.count(); ++i ) {
225 KABC::Addressee addr; 226 KABC::Addressee addr;
226 bool ok = false; 227 bool ok = false;
227 228
228 if ( dataList[ i ].contains( "VERSION:3.0" ) ) 229 if ( dataList[ i ].contains( "VERSION:3.0" ) )
229 ok = converter.vCardToAddressee( dataList[ i ], addr, KABC::VCardConverter::v3_0 ); 230 ok = converter.vCardToAddressee( dataList[ i ], addr, KABC::VCardConverter::v3_0 );
230 else if ( dataList[ i ].contains( "VERSION:2.1" ) ) 231 else if ( dataList[ i ].contains( "VERSION:2.1" ) )
231 ok = converter.vCardToAddressee( dataList[ i ], addr, KABC::VCardConverter::v2_1 ); 232 ok = converter.vCardToAddressee( dataList[ i ], addr, KABC::VCardConverter::v2_1 );
232 else { 233 else {
233 KMessageBox::sorry( parentWidget(), i18n( "Not supported vCard version." ) ); 234 KMessageBox::sorry( parentWidget(), i18n( "Not supported vCard version." ) );
234 continue; 235 continue;
235 } 236 }
236 237
237 if ( !addr.isEmpty() && ok ) 238 if ( !addr.isEmpty() && ok )
238 addrList.append( addr ); 239 addrList.append( addr );
239 else { 240 else {
240 QString text = i18n( "The selected file does not include a valid vCard. " 241 QString text = i18n( "The selected file does not include a valid vCard. "
241 "Please check the file and try again." ); 242 "Please check the file and try again." );
242 KMessageBox::sorry( parentWidget(), text ); 243 KMessageBox::sorry( parentWidget(), text );
243 } 244 }
244 } 245 }
245 */ 246 */
246 if ( addrList.isEmpty() ) { 247 if ( addrList.isEmpty() ) {
247 QString text = i18n( "The selected file does not\ninclude a valid vCard.\nPlease check the file and try again.\n" ); 248 QString text = i18n( "The selected file does not\ninclude a valid vCard.\nPlease check the file and try again.\n" );
248 KMessageBox::sorry( parentWidget(), text ); 249 KMessageBox::sorry( parentWidget(), text );
249 } 250 }
250 return addrList; 251 return addrList;
251} 252}
252 253
253 254
254#ifndef KAB_EMBEDDED 255#ifndef KAB_EMBEDDED
255#include "vcard_xxport.moc" 256#include "vcard_xxport.moc"
256#endif //KAB_EMBEDDED 257#endif //KAB_EMBEDDED
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 5d48884..ea543dd 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,1158 +1,1159 @@
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 51
52#include <klocale.h> 52#include <klocale.h>
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kconfig.h> 54#include <kconfig.h>
55#include <kfiledialog.h> 55#include <kfiledialog.h>
56 56
57KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 57KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
58 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) 58 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu)
59{ 59{
60 mServerSocket = 0; 60 mServerSocket = 0;
61 bar = new QProgressBar ( 1, 0 ); 61 bar = new QProgressBar ( 1, 0 );
62 bar->setCaption (""); 62 bar->setCaption ("");
63 63
64 int w = 300; 64 int w = 300;
65 if ( QApplication::desktop()->width() < 320 ) 65 if ( QApplication::desktop()->width() < 320 )
66 w = 220; 66 w = 220;
67 int h = bar->sizeHint().height() ; 67 int h = bar->sizeHint().height() ;
68 int dw = QApplication::desktop()->width(); 68 int dw = QApplication::desktop()->width();
69 int dh = QApplication::desktop()->height(); 69 int dh = QApplication::desktop()->height();
70 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 70 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
71 71
72} 72}
73 73
74KSyncManager::~KSyncManager() 74KSyncManager::~KSyncManager()
75{ 75{
76 delete bar; 76 delete bar;
77} 77}
78 78
79//LR ok 79//LR ok
80void KSyncManager::fillSyncMenu() 80void KSyncManager::fillSyncMenu()
81{ 81{
82 if ( mSyncMenu->count() ) 82 if ( mSyncMenu->count() )
83 mSyncMenu->clear(); 83 mSyncMenu->clear();
84 84
85 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 85 mSyncMenu->insertItem( i18n("Configure..."), 0 );
86 mSyncMenu->insertSeparator(); 86 mSyncMenu->insertSeparator();
87 if ( mServerSocket == 0 ) { 87 if ( mServerSocket == 0 ) {
88 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 88 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
89 } else { 89 } else {
90 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 90 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
91 } 91 }
92 mSyncMenu->insertSeparator(); 92 mSyncMenu->insertSeparator();
93 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 93 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
94 mSyncMenu->insertSeparator(); 94 mSyncMenu->insertSeparator();
95 95
96 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 96 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
97 config.setGroup("General"); 97 config.setGroup("General");
98 QStringList prof = config.readListEntry("SyncProfileNames"); 98 QStringList prof = config.readListEntry("SyncProfileNames");
99 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 99 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
100 if ( prof.count() < 2 ) { 100 if ( prof.count() < 2 ) {
101 prof.clear(); 101 prof.clear();
102 prof << i18n("Sharp_DTM"); 102 prof << i18n("Sharp_DTM");
103 prof << i18n("Local_file"); 103 prof << i18n("Local_file");
104 KSyncProfile* temp = new KSyncProfile (); 104 KSyncProfile* temp = new KSyncProfile ();
105 temp->setName( prof[0] ); 105 temp->setName( prof[0] );
106 temp->writeConfig(&config); 106 temp->writeConfig(&config);
107 temp->setName( prof[1] ); 107 temp->setName( prof[1] );
108 temp->writeConfig(&config); 108 temp->writeConfig(&config);
109 config.setGroup("General"); 109 config.setGroup("General");
110 config.writeEntry("SyncProfileNames",prof); 110 config.writeEntry("SyncProfileNames",prof);
111 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 111 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
112 config.sync(); 112 config.sync();
113 delete temp; 113 delete temp;
114 } 114 }
115 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 115 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
116 mSyncProfileNames = prof; 116 mSyncProfileNames = prof;
117 unsigned int i; 117 unsigned int i;
118 for ( i = 0; i < prof.count(); ++i ) { 118 for ( i = 0; i < prof.count(); ++i ) {
119 mSyncMenu->insertItem( prof[i], 1000+i ); 119 mSyncMenu->insertItem( prof[i], 1000+i );
120 if ( i == 2 ) 120 if ( i == 2 )
121 mSyncMenu->insertSeparator(); 121 mSyncMenu->insertSeparator();
122 } 122 }
123 QDir app_dir; 123 QDir app_dir;
124 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 124 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
125 if ( mTargetApp == PWMPI) { 125 if ( mTargetApp == PWMPI) {
126 mSyncMenu->removeItem( 1000 ); 126 mSyncMenu->removeItem( 1000 );
127 } 127 }
128 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 128 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
129 mSyncMenu->setItemEnabled( 1000, false ); 129 mSyncMenu->setItemEnabled( 1000, false );
130 } 130 }
131} 131}
132 132
133void KSyncManager::slotSyncMenu( int action ) 133void KSyncManager::slotSyncMenu( int action )
134{ 134{
135 //qDebug("syncaction %d ", action); 135 //qDebug("syncaction %d ", action);
136 if ( action == 0 ) { 136 if ( action == 0 ) {
137 137
138 // seems to be a Qt2 event handling bug 138 // seems to be a Qt2 event handling bug
139 // syncmenu.clear causes a segfault at first time 139 // syncmenu.clear causes a segfault at first time
140 // when we call it after the main event loop, it is ok 140 // when we call it after the main event loop, it is ok
141 // same behaviour when calling OM/Pi via QCOP for the first time 141 // same behaviour when calling OM/Pi via QCOP for the first time
142 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 142 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
143 //confSync(); 143 //confSync();
144 144
145 return; 145 return;
146 } 146 }
147 if ( action == 1 ) { 147 if ( action == 1 ) {
148 multiSync( true ); 148 multiSync( true );
149 return; 149 return;
150 } 150 }
151 if ( action == 2 ) { 151 if ( action == 2 ) {
152 enableQuick(); 152 enableQuick();
153 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 153 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
154 return; 154 return;
155 } 155 }
156 if ( action == 3 ) { 156 if ( action == 3 ) {
157 delete mServerSocket; 157 delete mServerSocket;
158 mServerSocket = 0; 158 mServerSocket = 0;
159 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 159 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
160 return; 160 return;
161 } 161 }
162 162
163 if (blockSave()) 163 if (blockSave())
164 return; 164 return;
165 165
166 setBlockSave(true); 166 setBlockSave(true);
167 167
168 mCurrentSyncProfile = action - 1000 ; 168 mCurrentSyncProfile = action - 1000 ;
169 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 169 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
170 mCurrentSyncName = mLocalMachineName ; 170 mCurrentSyncName = mLocalMachineName ;
171 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 171 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
172 KSyncProfile* temp = new KSyncProfile (); 172 KSyncProfile* temp = new KSyncProfile ();
173 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 173 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
174 temp->readConfig(&config); 174 temp->readConfig(&config);
175 mAskForPreferences = temp->getAskForPreferences(); 175 mAskForPreferences = temp->getAskForPreferences();
176 mSyncAlgoPrefs = temp->getSyncPrefs(); 176 mSyncAlgoPrefs = temp->getSyncPrefs();
177 mWriteBackFile = temp->getWriteBackFile(); 177 mWriteBackFile = temp->getWriteBackFile();
178 mWriteBackExistingOnly = temp->getWriteBackExisting(); 178 mWriteBackExistingOnly = temp->getWriteBackExisting();
179 mWriteBackInFuture = 0; 179 mWriteBackInFuture = 0;
180 if ( temp->getWriteBackFuture() ) 180 if ( temp->getWriteBackFuture() )
181 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 181 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
182 mShowSyncSummary = temp->getShowSummaryAfterSync(); 182 mShowSyncSummary = temp->getShowSummaryAfterSync();
183 if ( action == 1000 ) { 183 if ( action == 1000 ) {
184 syncSharp(); 184 syncSharp();
185 185
186 } else if ( action == 1001 ) { 186 } else if ( action == 1001 ) {
187 syncLocalFile(); 187 syncLocalFile();
188 188
189 } else if ( action == 1002 ) { 189 } else if ( action == 1002 ) {
190 quickSyncLocalFile(); 190 quickSyncLocalFile();
191 191
192 } else if ( action >= 1003 ) { 192 } else if ( action >= 1003 ) {
193 if ( temp->getIsLocalFileSync() ) { 193 if ( temp->getIsLocalFileSync() ) {
194 switch(mTargetApp) 194 switch(mTargetApp)
195 { 195 {
196 case (KAPI): 196 case (KAPI):
197 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 197 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
198 mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 198 mLastSyncedLocalFile = temp->getRemoteFileNameAB();
199 break; 199 break;
200 case (KOPI): 200 case (KOPI):
201 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 201 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
202 mLastSyncedLocalFile = temp->getRemoteFileName(); 202 mLastSyncedLocalFile = temp->getRemoteFileName();
203 break; 203 break;
204 case (PWMPI): 204 case (PWMPI):
205 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 205 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
206 mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 206 mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
207 break; 207 break;
208 default: 208 default:
209 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 209 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
210 break; 210 break;
211 211
212 } 212 }
213 } else { 213 } else {
214 if ( temp->getIsPhoneSync() ) { 214 if ( temp->getIsPhoneSync() ) {
215 mPhoneDevice = temp->getPhoneDevice( ) ; 215 mPhoneDevice = temp->getPhoneDevice( ) ;
216 mPhoneConnection = temp->getPhoneConnection( ); 216 mPhoneConnection = temp->getPhoneConnection( );
217 mPhoneModel = temp->getPhoneModel( ); 217 mPhoneModel = temp->getPhoneModel( );
218 syncPhone(); 218 syncPhone();
219 } else if ( temp->getIsPiSync() ) { 219 } else if ( temp->getIsPiSync() ) {
220 mPassWordPiSync = temp->getRemotePw(); 220 mPassWordPiSync = temp->getRemotePw();
221 mActiveSyncPort = temp->getRemotePort(); 221 mActiveSyncPort = temp->getRemotePort();
222 mActiveSyncIP = temp->getRemoteIP(); 222 mActiveSyncIP = temp->getRemoteIP();
223 syncPi(); 223 syncPi();
224 } 224 }
225 syncRemote( temp ); 225 syncRemote( temp );
226 226
227 } 227 }
228 } 228 }
229 delete temp; 229 delete temp;
230 setBlockSave(false); 230 setBlockSave(false);
231} 231}
232void KSyncManager::enableQuick() 232void KSyncManager::enableQuick()
233{ 233{
234 QDialog dia ( 0, "input-dialog", true ); 234 QDialog dia ( 0, "input-dialog", true );
235 QLineEdit lab ( &dia ); 235 QLineEdit lab ( &dia );
236 QVBoxLayout lay( &dia ); 236 QVBoxLayout lay( &dia );
237 lab.setText( mPrefs->mPassiveSyncPort ); 237 lab.setText( mPrefs->mPassiveSyncPort );
238 lay.setMargin(7); 238 lay.setMargin(7);
239 lay.setSpacing(7); 239 lay.setSpacing(7);
240 int po = 9197+mTargetApp; 240 int po = 9197+mTargetApp;
241 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 241 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
242 lay.addWidget( &label); 242 lay.addWidget( &label);
243 lay.addWidget( &lab); 243 lay.addWidget( &lab);
244 244
245 QLineEdit lepw ( &dia ); 245 QLineEdit lepw ( &dia );
246 lepw.setText( mPrefs->mPassiveSyncPw ); 246 lepw.setText( mPrefs->mPassiveSyncPw );
247 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 247 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
248 lay.addWidget( &label2); 248 lay.addWidget( &label2);
249 lay.addWidget( &lepw); 249 lay.addWidget( &lepw);
250 dia.setFixedSize( 230,80 ); 250 dia.setFixedSize( 230,80 );
251 dia.setCaption( i18n("Enter port for Pi-Sync") ); 251 dia.setCaption( i18n("Enter port for Pi-Sync") );
252 QPushButton pb ( "OK", &dia); 252 QPushButton pb ( "OK", &dia);
253 lay.addWidget( &pb ); 253 lay.addWidget( &pb );
254 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 254 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
255 dia.show(); 255 dia.show();
256 if ( ! dia.exec() ) 256 if ( ! dia.exec() )
257 return; 257 return;
258 dia.hide(); 258 dia.hide();
259 qApp->processEvents(); 259 qApp->processEvents();
260 mPrefs->mPassiveSyncPw = lepw.text(); 260 mPrefs->mPassiveSyncPw = lepw.text();
261 mPrefs->mPassiveSyncPort = lab.text(); 261 mPrefs->mPassiveSyncPort = lab.text();
262 bool ok; 262 bool ok;
263 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 263 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
264 if ( ! ok ) { 264 if ( ! ok ) {
265 KMessageBox::information( 0, i18n("No valid port")); 265 KMessageBox::information( 0, i18n("No valid port"));
266 return; 266 return;
267 } 267 }
268 //qDebug("port %d ", port); 268 //qDebug("port %d ", port);
269 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 269 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
270 mServerSocket->setFileName( defaultFileName() ); 270 mServerSocket->setFileName( defaultFileName() );
271 //qDebug("connected "); 271 //qDebug("connected ");
272 if ( !mServerSocket->ok() ) { 272 if ( !mServerSocket->ok() ) {
273 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 273 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
274 delete mServerSocket; 274 delete mServerSocket;
275 mServerSocket = 0; 275 mServerSocket = 0;
276 return; 276 return;
277 } 277 }
278 connect( mServerSocket, SIGNAL ( saveFile() ),this, SIGNAL ( save() ) ); 278 //connect( mServerSocket, SIGNAL ( saveFile() ),this, SIGNAL ( save() ) );
279 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
279 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 280 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
280} 281}
281 282
282void KSyncManager::syncLocalFile() 283void KSyncManager::syncLocalFile()
283{ 284{
284 285
285 QString fn =mLastSyncedLocalFile; 286 QString fn =mLastSyncedLocalFile;
286 QString ext; 287 QString ext;
287 288
288 switch(mTargetApp) 289 switch(mTargetApp)
289 { 290 {
290 case (KAPI): 291 case (KAPI):
291 ext = "(*.vcf)"; 292 ext = "(*.vcf)";
292 break; 293 break;
293 case (KOPI): 294 case (KOPI):
294 ext = "(*.ics/*.vcs)"; 295 ext = "(*.ics/*.vcs)";
295 break; 296 break;
296 case (PWMPI): 297 case (PWMPI):
297 ext = "(*.pwm)"; 298 ext = "(*.pwm)";
298 break; 299 break;
299 default: 300 default:
300 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 301 qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
301 break; 302 break;
302 303
303 } 304 }
304 305
305 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 306 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
306 if ( fn == "" ) 307 if ( fn == "" )
307 return; 308 return;
308 if ( syncWithFile( fn, false ) ) { 309 if ( syncWithFile( fn, false ) ) {
309 qDebug("syncLocalFile() successful "); 310 qDebug("syncLocalFile() successful ");
310 } 311 }
311 312
312} 313}
313bool KSyncManager::syncWithFile( QString fn , bool quick ) 314bool KSyncManager::syncWithFile( QString fn , bool quick )
314{ 315{
315 bool ret = false; 316 bool ret = false;
316 QFileInfo info; 317 QFileInfo info;
317 info.setFile( fn ); 318 info.setFile( fn );
318 QString mess; 319 QString mess;
319 bool loadbup = true; 320 bool loadbup = true;
320 if ( !info. exists() ) { 321 if ( !info. exists() ) {
321 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 322 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
322 int result = QMessageBox::warning( mParent, i18n("Warning!"), 323 int result = QMessageBox::warning( mParent, i18n("Warning!"),
323 mess ); 324 mess );
324 return ret; 325 return ret;
325 } 326 }
326 int result = 0; 327 int result = 0;
327 if ( !quick ) { 328 if ( !quick ) {
328 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 329 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
329 result = QMessageBox::warning( mParent, i18n("Warning!"), 330 result = QMessageBox::warning( mParent, i18n("Warning!"),
330 mess, 331 mess,
331 i18n("Sync"), i18n("Cancel"), 0, 332 i18n("Sync"), i18n("Cancel"), 0,
332 0, 1 ); 333 0, 1 );
333 if ( result ) 334 if ( result )
334 return false; 335 return false;
335 } 336 }
336 if ( mAskForPreferences ) 337 if ( mAskForPreferences )
337 edit_sync_options(); 338 edit_sync_options();
338 if ( result == 0 ) { 339 if ( result == 0 ) {
339 //qDebug("Now sycing ... "); 340 //qDebug("Now sycing ... ");
340 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 341 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
341 mParent->setCaption( i18n("Synchronization successful") ); 342 mParent->setCaption( i18n("Synchronization successful") );
342 else 343 else
343 mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 344 mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
344 if ( ! quick ) 345 if ( ! quick )
345 mLastSyncedLocalFile = fn; 346 mLastSyncedLocalFile = fn;
346 } 347 }
347 return ret; 348 return ret;
348} 349}
349void KSyncManager::quickSyncLocalFile() 350void KSyncManager::quickSyncLocalFile()
350{ 351{
351 352
352 if ( syncWithFile( mLastSyncedLocalFile, false ) ) { 353 if ( syncWithFile( mLastSyncedLocalFile, false ) ) {
353 qDebug("quick syncLocalFile() successful "); 354 qDebug("quick syncLocalFile() successful ");
354 355
355 } 356 }
356} 357}
357void KSyncManager::multiSync( bool askforPrefs ) 358void KSyncManager::multiSync( bool askforPrefs )
358{ 359{
359 if (blockSave()) 360 if (blockSave())
360 return; 361 return;
361 setBlockSave(true); 362 setBlockSave(true);
362 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 363 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
363 if ( QMessageBox::information( mParent, i18n("Sync"), 364 if ( QMessageBox::information( mParent, i18n("Sync"),
364 question, 365 question,
365 i18n("Yes"), i18n("No"), 366 i18n("Yes"), i18n("No"),
366 0, 0 ) != 0 ) { 367 0, 0 ) != 0 ) {
367 setBlockSave(false); 368 setBlockSave(false);
368 mParent->setCaption(i18n("Aborted! Nothing synced!")); 369 mParent->setCaption(i18n("Aborted! Nothing synced!"));
369 return; 370 return;
370 } 371 }
371 mCurrentSyncDevice = i18n("Multiple profiles") ; 372 mCurrentSyncDevice = i18n("Multiple profiles") ;
372 mSyncAlgoPrefs = mRingSyncAlgoPrefs; 373 mSyncAlgoPrefs = mRingSyncAlgoPrefs;
373 if ( askforPrefs ) { 374 if ( askforPrefs ) {
374 edit_sync_options(); 375 edit_sync_options();
375 mRingSyncAlgoPrefs = mSyncAlgoPrefs; 376 mRingSyncAlgoPrefs = mSyncAlgoPrefs;
376 } 377 }
377 mParent->setCaption(i18n("Multiple sync started.") ); 378 mParent->setCaption(i18n("Multiple sync started.") );
378 qApp->processEvents(); 379 qApp->processEvents();
379 int num = ringSync() ; 380 int num = ringSync() ;
380 if ( num > 1 ) 381 if ( num > 1 )
381 ringSync(); 382 ringSync();
382 setBlockSave(false); 383 setBlockSave(false);
383 if ( num ) 384 if ( num )
384 emit save(); 385 emit save();
385 if ( num ) 386 if ( num )
386 mParent->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 387 mParent->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
387 else 388 else
388 mParent->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 389 mParent->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
389 return; 390 return;
390} 391}
391int KSyncManager::ringSync() 392int KSyncManager::ringSync()
392{ 393{
393 int syncedProfiles = 0; 394 int syncedProfiles = 0;
394 unsigned int i; 395 unsigned int i;
395 QTime timer; 396 QTime timer;
396 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 397 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
397 QStringList syncProfileNames = mSyncProfileNames; 398 QStringList syncProfileNames = mSyncProfileNames;
398 KSyncProfile* temp = new KSyncProfile (); 399 KSyncProfile* temp = new KSyncProfile ();
399 mAskForPreferences = false; 400 mAskForPreferences = false;
400 for ( i = 0; i < syncProfileNames.count(); ++i ) { 401 for ( i = 0; i < syncProfileNames.count(); ++i ) {
401 mCurrentSyncProfile = i; 402 mCurrentSyncProfile = i;
402 temp->setName(syncProfileNames[mCurrentSyncProfile]); 403 temp->setName(syncProfileNames[mCurrentSyncProfile]);
403 temp->readConfig(&config); 404 temp->readConfig(&config);
404 405
405 QString includeInRingSync; 406 QString includeInRingSync;
406 switch(mTargetApp) 407 switch(mTargetApp)
407 { 408 {
408 case (KAPI): 409 case (KAPI):
409 includeInRingSync = temp->getIncludeInRingSyncAB(); 410 includeInRingSync = temp->getIncludeInRingSyncAB();
410 break; 411 break;
411 case (KOPI): 412 case (KOPI):
412 includeInRingSync = temp->getIncludeInRingSync(); 413 includeInRingSync = temp->getIncludeInRingSync();
413 break; 414 break;
414 case (PWMPI): 415 case (PWMPI):
415 includeInRingSync = temp->getIncludeInRingSyncPWM(); 416 includeInRingSync = temp->getIncludeInRingSyncPWM();
416 break; 417 break;
417 default: 418 default:
418 qDebug("KSyncManager::ringSync: invalid apptype selected"); 419 qDebug("KSyncManager::ringSync: invalid apptype selected");
419 break; 420 break;
420 421
421 } 422 }
422 423
423 424
424 if ( includeInRingSync && ( i < 1 || i > 2 )) { 425 if ( includeInRingSync && ( i < 1 || i > 2 )) {
425 mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 426 mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
426 ++syncedProfiles; 427 ++syncedProfiles;
427 // mAskForPreferences = temp->getAskForPreferences(); 428 // mAskForPreferences = temp->getAskForPreferences();
428 mWriteBackFile = temp->getWriteBackFile(); 429 mWriteBackFile = temp->getWriteBackFile();
429 mWriteBackExistingOnly = temp->getWriteBackExisting(); 430 mWriteBackExistingOnly = temp->getWriteBackExisting();
430 mWriteBackInFuture = 0; 431 mWriteBackInFuture = 0;
431 if ( temp->getWriteBackFuture() ) 432 if ( temp->getWriteBackFuture() )
432 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 433 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
433 mShowSyncSummary = false; 434 mShowSyncSummary = false;
434 mCurrentSyncDevice = syncProfileNames[i] ; 435 mCurrentSyncDevice = syncProfileNames[i] ;
435 mCurrentSyncName = mLocalMachineName; 436 mCurrentSyncName = mLocalMachineName;
436 if ( i == 0 ) { 437 if ( i == 0 ) {
437 syncSharp(); 438 syncSharp();
438 } else { 439 } else {
439 if ( temp->getIsLocalFileSync() ) { 440 if ( temp->getIsLocalFileSync() ) {
440 switch(mTargetApp) 441 switch(mTargetApp)
441 { 442 {
442 case (KAPI): 443 case (KAPI):
443 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 444 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
444 mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 445 mLastSyncedLocalFile = temp->getRemoteFileNameAB();
445 break; 446 break;
446 case (KOPI): 447 case (KOPI):
447 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 448 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
448 mLastSyncedLocalFile = temp->getRemoteFileName(); 449 mLastSyncedLocalFile = temp->getRemoteFileName();
449 break; 450 break;
450 case (PWMPI): 451 case (PWMPI):
451 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 452 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
452 mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 453 mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
453 break; 454 break;
454 default: 455 default:
455 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 456 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
456 break; 457 break;
457 } 458 }
458 } else { 459 } else {
459 if ( temp->getIsPhoneSync() ) { 460 if ( temp->getIsPhoneSync() ) {
460 mPhoneDevice = temp->getPhoneDevice( ) ; 461 mPhoneDevice = temp->getPhoneDevice( ) ;
461 mPhoneConnection = temp->getPhoneConnection( ); 462 mPhoneConnection = temp->getPhoneConnection( );
462 mPhoneModel = temp->getPhoneModel( ); 463 mPhoneModel = temp->getPhoneModel( );
463 syncPhone(); 464 syncPhone();
464 } else 465 } else
465 syncRemote( temp, false ); 466 syncRemote( temp, false );
466 467
467 } 468 }
468 } 469 }
469 timer.start(); 470 timer.start();
470 mParent->setCaption(i18n("Multiple sync in progress ... please wait!") ); 471 mParent->setCaption(i18n("Multiple sync in progress ... please wait!") );
471 while ( timer.elapsed () < 2000 ) { 472 while ( timer.elapsed () < 2000 ) {
472 qApp->processEvents(); 473 qApp->processEvents();
473#ifndef _WIN32_ 474#ifndef _WIN32_
474 sleep (1); 475 sleep (1);
475#endif 476#endif
476 } 477 }
477 478
478 } 479 }
479 480
480 } 481 }
481 delete temp; 482 delete temp;
482 return syncedProfiles; 483 return syncedProfiles;
483} 484}
484 485
485void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 486void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
486{ 487{
487 QString question; 488 QString question;
488 if ( ask ) { 489 if ( ask ) {
489 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 490 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
490 if ( QMessageBox::information( mParent, i18n("Sync"), 491 if ( QMessageBox::information( mParent, i18n("Sync"),
491 question, 492 question,
492 i18n("Yes"), i18n("No"), 493 i18n("Yes"), i18n("No"),
493 0, 0 ) != 0 ) 494 0, 0 ) != 0 )
494 return; 495 return;
495 } 496 }
496 497
497 QString preCommand; 498 QString preCommand;
498 QString localTempFile; 499 QString localTempFile;
499 QString postCommand; 500 QString postCommand;
500 501
501 switch(mTargetApp) 502 switch(mTargetApp)
502 { 503 {
503 case (KAPI): 504 case (KAPI):
504 preCommand = prof->getPreSyncCommandAB(); 505 preCommand = prof->getPreSyncCommandAB();
505 postCommand = prof->getPostSyncCommandAB(); 506 postCommand = prof->getPostSyncCommandAB();
506 localTempFile = prof->getLocalTempFileAB(); 507 localTempFile = prof->getLocalTempFileAB();
507 break; 508 break;
508 case (KOPI): 509 case (KOPI):
509 preCommand = prof->getPreSyncCommand(); 510 preCommand = prof->getPreSyncCommand();
510 postCommand = prof->getPostSyncCommand(); 511 postCommand = prof->getPostSyncCommand();
511 localTempFile = prof->getLocalTempFile(); 512 localTempFile = prof->getLocalTempFile();
512 break; 513 break;
513 case (PWMPI): 514 case (PWMPI):
514 preCommand = prof->getPreSyncCommandPWM(); 515 preCommand = prof->getPreSyncCommandPWM();
515 postCommand = prof->getPostSyncCommandPWM(); 516 postCommand = prof->getPostSyncCommandPWM();
516 localTempFile = prof->getLocalTempFilePWM(); 517 localTempFile = prof->getLocalTempFilePWM();
517 break; 518 break;
518 default: 519 default:
519 qDebug("KSyncManager::syncRemote: invalid apptype selected"); 520 qDebug("KSyncManager::syncRemote: invalid apptype selected");
520 break; 521 break;
521 } 522 }
522 523
523 524
524 int fi; 525 int fi;
525 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 526 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
526 QString pwd = getPassword(); 527 QString pwd = getPassword();
527 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 528 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
528 529
529 } 530 }
530 int maxlen = 30; 531 int maxlen = 30;
531 if ( QApplication::desktop()->width() > 320 ) 532 if ( QApplication::desktop()->width() > 320 )
532 maxlen += 25; 533 maxlen += 25;
533 mParent->setCaption ( i18n( "Copy remote file to local machine..." ) ); 534 mParent->setCaption ( i18n( "Copy remote file to local machine..." ) );
534 int fileSize = 0; 535 int fileSize = 0;
535 int result = system ( preCommand ); 536 int result = system ( preCommand );
536 // 0 : okay 537 // 0 : okay
537 // 256: no such file or dir 538 // 256: no such file or dir
538 // 539 //
539 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 540 qDebug("KO: Remote copy result(0 = okay): %d ",result );
540 if ( result != 0 ) { 541 if ( result != 0 ) {
541 unsigned int len = maxlen; 542 unsigned int len = maxlen;
542 while ( len < preCommand.length() ) { 543 while ( len < preCommand.length() ) {
543 preCommand.insert( len , "\n" ); 544 preCommand.insert( len , "\n" );
544 len += maxlen +2; 545 len += maxlen +2;
545 } 546 }
546 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) ; 547 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) ;
547 QMessageBox::information( mParent, i18n("Sync - ERROR"), 548 QMessageBox::information( mParent, i18n("Sync - ERROR"),
548 question, 549 question,
549 i18n("Okay!")) ; 550 i18n("Okay!")) ;
550 mParent->setCaption (""); 551 mParent->setCaption ("");
551 return; 552 return;
552 } 553 }
553 mParent->setCaption ( i18n( "Copying succeed." ) ); 554 mParent->setCaption ( i18n( "Copying succeed." ) );
554 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 555 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
555 556
556 557
557 558
558 if ( syncWithFile( localTempFile, true ) ) { 559 if ( syncWithFile( localTempFile, true ) ) {
559// Event* e = mView->getLastSyncEvent(); 560// Event* e = mView->getLastSyncEvent();
560// e->setReadOnly( false ); 561// e->setReadOnly( false );
561// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 562// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
562// e->setReadOnly( true ); 563// e->setReadOnly( true );
563 if ( mWriteBackFile ) { 564 if ( mWriteBackFile ) {
564 int fi; 565 int fi;
565 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 566 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
566 QString pwd = getPassword(); 567 QString pwd = getPassword();
567 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 568 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
568 569
569 } 570 }
570 mParent->setCaption ( i18n( "Writing back file ..." ) ); 571 mParent->setCaption ( i18n( "Writing back file ..." ) );
571 result = system ( postCommand ); 572 result = system ( postCommand );
572 qDebug("Writing back file result: %d ", result); 573 qDebug("Writing back file result: %d ", result);
573 if ( result != 0 ) { 574 if ( result != 0 ) {
574 mParent->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 575 mParent->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
575 return; 576 return;
576 } else { 577 } else {
577 mParent->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 578 mParent->setCaption ( i18n( "Syncronization sucessfully completed" ) );
578 } 579 }
579 } 580 }
580 } 581 }
581 return; 582 return;
582} 583}
583 584
584void KSyncManager::edit_sync_options() 585void KSyncManager::edit_sync_options()
585{ 586{
586 //mDialogManager->showSyncOptions(); 587 //mDialogManager->showSyncOptions();
587 //mSyncAlgoPrefs 588 //mSyncAlgoPrefs
588 QDialog dia( mParent, "dia", true ); 589 QDialog dia( mParent, "dia", true );
589 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 590 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
590 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 591 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
591 QVBoxLayout lay ( &dia ); 592 QVBoxLayout lay ( &dia );
592 lay.setSpacing( 2 ); 593 lay.setSpacing( 2 );
593 lay.setMargin( 3 ); 594 lay.setMargin( 3 );
594 lay.addWidget(&gr); 595 lay.addWidget(&gr);
595 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 596 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
596 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 597 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
597 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 598 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
598 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 599 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
599 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 600 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
600 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 601 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
601 //QRadioButton both( i18n("Take both on conflict"), &gr ); 602 //QRadioButton both( i18n("Take both on conflict"), &gr );
602 QPushButton pb ( "OK", &dia); 603 QPushButton pb ( "OK", &dia);
603 lay.addWidget( &pb ); 604 lay.addWidget( &pb );
604 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 605 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
605 switch ( mSyncAlgoPrefs ) { 606 switch ( mSyncAlgoPrefs ) {
606 case 0: 607 case 0:
607 loc.setChecked( true); 608 loc.setChecked( true);
608 break; 609 break;
609 case 1: 610 case 1:
610 rem.setChecked( true ); 611 rem.setChecked( true );
611 break; 612 break;
612 case 2: 613 case 2:
613 newest.setChecked( true); 614 newest.setChecked( true);
614 break; 615 break;
615 case 3: 616 case 3:
616 ask.setChecked( true); 617 ask.setChecked( true);
617 break; 618 break;
618 case 4: 619 case 4:
619 f_loc.setChecked( true); 620 f_loc.setChecked( true);
620 break; 621 break;
621 case 5: 622 case 5:
622 f_rem.setChecked( true); 623 f_rem.setChecked( true);
623 break; 624 break;
624 case 6: 625 case 6:
625 // both.setChecked( true); 626 // both.setChecked( true);
626 break; 627 break;
627 default: 628 default:
628 break; 629 break;
629 } 630 }
630 if ( dia.exec() ) { 631 if ( dia.exec() ) {
631 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 632 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
632 } 633 }
633 634
634 635
635} 636}
636QString KSyncManager::getPassword( ) 637QString KSyncManager::getPassword( )
637{ 638{
638 QString retfile = ""; 639 QString retfile = "";
639 QDialog dia ( mParent, "input-dialog", true ); 640 QDialog dia ( mParent, "input-dialog", true );
640 QLineEdit lab ( &dia ); 641 QLineEdit lab ( &dia );
641 lab.setEchoMode( QLineEdit::Password ); 642 lab.setEchoMode( QLineEdit::Password );
642 QVBoxLayout lay( &dia ); 643 QVBoxLayout lay( &dia );
643 lay.setMargin(7); 644 lay.setMargin(7);
644 lay.setSpacing(7); 645 lay.setSpacing(7);
645 lay.addWidget( &lab); 646 lay.addWidget( &lab);
646 dia.setFixedSize( 230,50 ); 647 dia.setFixedSize( 230,50 );
647 dia.setCaption( i18n("Enter password") ); 648 dia.setCaption( i18n("Enter password") );
648 QPushButton pb ( "OK", &dia); 649 QPushButton pb ( "OK", &dia);
649 lay.addWidget( &pb ); 650 lay.addWidget( &pb );
650 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 651 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
651 dia.show(); 652 dia.show();
652 int res = dia.exec(); 653 int res = dia.exec();
653 if ( res ) 654 if ( res )
654 retfile = lab.text(); 655 retfile = lab.text();
655 dia.hide(); 656 dia.hide();
656 qApp->processEvents(); 657 qApp->processEvents();
657 return retfile; 658 return retfile;
658 659
659} 660}
660 661
661 662
662void KSyncManager::confSync() 663void KSyncManager::confSync()
663{ 664{
664 static KSyncPrefsDialog* sp = 0; 665 static KSyncPrefsDialog* sp = 0;
665 if ( ! sp ) { 666 if ( ! sp ) {
666 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 667 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
667 } 668 }
668 sp->usrReadConfig(); 669 sp->usrReadConfig();
669#ifndef DESKTOP_VERSION 670#ifndef DESKTOP_VERSION
670 sp->showMaximized(); 671 sp->showMaximized();
671#else 672#else
672 sp->show(); 673 sp->show();
673#endif 674#endif
674 sp->exec(); 675 sp->exec();
675 mSyncProfileNames = sp->getSyncProfileNames(); 676 mSyncProfileNames = sp->getSyncProfileNames();
676 mLocalMachineName = sp->getLocalMachineName (); 677 mLocalMachineName = sp->getLocalMachineName ();
677 fillSyncMenu(); 678 fillSyncMenu();
678} 679}
679 680
680void KSyncManager::syncSharp() 681void KSyncManager::syncSharp()
681{ 682{
682 if ( ! syncExternalApplication("sharp") ) 683 if ( ! syncExternalApplication("sharp") )
683 qDebug("ERROR sync sharp ");; 684 qDebug("ERROR sync sharp ");;
684} 685}
685 686
686bool KSyncManager::syncExternalApplication(QString resource) 687bool KSyncManager::syncExternalApplication(QString resource)
687{ 688{
688 689
689 emit save(); 690 emit save();
690 691
691 if ( mAskForPreferences ) 692 if ( mAskForPreferences )
692 edit_sync_options(); 693 edit_sync_options();
693 694
694 qDebug("sync %s", resource.latin1()); 695 qDebug("sync %s", resource.latin1());
695 696
696 bool syncOK = mImplementation->syncExternal(this, resource); 697 bool syncOK = mImplementation->syncExternal(this, resource);
697 698
698 return syncOK; 699 return syncOK;
699 700
700} 701}
701 702
702void KSyncManager::syncPhone() 703void KSyncManager::syncPhone()
703{ 704{
704 emit save(); 705 emit save();
705 706
706 qDebug("pending syncPhone(); "); 707 qDebug("pending syncPhone(); ");
707 //mView->syncPhone(); 708 //mView->syncPhone();
708 709
709} 710}
710 711
711void KSyncManager::showProgressBar(int percentage, QString caption, int total) 712void KSyncManager::showProgressBar(int percentage, QString caption, int total)
712{ 713{
713 if (!bar->isVisible()) 714 if (!bar->isVisible())
714 { 715 {
715 bar->setCaption (caption); 716 bar->setCaption (caption);
716 bar->setTotalSteps ( total ) ; 717 bar->setTotalSteps ( total ) ;
717 718
718 bar->show(); 719 bar->show();
719 } 720 }
720 721
721 bar->setProgress( percentage ); 722 bar->setProgress( percentage );
722} 723}
723 724
724void KSyncManager::hideProgressBar() 725void KSyncManager::hideProgressBar()
725{ 726{
726 bar->hide(); 727 bar->hide();
727} 728}
728 729
729bool KSyncManager::isProgressBarCanceled() 730bool KSyncManager::isProgressBarCanceled()
730{ 731{
731 return !bar->isVisible(); 732 return !bar->isVisible();
732} 733}
733 734
734QString KSyncManager::syncFileName() 735QString KSyncManager::syncFileName()
735{ 736{
736 737
737 QString fn = "tempfile"; 738 QString fn = "tempfile";
738 switch(mTargetApp) 739 switch(mTargetApp)
739 { 740 {
740 case (KAPI): 741 case (KAPI):
741 fn = "addressbook.vcf"; 742 fn = "addressbook.vcf";
742 break; 743 break;
743 case (KOPI): 744 case (KOPI):
744 fn = "synccalendar.ics"; 745 fn = "synccalendar.ics";
745 break; 746 break;
746 case (PWMPI): 747 case (PWMPI):
747 fn = "manager.pwm"; 748 fn = "manager.pwm";
748 break; 749 break;
749 default: 750 default:
750 break; 751 break;
751 } 752 }
752#ifdef _WIN32_ 753#ifdef _WIN32_
753 return locateLocal( "tmp", fn ); 754 return locateLocal( "tmp", fn );
754#else 755#else
755 return (QString( "/tmp/" )+ fn ); 756 return (QString( "/tmp/" )+ fn );
756#endif 757#endif
757} 758}
758 759
759void KSyncManager::syncPi() 760void KSyncManager::syncPi()
760{ 761{
761 qApp->processEvents(); 762 qApp->processEvents();
762 bool ok; 763 bool ok;
763 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 764 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
764 if ( ! ok ) { 765 if ( ! ok ) {
765 mParent->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 766 mParent->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
766 return; 767 return;
767 } 768 }
768 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); 769 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this );
769 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 770 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
770 mParent->setCaption( i18n("Sending request for remote file ...") ); 771 mParent->setCaption( i18n("Sending request for remote file ...") );
771 commandSocket->readFile( syncFileName() ); 772 commandSocket->readFile( syncFileName() );
772} 773}
773 774
774void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 775void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
775{ 776{
776 qDebug("MainWindow::deleteCommandSocket %d", state); 777 qDebug("MainWindow::deleteCommandSocket %d", state);
777 778
778 //enum { success, errorW, errorR, quiet }; 779 //enum { success, errorW, errorR, quiet };
779 if ( state == KCommandSocket::errorR ) { 780 if ( state == KCommandSocket::errorR ) {
780 mParent->setCaption( i18n("ERROR: Receiving remote file failed.") ); 781 mParent->setCaption( i18n("ERROR: Receiving remote file failed.") );
781 delete s; 782 delete s;
782 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 783 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
783 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 784 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
784 commandSocket->sendStop(); 785 commandSocket->sendStop();
785 return; 786 return;
786 787
787 } else if ( state == KCommandSocket::errorW ) { 788 } else if ( state == KCommandSocket::errorW ) {
788 mParent->setCaption( i18n("ERROR:Writing back file failed.") ); 789 mParent->setCaption( i18n("ERROR:Writing back file failed.") );
789 790
790 } else if ( state == KCommandSocket::successR ) { 791 } else if ( state == KCommandSocket::successR ) {
791 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 792 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
792 793
793 } else if ( state == KCommandSocket::successW ) { 794 } else if ( state == KCommandSocket::successW ) {
794 mParent->setCaption( i18n("Pi-Sync succesful!") ); 795 mParent->setCaption( i18n("Pi-Sync succesful!") );
795 } 796 }
796 797
797 delete s; 798 delete s;
798} 799}
799 800
800void KSyncManager::readFileFromSocket() 801void KSyncManager::readFileFromSocket()
801{ 802{
802 QString fileName = syncFileName(); 803 QString fileName = syncFileName();
803 mParent->setCaption( i18n("Remote file saved to temp file.") ); 804 mParent->setCaption( i18n("Remote file saved to temp file.") );
804 if ( ! syncWithFile( fileName , true ) ) { 805 if ( ! syncWithFile( fileName , true ) ) {
805 mParent->setCaption( i18n("Syncing failed.") ); 806 mParent->setCaption( i18n("Syncing failed.") );
806 qDebug("Syncing failed "); 807 qDebug("Syncing failed ");
807 return; 808 return;
808 } 809 }
809 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 810 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
810 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 811 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
811 if ( mWriteBackFile ) 812 if ( mWriteBackFile )
812 commandSocket->writeFile( fileName ); 813 commandSocket->writeFile( fileName );
813 else { 814 else {
814 commandSocket->sendStop(); 815 commandSocket->sendStop();
815 mParent->setCaption( i18n("Pi-Sync succesful!") ); 816 mParent->setCaption( i18n("Pi-Sync succesful!") );
816 } 817 }
817} 818}
818 819
819 820
820 821
821 822
822 823
823 824
824 825
825 826
826 827
827 828
828 829
829 830
830 831
831 832
832 833
833 834
834 835
835 836
836 837
837 838
838 839
839 840
840 841
841KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 842KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
842{ 843{
843 mPassWord = pw; 844 mPassWord = pw;
844 mSocket = 0; 845 mSocket = 0;
845 mSyncActionDialog = 0; 846 mSyncActionDialog = 0;
846 blockRC = false; 847 blockRC = false;
847}; 848};
848 849
849void KServerSocket::newConnection ( int socket ) 850void KServerSocket::newConnection ( int socket )
850{ 851{
851 // qDebug("KServerSocket:New connection %d ", socket); 852 // qDebug("KServerSocket:New connection %d ", socket);
852 if ( mSocket ) { 853 if ( mSocket ) {
853 qDebug("KServerSocket::newConnection Socket deleted! "); 854 qDebug("KServerSocket::newConnection Socket deleted! ");
854 delete mSocket; 855 delete mSocket;
855 mSocket = 0; 856 mSocket = 0;
856 } 857 }
857 mSocket = new QSocket( this ); 858 mSocket = new QSocket( this );
858 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 859 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
859 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 860 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
860 mSocket->setSocket( socket ); 861 mSocket->setSocket( socket );
861} 862}
862 863
863void KServerSocket::discardClient() 864void KServerSocket::discardClient()
864{ 865{
865 //qDebug(" KServerSocket::discardClient()"); 866 //qDebug(" KServerSocket::discardClient()");
866 if ( mSocket ) { 867 if ( mSocket ) {
867 delete mSocket; 868 delete mSocket;
868 mSocket = 0; 869 mSocket = 0;
869 } 870 }
870 //emit endConnect(); 871 //emit endConnect();
871} 872}
872void KServerSocket::readClient() 873void KServerSocket::readClient()
873{ 874{
874 if ( blockRC ) 875 if ( blockRC )
875 return; 876 return;
876 if ( mSocket == 0 ) { 877 if ( mSocket == 0 ) {
877 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 878 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
878 return; 879 return;
879 } 880 }
880 qDebug("KServerSocket readClient()"); 881 qDebug("KServerSocket readClient()");
881 if ( mSocket->canReadLine() ) { 882 if ( mSocket->canReadLine() ) {
882 QString line = mSocket->readLine(); 883 QString line = mSocket->readLine();
883 qDebug("KServerSocket readline: %s ", line.latin1()); 884 qDebug("KServerSocket readline: %s ", line.latin1());
884 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 885 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
885 if ( tokens[0] == "GET" ) { 886 if ( tokens[0] == "GET" ) {
886 if ( tokens[1] == mPassWord ) 887 if ( tokens[1] == mPassWord )
887 //emit sendFile( mSocket ); 888 //emit sendFile( mSocket );
888 send_file(); 889 send_file();
889 else { 890 else {
890 KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); 891 KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password"));
891 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 892 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
892 } 893 }
893 } 894 }
894 if ( tokens[0] == "PUT" ) { 895 if ( tokens[0] == "PUT" ) {
895 if ( tokens[1] == mPassWord ) { 896 if ( tokens[1] == mPassWord ) {
896 //emit getFile( mSocket ); 897 //emit getFile( mSocket );
897 blockRC = true; 898 blockRC = true;
898 get_file(); 899 get_file();
899 } 900 }
900 else { 901 else {
901 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); 902 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password"));
902 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 903 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
903 } 904 }
904 } 905 }
905 if ( tokens[0] == "STOP" ) { 906 if ( tokens[0] == "STOP" ) {
906 //emit endConnect(); 907 //emit endConnect();
907 end_connect(); 908 end_connect();
908 } 909 }
909 } 910 }
910} 911}
911void KServerSocket::end_connect() 912void KServerSocket::end_connect()
912{ 913{
913 delete mSyncActionDialog; 914 delete mSyncActionDialog;
914 mSyncActionDialog = 0; 915 mSyncActionDialog = 0;
915} 916}
916void KServerSocket::send_file() 917void KServerSocket::send_file()
917{ 918{
918 //qDebug("MainWindow::sendFile(QSocket* s) "); 919 //qDebug("MainWindow::sendFile(QSocket* s) ");
919 if ( mSyncActionDialog ) 920 if ( mSyncActionDialog )
920 delete mSyncActionDialog; 921 delete mSyncActionDialog;
921 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 922 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
922 mSyncActionDialog->setCaption(i18n("Received sync request")); 923 mSyncActionDialog->setCaption(i18n("Received sync request"));
923 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 924 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
924 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 925 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
925 lay->addWidget( label); 926 lay->addWidget( label);
926 lay->setMargin(7); 927 lay->setMargin(7);
927 lay->setSpacing(7); 928 lay->setSpacing(7);
928 mSyncActionDialog->setFixedSize( 230, 120); 929 mSyncActionDialog->setFixedSize( 230, 120);
929 mSyncActionDialog->show(); 930 mSyncActionDialog->show();
930 qDebug("KSS::saving ... "); 931 qDebug("KSS::saving ... ");
931 emit saveFile(); 932 emit request_file();
932 qApp->processEvents(); 933 qApp->processEvents();
933 QString fileName = mFileName; 934 QString fileName = mFileName;
934 QFile file( fileName ); 935 QFile file( fileName );
935 if (!file.open( IO_ReadOnly ) ) { 936 if (!file.open( IO_ReadOnly ) ) {
936 delete mSyncActionDialog; 937 delete mSyncActionDialog;
937 mSyncActionDialog = 0; 938 mSyncActionDialog = 0;
938 qDebug("KSS::error open file "); 939 qDebug("KSS::error open file ");
939 mSocket->close(); 940 mSocket->close();
940 if ( mSocket->state() == QSocket::Idle ) 941 if ( mSocket->state() == QSocket::Idle )
941 QTimer::singleShot( 10, this , SLOT ( discardClient())); 942 QTimer::singleShot( 10, this , SLOT ( discardClient()));
942 return ; 943 return ;
943 944
944 } 945 }
945 mSyncActionDialog->setCaption( i18n("Sending file...") ); 946 mSyncActionDialog->setCaption( i18n("Sending file...") );
946 QTextStream ts( &file ); 947 QTextStream ts( &file );
947 ts.setCodec( QTextCodec::codecForName("utf8") ); 948 ts.setCodec( QTextCodec::codecForName("utf8") );
948 QTextStream os( mSocket ); 949 QTextStream os( mSocket );
949 os.setCodec( QTextCodec::codecForName("utf8") ); 950 os.setCodec( QTextCodec::codecForName("utf8") );
950 //os.setEncoding( QTextStream::UnicodeUTF8 ); 951 //os.setEncoding( QTextStream::UnicodeUTF8 );
951 while ( ! ts.atEnd() ) { 952 while ( ! ts.atEnd() ) {
952 os << ts.readLine() << "\n"; 953 os << ts.readLine() << "\n";
953 } 954 }
954 //os << ts.read(); 955 //os << ts.read();
955 file.close(); 956 file.close();
956 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 957 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
957 mSocket->close(); 958 mSocket->close();
958 if ( mSocket->state() == QSocket::Idle ) 959 if ( mSocket->state() == QSocket::Idle )
959 QTimer::singleShot( 10, this , SLOT ( discardClient())); 960 QTimer::singleShot( 10, this , SLOT ( discardClient()));
960} 961}
961void KServerSocket::get_file() 962void KServerSocket::get_file()
962{ 963{
963 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 964 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
964 965
965 piTime.start(); 966 piTime.start();
966 piFileString = ""; 967 piFileString = "";
967 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 968 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
968} 969}
969 970
970 971
971void KServerSocket::readBackFileFromSocket() 972void KServerSocket::readBackFileFromSocket()
972{ 973{
973 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 974 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
974 while ( mSocket->canReadLine () ) { 975 while ( mSocket->canReadLine () ) {
975 piTime.restart(); 976 piTime.restart();
976 QString line = mSocket->readLine (); 977 QString line = mSocket->readLine ();
977 piFileString += line; 978 piFileString += line;
978 //qDebug("readline: %s ", line.latin1()); 979 //qDebug("readline: %s ", line.latin1());
979 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 980 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
980 981
981 } 982 }
982 if ( piTime.elapsed () < 3000 ) { 983 if ( piTime.elapsed () < 3000 ) {
983 // wait for more 984 // wait for more
984 //qDebug("waitformore "); 985 //qDebug("waitformore ");
985 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 986 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
986 return; 987 return;
987 } 988 }
988 QString fileName = mFileName; 989 QString fileName = mFileName;
989 QFile file ( fileName ); 990 QFile file ( fileName );
990 if (!file.open( IO_WriteOnly ) ) { 991 if (!file.open( IO_WriteOnly ) ) {
991 delete mSyncActionDialog; 992 delete mSyncActionDialog;
992 mSyncActionDialog = 0; 993 mSyncActionDialog = 0;
993 qDebug("error open cal file "); 994 qDebug("error open cal file ");
994 piFileString = ""; 995 piFileString = "";
995 emit file_received( false ); 996 emit file_received( false );
996 blockRC = false; 997 blockRC = false;
997 return ; 998 return ;
998 999
999 } 1000 }
1000 1001
1001 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1002 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1002 QTextStream ts ( &file ); 1003 QTextStream ts ( &file );
1003 ts.setCodec( QTextCodec::codecForName("utf8") ); 1004 ts.setCodec( QTextCodec::codecForName("utf8") );
1004 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 1005 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1005 ts << piFileString; 1006 ts << piFileString;
1006 mSocket->close(); 1007 mSocket->close();
1007 if ( mSocket->state() == QSocket::Idle ) 1008 if ( mSocket->state() == QSocket::Idle )
1008 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1009 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1009 file.close(); 1010 file.close();
1010 delete mSyncActionDialog; 1011 delete mSyncActionDialog;
1011 mSyncActionDialog = 0; 1012 mSyncActionDialog = 0;
1012 piFileString = ""; 1013 piFileString = "";
1013 blockRC = false; 1014 blockRC = false;
1014 emit file_received( true ); 1015 emit file_received( true );
1015 1016
1016} 1017}
1017 1018
1018KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) 1019KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
1019{ 1020{
1020 mPassWord = password; 1021 mPassWord = password;
1021 mSocket = 0; 1022 mSocket = 0;
1022 mPort = port; 1023 mPort = port;
1023 mHost = host; 1024 mHost = host;
1024 1025
1025 mRetVal = quiet; 1026 mRetVal = quiet;
1026 mTimerSocket = new QTimer ( this ); 1027 mTimerSocket = new QTimer ( this );
1027 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); 1028 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
1028} 1029}
1029void KCommandSocket::readFile( QString fn ) 1030void KCommandSocket::readFile( QString fn )
1030{ 1031{
1031 if ( !mSocket ) { 1032 if ( !mSocket ) {
1032 mSocket = new QSocket( this ); 1033 mSocket = new QSocket( this );
1033 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1034 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1034 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1035 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1035 } 1036 }
1036 mFileString = ""; 1037 mFileString = "";
1037 mFileName = fn; 1038 mFileName = fn;
1038 mFirst = true; 1039 mFirst = true;
1039 mSocket->connectToHost( mHost, mPort ); 1040 mSocket->connectToHost( mHost, mPort );
1040 QTextStream os( mSocket ); 1041 QTextStream os( mSocket );
1041 os.setEncoding( QTextStream::UnicodeUTF8 ); 1042 os.setEncoding( QTextStream::UnicodeUTF8 );
1042 os << "GET " << mPassWord << "\r\n"; 1043 os << "GET " << mPassWord << "\r\n";
1043 mTimerSocket->start( 10000 ); 1044 mTimerSocket->start( 10000 );
1044} 1045}
1045 1046
1046void KCommandSocket::writeFile( QString fileName ) 1047void KCommandSocket::writeFile( QString fileName )
1047{ 1048{
1048 if ( !mSocket ) { 1049 if ( !mSocket ) {
1049 mSocket = new QSocket( this ); 1050 mSocket = new QSocket( this );
1050 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1051 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1051 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 1052 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1052 } 1053 }
1053 mFileName = fileName ; 1054 mFileName = fileName ;
1054 mSocket->connectToHost( mHost, mPort ); 1055 mSocket->connectToHost( mHost, mPort );
1055} 1056}
1056void KCommandSocket::writeFileToSocket() 1057void KCommandSocket::writeFileToSocket()
1057{ 1058{
1058 QFile file2( mFileName ); 1059 QFile file2( mFileName );
1059 if (!file2.open( IO_ReadOnly ) ) { 1060 if (!file2.open( IO_ReadOnly ) ) {
1060 mRetVal= errorW; 1061 mRetVal= errorW;
1061 mSocket->close(); 1062 mSocket->close();
1062 if ( mSocket->state() == QSocket::Idle ) 1063 if ( mSocket->state() == QSocket::Idle )
1063 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1064 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1064 return ; 1065 return ;
1065 } 1066 }
1066 QTextStream ts2( &file2 ); 1067 QTextStream ts2( &file2 );
1067 ts2.setCodec( QTextCodec::codecForName("utf8") ); 1068 ts2.setCodec( QTextCodec::codecForName("utf8") );
1068 QTextStream os2( mSocket ); 1069 QTextStream os2( mSocket );
1069 os2.setCodec( QTextCodec::codecForName("utf8") ); 1070 os2.setCodec( QTextCodec::codecForName("utf8") );
1070 os2 << "PUT " << mPassWord << "\r\n";; 1071 os2 << "PUT " << mPassWord << "\r\n";;
1071 while ( ! ts2.atEnd() ) { 1072 while ( ! ts2.atEnd() ) {
1072 os2 << ts2.readLine() << "\n"; 1073 os2 << ts2.readLine() << "\n";
1073 } 1074 }
1074 mRetVal= successW; 1075 mRetVal= successW;
1075 file2.close(); 1076 file2.close();
1076 mSocket->close(); 1077 mSocket->close();
1077 if ( mSocket->state() == QSocket::Idle ) 1078 if ( mSocket->state() == QSocket::Idle )
1078 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1079 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1079} 1080}
1080void KCommandSocket::sendStop() 1081void KCommandSocket::sendStop()
1081{ 1082{
1082 if ( !mSocket ) { 1083 if ( !mSocket ) {
1083 mSocket = new QSocket( this ); 1084 mSocket = new QSocket( this );
1084 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1085 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1085 } 1086 }
1086 mSocket->connectToHost( mHost, mPort ); 1087 mSocket->connectToHost( mHost, mPort );
1087 QTextStream os2( mSocket ); 1088 QTextStream os2( mSocket );
1088 os2.setCodec( QTextCodec::codecForName("utf8") ); 1089 os2.setCodec( QTextCodec::codecForName("utf8") );
1089 os2 << "STOP\r\n"; 1090 os2 << "STOP\r\n";
1090 mSocket->close(); 1091 mSocket->close();
1091 if ( mSocket->state() == QSocket::Idle ) 1092 if ( mSocket->state() == QSocket::Idle )
1092 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1093 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1093} 1094}
1094 1095
1095void KCommandSocket::startReadFileFromSocket() 1096void KCommandSocket::startReadFileFromSocket()
1096{ 1097{
1097 if ( ! mFirst ) 1098 if ( ! mFirst )
1098 return; 1099 return;
1099 mFirst = false; 1100 mFirst = false;
1100 mTimerSocket->stop(); 1101 mTimerSocket->stop();
1101 mFileString = ""; 1102 mFileString = "";
1102 mTime.start(); 1103 mTime.start();
1103 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 1104 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
1104 1105
1105} 1106}
1106void KCommandSocket::readFileFromSocket() 1107void KCommandSocket::readFileFromSocket()
1107{ 1108{
1108 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 1109 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
1109 while ( mSocket->canReadLine () ) { 1110 while ( mSocket->canReadLine () ) {
1110 mTime.restart(); 1111 mTime.restart();
1111 QString line = mSocket->readLine (); 1112 QString line = mSocket->readLine ();
1112 mFileString += line; 1113 mFileString += line;
1113 //qDebug("readline: %s ", line.latin1()); 1114 //qDebug("readline: %s ", line.latin1());
1114 } 1115 }
1115 if ( mTime.elapsed () < 3000 ) { 1116 if ( mTime.elapsed () < 3000 ) {
1116 // wait for more 1117 // wait for more
1117 //qDebug("waitformore "); 1118 //qDebug("waitformore ");
1118 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 1119 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
1119 return; 1120 return;
1120 } 1121 }
1121 QString fileName = mFileName; 1122 QString fileName = mFileName;
1122 QFile file ( fileName ); 1123 QFile file ( fileName );
1123 if (!file.open( IO_WriteOnly ) ) { 1124 if (!file.open( IO_WriteOnly ) ) {
1124 mFileString = ""; 1125 mFileString = "";
1125 mRetVal = errorR; 1126 mRetVal = errorR;
1126 qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); 1127 qDebug("Error open temp calender file for writing: %s",fileName.latin1() );
1127 deleteSocket(); 1128 deleteSocket();
1128 return ; 1129 return ;
1129 1130
1130 } 1131 }
1131 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1132 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1132 QTextStream ts ( &file ); 1133 QTextStream ts ( &file );
1133 ts.setCodec( QTextCodec::codecForName("utf8") ); 1134 ts.setCodec( QTextCodec::codecForName("utf8") );
1134 ts << mFileString; 1135 ts << mFileString;
1135 file.close(); 1136 file.close();
1136 mFileString = ""; 1137 mFileString = "";
1137 mRetVal = successR; 1138 mRetVal = successR;
1138 mSocket->close(); 1139 mSocket->close();
1139 // if state is not idle, deleteSocket(); is called via 1140 // if state is not idle, deleteSocket(); is called via
1140 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1141 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1141 if ( mSocket->state() == QSocket::Idle ) 1142 if ( mSocket->state() == QSocket::Idle )
1142 deleteSocket(); 1143 deleteSocket();
1143} 1144}
1144 1145
1145void KCommandSocket::deleteSocket() 1146void KCommandSocket::deleteSocket()
1146{ 1147{
1147 if ( mTimerSocket->isActive () ) { 1148 if ( mTimerSocket->isActive () ) {
1148 mTimerSocket->stop(); 1149 mTimerSocket->stop();
1149 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); 1150 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? "));
1150 mRetVal = errorR; 1151 mRetVal = errorR;
1151 } 1152 }
1152 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 1153 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
1153 if ( mSocket) 1154 if ( mSocket)
1154 delete mSocket; 1155 delete mSocket;
1155 mSocket = 0; 1156 mSocket = 0;
1156 emit commandFinished( this, mRetVal ); 1157 emit commandFinished( this, mRetVal );
1157} 1158}
1158 1159
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 52e2772..0eb3323 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,228 +1,227 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 19
20$Id$ 20$Id$
21*/ 21*/
22#ifndef _KSYNCMANAGER_H 22#ifndef _KSYNCMANAGER_H
23#define _KSYNCMANAGER_H 23#define _KSYNCMANAGER_H
24 24
25#include <qobject.h> 25#include <qobject.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qsocket.h> 27#include <qsocket.h>
28#include <qdatetime.h> 28#include <qdatetime.h>
29#include <qserversocket.h> 29#include <qserversocket.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qregexp.h> 31#include <qregexp.h>
32 32
33class QPopupMenu; 33class QPopupMenu;
34class KSyncProfile; 34class KSyncProfile;
35class KPimPrefs; 35class KPimPrefs;
36class QWidget; 36class QWidget;
37class KSyncManager; 37class KSyncManager;
38class KSyncInterface; 38class KSyncInterface;
39class QProgressBar; 39class QProgressBar;
40 40
41 41
42class KServerSocket : public QServerSocket 42class KServerSocket : public QServerSocket
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45 45
46public: 46public:
47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); 47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
48 48
49 void newConnection ( int socket ) ; 49 void newConnection ( int socket ) ;
50 void setFileName( QString fn ) {mFileName = fn;}; 50 void setFileName( QString fn ) {mFileName = fn;};
51 51
52signals: 52signals:
53 //void sendFile(QSocket*);
54 //void getFile(QSocket*);
55 void file_received( bool ); 53 void file_received( bool );
56 //void file_sent(); 54 void request_file();
57 void saveFile(); 55 void saveFile();
58 void endConnect(); 56 void endConnect();
59private slots: 57private slots:
60 void discardClient(); 58 void discardClient();
61 void readClient(); 59 void readClient();
62 void readBackFileFromSocket(); 60 void readBackFileFromSocket();
63 private : 61 private :
64 bool blockRC; 62 bool blockRC;
65 void send_file(); 63 void send_file();
66 void get_file(); 64 void get_file();
67 void end_connect(); 65 void end_connect();
68 QDialog* mSyncActionDialog; 66 QDialog* mSyncActionDialog;
69 QSocket* mSocket; 67 QSocket* mSocket;
70 QString mPassWord; 68 QString mPassWord;
71 QString mFileName; 69 QString mFileName;
72 QTime piTime; 70 QTime piTime;
73 QString piFileString; 71 QString piFileString;
74}; 72};
75 73
76class KCommandSocket : public QObject 74class KCommandSocket : public QObject
77{ 75{
78 Q_OBJECT 76 Q_OBJECT
79public: 77public:
80 enum state { successR, errorR, successW, errorW, quiet }; 78 enum state { successR, errorR, successW, errorW, quiet };
81 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); 79 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
82 void readFile( QString ); 80 void readFile( QString );
83 void writeFile( QString ); 81 void writeFile( QString );
84 void sendStop(); 82 void sendStop();
85 83
86 84
87signals: 85signals:
88 void commandFinished( KCommandSocket*, int ); 86 void commandFinished( KCommandSocket*, int );
89private slots: 87private slots:
90 void startReadFileFromSocket(); 88 void startReadFileFromSocket();
91 void readFileFromSocket(); 89 void readFileFromSocket();
92 void deleteSocket(); 90 void deleteSocket();
93 void writeFileToSocket(); 91 void writeFileToSocket();
94 private : 92 private :
95 QSocket* mSocket; 93 QSocket* mSocket;
96 QString mPassWord; 94 QString mPassWord;
97 Q_UINT16 mPort; 95 Q_UINT16 mPort;
98 QString mHost; 96 QString mHost;
99 QString mFileName; 97 QString mFileName;
100 QTimer* mTimerSocket; 98 QTimer* mTimerSocket;
101 int mRetVal; 99 int mRetVal;
102 QTime mTime; 100 QTime mTime;
103 QString mFileString; 101 QString mFileString;
104 bool mFirst; 102 bool mFirst;
105}; 103};
106 104
107 105
108class KSyncManager : public QObject 106class KSyncManager : public QObject
109{ 107{
110 Q_OBJECT 108 Q_OBJECT
111 109
112 public: 110 public:
113 enum TargetApp { 111 enum TargetApp {
114 KOPI = 0, 112 KOPI = 0,
115 KAPI = 1, 113 KAPI = 1,
116 PWMPI = 2 }; 114 PWMPI = 2 };
117 115
118 116
119 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 117 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
120 ~KSyncManager() ; 118 ~KSyncManager() ;
121 119
122 bool blockSave() { return mBlockSaveFlag; } 120 bool blockSave() { return mBlockSaveFlag; }
123 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 121 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
124 void setDefaultFileName( QString s) { mDefFileName = s ;} 122 void setDefaultFileName( QString s) { mDefFileName = s ;}
125 QString defaultFileName() { return mDefFileName ;} 123 QString defaultFileName() { return mDefFileName ;}
126 QString syncFileName(); 124 QString syncFileName();
127 void fillSyncMenu(); 125 void fillSyncMenu();
128 126
129 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 127 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
130 QString getCurrentSyncName() { return mCurrentSyncName; } 128 QString getCurrentSyncName() { return mCurrentSyncName; }
131 129
132 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 130 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
133 void hideProgressBar(); 131 void hideProgressBar();
134 bool isProgressBarCanceled(); 132 bool isProgressBarCanceled();
135 133
136 // sync stuff 134 // sync stuff
137 QString mLocalMachineName; 135 QString mLocalMachineName;
138 QStringList mExternSyncProfiles; 136 QStringList mExternSyncProfiles;
139 QStringList mSyncProfileNames; 137 QStringList mSyncProfileNames;
140 bool mAskForPreferences; 138 bool mAskForPreferences;
141 bool mShowSyncSummary; 139 bool mShowSyncSummary;
142 bool mShowSyncEvents; 140 bool mShowSyncEvents;
143 bool mShowTodoInAgenda; 141 bool mShowTodoInAgenda;
144 bool mWriteBackExistingOnly; 142 bool mWriteBackExistingOnly;
145 int mSyncAlgoPrefs; 143 int mSyncAlgoPrefs;
146 int mRingSyncAlgoPrefs; 144 int mRingSyncAlgoPrefs;
147 bool mWriteBackFile; 145 bool mWriteBackFile;
148 int mWriteBackInFuture; 146 int mWriteBackInFuture;
149 QString mPhoneDevice; 147 QString mPhoneDevice;
150 QString mPhoneConnection; 148 QString mPhoneConnection;
151 QString mPhoneModel; 149 QString mPhoneModel;
152 QString mLastSyncedLocalFile; // save! 150 QString mLastSyncedLocalFile; // save!
153 QString mPassWordPiSync; 151 QString mPassWordPiSync;
154 QString mActiveSyncPort; 152 QString mActiveSyncPort;
155 QString mActiveSyncIP ; 153 QString mActiveSyncIP ;
156 154
157 signals: 155 signals:
158 void save(); 156 void save();
157 void request_file();
159 void getFile( bool ); 158 void getFile( bool );
160 159
161 public slots: 160 public slots:
162 void slotSyncMenu( int ); 161 void slotSyncMenu( int );
163 162
164 private: 163 private:
165 // LR ******************************* 164 // LR *******************************
166 // sync stuff! 165 // sync stuff!
167 void syncPi(); 166 void syncPi();
168 void deleteCommandSocket(KCommandSocket*s, int state); 167 void deleteCommandSocket(KCommandSocket*s, int state);
169 void readFileFromSocket(); 168 void readFileFromSocket();
170 KServerSocket * mServerSocket; 169 KServerSocket * mServerSocket;
171 void enableQuick(); 170 void enableQuick();
172 KPimPrefs* mPrefs; 171 KPimPrefs* mPrefs;
173 QString mDefFileName; 172 QString mDefFileName;
174 QString mCurrentSyncDevice; 173 QString mCurrentSyncDevice;
175 QString mCurrentSyncName; 174 QString mCurrentSyncName;
176 void quickSyncLocalFile(); 175 void quickSyncLocalFile();
177 bool syncWithFile( QString fn , bool quick ); 176 bool syncWithFile( QString fn , bool quick );
178 void syncLocalFile(); 177 void syncLocalFile();
179 void syncPhone(); 178 void syncPhone();
180 void syncSharp(); 179 void syncSharp();
181 bool syncExternalApplication(QString); 180 bool syncExternalApplication(QString);
182 void multiSync( bool askforPrefs ); 181 void multiSync( bool askforPrefs );
183 int mCurrentSyncProfile ; 182 int mCurrentSyncProfile ;
184 void syncRemote( KSyncProfile* prof, bool ask = true); 183 void syncRemote( KSyncProfile* prof, bool ask = true);
185 void edit_sync_options(); 184 void edit_sync_options();
186 int ringSync(); 185 int ringSync();
187 QString getPassword( ); 186 QString getPassword( );
188 187
189 private slots: 188 private slots:
190 void confSync(); 189 void confSync();
191 // ********************* 190 // *********************
192 191
193 private: 192 private:
194 bool mBlockSaveFlag; 193 bool mBlockSaveFlag;
195 194
196 195
197 QWidget* mParent; 196 QWidget* mParent;
198 KSyncInterface* mImplementation; 197 KSyncInterface* mImplementation;
199 TargetApp mTargetApp; 198 TargetApp mTargetApp;
200 QPopupMenu* mSyncMenu; 199 QPopupMenu* mSyncMenu;
201 200
202 QProgressBar* bar; 201 QProgressBar* bar;
203 202
204 203
205 204
206 205
207 206
208}; 207};
209 208
210 209
211class KSyncInterface 210class KSyncInterface
212{ 211{
213 212
214 213
215 public : 214 public :
216 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; 215 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0;
217 216
218 virtual bool syncExternal(KSyncManager* manager, QString resource) 217 virtual bool syncExternal(KSyncManager* manager, QString resource)
219 { 218 {
220 // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager. 219 // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager.
221 return false; 220 return false;
222 } 221 }
223 222
224 223
225}; 224};
226 225
227 226
228#endif 227#endif