summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp22
-rw-r--r--kabc/addressbook.h1
-rw-r--r--kabc/addressee.cpp75
-rw-r--r--kabc/addressee.h4
-rw-r--r--kabc/phonenumber.cpp24
-rw-r--r--kaddressbook/kabcore.cpp130
-rw-r--r--kaddressbook/kabcore.h5
-rw-r--r--kaddressbook/kaimportoldialog.cpp712
-rw-r--r--kaddressbook/kaimportoldialog.h63
-rw-r--r--kaddressbook/phoneeditwidget.cpp11
-rw-r--r--korganizer/journalentry.h1
-rw-r--r--korganizer/kojournalview.cpp9
-rw-r--r--libkdepim/externalapphandler.cpp2
-rw-r--r--libkdepim/ksyncmanager.cpp71
-rw-r--r--libkdepim/ksyncmanager.h3
-rw-r--r--libkdepim/libkdepim.pro15
16 files changed, 337 insertions, 811 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index f9e4387..fe59fcb 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -1,1296 +1,1314 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28/*US 28/*US
29 29
30#include <qfile.h> 30#include <qfile.h>
31#include <qregexp.h> 31#include <qregexp.h>
32#include <qtimer.h> 32#include <qtimer.h>
33 33
34#include <kapplication.h> 34#include <kapplication.h>
35#include <kinstance.h> 35#include <kinstance.h>
36#include <kstandarddirs.h> 36#include <kstandarddirs.h>
37 37
38#include "errorhandler.h" 38#include "errorhandler.h"
39*/ 39*/
40#include <qptrlist.h> 40#include <qptrlist.h>
41#include <qtextstream.h> 41#include <qtextstream.h>
42#include <qfile.h> 42#include <qfile.h>
43#include <qregexp.h> 43#include <qregexp.h>
44 44
45#include <kglobal.h> 45#include <kglobal.h>
46#include <klocale.h> 46#include <klocale.h>
47#include <kmessagebox.h> 47#include <kmessagebox.h>
48#include <kdebug.h> 48#include <kdebug.h>
49#include <libkcal/syncdefines.h> 49#include <libkcal/syncdefines.h>
50#include <libkdepim/phoneaccess.h> 50#include <libkdepim/phoneaccess.h>
51#include "addressbook.h" 51#include "addressbook.h"
52#include "resource.h" 52#include "resource.h"
53#include "vcardconverter.h" 53#include "vcardconverter.h"
54#include "vcardparser/vcardtool.h" 54#include "vcardparser/vcardtool.h"
55 55
56//US #include "addressbook.moc" 56//US #include "addressbook.moc"
57 57
58using namespace KABC; 58using namespace KABC;
59 59
60struct AddressBook::AddressBookData 60struct AddressBook::AddressBookData
61{ 61{
62 Addressee::List mAddressees; 62 Addressee::List mAddressees;
63 Addressee::List mRemovedAddressees; 63 Addressee::List mRemovedAddressees;
64 Field::List mAllFields; 64 Field::List mAllFields;
65 KConfig *mConfig; 65 KConfig *mConfig;
66 KRES::Manager<Resource> *mManager; 66 KRES::Manager<Resource> *mManager;
67//US ErrorHandler *mErrorHandler; 67//US ErrorHandler *mErrorHandler;
68}; 68};
69 69
70struct AddressBook::Iterator::IteratorData 70struct AddressBook::Iterator::IteratorData
71{ 71{
72 Addressee::List::Iterator mIt; 72 Addressee::List::Iterator mIt;
73}; 73};
74 74
75struct AddressBook::ConstIterator::ConstIteratorData 75struct AddressBook::ConstIterator::ConstIteratorData
76{ 76{
77 Addressee::List::ConstIterator mIt; 77 Addressee::List::ConstIterator mIt;
78}; 78};
79 79
80AddressBook::Iterator::Iterator() 80AddressBook::Iterator::Iterator()
81{ 81{
82 d = new IteratorData; 82 d = new IteratorData;
83} 83}
84 84
85AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) 85AddressBook::Iterator::Iterator( const AddressBook::Iterator &i )
86{ 86{
87 d = new IteratorData; 87 d = new IteratorData;
88 d->mIt = i.d->mIt; 88 d->mIt = i.d->mIt;
89} 89}
90 90
91AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) 91AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i )
92{ 92{
93 if( this == &i ) return *this; // guard against self assignment 93 if( this == &i ) return *this; // guard against self assignment
94 delete d; // delete the old data the Iterator was completely constructed before 94 delete d; // delete the old data the Iterator was completely constructed before
95 d = new IteratorData; 95 d = new IteratorData;
96 d->mIt = i.d->mIt; 96 d->mIt = i.d->mIt;
97 return *this; 97 return *this;
98} 98}
99 99
100AddressBook::Iterator::~Iterator() 100AddressBook::Iterator::~Iterator()
101{ 101{
102 delete d; 102 delete d;
103} 103}
104 104
105const Addressee &AddressBook::Iterator::operator*() const 105const Addressee &AddressBook::Iterator::operator*() const
106{ 106{
107 return *(d->mIt); 107 return *(d->mIt);
108} 108}
109 109
110Addressee &AddressBook::Iterator::operator*() 110Addressee &AddressBook::Iterator::operator*()
111{ 111{
112 return *(d->mIt); 112 return *(d->mIt);
113} 113}
114 114
115Addressee *AddressBook::Iterator::operator->() 115Addressee *AddressBook::Iterator::operator->()
116{ 116{
117 return &(*(d->mIt)); 117 return &(*(d->mIt));
118} 118}
119 119
120AddressBook::Iterator &AddressBook::Iterator::operator++() 120AddressBook::Iterator &AddressBook::Iterator::operator++()
121{ 121{
122 (d->mIt)++; 122 (d->mIt)++;
123 return *this; 123 return *this;
124} 124}
125 125
126AddressBook::Iterator &AddressBook::Iterator::operator++(int) 126AddressBook::Iterator &AddressBook::Iterator::operator++(int)
127{ 127{
128 (d->mIt)++; 128 (d->mIt)++;
129 return *this; 129 return *this;
130} 130}
131 131
132AddressBook::Iterator &AddressBook::Iterator::operator--() 132AddressBook::Iterator &AddressBook::Iterator::operator--()
133{ 133{
134 (d->mIt)--; 134 (d->mIt)--;
135 return *this; 135 return *this;
136} 136}
137 137
138AddressBook::Iterator &AddressBook::Iterator::operator--(int) 138AddressBook::Iterator &AddressBook::Iterator::operator--(int)
139{ 139{
140 (d->mIt)--; 140 (d->mIt)--;
141 return *this; 141 return *this;
142} 142}
143 143
144bool AddressBook::Iterator::operator==( const Iterator &it ) 144bool AddressBook::Iterator::operator==( const Iterator &it )
145{ 145{
146 return ( d->mIt == it.d->mIt ); 146 return ( d->mIt == it.d->mIt );
147} 147}
148 148
149bool AddressBook::Iterator::operator!=( const Iterator &it ) 149bool AddressBook::Iterator::operator!=( const Iterator &it )
150{ 150{
151 return ( d->mIt != it.d->mIt ); 151 return ( d->mIt != it.d->mIt );
152} 152}
153 153
154 154
155AddressBook::ConstIterator::ConstIterator() 155AddressBook::ConstIterator::ConstIterator()
156{ 156{
157 d = new ConstIteratorData; 157 d = new ConstIteratorData;
158} 158}
159 159
160AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) 160AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i )
161{ 161{
162 d = new ConstIteratorData; 162 d = new ConstIteratorData;
163 d->mIt = i.d->mIt; 163 d->mIt = i.d->mIt;
164} 164}
165 165
166AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) 166AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i )
167{ 167{
168 if( this == &i ) return *this; // guard for self assignment 168 if( this == &i ) return *this; // guard for self assignment
169 delete d; // delete the old data because the Iterator was really constructed before 169 delete d; // delete the old data because the Iterator was really constructed before
170 d = new ConstIteratorData; 170 d = new ConstIteratorData;
171 d->mIt = i.d->mIt; 171 d->mIt = i.d->mIt;
172 return *this; 172 return *this;
173} 173}
174 174
175AddressBook::ConstIterator::~ConstIterator() 175AddressBook::ConstIterator::~ConstIterator()
176{ 176{
177 delete d; 177 delete d;
178} 178}
179 179
180const Addressee &AddressBook::ConstIterator::operator*() const 180const Addressee &AddressBook::ConstIterator::operator*() const
181{ 181{
182 return *(d->mIt); 182 return *(d->mIt);
183} 183}
184 184
185const Addressee* AddressBook::ConstIterator::operator->() const 185const Addressee* AddressBook::ConstIterator::operator->() const
186{ 186{
187 return &(*(d->mIt)); 187 return &(*(d->mIt));
188} 188}
189 189
190AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() 190AddressBook::ConstIterator &AddressBook::ConstIterator::operator++()
191{ 191{
192 (d->mIt)++; 192 (d->mIt)++;
193 return *this; 193 return *this;
194} 194}
195 195
196AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) 196AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int)
197{ 197{
198 (d->mIt)++; 198 (d->mIt)++;
199 return *this; 199 return *this;
200} 200}
201 201
202AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() 202AddressBook::ConstIterator &AddressBook::ConstIterator::operator--()
203{ 203{
204 (d->mIt)--; 204 (d->mIt)--;
205 return *this; 205 return *this;
206} 206}
207 207
208AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) 208AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int)
209{ 209{
210 (d->mIt)--; 210 (d->mIt)--;
211 return *this; 211 return *this;
212} 212}
213 213
214bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) 214bool AddressBook::ConstIterator::operator==( const ConstIterator &it )
215{ 215{
216 return ( d->mIt == it.d->mIt ); 216 return ( d->mIt == it.d->mIt );
217} 217}
218 218
219bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) 219bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
220{ 220{
221 return ( d->mIt != it.d->mIt ); 221 return ( d->mIt != it.d->mIt );
222} 222}
223 223
224 224
225AddressBook::AddressBook() 225AddressBook::AddressBook()
226{ 226{
227 init(0, "contact"); 227 init(0, "contact");
228} 228}
229 229
230AddressBook::AddressBook( const QString &config ) 230AddressBook::AddressBook( const QString &config )
231{ 231{
232 init(config, "contact"); 232 init(config, "contact");
233} 233}
234 234
235AddressBook::AddressBook( const QString &config, const QString &family ) 235AddressBook::AddressBook( const QString &config, const QString &family )
236{ 236{
237 init(config, family); 237 init(config, family);
238 238
239} 239}
240 240
241// the default family is "contact" 241// the default family is "contact"
242void AddressBook::init(const QString &config, const QString &family ) 242void AddressBook::init(const QString &config, const QString &family )
243{ 243{
244 blockLSEchange = false; 244 blockLSEchange = false;
245 d = new AddressBookData; 245 d = new AddressBookData;
246 QString fami = family; 246 QString fami = family;
247 if (config != 0) { 247 if (config != 0) {
248 if ( family == "syncContact" ) { 248 if ( family == "syncContact" ) {
249 qDebug("creating sync config "); 249 qDebug("creating sync config ");
250 fami = "contact"; 250 fami = "contact";
251 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); 251 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") );
252 con->setGroup( "General" ); 252 con->setGroup( "General" );
253 con->writeEntry( "ResourceKeys", QString("sync") ); 253 con->writeEntry( "ResourceKeys", QString("sync") );
254 con->writeEntry( "Standard", QString("sync") ); 254 con->writeEntry( "Standard", QString("sync") );
255 con->setGroup( "Resource_sync" ); 255 con->setGroup( "Resource_sync" );
256 con->writeEntry( "FileName", config ); 256 con->writeEntry( "FileName", config );
257 con->writeEntry( "FileFormat", QString("vcard") ); 257 con->writeEntry( "FileFormat", QString("vcard") );
258 con->writeEntry( "ResourceIdentifier", QString("sync") ); 258 con->writeEntry( "ResourceIdentifier", QString("sync") );
259 con->writeEntry( "ResourceName", QString("sync_res") ); 259 con->writeEntry( "ResourceName", QString("sync_res") );
260 if ( config.right(4) == ".xml" ) 260 if ( config.right(4) == ".xml" )
261 con->writeEntry( "ResourceType", QString("qtopia") ); 261 con->writeEntry( "ResourceType", QString("qtopia") );
262 else if ( config == "sharp" ) { 262 else if ( config == "sharp" ) {
263 con->writeEntry( "ResourceType", QString("sharp") ); 263 con->writeEntry( "ResourceType", QString("sharp") );
264 } else { 264 } else {
265 con->writeEntry( "ResourceType", QString("file") ); 265 con->writeEntry( "ResourceType", QString("file") );
266 } 266 }
267 //con->sync(); 267 //con->sync();
268 d->mConfig = con; 268 d->mConfig = con;
269 } 269 }
270 else 270 else
271 d->mConfig = new KConfig( locateLocal("config", config) ); 271 d->mConfig = new KConfig( locateLocal("config", config) );
272// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 272// qDebug("AddressBook::init 1 config=%s",config.latin1() );
273 } 273 }
274 else { 274 else {
275 d->mConfig = 0; 275 d->mConfig = 0;
276// qDebug("AddressBook::init 1 config=0"); 276// qDebug("AddressBook::init 1 config=0");
277 } 277 }
278 278
279//US d->mErrorHandler = 0; 279//US d->mErrorHandler = 0;
280 d->mManager = new KRES::Manager<Resource>( fami ); 280 d->mManager = new KRES::Manager<Resource>( fami );
281 d->mManager->readConfig( d->mConfig ); 281 d->mManager->readConfig( d->mConfig );
282 if ( family == "syncContact" ) { 282 if ( family == "syncContact" ) {
283 KRES::Manager<Resource> *manager = d->mManager; 283 KRES::Manager<Resource> *manager = d->mManager;
284 KRES::Manager<Resource>::ActiveIterator it; 284 KRES::Manager<Resource>::ActiveIterator it;
285 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 285 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
286 (*it)->setAddressBook( this ); 286 (*it)->setAddressBook( this );
287 if ( !(*it)->open() ) 287 if ( !(*it)->open() )
288 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); 288 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
289 } 289 }
290 Resource *res = standardResource(); 290 Resource *res = standardResource();
291 if ( !res ) { 291 if ( !res ) {
292 qDebug("ERROR: no standard resource"); 292 qDebug("ERROR: no standard resource");
293 res = manager->createResource( "file" ); 293 res = manager->createResource( "file" );
294 if ( res ) 294 if ( res )
295 { 295 {
296 addResource( res ); 296 addResource( res );
297 } 297 }
298 else 298 else
299 qDebug(" No resource available!!!"); 299 qDebug(" No resource available!!!");
300 } 300 }
301 setStandardResource( res ); 301 setStandardResource( res );
302 manager->writeConfig(); 302 manager->writeConfig();
303 } 303 }
304 addCustomField( i18n( "Department" ), KABC::Field::Organization, 304 addCustomField( i18n( "Department" ), KABC::Field::Organization,
305 "X-Department", "KADDRESSBOOK" ); 305 "X-Department", "KADDRESSBOOK" );
306 addCustomField( i18n( "Profession" ), KABC::Field::Organization, 306 addCustomField( i18n( "Profession" ), KABC::Field::Organization,
307 "X-Profession", "KADDRESSBOOK" ); 307 "X-Profession", "KADDRESSBOOK" );
308 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 308 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
309 "X-AssistantsName", "KADDRESSBOOK" ); 309 "X-AssistantsName", "KADDRESSBOOK" );
310 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 310 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
311 "X-ManagersName", "KADDRESSBOOK" ); 311 "X-ManagersName", "KADDRESSBOOK" );
312 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 312 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
313 "X-SpousesName", "KADDRESSBOOK" ); 313 "X-SpousesName", "KADDRESSBOOK" );
314 addCustomField( i18n( "Office" ), KABC::Field::Personal, 314 addCustomField( i18n( "Office" ), KABC::Field::Personal,
315 "X-Office", "KADDRESSBOOK" ); 315 "X-Office", "KADDRESSBOOK" );
316 addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 316 addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
317 "X-IMAddress", "KADDRESSBOOK" ); 317 "X-IMAddress", "KADDRESSBOOK" );
318 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 318 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
319 "X-Anniversary", "KADDRESSBOOK" ); 319 "X-Anniversary", "KADDRESSBOOK" );
320 320
321 //US added this field to become compatible with Opie/qtopia addressbook 321 //US added this field to become compatible with Opie/qtopia addressbook
322 // values can be "female" or "male" or "". An empty field represents undefined. 322 // values can be "female" or "male" or "". An empty field represents undefined.
323 addCustomField( i18n( "Gender" ), KABC::Field::Personal, 323 addCustomField( i18n( "Gender" ), KABC::Field::Personal,
324 "X-Gender", "KADDRESSBOOK" ); 324 "X-Gender", "KADDRESSBOOK" );
325 addCustomField( i18n( "Children" ), KABC::Field::Personal, 325 addCustomField( i18n( "Children" ), KABC::Field::Personal,
326 "X-Children", "KADDRESSBOOK" ); 326 "X-Children", "KADDRESSBOOK" );
327 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 327 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
328 "X-FreeBusyUrl", "KADDRESSBOOK" ); 328 "X-FreeBusyUrl", "KADDRESSBOOK" );
329 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, 329 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal,
330 "X-ExternalID", "KADDRESSBOOK" ); 330 "X-ExternalID", "KADDRESSBOOK" );
331} 331}
332 332
333AddressBook::~AddressBook() 333AddressBook::~AddressBook()
334{ 334{
335 delete d->mConfig; d->mConfig = 0; 335 delete d->mConfig; d->mConfig = 0;
336 delete d->mManager; d->mManager = 0; 336 delete d->mManager; d->mManager = 0;
337//US delete d->mErrorHandler; d->mErrorHandler = 0; 337//US delete d->mErrorHandler; d->mErrorHandler = 0;
338 delete d; d = 0; 338 delete d; d = 0;
339} 339}
340 340
341bool AddressBook::load() 341bool AddressBook::load()
342{ 342{
343 343
344 clear(); 344 clear();
345 KRES::Manager<Resource>::ActiveIterator it; 345 KRES::Manager<Resource>::ActiveIterator it;
346 bool ok = true; 346 bool ok = true;
347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
348 if ( !(*it)->load() ) { 348 if ( !(*it)->load() ) {
349 qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); 349 qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
350 ok = false; 350 ok = false;
351 } else { 351 } else {
352 qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) ); 352 qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) );
353 } 353 }
354 // mark all addressees as unchanged 354 // mark all addressees as unchanged
355 Addressee::List::Iterator addrIt; 355 Addressee::List::Iterator addrIt;
356 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { 356 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) {
357 (*addrIt).setChanged( false ); 357 (*addrIt).setChanged( false );
358 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); 358 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" );
359 if ( !id.isEmpty() ) { 359 if ( !id.isEmpty() ) {
360 //qDebug("setId aa %s ", id.latin1()); 360 //qDebug("setId aa %s ", id.latin1());
361 (*addrIt).setIDStr(id ); 361 (*addrIt).setIDStr(id );
362 } 362 }
363 } 363 }
364 blockLSEchange = true; 364 blockLSEchange = true;
365 return ok; 365 return ok;
366} 366}
367 367
368bool AddressBook::save( Ticket *ticket ) 368bool AddressBook::save( Ticket *ticket )
369{ 369{
370 kdDebug(5700) << "AddressBook::save()"<< endl; 370 kdDebug(5700) << "AddressBook::save()"<< endl;
371 371
372 if ( ticket->resource() ) { 372 if ( ticket->resource() ) {
373 deleteRemovedAddressees(); 373 deleteRemovedAddressees();
374 return ticket->resource()->save( ticket ); 374 return ticket->resource()->save( ticket );
375 } 375 }
376 376
377 return false; 377 return false;
378} 378}
379// exports all Addressees, which are syncable 379// exports all Addressees, which are syncable
380void AddressBook::export2File( QString fileName, QString resourceName ) 380void AddressBook::export2File( QString fileName, QString resourceName )
381{ 381{
382 382
383 QFile outFile( fileName ); 383 QFile outFile( fileName );
384 if ( !outFile.open( IO_WriteOnly ) ) { 384 if ( !outFile.open( IO_WriteOnly ) ) {
385 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); 385 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
386 KMessageBox::error( 0, text.arg( fileName ) ); 386 KMessageBox::error( 0, text.arg( fileName ) );
387 return ; 387 return ;
388 } 388 }
389 QTextStream t( &outFile ); 389 QTextStream t( &outFile );
390 t.setEncoding( QTextStream::UnicodeUTF8 ); 390 t.setEncoding( QTextStream::UnicodeUTF8 );
391 Iterator it; 391 Iterator it;
392 KABC::VCardConverter::Version version; 392 KABC::VCardConverter::Version version;
393 version = KABC::VCardConverter::v3_0; 393 version = KABC::VCardConverter::v3_0;
394 for ( it = begin(); it != end(); ++it ) { 394 for ( it = begin(); it != end(); ++it ) {
395 if ( (*it).resource() ) { 395 if ( (*it).resource() ) {
396 bool include = (*it).resource()->includeInSync(); 396 bool include = (*it).resource()->includeInSync();
397 if ( !resourceName.isEmpty() ) 397 if ( !resourceName.isEmpty() )
398 include = (resourceName == (*it).resource()->resourceName() ); 398 include = (resourceName == (*it).resource()->resourceName() );
399 if ( include ) { 399 if ( include ) {
400 //qDebug(QString ("Exporting resource %1 to file %2").arg( (*it).resource()->resourceName() ).arg( fileName ) ); 400 //qDebug(QString ("Exporting resource %1 to file %2").arg( (*it).resource()->resourceName() ).arg( fileName ) );
401 if ( !(*it).IDStr().isEmpty() ) { 401 if ( !(*it).IDStr().isEmpty() ) {
402 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); 402 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() );
403 } 403 }
404 KABC::VCardConverter converter; 404 KABC::VCardConverter converter;
405 QString vcard; 405 QString vcard;
406 //Resource *resource() const; 406 //Resource *resource() const;
407 converter.addresseeToVCard( *it, vcard, version ); 407 converter.addresseeToVCard( *it, vcard, version );
408 t << vcard << "\r\n"; 408 t << vcard << "\r\n";
409 } 409 }
410 } 410 }
411 } 411 }
412 t << "\r\n\r\n"; 412 t << "\r\n\r\n";
413 outFile.close(); 413 outFile.close();
414} 414}
415// if QStringList uids is empty, all are exported 415// if QStringList uids is empty, all are exported
416bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) 416bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName )
417{ 417{
418 KABC::VCardConverter converter; 418 KABC::VCardConverter converter;
419 QString datastream; 419 QString datastream;
420 Iterator it; 420 Iterator it;
421 bool all = uids.isEmpty(); 421 bool all = uids.isEmpty();
422 for ( it = begin(); it != end(); ++it ) { 422 for ( it = begin(); it != end(); ++it ) {
423 // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 423 // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
424 if ( ! all ) { 424 if ( ! all ) {
425 if ( ! ( uids.contains((*it).uid() ) )) 425 if ( ! ( uids.contains((*it).uid() ) ))
426 continue; 426 continue;
427 } 427 }
428 KABC::Addressee a = ( *it ); 428 KABC::Addressee a = ( *it );
429 if ( a.isEmpty() ) 429 if ( a.isEmpty() )
430 continue; 430 continue;
431 if ( all && a.resource() && !a.resource()->includeInSync() ) 431 if ( all && a.resource() && !a.resource()->includeInSync() )
432 continue; 432 continue;
433 a.simplifyEmails(); 433 a.simplifyEmails();
434 a.simplifyPhoneNumbers(); 434 a.simplifyPhoneNumbers();
435 a.simplifyPhoneNumberTypes(); 435 a.simplifyPhoneNumberTypes();
436 a.simplifyAddresses(); 436 a.simplifyAddresses();
437 437
438 QString vcard; 438 QString vcard;
439 QString vcardnew; 439 QString vcardnew;
440 converter.addresseeToVCard( a, vcard ); 440 converter.addresseeToVCard( a, vcard );
441 int start = 0; 441 int start = 0;
442 int next; 442 int next;
443 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 443 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
444 int semi = vcard.find(";", next); 444 int semi = vcard.find(";", next);
445 int dopp = vcard.find(":", next); 445 int dopp = vcard.find(":", next);
446 int sep; 446 int sep;
447 if ( semi < dopp && semi >= 0 ) 447 if ( semi < dopp && semi >= 0 )
448 sep = semi ; 448 sep = semi ;
449 else 449 else
450 sep = dopp; 450 sep = dopp;
451 vcardnew +=vcard.mid( start, next - start); 451 vcardnew +=vcard.mid( start, next - start);
452 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); 452 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper();
453 start = sep; 453 start = sep;
454 } 454 }
455 vcardnew += vcard.mid( start,vcard.length() ); 455 vcardnew += vcard.mid( start,vcard.length() );
456 vcard = ""; 456 vcard = "";
457 start = 0; 457 start = 0;
458 while ( (next = vcardnew.find("ADR", start) )>= 0 ) { 458 while ( (next = vcardnew.find("ADR", start) )>= 0 ) {
459 int sep = vcardnew.find(":", next); 459 int sep = vcardnew.find(":", next);
460 vcard +=vcardnew.mid( start, next - start+3); 460 vcard +=vcardnew.mid( start, next - start+3);
461 start = sep; 461 start = sep;
462 } 462 }
463 vcard += vcardnew.mid( start,vcardnew.length() ); 463 vcard += vcardnew.mid( start,vcardnew.length() );
464 vcard.replace ( QRegExp(";;;") , "" ); 464 vcard.replace ( QRegExp(";;;") , "" );
465 vcard.replace ( QRegExp(";;") , "" ); 465 vcard.replace ( QRegExp(";;") , "" );
466 datastream += vcard; 466 datastream += vcard;
467 467
468 } 468 }
469 469
470 QFile outFile(fileName); 470 QFile outFile(fileName);
471 if ( outFile.open(IO_WriteOnly) ) { 471 if ( outFile.open(IO_WriteOnly) ) {
472 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 472 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
473 QTextStream t( &outFile ); // use a text stream 473 QTextStream t( &outFile ); // use a text stream
474 t.setEncoding( QTextStream::UnicodeUTF8 ); 474 t.setEncoding( QTextStream::UnicodeUTF8 );
475 t <<datastream; 475 t <<datastream;
476 t << "\r\n\r\n"; 476 t << "\r\n\r\n";
477 outFile.close(); 477 outFile.close();
478 478
479 } else { 479 } else {
480 qDebug("Error open temp file "); 480 qDebug("Error open temp file ");
481 return false; 481 return false;
482 } 482 }
483 return true; 483 return true;
484 484
485} 485}
486int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld, QString resource ) 486int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld, QString resource )
487{ 487{
488 488
489 if ( removeOld ) 489 if ( removeOld )
490 setUntagged( true, resource ); 490 setUntagged( true, resource );
491 KABC::Addressee::List list; 491 KABC::Addressee::List list;
492 QFile file( fileName ); 492 QFile file( fileName );
493 file.open( IO_ReadOnly ); 493 file.open( IO_ReadOnly );
494 QByteArray rawData = file.readAll(); 494 QByteArray rawData = file.readAll();
495 file.close(); 495 file.close();
496 QString data; 496 QString data;
497 if ( replaceLabel ) { 497 if ( replaceLabel ) {
498 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); 498 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 );
499 data.replace ( QRegExp("LABEL") , "ADR" ); 499 data.replace ( QRegExp("LABEL") , "ADR" );
500 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); 500 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" );
501 } else 501 } else
502 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 502 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
503 KABC::VCardTool tool; 503 KABC::VCardTool tool;
504 list = tool.parseVCards( data ); 504 list = tool.parseVCards( data );
505 KABC::Addressee::List::Iterator it; 505 KABC::Addressee::List::Iterator it;
506 506
507 Resource * setRes = 0; 507 Resource * setRes = 0;
508 if ( !resource.isEmpty() ) { 508 if ( !resource.isEmpty() ) {
509 KRES::Manager<Resource>::ActiveIterator it; 509 KRES::Manager<Resource>::ActiveIterator it;
510 KRES::Manager<Resource> *manager = d->mManager; 510 KRES::Manager<Resource> *manager = d->mManager;
511 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 511 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
512 //qDebug("SaveAB::checking resource..." ); 512 //qDebug("SaveAB::checking resource..." );
513 if ( (*it)->resourceName() == resource ) { 513 if ( (*it)->resourceName() == resource ) {
514 setRes = (*it); 514 setRes = (*it);
515 qDebug("KA: AB: Inserting imported contacs to resource %s", resource.latin1()); 515 qDebug("KA: AB: Inserting imported contacs to resource %s", resource.latin1());
516 break; 516 break;
517 } 517 }
518 } 518 }
519 } 519 }
520 for ( it = list.begin(); it != list.end(); ++it ) { 520 for ( it = list.begin(); it != list.end(); ++it ) {
521 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); 521 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" );
522 if ( !id.isEmpty() ) 522 if ( !id.isEmpty() )
523 (*it).setIDStr(id ); 523 (*it).setIDStr(id );
524 (*it).setResource( setRes ); 524 (*it).setResource( setRes );
525 if ( replaceLabel ) 525 if ( replaceLabel )
526 (*it).removeVoice(); 526 (*it).removeVoice();
527 if ( removeOld ) 527 if ( removeOld )
528 (*it).setTagged( true ); 528 (*it).setTagged( true );
529 insertAddressee( (*it), false, true ); 529 insertAddressee( (*it), false, true );
530 } 530 }
531 if ( removeOld ) 531 if ( removeOld )
532 removeUntagged(); 532 removeUntagged();
533 return list.count(); 533 return list.count();
534} 534}
535void AddressBook::setUntagged(bool setNonSyncTagged, QString resource) // = false , "") 535void AddressBook::setUntagged(bool setNonSyncTagged, QString resource) // = false , "")
536{ 536{
537 Iterator ait; 537 Iterator ait;
538 if ( !resource.isEmpty() ) { 538 if ( !resource.isEmpty() ) {
539 for ( ait = begin(); ait != end(); ++ait ) { 539 for ( ait = begin(); ait != end(); ++ait ) {
540 if ( (*ait).resource() && (*ait).resource()->resourceName() == resource ) { 540 if ( (*ait).resource() && (*ait).resource()->resourceName() == resource ) {
541 (*ait).setTagged( false ); 541 (*ait).setTagged( false );
542 } 542 }
543 else 543 else
544 (*ait).setTagged( true ); 544 (*ait).setTagged( true );
545 } 545 }
546 } else { 546 } else {
547 for ( ait = begin(); ait != end(); ++ait ) { 547 for ( ait = begin(); ait != end(); ++ait ) {
548 if ( setNonSyncTagged ) { 548 if ( setNonSyncTagged ) {
549 if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { 549 if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) {
550 (*ait).setTagged( true ); 550 (*ait).setTagged( true );
551 } else 551 } else
552 (*ait).setTagged( false ); 552 (*ait).setTagged( false );
553 } else 553 } else
554 (*ait).setTagged( false ); 554 (*ait).setTagged( false );
555 } 555 }
556 } 556 }
557} 557}
558void AddressBook::removeUntagged() 558void AddressBook::removeUntagged()
559{ 559{
560 Iterator ait; 560 Iterator ait;
561 bool todelete = false; 561 bool todelete = false;
562 Iterator todel; 562 Iterator todel;
563 for ( ait = begin(); ait != end(); ++ait ) { 563 for ( ait = begin(); ait != end(); ++ait ) {
564 if ( todelete ) 564 if ( todelete )
565 removeAddressee( todel ); 565 removeAddressee( todel );
566 if (!(*ait).tagged()) { 566 if (!(*ait).tagged()) {
567 todelete = true; 567 todelete = true;
568 todel = ait; 568 todel = ait;
569 } else 569 } else
570 todelete = false; 570 todelete = false;
571 } 571 }
572 if ( todelete ) 572 if ( todelete )
573 removeAddressee( todel ); 573 removeAddressee( todel );
574 deleteRemovedAddressees(); 574 deleteRemovedAddressees();
575} 575}
576void AddressBook::smplifyAddressees() 576void AddressBook::smplifyAddressees()
577{ 577{
578 Iterator ait; 578 Iterator ait;
579 for ( ait = begin(); ait != end(); ++ait ) { 579 for ( ait = begin(); ait != end(); ++ait ) {
580 (*ait).simplifyEmails(); 580 (*ait).simplifyEmails();
581 (*ait).simplifyPhoneNumbers(); 581 (*ait).simplifyPhoneNumbers();
582 (*ait).simplifyPhoneNumberTypes(); 582 (*ait).simplifyPhoneNumberTypes();
583 (*ait).simplifyAddresses(); 583 (*ait).simplifyAddresses();
584 } 584 }
585} 585}
586void AddressBook::removeSyncInfo( QString syncProfile) 586void AddressBook::removeSyncInfo( QString syncProfile)
587{ 587{
588 Iterator ait; 588 Iterator ait;
589 for ( ait = begin(); ait != end(); ++ait ) { 589 for ( ait = begin(); ait != end(); ++ait ) {
590 (*ait).removeID( syncProfile ); 590 (*ait).removeID( syncProfile );
591 } 591 }
592 if ( syncProfile.isEmpty() ) { 592 if ( syncProfile.isEmpty() ) {
593 Iterator it = begin(); 593 Iterator it = begin();
594 Iterator it2 ; 594 Iterator it2 ;
595 while ( it != end() ) { 595 while ( it != end() ) {
596 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 596 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
597 it2 = it; 597 it2 = it;
598 //qDebug("removing %s ",(*it).uid().latin1() ); 598 //qDebug("removing %s ",(*it).uid().latin1() );
599 ++it; 599 ++it;
600 removeAddressee( it2 ); 600 removeAddressee( it2 );
601 } else { 601 } else {
602 //qDebug("skipping %s ",(*it).uid().latin1() ); 602 //qDebug("skipping %s ",(*it).uid().latin1() );
603 ++it; 603 ++it;
604 } 604 }
605 } 605 }
606 } else { 606 } else {
607 Addressee lse; 607 Addressee lse;
608 lse = findByUid( "last-syncAddressee-"+ syncProfile ); 608 lse = findByUid( "last-syncAddressee-"+ syncProfile );
609 if ( ! lse.isEmpty() ) 609 if ( ! lse.isEmpty() )
610 removeAddressee( lse ); 610 removeAddressee( lse );
611 } 611 }
612 612
613} 613}
614void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) 614void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync )
615{ 615{
616 Iterator ait; 616 Iterator ait;
617 for ( ait = begin(); ait != end(); ++ait ) { 617 for ( ait = begin(); ait != end(); ++ait ) {
618 QString id = (*ait).IDStr(); 618 QString id = (*ait).IDStr();
619 (*ait).setIDStr( ":"); 619 (*ait).setIDStr( ":");
620 (*ait).setExternalUID( id ); 620 (*ait).setExternalUID( id );
621 (*ait).setOriginalExternalUID( id ); 621 (*ait).setOriginalExternalUID( id );
622 if ( isPreSync ) 622 if ( isPreSync )
623 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 623 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
624 else { 624 else {
625 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 625 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
626 (*ait).setID( currentSyncDevice,id ); 626 (*ait).setID( currentSyncDevice,id );
627 627
628 } 628 }
629 } 629 }
630} 630}
631void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) 631void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice )
632{ 632{
633 633
634 setUntagged(); 634 setUntagged();
635 KABC::Addressee::List list; 635 KABC::Addressee::List list;
636 QFile file( fileName ); 636 QFile file( fileName );
637 file.open( IO_ReadOnly ); 637 file.open( IO_ReadOnly );
638 QByteArray rawData = file.readAll(); 638 QByteArray rawData = file.readAll();
639 file.close(); 639 file.close();
640 QString data; 640 QString data;
641 641
642 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 642 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
643 KABC::VCardTool tool; 643 KABC::VCardTool tool;
644 list = tool.parseVCards( data ); 644 list = tool.parseVCards( data );
645 KABC::Addressee::List::Iterator it; 645 KABC::Addressee::List::Iterator it;
646 for ( it = list.begin(); it != list.end(); ++it ) { 646 for ( it = list.begin(); it != list.end(); ++it ) {
647 Iterator ait; 647 Iterator ait;
648 for ( ait = begin(); ait != end(); ++ait ) { 648 for ( ait = begin(); ait != end(); ++ait ) {
649 if ( !(*ait).tagged() ) { 649 if ( !(*ait).tagged() ) {
650 if ( (*ait).containsAdr(*it)) { 650 if ( (*ait).containsAdr(*it)) {
651 (*ait).setTagged(true); 651 (*ait).setTagged(true);
652 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); 652 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" );
653 (*it).setIDStr( ":"); 653 (*it).setIDStr( ":");
654 (*it).setID( currentSyncDevice,id ); 654 (*it).setID( currentSyncDevice,id );
655 (*it).setExternalUID( id ); 655 (*it).setExternalUID( id );
656 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 656 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
657 (*it).setUid( ( (*ait).uid() )); 657 (*it).setUid( ( (*ait).uid() ));
658 break; 658 break;
659 } 659 }
660 } 660 }
661 661
662 } 662 }
663 if ( ait == end() ) 663 if ( ait == end() )
664 qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); 664 qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1());
665 } 665 }
666 clear(); 666 clear();
667 for ( it = list.begin(); it != list.end(); ++it ) { 667 for ( it = list.begin(); it != list.end(); ++it ) {
668 insertAddressee( (*it) ); 668 insertAddressee( (*it) );
669 } 669 }
670} 670}
671 671
672bool AddressBook::saveABphone( QString fileName ) 672bool AddressBook::saveABphone( QString fileName )
673{ 673{
674 //smplifyAddressees(); 674 //smplifyAddressees();
675 qDebug("saveABphone:: saving AB... "); 675 qDebug("saveABphone:: saving AB... ");
676 if ( ! export2PhoneFormat( QStringList() ,fileName ) ) 676 if ( ! export2PhoneFormat( QStringList() ,fileName ) )
677 return false; 677 return false;
678 qDebug("saveABphone:: writing to phone... "); 678 qDebug("saveABphone:: writing to phone... ");
679 if ( !PhoneAccess::writeToPhone( fileName) ) { 679 if ( !PhoneAccess::writeToPhone( fileName) ) {
680 return false; 680 return false;
681 } 681 }
682 qDebug("saveABphone:: re-reading from phone... "); 682 qDebug("saveABphone:: re-reading from phone... ");
683 if ( !PhoneAccess::readFromPhone( fileName) ) { 683 if ( !PhoneAccess::readFromPhone( fileName) ) {
684 return false; 684 return false;
685 } 685 }
686 return true; 686 return true;
687} 687}
688bool AddressBook::saveAB() 688bool AddressBook::saveAB()
689{ 689{
690 bool ok = true; 690 bool ok = true;
691 691
692 deleteRemovedAddressees(); 692 deleteRemovedAddressees();
693 Iterator ait; 693 Iterator ait;
694 for ( ait = begin(); ait != end(); ++ait ) { 694 for ( ait = begin(); ait != end(); ++ait ) {
695 if ( !(*ait).IDStr().isEmpty() ) { 695 if ( !(*ait).IDStr().isEmpty() ) {
696 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 696 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
697 } 697 }
698 } 698 }
699 KRES::Manager<Resource>::ActiveIterator it; 699 KRES::Manager<Resource>::ActiveIterator it;
700 KRES::Manager<Resource> *manager = d->mManager; 700 KRES::Manager<Resource> *manager = d->mManager;
701 qDebug("SaveAB::saving..." ); 701 qDebug("SaveAB::saving..." );
702 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 702 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
703 qDebug("SaveAB::checking resource..." ); 703 qDebug("SaveAB::checking resource..." );
704 if ( (*it)->readOnly() ) 704 if ( (*it)->readOnly() )
705 qDebug("SaveAB::resource is readonly." ); 705 qDebug("SaveAB::resource is readonly." );
706 if ( (*it)->isOpen() ) 706 if ( (*it)->isOpen() )
707 qDebug("SaveAB::resource is open" ); 707 qDebug("SaveAB::resource is open" );
708 708
709 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 709 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
710 Ticket *ticket = requestSaveTicket( *it ); 710 Ticket *ticket = requestSaveTicket( *it );
711 qDebug("SaveAB::StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 711 qDebug("SaveAB::StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
712 if ( !ticket ) { 712 if ( !ticket ) {
713 qDebug( i18n( "SaveAB::Unable to save to resource '%1'. It is locked." ) 713 qDebug( i18n( "SaveAB::Unable to save to resource '%1'. It is locked." )
714 .arg( (*it)->resourceName() ) ); 714 .arg( (*it)->resourceName() ) );
715 return false; 715 return false;
716 } 716 }
717 717
718 //if ( !save( ticket ) ) 718 //if ( !save( ticket ) )
719 if ( ticket->resource() ) { 719 if ( ticket->resource() ) {
720 QString name = ticket->resource()->resourceName(); 720 QString name = ticket->resource()->resourceName();
721 if ( ! ticket->resource()->save( ticket ) ) 721 if ( ! ticket->resource()->save( ticket ) )
722 ok = false; 722 ok = false;
723 else 723 else
724 qDebug("SaveAB::resource saved '%s'", name.latin1() ); 724 qDebug("SaveAB::resource saved '%s'", name.latin1() );
725 725
726 } else 726 } else
727 ok = false; 727 ok = false;
728 728
729 } 729 }
730 } 730 }
731 return ok; 731 return ok;
732} 732}
733 733
734AddressBook::Iterator AddressBook::begin() 734AddressBook::Iterator AddressBook::begin()
735{ 735{
736 Iterator it = Iterator(); 736 Iterator it = Iterator();
737 it.d->mIt = d->mAddressees.begin(); 737 it.d->mIt = d->mAddressees.begin();
738 return it; 738 return it;
739} 739}
740 740
741AddressBook::ConstIterator AddressBook::begin() const 741AddressBook::ConstIterator AddressBook::begin() const
742{ 742{
743 ConstIterator it = ConstIterator(); 743 ConstIterator it = ConstIterator();
744 it.d->mIt = d->mAddressees.begin(); 744 it.d->mIt = d->mAddressees.begin();
745 return it; 745 return it;
746} 746}
747 747
748AddressBook::Iterator AddressBook::end() 748AddressBook::Iterator AddressBook::end()
749{ 749{
750 Iterator it = Iterator(); 750 Iterator it = Iterator();
751 it.d->mIt = d->mAddressees.end(); 751 it.d->mIt = d->mAddressees.end();
752 return it; 752 return it;
753} 753}
754 754
755AddressBook::ConstIterator AddressBook::end() const 755AddressBook::ConstIterator AddressBook::end() const
756{ 756{
757 ConstIterator it = ConstIterator(); 757 ConstIterator it = ConstIterator();
758 it.d->mIt = d->mAddressees.end(); 758 it.d->mIt = d->mAddressees.end();
759 return it; 759 return it;
760} 760}
761 761
762void AddressBook::clear() 762void AddressBook::clear()
763{ 763{
764 d->mAddressees.clear(); 764 d->mAddressees.clear();
765} 765}
766 766
767Ticket *AddressBook::requestSaveTicket( Resource *resource ) 767Ticket *AddressBook::requestSaveTicket( Resource *resource )
768{ 768{
769 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 769 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
770 770
771 if ( !resource ) 771 if ( !resource )
772 { 772 {
773 qDebug("AddressBook::requestSaveTicket no resource" ); 773 qDebug("AddressBook::requestSaveTicket no resource" );
774 resource = standardResource(); 774 resource = standardResource();
775 } 775 }
776 776
777 KRES::Manager<Resource>::ActiveIterator it; 777 KRES::Manager<Resource>::ActiveIterator it;
778 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 778 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
779 if ( (*it) == resource ) { 779 if ( (*it) == resource ) {
780 if ( (*it)->readOnly() || !(*it)->isOpen() ) 780 if ( (*it)->readOnly() || !(*it)->isOpen() )
781 return 0; 781 return 0;
782 else 782 else
783 return (*it)->requestSaveTicket(); 783 return (*it)->requestSaveTicket();
784 } 784 }
785 } 785 }
786 786
787 return 0; 787 return 0;
788} 788}
789//void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); 789//void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false);
790void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) 790void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource )
791{ 791{
792 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { 792 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) {
793 //qDebug("block insert "); 793 //qDebug("block insert ");
794 return; 794 return;
795 } 795 }
796 //qDebug("inserting.... %s ",a.uid().latin1() ); 796 //qDebug("inserting.... %s ",a.uid().latin1() );
797 bool found = false; 797 bool found = false;
798 Addressee::List::Iterator it; 798 Addressee::List::Iterator it;
799 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 799 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
800 if ( a.uid() == (*it).uid() ) { 800 if ( a.uid() == (*it).uid() ) {
801 801
802 bool changed = false; 802 bool changed = false;
803 Addressee addr = a; 803 Addressee addr = a;
804 if ( addr != (*it) ) 804 if ( addr != (*it) )
805 changed = true; 805 changed = true;
806 806
807 if ( takeResource ) { 807 if ( takeResource ) {
808 Resource * res = (*it).resource(); 808 Resource * res = (*it).resource();
809 (*it) = a; 809 (*it) = a;
810 (*it).setResource( res ); 810 (*it).setResource( res );
811 } else { 811 } else {
812 (*it) = a; 812 (*it) = a;
813 if ( (*it).resource() == 0 ) 813 if ( (*it).resource() == 0 )
814 (*it).setResource( standardResource() ); 814 (*it).setResource( standardResource() );
815 } 815 }
816 if ( changed ) { 816 if ( changed ) {
817 if ( setRev ) { 817 if ( setRev ) {
818 (*it).setRevision( QDateTime::currentDateTime() ); 818 (*it).setRevision( QDateTime::currentDateTime() );
819 } 819 }
820 (*it).setChanged( true ); 820 (*it).setChanged( true );
821 } 821 }
822 822
823 found = true; 823 found = true;
824 } else { 824 } else {
825 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 825 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
826 QString name = (*it).uid().mid( 19 ); 826 QString name = (*it).uid().mid( 19 );
827 Addressee b = a; 827 Addressee b = a;
828 QString id = b.getID( name ); 828 QString id = b.getID( name );
829 if ( ! id.isEmpty() ) { 829 if ( ! id.isEmpty() ) {
830 QString des = (*it).note(); 830 QString des = (*it).note();
831 int startN; 831 int startN;
832 if( (startN = des.find( id ) ) >= 0 ) { 832 if( (startN = des.find( id ) ) >= 0 ) {
833 int endN = des.find( ",", startN+1 ); 833 int endN = des.find( ",", startN+1 );
834 des = des.left( startN ) + des.mid( endN+1 ); 834 des = des.left( startN ) + des.mid( endN+1 );
835 (*it).setNote( des ); 835 (*it).setNote( des );
836 } 836 }
837 } 837 }
838 } 838 }
839 } 839 }
840 } 840 }
841 if ( found ) 841 if ( found )
842 return; 842 return;
843 843
844 d->mAddressees.append( a ); 844 d->mAddressees.append( a );
845 Addressee& addr = d->mAddressees.last(); 845 Addressee& addr = d->mAddressees.last();
846 if ( addr.resource() == 0 ) 846 if ( addr.resource() == 0 )
847 addr.setResource( standardResource() ); 847 addr.setResource( standardResource() );
848 addr.setChanged( true ); 848 addr.setChanged( true );
849} 849}
850 850
851void AddressBook::removeAddressee( const Addressee &a ) 851void AddressBook::removeAddressee( const Addressee &a )
852{ 852{
853 Iterator it; 853 Iterator it;
854 Iterator it2; 854 Iterator it2;
855 bool found = false; 855 bool found = false;
856 for ( it = begin(); it != end(); ++it ) { 856 for ( it = begin(); it != end(); ++it ) {
857 if ( a.uid() == (*it).uid() ) { 857 if ( a.uid() == (*it).uid() ) {
858 found = true; 858 found = true;
859 it2 = it; 859 it2 = it;
860 } else { 860 } else {
861 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 861 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
862 QString name = (*it).uid().mid( 19 ); 862 QString name = (*it).uid().mid( 19 );
863 Addressee b = a; 863 Addressee b = a;
864 QString id = b.getID( name ); 864 QString id = b.getID( name );
865 if ( ! id.isEmpty() ) { 865 if ( ! id.isEmpty() ) {
866 QString des = (*it).note(); 866 QString des = (*it).note();
867 if( des.find( id ) < 0 ) { 867 if( des.find( id ) < 0 ) {
868 des += id + ","; 868 des += id + ",";
869 (*it).setNote( des ); 869 (*it).setNote( des );
870 } 870 }
871 } 871 }
872 } 872 }
873 873
874 } 874 }
875 } 875 }
876 876
877 if ( found ) 877 if ( found )
878 removeAddressee( it2 ); 878 removeAddressee( it2 );
879 879
880} 880}
881 881
882void AddressBook::removeSyncAddressees( bool removeDeleted ) 882void AddressBook::removeSyncAddressees( bool removeDeleted )
883{ 883{
884 Iterator it = begin(); 884 Iterator it = begin();
885 Iterator it2 ; 885 Iterator it2 ;
886 QDateTime dt ( QDate( 2003,1,1) ); 886 QDateTime dt ( QDate( 2003,1,1) );
887 while ( it != end() ) { 887 while ( it != end() ) {
888 (*it).setRevision( dt ); 888 (*it).setRevision( dt );
889 if (( *it).IDStr() != "changed" ) { 889 if (( *it).IDStr() != "changed" ) {
890 // "changed" is used for tagging changed addressees when syncing with KDE or OL 890 // "changed" is used for tagging changed addressees when syncing with KDE or OL
891 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 891 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
892 (*it).setIDStr(":"); 892 (*it).setIDStr(":");
893 } 893 }
894 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { 894 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) {
895 it2 = it; 895 it2 = it;
896 //qDebug("removing %s ",(*it).uid().latin1() ); 896 //qDebug("removing %s ",(*it).uid().latin1() );
897 ++it; 897 ++it;
898 removeAddressee( it2 ); 898 removeAddressee( it2 );
899 } else { 899 } else {
900 //qDebug("skipping %s ",(*it).uid().latin1() ); 900 //qDebug("skipping %s ",(*it).uid().latin1() );
901 if ( removeDeleted ) { 901 if ( removeDeleted ) {
902 // we have no postprocessing in the resource, we have to do it here 902 // we have no postprocessing in the resource, we have to do it here
903 // we have to compute csum for all, because it could be the first sync 903 // we have to compute csum for all, because it could be the first sync
904 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 904 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
905 } 905 }
906 ++it; 906 ++it;
907 } 907 }
908 } 908 }
909 deleteRemovedAddressees(); 909 deleteRemovedAddressees();
910} 910}
911 911
912void AddressBook::removeAddressee( const Iterator &it ) 912void AddressBook::removeAddressee( const Iterator &it )
913{ 913{
914 d->mRemovedAddressees.append( (*it) ); 914 d->mRemovedAddressees.append( (*it) );
915 d->mAddressees.remove( it.d->mIt ); 915 d->mAddressees.remove( it.d->mIt );
916} 916}
917 917
918AddressBook::Iterator AddressBook::find( const Addressee &a ) 918AddressBook::Iterator AddressBook::find( const Addressee &a )
919{ 919{
920 Iterator it; 920 Iterator it;
921 for ( it = begin(); it != end(); ++it ) { 921 for ( it = begin(); it != end(); ++it ) {
922 if ( a.uid() == (*it).uid() ) { 922 if ( a.uid() == (*it).uid() ) {
923 return it; 923 return it;
924 } 924 }
925 } 925 }
926 return end(); 926 return end();
927} 927}
928 928
929Addressee AddressBook::findByUid( const QString &uid ) 929Addressee AddressBook::findByUid( const QString &uid )
930{ 930{
931 Iterator it; 931 Iterator it;
932 for ( it = begin(); it != end(); ++it ) { 932 for ( it = begin(); it != end(); ++it ) {
933 if ( uid == (*it).uid() ) { 933 if ( uid == (*it).uid() ) {
934 return *it; 934 return *it;
935 } 935 }
936 } 936 }
937 return Addressee(); 937 return Addressee();
938} 938}
939void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset ) 939void AddressBook::preExternSync( AddressBook* aBook, const QString& csd , bool isSubset )
940{ 940{
941 //qDebug("AddressBook::preExternSync "); 941 //qDebug("AddressBook::preExternSync ");
942 AddressBook::Iterator it; 942 AddressBook::Iterator it;
943 for ( it = begin(); it != end(); ++it ) { 943 for ( it = begin(); it != end(); ++it ) {
944 (*it).setID( csd, (*it).externalUID() ); 944 (*it).setID( csd, (*it).externalUID() );
945 (*it).computeCsum( csd ); 945 (*it).computeCsum( csd );
946 } 946 }
947 mergeAB( aBook ,csd, isSubset ); 947 mergeAB( aBook ,csd, isSubset );
948} 948}
949void AddressBook::preOLSync( AddressBook* aBook, const QString& csd )
950{
951 //qDebug("AddressBook::preExternSync ");
952 AddressBook::Iterator it;
953 for ( it = begin(); it != end(); ++it ) {
954 (*it).setID( csd, (*it).externalUID() );
955 (*it).computeCsum( csd );
956 }
957
958 Addressee ad;
959 for ( it = begin(); it != end(); ++it ) {
960 ad = aBook->findByExternUid( (*it).externalUID(), csd );
961 if ( !ad.isEmpty() ) {
962 (*it).mergeOLContact( ad );
963 }
964 }
965}
949void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID) 966void AddressBook::postExternSync( AddressBook* aBook , const QString& csd, bool setID)
950{ 967{
951 //qDebug("AddressBook::postExternSync "); 968 //qDebug("AddressBook::postExternSync ");
952 AddressBook::Iterator it; 969 AddressBook::Iterator it;
953 int foundEmpty = 0; 970 int foundEmpty = 0;
954 for ( it = begin(); it != end(); ++it ) { 971 for ( it = begin(); it != end(); ++it ) {
955 //qDebug("check uid %s ", (*it).uid().latin1() ); 972 //qDebug("check uid %s ", (*it).uid().latin1() );
956 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || 973 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
957 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM || 974 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ||
958 (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) { 975 (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL) {
959 Addressee ad = aBook->findByUid( ( (*it).uid() )); 976 Addressee ad = aBook->findByUid( ( (*it).uid() ));
960 if ( ad.isEmpty() ) { 977 if ( ad.isEmpty() ) {
961 ++foundEmpty; 978 ++foundEmpty;
962 //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1()); 979 //qDebug("postExternSync:addressee is empty: %s ", (*it).uid().latin1());
963 //qDebug("-- formatted name %s ",(*it).formattedName().latin1() ); 980 //qDebug("-- formatted name %s ",(*it).formattedName().latin1() );
964 } else { 981 } else {
965 (*it).setIDStr(":"); 982 (*it).setIDStr(":");
966 if ( setID ) { 983 if ( setID ) {
967 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) 984 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
968 ad.setID( csd, (*it).externalUID() ); 985 ad.setID( csd, (*it).externalUID() );{
986 }
969 } else 987 } else
970 ad.setID( csd, (*it).uid() ); 988 ad.setID( csd, (*it).uid() );
971 (*it).computeCsum( csd ); 989 (*it).computeCsum( csd );
972 ad.setCsum( csd, (*it).getCsum( csd ) ); 990 ad.setCsum( csd, (*it).getCsum( csd ) );
973 //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() ); 991 //qDebug("CSUM %s ",(*it).getCsum( csd ).latin1() );
974 aBook->insertAddressee( ad , false); 992 aBook->insertAddressee( ad , false);
975 } 993 }
976 } 994 }
977 } 995 }
978 if ( foundEmpty ) { 996 if ( foundEmpty ) {
979 qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty ); 997 qDebug("postExternSync:%d empty addressees found:\n probably filtered out by incoming sync filter.",foundEmpty );
980 } 998 }
981 999
982} 1000}
983 1001
984bool AddressBook::containsExternalUid( const QString& uid ) 1002bool AddressBook::containsExternalUid( const QString& uid )
985{ 1003{
986 Iterator it; 1004 Iterator it;
987 for ( it = begin(); it != end(); ++it ) { 1005 for ( it = begin(); it != end(); ++it ) {
988 if ( uid == (*it).externalUID( ) ) 1006 if ( uid == (*it).externalUID( ) )
989 return true; 1007 return true;
990 } 1008 }
991 return false; 1009 return false;
992} 1010}
993const Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) const 1011const Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) const
994{ 1012{
995 ConstIterator it; 1013 ConstIterator it;
996 for ( it = begin(); it != end(); ++it ) { 1014 for ( it = begin(); it != end(); ++it ) {
997 if ( uid == (*it).getID( profile ) ) 1015 if ( uid == (*it).getID( profile ) )
998 return (*it); 1016 return (*it);
999 } 1017 }
1000 return Addressee(); 1018 return Addressee();
1001} 1019}
1002void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset ) 1020void AddressBook::mergeAB( AddressBook *aBook, const QString& profile , bool isSubset )
1003{ 1021{
1004 Iterator it; 1022 Iterator it;
1005 Addressee ad; 1023 Addressee ad;
1006 for ( it = begin(); it != end(); ++it ) { 1024 for ( it = begin(); it != end(); ++it ) {
1007 ad = aBook->findByExternUid( (*it).externalUID(), profile ); 1025 ad = aBook->findByExternUid( (*it).externalUID(), profile );
1008 if ( !ad.isEmpty() ) { 1026 if ( !ad.isEmpty() ) {
1009 (*it).mergeContact( ad ,isSubset); 1027 (*it).mergeContact( ad ,isSubset);
1010 } 1028 }
1011 } 1029 }
1012#if 0 1030#if 0
1013 // test only 1031 // test only
1014 for ( it = begin(); it != end(); ++it ) { 1032 for ( it = begin(); it != end(); ++it ) {
1015 1033
1016 qDebug("uid %s ", (*it).uid().latin1()); 1034 qDebug("uid %s ", (*it).uid().latin1());
1017 } 1035 }
1018#endif 1036#endif
1019} 1037}
1020 1038
1021#if 0 1039#if 0
1022Addressee::List AddressBook::getExternLastSyncAddressees() 1040Addressee::List AddressBook::getExternLastSyncAddressees()
1023{ 1041{
1024 Addressee::List results; 1042 Addressee::List results;
1025 1043
1026 Iterator it; 1044 Iterator it;
1027 for ( it = begin(); it != end(); ++it ) { 1045 for ( it = begin(); it != end(); ++it ) {
1028 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { 1046 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) {
1029 if ( (*it).familyName().left(4) == "!E: " ) 1047 if ( (*it).familyName().left(4) == "!E: " )
1030 results.append( *it ); 1048 results.append( *it );
1031 } 1049 }
1032 } 1050 }
1033 1051
1034 return results; 1052 return results;
1035} 1053}
1036#endif 1054#endif
1037void AddressBook::resetTempSyncStat() 1055void AddressBook::resetTempSyncStat()
1038{ 1056{
1039 Iterator it; 1057 Iterator it;
1040 for ( it = begin(); it != end(); ++it ) { 1058 for ( it = begin(); it != end(); ++it ) {
1041 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); 1059 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
1042 } 1060 }
1043 1061
1044} 1062}
1045 1063
1046QStringList AddressBook:: uidList() 1064QStringList AddressBook:: uidList()
1047{ 1065{
1048 QStringList results; 1066 QStringList results;
1049 Iterator it; 1067 Iterator it;
1050 for ( it = begin(); it != end(); ++it ) { 1068 for ( it = begin(); it != end(); ++it ) {
1051 results.append( (*it).uid() ); 1069 results.append( (*it).uid() );
1052 } 1070 }
1053 return results; 1071 return results;
1054} 1072}
1055 1073
1056 1074
1057Addressee::List AddressBook::allAddressees() 1075Addressee::List AddressBook::allAddressees()
1058{ 1076{
1059 return d->mAddressees; 1077 return d->mAddressees;
1060 1078
1061} 1079}
1062 1080
1063Addressee::List AddressBook::findByName( const QString &name ) 1081Addressee::List AddressBook::findByName( const QString &name )
1064{ 1082{
1065 Addressee::List results; 1083 Addressee::List results;
1066 1084
1067 Iterator it; 1085 Iterator it;
1068 for ( it = begin(); it != end(); ++it ) { 1086 for ( it = begin(); it != end(); ++it ) {
1069 if ( name == (*it).realName() ) { 1087 if ( name == (*it).realName() ) {
1070 results.append( *it ); 1088 results.append( *it );
1071 } 1089 }
1072 } 1090 }
1073 1091
1074 return results; 1092 return results;
1075} 1093}
1076 1094
1077Addressee::List AddressBook::findByEmail( const QString &email ) 1095Addressee::List AddressBook::findByEmail( const QString &email )
1078{ 1096{
1079 Addressee::List results; 1097 Addressee::List results;
1080 QStringList mailList; 1098 QStringList mailList;
1081 1099
1082 Iterator it; 1100 Iterator it;
1083 for ( it = begin(); it != end(); ++it ) { 1101 for ( it = begin(); it != end(); ++it ) {
1084 mailList = (*it).emails(); 1102 mailList = (*it).emails();
1085 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { 1103 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
1086 if ( email == (*ite) ) { 1104 if ( email == (*ite) ) {
1087 results.append( *it ); 1105 results.append( *it );
1088 } 1106 }
1089 } 1107 }
1090 } 1108 }
1091 1109
1092 return results; 1110 return results;
1093} 1111}
1094 1112
1095Addressee::List AddressBook::findByCategory( const QString &category ) 1113Addressee::List AddressBook::findByCategory( const QString &category )
1096{ 1114{
1097 Addressee::List results; 1115 Addressee::List results;
1098 1116
1099 Iterator it; 1117 Iterator it;
1100 for ( it = begin(); it != end(); ++it ) { 1118 for ( it = begin(); it != end(); ++it ) {
1101 if ( (*it).hasCategory( category) ) { 1119 if ( (*it).hasCategory( category) ) {
1102 results.append( *it ); 1120 results.append( *it );
1103 } 1121 }
1104 } 1122 }
1105 1123
1106 return results; 1124 return results;
1107} 1125}
1108 1126
1109void AddressBook::dump() const 1127void AddressBook::dump() const
1110{ 1128{
1111 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; 1129 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl;
1112 1130
1113 ConstIterator it; 1131 ConstIterator it;
1114 for( it = begin(); it != end(); ++it ) { 1132 for( it = begin(); it != end(); ++it ) {
1115 (*it).dump(); 1133 (*it).dump();
1116 } 1134 }
1117 1135
1118 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; 1136 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl;
1119} 1137}
1120 1138
1121QString AddressBook::identifier() 1139QString AddressBook::identifier()
1122{ 1140{
1123 QStringList identifier; 1141 QStringList identifier;
1124 1142
1125 1143
1126 KRES::Manager<Resource>::ActiveIterator it; 1144 KRES::Manager<Resource>::ActiveIterator it;
1127 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 1145 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
1128 if ( !(*it)->identifier().isEmpty() ) 1146 if ( !(*it)->identifier().isEmpty() )
1129 identifier.append( (*it)->identifier() ); 1147 identifier.append( (*it)->identifier() );
1130 } 1148 }
1131 1149
1132 return identifier.join( ":" ); 1150 return identifier.join( ":" );
1133} 1151}
1134 1152
1135Field::List AddressBook::fields( int category ) 1153Field::List AddressBook::fields( int category )
1136{ 1154{
1137 if ( d->mAllFields.isEmpty() ) { 1155 if ( d->mAllFields.isEmpty() ) {
1138 d->mAllFields = Field::allFields(); 1156 d->mAllFields = Field::allFields();
1139 } 1157 }
1140 1158
1141 if ( category == Field::All ) return d->mAllFields; 1159 if ( category == Field::All ) return d->mAllFields;
1142 1160
1143 Field::List result; 1161 Field::List result;
1144 Field::List::ConstIterator it; 1162 Field::List::ConstIterator it;
1145 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { 1163 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) {
1146 if ( (*it)->category() & category ) result.append( *it ); 1164 if ( (*it)->category() & category ) result.append( *it );
1147 } 1165 }
1148 1166
1149 return result; 1167 return result;
1150} 1168}
1151 1169
1152bool AddressBook::addCustomField( const QString &label, int category, 1170bool AddressBook::addCustomField( const QString &label, int category,
1153 const QString &key, const QString &app ) 1171 const QString &key, const QString &app )
1154{ 1172{
1155 if ( d->mAllFields.isEmpty() ) { 1173 if ( d->mAllFields.isEmpty() ) {
1156 d->mAllFields = Field::allFields(); 1174 d->mAllFields = Field::allFields();
1157 } 1175 }
1158//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; 1176//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app;
1159 QString a = app.isNull() ? KGlobal::getAppName() : app; 1177 QString a = app.isNull() ? KGlobal::getAppName() : app;
1160 1178
1161 QString k = key.isNull() ? label : key; 1179 QString k = key.isNull() ? label : key;
1162 1180
1163 Field *field = Field::createCustomField( label, category, k, a ); 1181 Field *field = Field::createCustomField( label, category, k, a );
1164 1182
1165 if ( !field ) return false; 1183 if ( !field ) return false;
1166 1184
1167 d->mAllFields.append( field ); 1185 d->mAllFields.append( field );
1168 1186
1169 return true; 1187 return true;
1170} 1188}
1171 1189
1172QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) 1190QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab )
1173{ 1191{
1174 if (!ab.d) return s; 1192 if (!ab.d) return s;
1175 1193
1176 return s << ab.d->mAddressees; 1194 return s << ab.d->mAddressees;
1177} 1195}
1178 1196
1179QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) 1197QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab )
1180{ 1198{
1181 if (!ab.d) return s; 1199 if (!ab.d) return s;
1182 1200
1183 s >> ab.d->mAddressees; 1201 s >> ab.d->mAddressees;
1184 1202
1185 return s; 1203 return s;
1186} 1204}
1187 1205
1188bool AddressBook::addResource( Resource *resource ) 1206bool AddressBook::addResource( Resource *resource )
1189{ 1207{
1190 if ( !resource->open() ) { 1208 if ( !resource->open() ) {
1191 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; 1209 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl;
1192 return false; 1210 return false;
1193 } 1211 }
1194 1212
1195 resource->setAddressBook( this ); 1213 resource->setAddressBook( this );
1196 1214
1197 d->mManager->add( resource ); 1215 d->mManager->add( resource );
1198 return true; 1216 return true;
1199} 1217}
1200void AddressBook::removeResources() 1218void AddressBook::removeResources()
1201{ 1219{
1202 //remove all possible resources. This should cleanup the configfile. 1220 //remove all possible resources. This should cleanup the configfile.
1203 QPtrList<KABC::Resource> mResources = resources(); 1221 QPtrList<KABC::Resource> mResources = resources();
1204 1222
1205 QPtrListIterator<KABC::Resource> it(mResources); 1223 QPtrListIterator<KABC::Resource> it(mResources);
1206 for ( ; it.current(); ++it ) { 1224 for ( ; it.current(); ++it ) {
1207 KABC::Resource *res = it.current(); 1225 KABC::Resource *res = it.current();
1208 removeResource(res); 1226 removeResource(res);
1209 } 1227 }
1210} 1228}
1211 1229
1212bool AddressBook::removeResource( Resource *resource ) 1230bool AddressBook::removeResource( Resource *resource )
1213{ 1231{
1214 resource->close(); 1232 resource->close();
1215 1233
1216 if ( resource == standardResource() ) 1234 if ( resource == standardResource() )
1217 d->mManager->setStandardResource( 0 ); 1235 d->mManager->setStandardResource( 0 );
1218 1236
1219 resource->setAddressBook( 0 ); 1237 resource->setAddressBook( 0 );
1220 1238
1221 d->mManager->remove( resource ); 1239 d->mManager->remove( resource );
1222 return true; 1240 return true;
1223} 1241}
1224 1242
1225QPtrList<Resource> AddressBook::resources() 1243QPtrList<Resource> AddressBook::resources()
1226{ 1244{
1227 QPtrList<Resource> list; 1245 QPtrList<Resource> list;
1228 1246
1229// qDebug("AddressBook::resources() 1"); 1247// qDebug("AddressBook::resources() 1");
1230 1248
1231 KRES::Manager<Resource>::ActiveIterator it; 1249 KRES::Manager<Resource>::ActiveIterator it;
1232 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 1250 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
1233 list.append( *it ); 1251 list.append( *it );
1234 1252
1235 return list; 1253 return list;
1236} 1254}
1237 1255
1238/*US 1256/*US
1239void AddressBook::setErrorHandler( ErrorHandler *handler ) 1257void AddressBook::setErrorHandler( ErrorHandler *handler )
1240{ 1258{
1241 delete d->mErrorHandler; 1259 delete d->mErrorHandler;
1242 d->mErrorHandler = handler; 1260 d->mErrorHandler = handler;
1243} 1261}
1244*/ 1262*/
1245 1263
1246void AddressBook::error( const QString& msg ) 1264void AddressBook::error( const QString& msg )
1247{ 1265{
1248/*US 1266/*US
1249 if ( !d->mErrorHandler ) // create default error handler 1267 if ( !d->mErrorHandler ) // create default error handler
1250 d->mErrorHandler = new ConsoleErrorHandler; 1268 d->mErrorHandler = new ConsoleErrorHandler;
1251 1269
1252 if ( d->mErrorHandler ) 1270 if ( d->mErrorHandler )
1253 d->mErrorHandler->error( msg ); 1271 d->mErrorHandler->error( msg );
1254 else 1272 else
1255 kdError(5700) << "no error handler defined" << endl; 1273 kdError(5700) << "no error handler defined" << endl;
1256*/ 1274*/
1257 kdDebug(5700) << "msg" << endl; 1275 kdDebug(5700) << "msg" << endl;
1258 qDebug(msg); 1276 qDebug(msg);
1259} 1277}
1260 1278
1261void AddressBook::deleteRemovedAddressees() 1279void AddressBook::deleteRemovedAddressees()
1262{ 1280{
1263 Addressee::List::Iterator it; 1281 Addressee::List::Iterator it;
1264 for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { 1282 for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) {
1265 Resource *resource = (*it).resource(); 1283 Resource *resource = (*it).resource();
1266 if ( resource && !resource->readOnly() && resource->isOpen() ) 1284 if ( resource && !resource->readOnly() && resource->isOpen() )
1267 resource->removeAddressee( *it ); 1285 resource->removeAddressee( *it );
1268 } 1286 }
1269 1287
1270 d->mRemovedAddressees.clear(); 1288 d->mRemovedAddressees.clear();
1271} 1289}
1272 1290
1273void AddressBook::setStandardResource( Resource *resource ) 1291void AddressBook::setStandardResource( Resource *resource )
1274{ 1292{
1275// qDebug("AddressBook::setStandardResource 1"); 1293// qDebug("AddressBook::setStandardResource 1");
1276 d->mManager->setStandardResource( resource ); 1294 d->mManager->setStandardResource( resource );
1277} 1295}
1278 1296
1279Resource *AddressBook::standardResource() 1297Resource *AddressBook::standardResource()
1280{ 1298{
1281 return d->mManager->standardResource(); 1299 return d->mManager->standardResource();
1282} 1300}
1283 1301
1284KRES::Manager<Resource> *AddressBook::resourceManager() 1302KRES::Manager<Resource> *AddressBook::resourceManager()
1285{ 1303{
1286 return d->mManager; 1304 return d->mManager;
1287} 1305}
1288 1306
1289void AddressBook::cleanUp() 1307void AddressBook::cleanUp()
1290{ 1308{
1291 KRES::Manager<Resource>::ActiveIterator it; 1309 KRES::Manager<Resource>::ActiveIterator it;
1292 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 1310 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
1293 if ( !(*it)->readOnly() && (*it)->isOpen() ) 1311 if ( !(*it)->readOnly() && (*it)->isOpen() )
1294 (*it)->cleanUp(); 1312 (*it)->cleanUp();
1295 } 1313 }
1296} 1314}
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index e6daa5e..a8a9fc1 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -1,350 +1,351 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#ifndef KABC_ADDRESSBOOK_H 28#ifndef KABC_ADDRESSBOOK_H
29#define KABC_ADDRESSBOOK_H 29#define KABC_ADDRESSBOOK_H
30 30
31#include <qobject.h> 31#include <qobject.h>
32 32
33#include <kresources/manager.h> 33#include <kresources/manager.h>
34#include <qptrlist.h> 34#include <qptrlist.h>
35 35
36#include "addressee.h" 36#include "addressee.h"
37#include "field.h" 37#include "field.h"
38 38
39namespace KABC { 39namespace KABC {
40 40
41class ErrorHandler; 41class ErrorHandler;
42class Resource; 42class Resource;
43class Ticket; 43class Ticket;
44 44
45/** 45/**
46 @short Address Book 46 @short Address Book
47 47
48 This class provides access to a collection of address book entries. 48 This class provides access to a collection of address book entries.
49*/ 49*/
50class AddressBook : public QObject 50class AddressBook : public QObject
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 53
54 friend QDataStream &operator<<( QDataStream &, const AddressBook & ); 54 friend QDataStream &operator<<( QDataStream &, const AddressBook & );
55 friend QDataStream &operator>>( QDataStream &, AddressBook & ); 55 friend QDataStream &operator>>( QDataStream &, AddressBook & );
56 friend class StdAddressBook; 56 friend class StdAddressBook;
57 57
58 public: 58 public:
59 /** 59 /**
60 @short Address Book Iterator 60 @short Address Book Iterator
61 61
62 This class provides an iterator for address book entries. 62 This class provides an iterator for address book entries.
63 */ 63 */
64 class Iterator 64 class Iterator
65 { 65 {
66 public: 66 public:
67 Iterator(); 67 Iterator();
68 Iterator( const Iterator & ); 68 Iterator( const Iterator & );
69 ~Iterator(); 69 ~Iterator();
70 70
71 Iterator &operator=( const Iterator & ); 71 Iterator &operator=( const Iterator & );
72 const Addressee &operator*() const; 72 const Addressee &operator*() const;
73 Addressee &operator*(); 73 Addressee &operator*();
74 Addressee* operator->(); 74 Addressee* operator->();
75 Iterator &operator++(); 75 Iterator &operator++();
76 Iterator &operator++(int); 76 Iterator &operator++(int);
77 Iterator &operator--(); 77 Iterator &operator--();
78 Iterator &operator--(int); 78 Iterator &operator--(int);
79 bool operator==( const Iterator &it ); 79 bool operator==( const Iterator &it );
80 bool operator!=( const Iterator &it ); 80 bool operator!=( const Iterator &it );
81 81
82 struct IteratorData; 82 struct IteratorData;
83 IteratorData *d; 83 IteratorData *d;
84 }; 84 };
85 85
86 /** 86 /**
87 @short Address Book Const Iterator 87 @short Address Book Const Iterator
88 88
89 This class provides a const iterator for address book entries. 89 This class provides a const iterator for address book entries.
90 */ 90 */
91 class ConstIterator 91 class ConstIterator
92 { 92 {
93 public: 93 public:
94 ConstIterator(); 94 ConstIterator();
95 ConstIterator( const ConstIterator & ); 95 ConstIterator( const ConstIterator & );
96 ~ConstIterator(); 96 ~ConstIterator();
97 97
98 ConstIterator &operator=( const ConstIterator & ); 98 ConstIterator &operator=( const ConstIterator & );
99 const Addressee &operator*() const; 99 const Addressee &operator*() const;
100 const Addressee* operator->() const; 100 const Addressee* operator->() const;
101 ConstIterator &operator++(); 101 ConstIterator &operator++();
102 ConstIterator &operator++(int); 102 ConstIterator &operator++(int);
103 ConstIterator &operator--(); 103 ConstIterator &operator--();
104 ConstIterator &operator--(int); 104 ConstIterator &operator--(int);
105 bool operator==( const ConstIterator &it ); 105 bool operator==( const ConstIterator &it );
106 bool operator!=( const ConstIterator &it ); 106 bool operator!=( const ConstIterator &it );
107 107
108 struct ConstIteratorData; 108 struct ConstIteratorData;
109 ConstIteratorData *d; 109 ConstIteratorData *d;
110 }; 110 };
111 111
112 /** 112 /**
113 Constructs a address book object. 113 Constructs a address book object.
114 114
115 @param format File format class. 115 @param format File format class.
116 */ 116 */
117 AddressBook(); 117 AddressBook();
118 AddressBook( const QString &config ); 118 AddressBook( const QString &config );
119 AddressBook( const QString &config, const QString &family ); 119 AddressBook( const QString &config, const QString &family );
120 virtual ~AddressBook(); 120 virtual ~AddressBook();
121 121
122 /** 122 /**
123 Requests a ticket for saving the addressbook. Calling this function locks 123 Requests a ticket for saving the addressbook. Calling this function locks
124 the addressbook for all other processes. If the address book is already 124 the addressbook for all other processes. If the address book is already
125 locked the function returns 0. You need the returned @ref Ticket object 125 locked the function returns 0. You need the returned @ref Ticket object
126 for calling the @ref save() function. 126 for calling the @ref save() function.
127 127
128 @see save() 128 @see save()
129 */ 129 */
130 Ticket *requestSaveTicket( Resource *resource=0 ); 130 Ticket *requestSaveTicket( Resource *resource=0 );
131 131
132 /** 132 /**
133 Load address book from file. 133 Load address book from file.
134 */ 134 */
135 bool load(); 135 bool load();
136 136
137 /** 137 /**
138 Save address book. The address book is saved to the file, the Ticket 138 Save address book. The address book is saved to the file, the Ticket
139 object has been requested for by @ref requestSaveTicket(). 139 object has been requested for by @ref requestSaveTicket().
140 140
141 @param ticket a ticket object returned by @ref requestSaveTicket() 141 @param ticket a ticket object returned by @ref requestSaveTicket()
142 */ 142 */
143 bool save( Ticket *ticket ); 143 bool save( Ticket *ticket );
144 bool saveAB( ); 144 bool saveAB( );
145 bool saveABphone( QString fileName ); 145 bool saveABphone( QString fileName );
146 void smplifyAddressees(); 146 void smplifyAddressees();
147 void removeSyncInfo( QString syncProfile); 147 void removeSyncInfo( QString syncProfile);
148 void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); 148 void preparePhoneSync( QString currentSyncDevice, bool isPreSync );
149 void export2File( QString fileName, QString resourceName = "" ); 149 void export2File( QString fileName, QString resourceName = "" );
150 bool export2PhoneFormat( QStringList uids ,QString fileName ); 150 bool export2PhoneFormat( QStringList uids ,QString fileName );
151 int importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false, QString resource = "" ); 151 int importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false, QString resource = "" );
152 void setUntagged( bool setNonSyncTagged = false, QString resource = "" ); 152 void setUntagged( bool setNonSyncTagged = false, QString resource = "" );
153 void removeUntagged(); 153 void removeUntagged();
154 void findNewExtIds( QString fileName, QString currentSyncDevice ); 154 void findNewExtIds( QString fileName, QString currentSyncDevice );
155 /** 155 /**
156 Returns a iterator for first entry of address book. 156 Returns a iterator for first entry of address book.
157 */ 157 */
158 Iterator begin(); 158 Iterator begin();
159 159
160 /** 160 /**
161 Returns a const iterator for first entry of address book. 161 Returns a const iterator for first entry of address book.
162 */ 162 */
163 ConstIterator begin() const; 163 ConstIterator begin() const;
164 164
165 /** 165 /**
166 Returns a iterator for first entry of address book. 166 Returns a iterator for first entry of address book.
167 */ 167 */
168 Iterator end(); 168 Iterator end();
169 169
170 /** 170 /**
171 Returns a const iterator for first entry of address book. 171 Returns a const iterator for first entry of address book.
172 */ 172 */
173 ConstIterator end() const; 173 ConstIterator end() const;
174 174
175 /** 175 /**
176 Removes all entries from address book. 176 Removes all entries from address book.
177 */ 177 */
178 void clear(); 178 void clear();
179 179
180 /** 180 /**
181 Insert an Addressee object into address book. If an object with the same 181 Insert an Addressee object into address book. If an object with the same
182 unique id already exists in the address book it it replaced by the new 182 unique id already exists in the address book it it replaced by the new
183 one. If not the new object is appended to the address book. 183 one. If not the new object is appended to the address book.
184 */ 184 */
185 void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); 185 void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false);
186 186
187 /** 187 /**
188 Removes entry from the address book. 188 Removes entry from the address book.
189 */ 189 */
190 void removeAddressee( const Addressee & ); 190 void removeAddressee( const Addressee & );
191 191
192 /** 192 /**
193 This is like @ref removeAddressee() just above, with the difference that 193 This is like @ref removeAddressee() just above, with the difference that
194 the first element is a iterator, returned by @ref begin(). 194 the first element is a iterator, returned by @ref begin().
195 */ 195 */
196 void removeAddressee( const Iterator & ); 196 void removeAddressee( const Iterator & );
197 197
198 /** 198 /**
199 Find the specified entry in address book. Returns end(), if the entry 199 Find the specified entry in address book. Returns end(), if the entry
200 couldn't be found. 200 couldn't be found.
201 */ 201 */
202 Iterator find( const Addressee & ); 202 Iterator find( const Addressee & );
203 203
204 /** 204 /**
205 Find the entry specified by an unique id. Returns an empty Addressee 205 Find the entry specified by an unique id. Returns an empty Addressee
206 object, if the address book does not contain an entry with this id. 206 object, if the address book does not contain an entry with this id.
207 */ 207 */
208 Addressee findByUid( const QString & ); 208 Addressee findByUid( const QString & );
209 209
210 210
211 /** 211 /**
212 Returns a list of all addressees in the address book. This list can 212 Returns a list of all addressees in the address book. This list can
213 be sorted with @ref KABC::AddresseeList for example. 213 be sorted with @ref KABC::AddresseeList for example.
214 */ 214 */
215 Addressee::List allAddressees(); 215 Addressee::List allAddressees();
216 216
217 /** 217 /**
218 Find all entries with the specified name in the address book. Returns 218 Find all entries with the specified name in the address book. Returns
219 an empty list, if no entries could be found. 219 an empty list, if no entries could be found.
220 */ 220 */
221 Addressee::List findByName( const QString & ); 221 Addressee::List findByName( const QString & );
222 222
223 /** 223 /**
224 Find all entries with the specified email address in the address book. 224 Find all entries with the specified email address in the address book.
225 Returns an empty list, if no entries could be found. 225 Returns an empty list, if no entries could be found.
226 */ 226 */
227 Addressee::List findByEmail( const QString & ); 227 Addressee::List findByEmail( const QString & );
228 228
229 /** 229 /**
230 Find all entries wich have the specified category in the address book. 230 Find all entries wich have the specified category in the address book.
231 Returns an empty list, if no entries could be found. 231 Returns an empty list, if no entries could be found.
232 */ 232 */
233 Addressee::List findByCategory( const QString & ); 233 Addressee::List findByCategory( const QString & );
234 234
235 /** 235 /**
236 Return a string identifying this addressbook. 236 Return a string identifying this addressbook.
237 */ 237 */
238 virtual QString identifier(); 238 virtual QString identifier();
239 239
240 /** 240 /**
241 Used for debug output. 241 Used for debug output.
242 */ 242 */
243 void dump() const; 243 void dump() const;
244 244
245 void emitAddressBookLocked() { emit addressBookLocked( this ); } 245 void emitAddressBookLocked() { emit addressBookLocked( this ); }
246 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } 246 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); }
247 void emitAddressBookChanged() { emit addressBookChanged( this ); } 247 void emitAddressBookChanged() { emit addressBookChanged( this ); }
248 248
249 /** 249 /**
250 Return list of all Fields known to the address book which are associated 250 Return list of all Fields known to the address book which are associated
251 with the given field category. 251 with the given field category.
252 */ 252 */
253 Field::List fields( int category = Field::All ); 253 Field::List fields( int category = Field::All );
254 254
255 /** 255 /**
256 Add custom field to address book. 256 Add custom field to address book.
257 257
258 @param label User visible label of the field. 258 @param label User visible label of the field.
259 @param category Ored list of field categories. 259 @param category Ored list of field categories.
260 @param key Identifier used as key for reading and writing the field. 260 @param key Identifier used as key for reading and writing the field.
261 @param app String used as application key for reading and writing 261 @param app String used as application key for reading and writing
262 the field. 262 the field.
263 */ 263 */
264 bool addCustomField( const QString &label, int category = Field::All, 264 bool addCustomField( const QString &label, int category = Field::All,
265 const QString &key = QString::null, 265 const QString &key = QString::null,
266 const QString &app = QString::null ); 266 const QString &app = QString::null );
267 267
268 268
269 /** 269 /**
270 Add address book resource. 270 Add address book resource.
271 */ 271 */
272 bool addResource( Resource * ); 272 bool addResource( Resource * );
273 273
274 /** 274 /**
275 Remove address book resource. 275 Remove address book resource.
276 */ 276 */
277 void removeResources(); 277 void removeResources();
278 bool removeResource( Resource * ); 278 bool removeResource( Resource * );
279 279
280 /** 280 /**
281 Return pointer list of all resources. 281 Return pointer list of all resources.
282 */ 282 */
283 QPtrList<Resource> resources(); 283 QPtrList<Resource> resources();
284 284
285 /** 285 /**
286 Set the @p ErrorHandler, that is used by @ref error() to 286 Set the @p ErrorHandler, that is used by @ref error() to
287 provide gui-independend error messages. 287 provide gui-independend error messages.
288 */ 288 */
289 void setErrorHandler( ErrorHandler * ); 289 void setErrorHandler( ErrorHandler * );
290 290
291 /** 291 /**
292 Shows gui independend error messages. 292 Shows gui independend error messages.
293 */ 293 */
294 void error( const QString& ); 294 void error( const QString& );
295 295
296 /** 296 /**
297 Query all resources to clean up their lock files 297 Query all resources to clean up their lock files
298 */ 298 */
299 void cleanUp(); 299 void cleanUp();
300 300
301 // sync stuff 301 // sync stuff
302 //Addressee::List getExternLastSyncAddressees(); 302 //Addressee::List getExternLastSyncAddressees();
303 void resetTempSyncStat(); 303 void resetTempSyncStat();
304 QStringList uidList(); 304 QStringList uidList();
305 void removeSyncAddressees( bool removeDeleted = false ); 305 void removeSyncAddressees( bool removeDeleted = false );
306 void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); 306 void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset );
307 const Addressee findByExternUid( const QString& uid , const QString& profile ) const; 307 const Addressee findByExternUid( const QString& uid , const QString& profile ) const;
308 bool containsExternalUid( const QString& uid ); 308 bool containsExternalUid( const QString& uid );
309 309
310 void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); 310 void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset );
311 void preOLSync( AddressBook* aBook, const QString& csd);
311 void postExternSync( AddressBook* aBook, const QString& csd , bool setID ); 312 void postExternSync( AddressBook* aBook, const QString& csd , bool setID );
312 signals: 313 signals:
313 /** 314 /**
314 Emitted, when the address book has changed on disk. 315 Emitted, when the address book has changed on disk.
315 */ 316 */
316 void addressBookChanged( AddressBook * ); 317 void addressBookChanged( AddressBook * );
317 318
318 /** 319 /**
319 Emitted, when the address book has been locked for writing. 320 Emitted, when the address book has been locked for writing.
320 */ 321 */
321 void addressBookLocked( AddressBook * ); 322 void addressBookLocked( AddressBook * );
322 323
323 /** 324 /**
324 Emitted, when the address book has been unlocked. 325 Emitted, when the address book has been unlocked.
325 */ 326 */
326 void addressBookUnlocked( AddressBook * ); 327 void addressBookUnlocked( AddressBook * );
327 328
328 protected: 329 protected:
329 void deleteRemovedAddressees(); 330 void deleteRemovedAddressees();
330 void setStandardResource( Resource * ); 331 void setStandardResource( Resource * );
331 Resource *standardResource(); 332 Resource *standardResource();
332 KRES::Manager<Resource> *resourceManager(); 333 KRES::Manager<Resource> *resourceManager();
333 334
334 void init(const QString &config, const QString &family); 335 void init(const QString &config, const QString &family);
335 336
336 private: 337 private:
337//US QPtrList<Resource> mDummy; // Remove in KDE 4 338//US QPtrList<Resource> mDummy; // Remove in KDE 4
338 339
339 340
340 struct AddressBookData; 341 struct AddressBookData;
341 AddressBookData *d; 342 AddressBookData *d;
342 bool blockLSEchange; 343 bool blockLSEchange;
343}; 344};
344 345
345QDataStream &operator<<( QDataStream &, const AddressBook & ); 346QDataStream &operator<<( QDataStream &, const AddressBook & );
346QDataStream &operator>>( QDataStream &, AddressBook & ); 347QDataStream &operator>>( QDataStream &, AddressBook & );
347 348
348} 349}
349 350
350#endif 351#endif
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 6cfac80..e8e440c 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,2286 +1,2355 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30 30
31#include <ksharedptr.h> 31#include <ksharedptr.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kmessagebox.h>
35#include <kidmanager.h> 36#include <kidmanager.h>
36//US 37//US
37#include <kstandarddirs.h> 38#include <kstandarddirs.h>
38#include <libkcal/syncdefines.h> 39#include <libkcal/syncdefines.h>
39 40
40//US #include "resource.h" 41//US #include "resource.h"
41#include "addressee.h" 42#include "addressee.h"
42 43
43using namespace KABC; 44using namespace KABC;
44 45
45static bool matchBinaryPattern( int value, int pattern ); 46static bool matchBinaryPattern( int value, int pattern );
46static bool matchBinaryPatternA( int value, int pattern ); 47static bool matchBinaryPatternA( int value, int pattern );
47static bool matchBinaryPatternP( int value, int pattern ); 48static bool matchBinaryPatternP( int value, int pattern );
48 49
49struct Addressee::AddresseeData : public KShared 50struct Addressee::AddresseeData : public KShared
50{ 51{
51 QString uid; 52 QString uid;
52 QString name; 53 QString name;
53 QString formattedName; 54 QString formattedName;
54 QString familyName; 55 QString familyName;
55 QString givenName; 56 QString givenName;
56 QString additionalName; 57 QString additionalName;
57 QString prefix; 58 QString prefix;
58 QString suffix; 59 QString suffix;
59 QString nickName; 60 QString nickName;
60 QDateTime birthday; 61 QDateTime birthday;
61 QString mailer; 62 QString mailer;
62 TimeZone timeZone; 63 TimeZone timeZone;
63 Geo geo; 64 Geo geo;
64 QString title; 65 QString title;
65 QString role; 66 QString role;
66 QString organization; 67 QString organization;
67 QString note; 68 QString note;
68 QString productId; 69 QString productId;
69 QDateTime revision; 70 QDateTime revision;
70 QString sortString; 71 QString sortString;
71 QString externalUID; 72 QString externalUID;
72 QString originalExternalUID; 73 QString originalExternalUID;
73 KURL url; 74 KURL url;
74 Secrecy secrecy; 75 Secrecy secrecy;
75 Picture logo; 76 Picture logo;
76 Picture photo; 77 Picture photo;
77 Sound sound; 78 Sound sound;
78 Agent agent; 79 Agent agent;
79 QString mExternalId; 80 QString mExternalId;
80 PhoneNumber::List phoneNumbers; 81 PhoneNumber::List phoneNumbers;
81 Address::List addresses; 82 Address::List addresses;
82 Key::List keys; 83 Key::List keys;
83 QStringList emails; 84 QStringList emails;
84 QStringList categories; 85 QStringList categories;
85 QStringList custom; 86 QStringList custom;
86 int mTempSyncStat; 87 int mTempSyncStat;
87 Resource *resource; 88 Resource *resource;
88 89
89 bool empty :1; 90 bool empty :1;
90 bool changed :1; 91 bool changed :1;
91 bool tagged :1; 92 bool tagged :1;
92}; 93};
93 94
94Addressee::Addressee() 95Addressee::Addressee()
95{ 96{
96 mData = new AddresseeData; 97 mData = new AddresseeData;
97 mData->empty = true; 98 mData->empty = true;
98 mData->changed = false; 99 mData->changed = false;
99 mData->resource = 0; 100 mData->resource = 0;
100 mData->mExternalId = ":"; 101 mData->mExternalId = ":";
101 mData->revision = QDateTime ( QDate( 2003,1,1)); 102 mData->revision = QDateTime ( QDate( 2003,1,1));
102 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 103 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
103} 104}
104 105
105Addressee::~Addressee() 106Addressee::~Addressee()
106{ 107{
107} 108}
108 109
109Addressee::Addressee( const Addressee &a ) 110Addressee::Addressee( const Addressee &a )
110{ 111{
111 mData = a.mData; 112 mData = a.mData;
112} 113}
113 114
114Addressee &Addressee::operator=( const Addressee &a ) 115Addressee &Addressee::operator=( const Addressee &a )
115{ 116{
116 mData = a.mData; 117 mData = a.mData;
117 return (*this); 118 return (*this);
118} 119}
119 120
120Addressee Addressee::copy() 121Addressee Addressee::copy()
121{ 122{
122 Addressee a; 123 Addressee a;
123 *(a.mData) = *mData; 124 *(a.mData) = *mData;
124 return a; 125 return a;
125} 126}
126 127
127void Addressee::detach() 128void Addressee::detach()
128{ 129{
129 if ( mData.count() == 1 ) return; 130 if ( mData.count() == 1 ) return;
130 *this = copy(); 131 *this = copy();
131} 132}
132 133
133bool Addressee::operator==( const Addressee &a ) const 134bool Addressee::operator==( const Addressee &a ) const
134{ 135{
135 if ( uid() != a.uid() ) return false; 136 if ( uid() != a.uid() ) return false;
136 if ( mData->name != a.mData->name ) return false; 137 if ( mData->name != a.mData->name ) return false;
137 if ( mData->formattedName != a.mData->formattedName ) return false; 138 if ( mData->formattedName != a.mData->formattedName ) return false;
138 if ( mData->familyName != a.mData->familyName ) return false; 139 if ( mData->familyName != a.mData->familyName ) return false;
139 if ( mData->givenName != a.mData->givenName ) return false; 140 if ( mData->givenName != a.mData->givenName ) return false;
140 if ( mData->additionalName != a.mData->additionalName ) return false; 141 if ( mData->additionalName != a.mData->additionalName ) return false;
141 if ( mData->prefix != a.mData->prefix ) return false; 142 if ( mData->prefix != a.mData->prefix ) return false;
142 if ( mData->suffix != a.mData->suffix ) return false; 143 if ( mData->suffix != a.mData->suffix ) return false;
143 if ( mData->nickName != a.mData->nickName ) return false; 144 if ( mData->nickName != a.mData->nickName ) return false;
144 if ( mData->birthday != a.mData->birthday ) return false; 145 if ( mData->birthday != a.mData->birthday ) return false;
145 if ( mData->mailer != a.mData->mailer ) return false; 146 if ( mData->mailer != a.mData->mailer ) return false;
146 if ( mData->timeZone != a.mData->timeZone ) return false; 147 if ( mData->timeZone != a.mData->timeZone ) return false;
147 if ( mData->geo != a.mData->geo ) return false; 148 if ( mData->geo != a.mData->geo ) return false;
148 if ( mData->title != a.mData->title ) return false; 149 if ( mData->title != a.mData->title ) return false;
149 if ( mData->role != a.mData->role ) return false; 150 if ( mData->role != a.mData->role ) return false;
150 if ( mData->organization != a.mData->organization ) return false; 151 if ( mData->organization != a.mData->organization ) return false;
151 if ( mData->note != a.mData->note ) return false; 152 if ( mData->note != a.mData->note ) return false;
152 if ( mData->productId != a.mData->productId ) return false; 153 if ( mData->productId != a.mData->productId ) return false;
153 //if ( mData->revision != a.mData->revision ) return false; 154 //if ( mData->revision != a.mData->revision ) return false;
154 if ( mData->sortString != a.mData->sortString ) return false; 155 if ( mData->sortString != a.mData->sortString ) return false;
155 if ( mData->secrecy != a.mData->secrecy ) return false; 156 if ( mData->secrecy != a.mData->secrecy ) return false;
156 if ( mData->logo != a.mData->logo ) return false; 157 if ( mData->logo != a.mData->logo ) return false;
157 if ( mData->photo != a.mData->photo ) return false; 158 if ( mData->photo != a.mData->photo ) return false;
158 if ( mData->sound != a.mData->sound ) return false; 159 if ( mData->sound != a.mData->sound ) return false;
159 if ( mData->agent != a.mData->agent ) return false; 160 if ( mData->agent != a.mData->agent ) return false;
160 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 161 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
161 ( mData->url != a.mData->url ) ) return false; 162 ( mData->url != a.mData->url ) ) return false;
162 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 163 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
163 if ( mData->addresses != a.mData->addresses ) return false; 164 if ( mData->addresses != a.mData->addresses ) return false;
164 if ( mData->keys != a.mData->keys ) return false; 165 if ( mData->keys != a.mData->keys ) return false;
165 if ( mData->emails != a.mData->emails ) return false; 166 if ( mData->emails != a.mData->emails ) return false;
166 if ( mData->categories != a.mData->categories ) return false; 167 if ( mData->categories != a.mData->categories ) return false;
167 if ( mData->custom != a.mData->custom ) return false; 168 if ( mData->custom != a.mData->custom ) return false;
168 169
169 return true; 170 return true;
170} 171}
171 172
172bool Addressee::operator!=( const Addressee &a ) const 173bool Addressee::operator!=( const Addressee &a ) const
173{ 174{
174 return !( a == *this ); 175 return !( a == *this );
175} 176}
176 177
177bool Addressee::isEmpty() const 178bool Addressee::isEmpty() const
178{ 179{
179 return mData->empty; 180 return mData->empty;
180} 181}
181ulong Addressee::getCsum4List( const QStringList & attList) 182ulong Addressee::getCsum4List( const QStringList & attList)
182{ 183{
183 int max = attList.count(); 184 int max = attList.count();
184 ulong cSum = 0; 185 ulong cSum = 0;
185 int j,k,i; 186 int j,k,i;
186 int add; 187 int add;
187 for ( i = 0; i < max ; ++i ) { 188 for ( i = 0; i < max ; ++i ) {
188 QString s = attList[i]; 189 QString s = attList[i];
189 if ( ! s.isEmpty() ){ 190 if ( ! s.isEmpty() ){
190 j = s.length(); 191 j = s.length();
191 for ( k = 0; k < j; ++k ) { 192 for ( k = 0; k < j; ++k ) {
192 int mul = k +1; 193 int mul = k +1;
193 add = s[k].unicode (); 194 add = s[k].unicode ();
194 if ( k < 16 ) 195 if ( k < 16 )
195 mul = mul * mul; 196 mul = mul * mul;
196 int ii = i+1; 197 int ii = i+1;
197 add = add * mul *ii*ii*ii; 198 add = add * mul *ii*ii*ii;
198 cSum += add; 199 cSum += add;
199 //qDebug("csum: %d %d %d", i,k,cSum); 200 //qDebug("csum: %d %d %d", i,k,cSum);
200 } 201 }
201 } 202 }
202 203
203 } 204 }
204 //QString dump = attList.join(","); 205 //QString dump = attList.join(",");
205 //qDebug("csum: %d %s", cSum,dump.latin1()); 206 //qDebug("csum: %d %s", cSum,dump.latin1());
206 207
207 return cSum; 208 return cSum;
208 209
209} 210}
210void Addressee::computeCsum(const QString &dev) 211void Addressee::computeCsum(const QString &dev)
211{ 212{
212 QStringList l; 213 QStringList l;
213 //if ( !mData->name.isEmpty() ) l.append(mData->name); 214 //if ( !mData->name.isEmpty() ) l.append(mData->name);
214 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 215 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
215 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 216 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
216 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 217 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
217 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); 218 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName );
218 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 219 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
219 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 220 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
220 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 221 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
221 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 222 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
222 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 223 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
223 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 224 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
224 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 225 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
225 if ( !mData->title .isEmpty() ) l.append( mData->title ); 226 if ( !mData->title .isEmpty() ) l.append( mData->title );
226 if ( !mData->role.isEmpty() ) l.append( mData->role ); 227 if ( !mData->role.isEmpty() ) l.append( mData->role );
227 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 228 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
228 if ( !mData->note.isEmpty() ) l.append( mData->note ); 229 if ( !mData->note.isEmpty() ) l.append( mData->note );
229 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 230 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
230 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 231 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
231 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 232 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
232 if ( !mData->logo.undefined() ) { 233 if ( !mData->logo.undefined() ) {
233 if ( !mData->logo.isIntern() ) 234 if ( !mData->logo.isIntern() )
234 l.append( mData->logo.url() ); 235 l.append( mData->logo.url() );
235 else 236 else
236 l.append( QString::number(mData->logo.data().width()* mData->logo.data().height())); 237 l.append( QString::number(mData->logo.data().width()* mData->logo.data().height()));
237 } else { 238 } else {
238 l.append( "nologo"); 239 l.append( "nologo");
239 } 240 }
240 if ( !mData->photo.undefined() ) { 241 if ( !mData->photo.undefined() ) {
241 if ( !mData->photo.isIntern() ) 242 if ( !mData->photo.isIntern() )
242 l.append( mData->photo.url() ); 243 l.append( mData->photo.url() );
243 else 244 else
244 l.append( QString::number(mData->photo.data().width()* mData->photo.data().height())); 245 l.append( QString::number(mData->photo.data().width()* mData->photo.data().height()));
245 } else { 246 } else {
246 l.append( "nophoto"); 247 l.append( "nophoto");
247 } 248 }
248#if 0 249#if 0
249 if ( !mData->sound.undefined() ) { 250 if ( !mData->sound.undefined() ) {
250 if ( !mData->sound.isIntern() ) 251 if ( !mData->sound.isIntern() )
251 l.append( mData->sound.url() ); 252 l.append( mData->sound.url() );
252 else 253 else
253 l.append( QString(mData->sound.data().with()* mData->sound.data().height())); 254 l.append( QString(mData->sound.data().with()* mData->sound.data().height()));
254 } else { 255 } else {
255 l.append( "nosound"); 256 l.append( "nosound");
256 } 257 }
257#endif 258#endif
258 //if ( !mData->agent.isEmpty() ) l.append( ); 259 //if ( !mData->agent.isEmpty() ) l.append( );
259 if ( mData->url.isValid() ) 260 if ( mData->url.isValid() )
260 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); 261 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() );
261 KABC::PhoneNumber::List phoneNumbers; 262 KABC::PhoneNumber::List phoneNumbers;
262 KABC::PhoneNumber::List::Iterator phoneIter; 263 KABC::PhoneNumber::List::Iterator phoneIter;
263 264
264 QStringList t; 265 QStringList t;
265 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 266 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
266 ++phoneIter ) 267 ++phoneIter )
267 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 268 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
268 t.sort(); 269 t.sort();
269 uint iii; 270 uint iii;
270 for ( iii = 0; iii < t.count(); ++iii) 271 for ( iii = 0; iii < t.count(); ++iii)
271 l.append( t[iii] ); 272 l.append( t[iii] );
272 t = mData->emails; 273 t = mData->emails;
273 t.sort(); 274 t.sort();
274 for ( iii = 0; iii < t.count(); ++iii) 275 for ( iii = 0; iii < t.count(); ++iii)
275 l.append( t[iii] ); 276 l.append( t[iii] );
276 t = mData->categories; 277 t = mData->categories;
277 t.sort(); 278 t.sort();
278 for ( iii = 0; iii < t.count(); ++iii) 279 for ( iii = 0; iii < t.count(); ++iii)
279 l.append( t[iii] ); 280 l.append( t[iii] );
280 t = mData->custom; 281 t = mData->custom;
281 t.sort(); 282 t.sort();
282 for ( iii = 0; iii < t.count(); ++iii) 283 for ( iii = 0; iii < t.count(); ++iii)
283 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { 284 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) {
284 int find = t[iii].find (':')+1; 285 int find = t[iii].find (':')+1;
285 //qDebug("lennnn %d %d ", find, t[iii].length()); 286 //qDebug("lennnn %d %d ", find, t[iii].length());
286 if ( find < t[iii].length()) 287 if ( find < t[iii].length())
287 l.append( t[iii] ); 288 l.append( t[iii] );
288 289
289 } 290 }
290 KABC::Address::List::Iterator addressIter; 291 KABC::Address::List::Iterator addressIter;
291 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 292 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
292 ++addressIter ) { 293 ++addressIter ) {
293 t = (*addressIter).asList(); 294 t = (*addressIter).asList();
294 t.sort(); 295 t.sort();
295 for ( iii = 0; iii < t.count(); ++iii) 296 for ( iii = 0; iii < t.count(); ++iii)
296 l.append( t[iii] ); 297 l.append( t[iii] );
297 } 298 }
298 uint cs = getCsum4List(l); 299 uint cs = getCsum4List(l);
299 300
300#if 0 301#if 0
301 for ( iii = 0; iii < l.count(); ++iii) 302 for ( iii = 0; iii < l.count(); ++iii)
302 qDebug("%d***%s***",iii,l[iii].latin1()); 303 qDebug("%d***%s***",iii,l[iii].latin1());
303 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 304 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
304#endif 305#endif
305 306
306 307
307 setCsum( dev, QString::number (cs )); 308 setCsum( dev, QString::number (cs ));
308} 309}
309bool Addressee::matchAddress( QRegExp* re ) const 310bool Addressee::matchAddress( QRegExp* re ) const
310{ 311{
311 KABC::Address::List::Iterator addressIter; 312 KABC::Address::List::Iterator addressIter;
312 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 313 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
313 ++addressIter ) { 314 ++addressIter ) {
314 if ( (*addressIter).matchAddress( re ) ) 315 if ( (*addressIter).matchAddress( re ) )
315 return true; 316 return true;
316 } 317 }
317 return false; 318 return false;
318} 319}
319bool Addressee::matchPhoneNumber( QRegExp* re ) const 320bool Addressee::matchPhoneNumber( QRegExp* re ) const
320{ 321{
321 KABC::PhoneNumber::List::Iterator phoneIter; 322 KABC::PhoneNumber::List::Iterator phoneIter;
322 323
323 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) { 324 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); ++phoneIter ) {
324#if QT_VERSION >= 0x030000 325#if QT_VERSION >= 0x030000
325 if (re->search( (*phoneIter).number() ) == 0) 326 if (re->search( (*phoneIter).number() ) == 0)
326#else 327#else
327 if (re->match( (*phoneIter).number() ) == 0) 328 if (re->match( (*phoneIter).number() ) == 0)
328#endif 329#endif
329 return true; 330 return true;
330 331
331 } 332 }
332 return false; 333 return false;
333 334
334} 335}
336void Addressee::mergeOLContact( const Addressee& ad )
337{
338 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
339 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
340 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
341 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
342 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
343 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
344 if ( !mData->sound.isIntern() ) {
345 if ( mData->sound.url().isEmpty() ) {
346 mData->sound = ad.mData->sound;
347 }
348 }
349 if ( !mData->agent.isIntern() ) {
350 if ( mData->agent.url().isEmpty() ) {
351 mData->agent = ad.mData->agent;
352 }
353 }
354 {
355 Key::List::Iterator itA;
356 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
357 bool found = false;
358 Key::List::Iterator it;
359 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
360 if ( (*it) == (*itA)) {
361 found = true;
362 break;
363
364 }
365 }
366 if ( ! found ) {
367 mData->keys.append( *itA );
368 }
369 }
370 }
371
372 KABC::Address addthis = otherAddress();
373 KABC::Address addother = ad.otherAddress();
374 if ( !addthis.isEmpty() && !addother.isEmpty() )
375 addthis.setType( addother.type() );
376 //qDebug("merge contact %s ", ad.uid().latin1());
377 setUid( ad.uid() );
378 setRevision( ad.revision() );
379
380
381}
382
335void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) 383void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
336{ 384{
337 // merge all standard non-outlook fields. 385 // merge all standard non-outlook fields.
338 //if isSubSet (e.g. mobile phone sync) merge all fields 386 //if isSubSet (e.g. mobile phone sync) merge all fields
339 387
340 detach(); 388 detach();
341 if ( isSubSet ) { 389 if ( isSubSet ) {
342 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 390 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
343 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 391 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
344 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 392 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
345 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 393 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
346 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 394 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
347 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 395 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
348 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 396 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
349 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 397 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
350 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 398 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
351 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 399 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
352 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 400 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
353 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 401 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
354 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 402 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
355 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 403 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
356 if ( !mData->birthday.isValid() ) 404 if ( !mData->birthday.isValid() )
357 if ( ad.mData->birthday.isValid()) 405 if ( ad.mData->birthday.isValid())
358 mData->birthday = ad.mData->birthday; 406 mData->birthday = ad.mData->birthday;
359 407
360 } 408 }
361 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 409 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
362 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 410 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
363 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 411 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
364 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 412 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
365 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 413 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
366 QStringList t; 414 QStringList t;
367 QStringList tAD; 415 QStringList tAD;
368 uint iii; 416 uint iii;
369 417
370 // ********** phone numbers 418 // ********** phone numbers
371 if ( isSubSet ) { 419 if ( isSubSet ) {
372 PhoneNumber::List phoneAD = ad.phoneNumbers(); 420 PhoneNumber::List phoneAD = ad.phoneNumbers();
373 PhoneNumber::List::Iterator phoneItAD; 421 PhoneNumber::List::Iterator phoneItAD;
374 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 422 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
375 bool found = false; 423 bool found = false;
376 PhoneNumber::List::Iterator it; 424 PhoneNumber::List::Iterator it;
377 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 425 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
378 if ( ( *phoneItAD ).contains( (*it) ) ) { 426 if ( ( *phoneItAD ).contains( (*it) ) ) {
379 found = true; 427 found = true;
380 (*it).setType( ( *phoneItAD ).type() ); 428 (*it).setType( ( *phoneItAD ).type() );
381 (*it).setNumber( ( *phoneItAD ).number() ); 429 (*it).setNumber( ( *phoneItAD ).number() );
382 break; 430 break;
383 } 431 }
384 } 432 }
385 // if ( isSubSet && ! found ) 433 // if ( isSubSet && ! found )
386 if ( ! found ) // LR try this one... 434 if ( ! found ) // LR try this one...
387 mData->phoneNumbers.append( *phoneItAD ); 435 mData->phoneNumbers.append( *phoneItAD );
388 } 436 }
389 } else { 437 } else {
390 PhoneNumber::List phoneAD = ad.phoneNumbers(); 438 PhoneNumber::List phoneAD = ad.phoneNumbers();
391 PhoneNumber::List::Iterator phoneItAD; 439 PhoneNumber::List::Iterator phoneItAD;
392 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 440 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
393 bool found = false; 441 bool found = false;
394 PhoneNumber::List::Iterator it; 442 PhoneNumber::List::Iterator it;
395 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 443 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
396 if ( ( *phoneItAD ).contains( (*it) ) ) { 444 if ( ( *phoneItAD ).contains( (*it) ) ) {
397 found = true; 445 found = true;
398 (*it).setType( ( *phoneItAD ).type() ); 446 (*it).setType( ( *phoneItAD ).type() );
399 (*it).setNumber( ( *phoneItAD ).number() ); 447 (*it).setNumber( ( *phoneItAD ).number() );
400 break; 448 break;
401 } 449 }
402 } 450 }
403 if ( ! found ) { // append numbers which do not have work or home type 451 if ( ! found ) { // append numbers which do not have work or home type
404 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) ) 452 if ( ! ( ( *phoneItAD ).type() & (PhoneNumber::Work | PhoneNumber::Home) ) )
405 mData->phoneNumbers.append( *phoneItAD ); 453 mData->phoneNumbers.append( *phoneItAD );
406 } 454 }
407 } 455 }
408 } 456 }
409 if ( isSubSet ) { 457 if ( isSubSet ) {
410 // ************* emails; 458 // ************* emails;
411 t = mData->emails; 459 t = mData->emails;
412 tAD = ad.mData->emails; 460 tAD = ad.mData->emails;
413 for ( iii = 0; iii < tAD.count(); ++iii) 461 for ( iii = 0; iii < tAD.count(); ++iii)
414 if ( !t.contains(tAD[iii] ) ) 462 if ( !t.contains(tAD[iii] ) )
415 mData->emails.append( tAD[iii] ); 463 mData->emails.append( tAD[iii] );
416 } 464 }
417 465
418 // ************* categories; 466 // ************* categories;
419 if ( isSubSet ) { 467 if ( isSubSet ) {
420 t = mData->categories; 468 t = mData->categories;
421 tAD = ad.mData->categories; 469 tAD = ad.mData->categories;
422 for ( iii = 0; iii < tAD.count(); ++iii) 470 for ( iii = 0; iii < tAD.count(); ++iii)
423 if ( !t.contains(tAD[iii] ) ) 471 if ( !t.contains(tAD[iii] ) )
424 mData->categories.append( tAD[iii] ); 472 mData->categories.append( tAD[iii] );
425 } 473 }
426 QStringList::ConstIterator it; 474 QStringList::ConstIterator it;
427 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { 475 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) {
428 QString qualifiedName = (*it).left( (*it).find( ":" )); 476 QString qualifiedName = (*it).left( (*it).find( ":" ));
429 bool found = false; 477 bool found = false;
430 QStringList::ConstIterator itL; 478 QStringList::ConstIterator itL;
431 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { 479 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
432 if ( (*itL).startsWith( qualifiedName ) ) { 480 if ( (*itL).startsWith( qualifiedName ) ) {
433 found = true; 481 found = true;
434 break; 482 break;
435 } 483 }
436 } 484 }
437 if ( ! found ) { 485 if ( ! found ) {
438 mData->custom.append( *it ); 486 mData->custom.append( *it );
439 } 487 }
440 } 488 }
441 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; 489 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
442 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; 490 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
443 if ( !mData->sound.isIntern() ) { 491 if ( !mData->sound.isIntern() ) {
444 if ( mData->sound.url().isEmpty() ) { 492 if ( mData->sound.url().isEmpty() ) {
445 mData->sound = ad.mData->sound; 493 mData->sound = ad.mData->sound;
446 } 494 }
447 } 495 }
448 if ( !mData->agent.isIntern() ) { 496 if ( !mData->agent.isIntern() ) {
449 if ( mData->agent.url().isEmpty() ) { 497 if ( mData->agent.url().isEmpty() ) {
450 mData->agent = ad.mData->agent; 498 mData->agent = ad.mData->agent;
451 } 499 }
452 } 500 }
453 { 501 {
454 Key::List::Iterator itA; 502 Key::List::Iterator itA;
455 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { 503 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
456 bool found = false; 504 bool found = false;
457 Key::List::Iterator it; 505 Key::List::Iterator it;
458 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 506 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
459 if ( (*it) == (*itA)) { 507 if ( (*it) == (*itA)) {
460 found = true; 508 found = true;
461 break; 509 break;
462 510
463 } 511 }
464 } 512 }
465 if ( ! found ) { 513 if ( ! found ) {
466 mData->keys.append( *itA ); 514 mData->keys.append( *itA );
467 } 515 }
468 } 516 }
469 } 517 }
470 if ( isSubSet ) { 518 if ( isSubSet ) {
471 KABC::Address::List::Iterator addressIterA; 519 KABC::Address::List::Iterator addressIterA;
472 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { 520 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) {
473 bool found = false; 521 bool found = false;
474 KABC::Address::List::Iterator addressIter; 522 KABC::Address::List::Iterator addressIter;
475 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 523 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
476 ++addressIter ) { 524 ++addressIter ) {
477 if ( (*addressIter) == (*addressIterA)) { 525 if ( (*addressIter) == (*addressIterA)) {
478 found = true; 526 found = true;
479 (*addressIter).setType( (*addressIterA).type() ); 527 (*addressIter).setType( (*addressIterA).type() );
480 break; 528 break;
481 } 529 }
482 530
483 } 531 }
484 if ( isSubSet && ! found ) { 532 if ( isSubSet && ! found ) {
485 mData->addresses.append( *addressIterA ); 533 mData->addresses.append( *addressIterA );
486 } 534 }
487 } 535 }
488 } 536 }
489 //qDebug("merge contact %s ", ad.uid().latin1()); 537 //qDebug("merge contact %s ", ad.uid().latin1());
490 setUid( ad.uid() ); 538 setUid( ad.uid() );
491 setRevision( ad.revision() ); 539 setRevision( ad.revision() );
492} 540}
493 541
494bool Addressee::removeVoice() 542bool Addressee::removeVoice()
495{ 543{
496 PhoneNumber::List phoneN = phoneNumbers(); 544 PhoneNumber::List phoneN = phoneNumbers();
497 PhoneNumber::List::Iterator phoneIt; 545 PhoneNumber::List::Iterator phoneIt;
498 bool found = false; 546 bool found = false;
499 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 547 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
500 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 548 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
501 if ((*phoneIt).type() - PhoneNumber::Voice ) { 549 if ((*phoneIt).type() - PhoneNumber::Voice ) {
502 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 550 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
503 insertPhoneNumber( (*phoneIt) ); 551 insertPhoneNumber( (*phoneIt) );
504 found = true; 552 found = true;
505 } 553 }
506 } 554 }
507 555
508 } 556 }
509 return found; 557 return found;
510} 558}
511 559
512bool Addressee::containsAdr(const Addressee& ad ) 560bool Addressee::containsAdr(const Addressee& ad )
513{ 561{
514 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; 562 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
515 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; 563 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
516 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; 564 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
517 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; 565 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
518 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; 566 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
519 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; 567 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
520 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; 568 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
521 569
522 // compare phone numbers 570 // compare phone numbers
523 PhoneNumber::List phoneN = ad.phoneNumbers(); 571 PhoneNumber::List phoneN = ad.phoneNumbers();
524 PhoneNumber::List::Iterator phoneIt; 572 PhoneNumber::List::Iterator phoneIt;
525 bool found = false; 573 bool found = false;
526 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 574 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
527 bool found = false; 575 bool found = false;
528 PhoneNumber::List phoneL = ad.phoneNumbers(); 576 PhoneNumber::List phoneL = ad.phoneNumbers();
529 PhoneNumber::List::Iterator phoneItL; 577 PhoneNumber::List::Iterator phoneItL;
530 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { 578 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
531 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { 579 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
532 found = true; 580 found = true;
533 break; 581 break;
534 } 582 }
535 } 583 }
536 if ( ! found ) 584 if ( ! found )
537 return false; 585 return false;
538 } 586 }
539 return true; 587 return true;
540 588
541} 589}
542void Addressee::simplifyAddresses() 590void Addressee::simplifyAddresses()
543{ 591{
544 592
545 593
546 Address::List list; 594 Address::List list;
547 Address::List::Iterator it; 595 Address::List::Iterator it;
548 Address::List::Iterator it2; 596 Address::List::Iterator it2;
549 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 597 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
550 it2 = it; 598 it2 = it;
551 ++it2; 599 ++it2;
552 for( ; it2 != mData->addresses.end(); ++it2 ) { 600 for( ; it2 != mData->addresses.end(); ++it2 ) {
553 if ( (*it) == (*it2) ) { 601 if ( (*it) == (*it2) ) {
554 list.append( *it ); 602 list.append( *it );
555 break; 603 break;
556 } 604 }
557 } 605 }
558 } 606 }
559 for( it = list.begin(); it != list.end(); ++it ) { 607 for( it = list.begin(); it != list.end(); ++it ) {
560 removeAddress( (*it) ); 608 removeAddress( (*it) );
561 } 609 }
562 610
563 list.clear(); 611 list.clear();
564 int max = 2; 612 int max = 2;
565 if ( mData->url.isValid() ) 613 if ( mData->url.isValid() )
566 max = 1; 614 max = 1;
567 if ( mData->addresses.count() <= max ) return ; 615 if ( mData->addresses.count() <= max ) return ;
568 int count = 0; 616 int count = 0;
569 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 617 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
570 if ( count >= max ) 618 if ( count >= max )
571 list.append( *it ); 619 list.append( *it );
572 ++count; 620 ++count;
573 } 621 }
574 for( it = list.begin(); it != list.end(); ++it ) { 622 for( it = list.begin(); it != list.end(); ++it ) {
575 removeAddress( (*it) ); 623 removeAddress( (*it) );
576 } 624 }
577} 625}
578 626
579// removes all emails but the first 627// removes all emails but the first
580// needed by phone sync 628// needed by phone sync
581void Addressee::simplifyEmails() 629void Addressee::simplifyEmails()
582{ 630{
583 if ( mData->emails.count() == 0 ) return ; 631 if ( mData->emails.count() == 0 ) return ;
584 QString email = mData->emails.first(); 632 QString email = mData->emails.first();
585 detach(); 633 detach();
586 mData->emails.clear(); 634 mData->emails.clear();
587 mData->emails.append( email ); 635 mData->emails.append( email );
588} 636}
589void Addressee::makePhoneNumbersOLcompatible() 637void Addressee::makePhoneNumbersOLcompatible()
590{ 638{
591 KABC::PhoneNumber::List::Iterator phoneIter; 639 KABC::PhoneNumber::List::Iterator phoneIter;
592 KABC::PhoneNumber::List::Iterator phoneIter2; 640 KABC::PhoneNumber::List::Iterator phoneIter2;
593 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 641 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
594 ++phoneIter ) { 642 ++phoneIter ) {
595 ( *phoneIter ).makeCompat(); 643 ( *phoneIter ).makeCompat();
596 } 644 }
597 int hasHome = hasPhoneNumberType( PhoneNumber::Home | PhoneNumber::Pref ); 645 int hasHome = hasPhoneNumberType( PhoneNumber::Home | PhoneNumber::Pref );
598 int hasHome2 = hasPhoneNumberType( PhoneNumber::Home ); 646 int hasHome2 = hasPhoneNumberType( PhoneNumber::Home );
599 int hasWork = hasPhoneNumberType( PhoneNumber::Work | PhoneNumber::Pref ); 647 int hasWork = hasPhoneNumberType( PhoneNumber::Work | PhoneNumber::Pref );
600 int hasWork2 = hasPhoneNumberType( PhoneNumber::Work ); 648 int hasWork2 = hasPhoneNumberType( PhoneNumber::Work );
601 int hasCell = hasPhoneNumberType( PhoneNumber::Cell ); 649 int hasCell = hasPhoneNumberType( PhoneNumber::Cell );
602 int hasCell2 = hasPhoneNumberType( PhoneNumber::Car ); 650 int hasCell2 = hasPhoneNumberType( PhoneNumber::Car );
603 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 651 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
604 ++phoneIter ) { 652 ++phoneIter ) {
605 if ( (*phoneIter).type() == PhoneNumber::Home && ! hasHome ) { 653 if ( (*phoneIter).type() == PhoneNumber::Home && ! hasHome ) {
606 (*phoneIter).setType( PhoneNumber::Home | PhoneNumber::Pref ); 654 (*phoneIter).setType( PhoneNumber::Home | PhoneNumber::Pref );
607 ++hasHome; 655 ++hasHome;
608 if ( hasHome2 ) --hasHome2; 656 if ( hasHome2 ) --hasHome2;
609 } else if ( ( (*phoneIter).type() == PhoneNumber::Home | PhoneNumber::Pref) && hasHome>1 && !hasHome2 ) { 657 } else if ( ( (*phoneIter).type() == PhoneNumber::Home | PhoneNumber::Pref) && hasHome>1 && !hasHome2 ) {
610 (*phoneIter).setType( PhoneNumber::Home ); 658 (*phoneIter).setType( PhoneNumber::Home );
611 --hasHome; 659 --hasHome;
612 ++hasHome2; 660 ++hasHome2;
613 } else if ( (*phoneIter).type() == PhoneNumber::Work && ! hasWork ) { 661 } else if ( (*phoneIter).type() == PhoneNumber::Work && ! hasWork ) {
614 (*phoneIter).setType( PhoneNumber::Work | PhoneNumber::Pref ); 662 (*phoneIter).setType( PhoneNumber::Work | PhoneNumber::Pref );
615 ++hasWork; 663 ++hasWork;
616 if ( hasWork2 ) --hasWork2; 664 if ( hasWork2 ) --hasWork2;
617 } else if ( ( (*phoneIter).type() == PhoneNumber::Work | PhoneNumber::Pref) && hasWork > 1 && ! hasWork2 ) { 665 } else if ( ( (*phoneIter).type() == PhoneNumber::Work | PhoneNumber::Pref) && hasWork > 1 && ! hasWork2 ) {
618 (*phoneIter).setType( PhoneNumber::Work ); 666 (*phoneIter).setType( PhoneNumber::Work );
619 --hasWork; 667 --hasWork;
620 ++hasWork2; 668 ++hasWork2;
621 } else if ( (*phoneIter).type() == PhoneNumber::Cell && hasCell > 1 && !hasCell2) { 669 } else if ( (*phoneIter).type() == PhoneNumber::Cell && hasCell > 1 && !hasCell2) {
622 (*phoneIter).setType( PhoneNumber::Car ); 670 (*phoneIter).setType( PhoneNumber::Car );
623 ++hasCell2; 671 ++hasCell2;
624 --hasCell; 672 --hasCell;
625 } else if ( (*phoneIter).type() == PhoneNumber::Car && hasCell2 > 1 && !hasCell) { 673 } else if ( (*phoneIter).type() == PhoneNumber::Car && hasCell2 > 1 && !hasCell) {
626 (*phoneIter).setType( PhoneNumber::Cell ); 674 (*phoneIter).setType( PhoneNumber::Cell );
627 ++hasCell; 675 ++hasCell;
628 --hasCell2; 676 --hasCell2;
629 } else{ 677 } else{
630 phoneIter2 = phoneIter; 678 phoneIter2 = phoneIter;
631 ++phoneIter2; 679 ++phoneIter2;
632 for ( ; phoneIter2 != mData->phoneNumbers.end(); 680 for ( ; phoneIter2 != mData->phoneNumbers.end();
633 ++phoneIter2 ) { 681 ++phoneIter2 ) {
634 if ( (*phoneIter2).type() == (*phoneIter).type() ) { 682 if ( (*phoneIter2).type() == (*phoneIter).type() ) {
635 (*phoneIter2).setType( PhoneNumber::Voice ); 683 (*phoneIter2).setType( PhoneNumber::Voice );
636 684
637 } 685 }
638 } 686 }
639 } 687 }
640 } 688 }
641} 689}
642void Addressee::simplifyPhoneNumbers() 690void Addressee::simplifyPhoneNumbers()
643{ 691{
644 int max = 4; 692 int max = 4;
645 int inList = mData->phoneNumbers.count(); 693 int inList = mData->phoneNumbers.count();
646 KABC::PhoneNumber::List removeNumbers; 694 KABC::PhoneNumber::List removeNumbers;
647 KABC::PhoneNumber::List::Iterator phoneIter; 695 KABC::PhoneNumber::List::Iterator phoneIter;
648 if ( inList > max ) { 696 if ( inList > max ) {
649 // delete non-preferred numbers 697 // delete non-preferred numbers
650 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 698 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
651 ++phoneIter ) { 699 ++phoneIter ) {
652 if ( inList > max ) { 700 if ( inList > max ) {
653 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { 701 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) {
654 removeNumbers.append( ( *phoneIter ) ); 702 removeNumbers.append( ( *phoneIter ) );
655 --inList; 703 --inList;
656 } 704 }
657 } else 705 } else
658 break; 706 break;
659 } 707 }
660 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 708 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
661 ++phoneIter ) { 709 ++phoneIter ) {
662 removePhoneNumber(( *phoneIter )); 710 removePhoneNumber(( *phoneIter ));
663 } 711 }
664 // delete preferred numbers 712 // delete preferred numbers
665 if ( inList > max ) { 713 if ( inList > max ) {
666 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 714 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
667 ++phoneIter ) { 715 ++phoneIter ) {
668 if ( inList > max ) { 716 if ( inList > max ) {
669 removeNumbers.append( ( *phoneIter ) ); 717 removeNumbers.append( ( *phoneIter ) );
670 --inList; 718 --inList;
671 } else 719 } else
672 break; 720 break;
673 } 721 }
674 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 722 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
675 ++phoneIter ) { 723 ++phoneIter ) {
676 removePhoneNumber(( *phoneIter )); 724 removePhoneNumber(( *phoneIter ));
677 } 725 }
678 } 726 }
679 } 727 }
680 // remove non-numeric characters 728 // remove non-numeric characters
681 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 729 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
682 ++phoneIter ) { 730 ++phoneIter ) {
683 if ( ! ( *phoneIter ).simplifyNumber() ) 731 if ( ! ( *phoneIter ).simplifyNumber() )
684 removeNumbers.append( ( *phoneIter ) ); 732 removeNumbers.append( ( *phoneIter ) );
685 } 733 }
686 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 734 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
687 ++phoneIter ) { 735 ++phoneIter ) {
688 removePhoneNumber(( *phoneIter )); 736 removePhoneNumber(( *phoneIter ));
689 } 737 }
690} 738}
691void Addressee::simplifyPhoneNumberTypes() 739void Addressee::simplifyPhoneNumberTypes()
692{ 740{
693 KABC::PhoneNumber::List::Iterator phoneIter; 741 KABC::PhoneNumber::List::Iterator phoneIter;
694 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 742 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
695 ++phoneIter ) 743 ++phoneIter )
696 ( *phoneIter ).simplifyType(); 744 ( *phoneIter ).simplifyType();
697} 745}
698void Addressee::removeID(const QString &prof) 746void Addressee::removeID(const QString &prof)
699{ 747{
700 detach(); 748 detach();
701 if ( prof.isEmpty() ) 749 if ( prof.isEmpty() )
702 mData->mExternalId = ":"; 750 mData->mExternalId = ":";
703 else 751 else
704 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 752 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
705 753
706} 754}
707void Addressee::setID( const QString & prof , const QString & id ) 755void Addressee::setID( const QString & prof , const QString & id )
708{ 756{
709 detach(); 757 detach();
710 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 758 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
711 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 759 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
712} 760}
713void Addressee::setTempSyncStat( int id ) 761void Addressee::setTempSyncStat( int id )
714{ 762{
715 if ( mData->mTempSyncStat == id ) return; 763 if ( mData->mTempSyncStat == id ) return;
716 detach(); 764 detach();
717 mData->mTempSyncStat = id; 765 mData->mTempSyncStat = id;
718} 766}
719int Addressee::tempSyncStat() const 767int Addressee::tempSyncStat() const
720{ 768{
721 return mData->mTempSyncStat; 769 return mData->mTempSyncStat;
722} 770}
723 771
724const QString Addressee::getID( const QString & prof) const 772const QString Addressee::getID( const QString & prof) const
725{ 773{
726 return KIdManager::getId ( mData->mExternalId, prof ); 774 return KIdManager::getId ( mData->mExternalId, prof );
727} 775}
728 776
729void Addressee::setCsum( const QString & prof , const QString & id ) 777void Addressee::setCsum( const QString & prof , const QString & id )
730{ 778{
731 detach(); 779 detach();
732 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 780 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
733 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 781 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
734 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 782 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
735} 783}
736 784
737const QString Addressee::getCsum( const QString & prof) const 785const QString Addressee::getCsum( const QString & prof) const
738{ 786{
739 return KIdManager::getCsum ( mData->mExternalId, prof ); 787 return KIdManager::getCsum ( mData->mExternalId, prof );
740} 788}
741 789
742void Addressee::setIDStr( const QString & s ) 790void Addressee::setIDStr( const QString & s )
743{ 791{
744 detach(); 792 detach();
745 mData->mExternalId = s; 793 mData->mExternalId = s;
746} 794}
747 795
748const QString Addressee::IDStr() const 796const QString Addressee::IDStr() const
749{ 797{
750 return mData->mExternalId; 798 return mData->mExternalId;
751} 799}
752 800
753void Addressee::setExternalUID( const QString &id ) 801void Addressee::setExternalUID( const QString &id )
754{ 802{
755 if ( id == mData->externalUID ) return; 803 if ( id == mData->externalUID ) return;
756 detach(); 804 detach();
757 mData->empty = false; 805 mData->empty = false;
758 mData->externalUID = id; 806 mData->externalUID = id;
759} 807}
760 808
761const QString Addressee::externalUID() const 809const QString Addressee::externalUID() const
762{ 810{
763 return mData->externalUID; 811 return mData->externalUID;
764} 812}
765void Addressee::setOriginalExternalUID( const QString &id ) 813void Addressee::setOriginalExternalUID( const QString &id )
766{ 814{
767 if ( id == mData->originalExternalUID ) return; 815 if ( id == mData->originalExternalUID ) return;
768 detach(); 816 detach();
769 mData->empty = false; 817 mData->empty = false;
770 //qDebug("*******Set orig uid %s ", id.latin1()); 818 //qDebug("*******Set orig uid %s ", id.latin1());
771 mData->originalExternalUID = id; 819 mData->originalExternalUID = id;
772} 820}
773 821
774QString Addressee::originalExternalUID() const 822QString Addressee::originalExternalUID() const
775{ 823{
776 return mData->originalExternalUID; 824 return mData->originalExternalUID;
777} 825}
778 826
779void Addressee::setUid( const QString &id ) 827void Addressee::setUid( const QString &id )
780{ 828{
781 if ( id == mData->uid ) return; 829 if ( id == mData->uid ) return;
782 detach(); 830 detach();
783 //qDebug("****setuid %s ", id.latin1()); 831 //qDebug("****setuid %s ", id.latin1());
784 mData->empty = false; 832 mData->empty = false;
785 mData->uid = id; 833 mData->uid = id;
786} 834}
787 835
788const QString Addressee::uid() const 836const QString Addressee::uid() const
789{ 837{
790 if ( mData->uid.isEmpty() ) 838 if ( mData->uid.isEmpty() )
791 mData->uid = KApplication::randomString( 10 ); 839 mData->uid = KApplication::randomString( 10 );
792 840
793 return mData->uid; 841 return mData->uid;
794} 842}
795 843
796QString Addressee::uidLabel() 844QString Addressee::uidLabel()
797{ 845{
798 return i18n("Unique Identifier"); 846 return i18n("Unique Identifier");
799} 847}
800 848
801void Addressee::setName( const QString &name ) 849void Addressee::setName( const QString &name )
802{ 850{
803 if ( name == mData->name ) return; 851 if ( name == mData->name ) return;
804 detach(); 852 detach();
805 mData->empty = false; 853 mData->empty = false;
806 mData->name = name; 854 mData->name = name;
807} 855}
808 856
809QString Addressee::name() const 857QString Addressee::name() const
810{ 858{
811 return mData->name; 859 return mData->name;
812} 860}
813 861
814QString Addressee::nameLabel() 862QString Addressee::nameLabel()
815{ 863{
816 return i18n("Name"); 864 return i18n("Name");
817} 865}
818 866
819 867
820void Addressee::setFormattedName( const QString &formattedName ) 868void Addressee::setFormattedName( const QString &formattedName )
821{ 869{
822 if ( formattedName == mData->formattedName ) return; 870 if ( formattedName == mData->formattedName ) return;
823 detach(); 871 detach();
824 mData->empty = false; 872 mData->empty = false;
825 mData->formattedName = formattedName; 873 mData->formattedName = formattedName;
826} 874}
827 875
828QString Addressee::formattedName() const 876QString Addressee::formattedName() const
829{ 877{
830 return mData->formattedName; 878 return mData->formattedName;
831} 879}
832 880
833QString Addressee::formattedNameLabel() 881QString Addressee::formattedNameLabel()
834{ 882{
835 return i18n("Formatted Name"); 883 return i18n("Formatted Name");
836} 884}
837 885
838 886
839void Addressee::setFamilyName( const QString &familyName ) 887void Addressee::setFamilyName( const QString &familyName )
840{ 888{
841 if ( familyName == mData->familyName ) return; 889 if ( familyName == mData->familyName ) return;
842 detach(); 890 detach();
843 mData->empty = false; 891 mData->empty = false;
844 mData->familyName = familyName; 892 mData->familyName = familyName;
845} 893}
846 894
847QString Addressee::familyName() const 895QString Addressee::familyName() const
848{ 896{
849 return mData->familyName; 897 return mData->familyName;
850} 898}
851 899
852QString Addressee::familyNameLabel() 900QString Addressee::familyNameLabel()
853{ 901{
854 return i18n("Family Name"); 902 return i18n("Family Name");
855} 903}
856 904
857 905
858void Addressee::setGivenName( const QString &givenName ) 906void Addressee::setGivenName( const QString &givenName )
859{ 907{
860 if ( givenName == mData->givenName ) return; 908 if ( givenName == mData->givenName ) return;
861 detach(); 909 detach();
862 mData->empty = false; 910 mData->empty = false;
863 mData->givenName = givenName; 911 mData->givenName = givenName;
864} 912}
865 913
866QString Addressee::givenName() const 914QString Addressee::givenName() const
867{ 915{
868 return mData->givenName; 916 return mData->givenName;
869} 917}
870 918
871QString Addressee::givenNameLabel() 919QString Addressee::givenNameLabel()
872{ 920{
873 return i18n("Given Name"); 921 return i18n("Given Name");
874} 922}
875 923
876 924
877void Addressee::setAdditionalName( const QString &additionalName ) 925void Addressee::setAdditionalName( const QString &additionalName )
878{ 926{
879 if ( additionalName == mData->additionalName ) return; 927 if ( additionalName == mData->additionalName ) return;
880 detach(); 928 detach();
881 mData->empty = false; 929 mData->empty = false;
882 mData->additionalName = additionalName; 930 mData->additionalName = additionalName;
883} 931}
884 932
885QString Addressee::additionalName() const 933QString Addressee::additionalName() const
886{ 934{
887 return mData->additionalName; 935 return mData->additionalName;
888} 936}
889 937
890QString Addressee::additionalNameLabel() 938QString Addressee::additionalNameLabel()
891{ 939{
892 return i18n("Additional Names"); 940 return i18n("Additional Names");
893} 941}
894 942
895 943
896void Addressee::setPrefix( const QString &prefix ) 944void Addressee::setPrefix( const QString &prefix )
897{ 945{
898 if ( prefix == mData->prefix ) return; 946 if ( prefix == mData->prefix ) return;
899 detach(); 947 detach();
900 mData->empty = false; 948 mData->empty = false;
901 mData->prefix = prefix; 949 mData->prefix = prefix;
902} 950}
903 951
904QString Addressee::prefix() const 952QString Addressee::prefix() const
905{ 953{
906 return mData->prefix; 954 return mData->prefix;
907} 955}
908 956
909QString Addressee::prefixLabel() 957QString Addressee::prefixLabel()
910{ 958{
911 return i18n("Honorific Prefixes"); 959 return i18n("Honorific Prefixes");
912} 960}
913 961
914 962
915void Addressee::setSuffix( const QString &suffix ) 963void Addressee::setSuffix( const QString &suffix )
916{ 964{
917 if ( suffix == mData->suffix ) return; 965 if ( suffix == mData->suffix ) return;
918 detach(); 966 detach();
919 mData->empty = false; 967 mData->empty = false;
920 mData->suffix = suffix; 968 mData->suffix = suffix;
921} 969}
922 970
923QString Addressee::suffix() const 971QString Addressee::suffix() const
924{ 972{
925 return mData->suffix; 973 return mData->suffix;
926} 974}
927 975
928QString Addressee::suffixLabel() 976QString Addressee::suffixLabel()
929{ 977{
930 return i18n("Honorific Suffixes"); 978 return i18n("Honorific Suffixes");
931} 979}
932 980
933 981
934void Addressee::setNickName( const QString &nickName ) 982void Addressee::setNickName( const QString &nickName )
935{ 983{
936 if ( nickName == mData->nickName ) return; 984 if ( nickName == mData->nickName ) return;
937 detach(); 985 detach();
938 mData->empty = false; 986 mData->empty = false;
939 mData->nickName = nickName; 987 mData->nickName = nickName;
940} 988}
941 989
942QString Addressee::nickName() const 990QString Addressee::nickName() const
943{ 991{
944 return mData->nickName; 992 return mData->nickName;
945} 993}
946 994
947QString Addressee::nickNameLabel() 995QString Addressee::nickNameLabel()
948{ 996{
949 return i18n("Nick Name"); 997 return i18n("Nick Name");
950} 998}
951 999
952 1000
953void Addressee::setBirthday( const QDateTime &birthday ) 1001void Addressee::setBirthday( const QDateTime &birthday )
954{ 1002{
955 if ( birthday == mData->birthday ) return; 1003 if ( birthday == mData->birthday ) return;
956 detach(); 1004 detach();
957 mData->empty = false; 1005 mData->empty = false;
958 mData->birthday = birthday; 1006 mData->birthday = birthday;
959} 1007}
960 1008
961QDateTime Addressee::birthday() const 1009QDateTime Addressee::birthday() const
962{ 1010{
963 return mData->birthday; 1011 return mData->birthday;
964} 1012}
965 1013
966QString Addressee::birthdayLabel() 1014QString Addressee::birthdayLabel()
967{ 1015{
968 return i18n("Birthday"); 1016 return i18n("Birthday");
969} 1017}
970 1018
971 1019
972QString Addressee::homeAddressStreetLabel() 1020QString Addressee::homeAddressStreetLabel()
973{ 1021{
974 return i18n("Home Address Street"); 1022 return i18n("Home Address Street");
975} 1023}
976 1024
977 1025
978QString Addressee::homeAddressLocalityLabel() 1026QString Addressee::homeAddressLocalityLabel()
979{ 1027{
980 return i18n("Home Address Locality"); 1028 return i18n("Home Address Locality");
981} 1029}
982 1030
983 1031
984QString Addressee::homeAddressRegionLabel() 1032QString Addressee::homeAddressRegionLabel()
985{ 1033{
986 return i18n("Home Address Region"); 1034 return i18n("Home Address Region");
987} 1035}
988 1036
989 1037
990QString Addressee::homeAddressPostalCodeLabel() 1038QString Addressee::homeAddressPostalCodeLabel()
991{ 1039{
992 return i18n("Home Address Postal Code"); 1040 return i18n("Home Address Postal Code");
993} 1041}
994 1042
995 1043
996QString Addressee::homeAddressCountryLabel() 1044QString Addressee::homeAddressCountryLabel()
997{ 1045{
998 return i18n("Home Address Country"); 1046 return i18n("Home Address Country");
999} 1047}
1000 1048
1001 1049
1002QString Addressee::homeAddressLabelLabel() 1050QString Addressee::homeAddressLabelLabel()
1003{ 1051{
1004 return i18n("Home Address Label"); 1052 return i18n("Home Address Label");
1005} 1053}
1006 1054
1007 1055
1008QString Addressee::businessAddressStreetLabel() 1056QString Addressee::businessAddressStreetLabel()
1009{ 1057{
1010 return i18n("Business Address Street"); 1058 return i18n("Business Address Street");
1011} 1059}
1012 1060
1013 1061
1014QString Addressee::businessAddressLocalityLabel() 1062QString Addressee::businessAddressLocalityLabel()
1015{ 1063{
1016 return i18n("Business Address Locality"); 1064 return i18n("Business Address Locality");
1017} 1065}
1018 1066
1019 1067
1020QString Addressee::businessAddressRegionLabel() 1068QString Addressee::businessAddressRegionLabel()
1021{ 1069{
1022 return i18n("Business Address Region"); 1070 return i18n("Business Address Region");
1023} 1071}
1024 1072
1025 1073
1026QString Addressee::businessAddressPostalCodeLabel() 1074QString Addressee::businessAddressPostalCodeLabel()
1027{ 1075{
1028 return i18n("Business Address Postal Code"); 1076 return i18n("Business Address Postal Code");
1029} 1077}
1030 1078
1031 1079
1032QString Addressee::businessAddressCountryLabel() 1080QString Addressee::businessAddressCountryLabel()
1033{ 1081{
1034 return i18n("Business Address Country"); 1082 return i18n("Business Address Country");
1035} 1083}
1036 1084
1037 1085
1038QString Addressee::businessAddressLabelLabel() 1086QString Addressee::businessAddressLabelLabel()
1039{ 1087{
1040 return i18n("Business Address Label"); 1088 return i18n("Business Address Label");
1041} 1089}
1042 1090
1043 1091
1044QString Addressee::homePhoneLabel() 1092QString Addressee::homePhoneLabel()
1045{ 1093{
1046 return i18n("Home Phone"); 1094 return i18n("Home Phone");
1047} 1095}
1048 1096
1049 1097
1050QString Addressee::businessPhoneLabel() 1098QString Addressee::businessPhoneLabel()
1051{ 1099{
1052 return i18n("Work Phone"); 1100 return i18n("Work Phone");
1053} 1101}
1054 1102
1055 1103
1056QString Addressee::mobilePhoneLabel() 1104QString Addressee::mobilePhoneLabel()
1057{ 1105{
1058 return i18n("Mobile"); 1106 return i18n("Mobile");
1059} 1107}
1060QString Addressee::mobileWorkPhoneLabel() 1108QString Addressee::mobileWorkPhoneLabel()
1061{ 1109{
1062 return i18n("Mobile2"); 1110 return i18n("Mobile2");
1063} 1111}
1064 1112
1065 1113
1066QString Addressee::homeFaxLabel() 1114QString Addressee::homeFaxLabel()
1067{ 1115{
1068 return i18n("Fax (Home)"); 1116 return i18n("Fax (Home)");
1069} 1117}
1070 1118
1071 1119
1072QString Addressee::businessFaxLabel() 1120QString Addressee::businessFaxLabel()
1073{ 1121{
1074 return i18n("Fax (Work)"); 1122 return i18n("Fax (Work)");
1075} 1123}
1076 1124
1077 1125
1078QString Addressee::isdnLabel() 1126QString Addressee::isdnLabel()
1079{ 1127{
1080 return i18n("ISDN"); 1128 return i18n("ISDN");
1081} 1129}
1082 1130
1083 1131
1084QString Addressee::pagerLabel() 1132QString Addressee::pagerLabel()
1085{ 1133{
1086 return i18n("Pager"); 1134 return i18n("Pager");
1087} 1135}
1088QString Addressee::otherPhoneLabel() 1136QString Addressee::otherPhoneLabel()
1089{ 1137{
1090 return i18n("Other Phone"); 1138 return i18n("Other Phone");
1091} 1139}
1092 1140
1093QString Addressee::sipLabel() 1141QString Addressee::sipLabel()
1094{ 1142{
1095 return i18n("SiP"); 1143 return i18n("SiP");
1096} 1144}
1097 1145
1098QString Addressee::emailLabel() 1146QString Addressee::emailLabel()
1099{ 1147{
1100 return i18n("Email Address"); 1148 return i18n("Email Address");
1101} 1149}
1102 1150
1103 1151
1104void Addressee::setMailer( const QString &mailer ) 1152void Addressee::setMailer( const QString &mailer )
1105{ 1153{
1106 if ( mailer == mData->mailer ) return; 1154 if ( mailer == mData->mailer ) return;
1107 detach(); 1155 detach();
1108 mData->empty = false; 1156 mData->empty = false;
1109 mData->mailer = mailer; 1157 mData->mailer = mailer;
1110} 1158}
1111 1159
1112QString Addressee::mailer() const 1160QString Addressee::mailer() const
1113{ 1161{
1114 return mData->mailer; 1162 return mData->mailer;
1115} 1163}
1116 1164
1117QString Addressee::mailerLabel() 1165QString Addressee::mailerLabel()
1118{ 1166{
1119 return i18n("Mail Client"); 1167 return i18n("Mail Client");
1120} 1168}
1121 1169
1122 1170
1123void Addressee::setTimeZone( const TimeZone &timeZone ) 1171void Addressee::setTimeZone( const TimeZone &timeZone )
1124{ 1172{
1125 if ( timeZone == mData->timeZone ) return; 1173 if ( timeZone == mData->timeZone ) return;
1126 detach(); 1174 detach();
1127 mData->empty = false; 1175 mData->empty = false;
1128 mData->timeZone = timeZone; 1176 mData->timeZone = timeZone;
1129} 1177}
1130 1178
1131TimeZone Addressee::timeZone() const 1179TimeZone Addressee::timeZone() const
1132{ 1180{
1133 return mData->timeZone; 1181 return mData->timeZone;
1134} 1182}
1135 1183
1136QString Addressee::timeZoneLabel() 1184QString Addressee::timeZoneLabel()
1137{ 1185{
1138 return i18n("Time Zone"); 1186 return i18n("Time Zone");
1139} 1187}
1140 1188
1141 1189
1142void Addressee::setGeo( const Geo &geo ) 1190void Addressee::setGeo( const Geo &geo )
1143{ 1191{
1144 if ( geo == mData->geo ) return; 1192 if ( geo == mData->geo ) return;
1145 detach(); 1193 detach();
1146 mData->empty = false; 1194 mData->empty = false;
1147 mData->geo = geo; 1195 mData->geo = geo;
1148} 1196}
1149 1197
1150Geo Addressee::geo() const 1198Geo Addressee::geo() const
1151{ 1199{
1152 return mData->geo; 1200 return mData->geo;
1153} 1201}
1154 1202
1155QString Addressee::geoLabel() 1203QString Addressee::geoLabel()
1156{ 1204{
1157 return i18n("Geographic Position"); 1205 return i18n("Geographic Position");
1158} 1206}
1159 1207
1160 1208
1161void Addressee::setTitle( const QString &title ) 1209void Addressee::setTitle( const QString &title )
1162{ 1210{
1163 if ( title == mData->title ) return; 1211 if ( title == mData->title ) return;
1164 detach(); 1212 detach();
1165 mData->empty = false; 1213 mData->empty = false;
1166 mData->title = title; 1214 mData->title = title;
1167} 1215}
1168 1216
1169QString Addressee::title() const 1217QString Addressee::title() const
1170{ 1218{
1171 return mData->title; 1219 return mData->title;
1172} 1220}
1173 1221
1174QString Addressee::titleLabel() 1222QString Addressee::titleLabel()
1175{ 1223{
1176 return i18n("Title"); 1224 return i18n("Title");
1177} 1225}
1178 1226
1179 1227
1180void Addressee::setRole( const QString &role ) 1228void Addressee::setRole( const QString &role )
1181{ 1229{
1182 if ( role == mData->role ) return; 1230 if ( role == mData->role ) return;
1183 detach(); 1231 detach();
1184 mData->empty = false; 1232 mData->empty = false;
1185 mData->role = role; 1233 mData->role = role;
1186} 1234}
1187 1235
1188QString Addressee::role() const 1236QString Addressee::role() const
1189{ 1237{
1190 return mData->role; 1238 return mData->role;
1191} 1239}
1192 1240
1193QString Addressee::roleLabel() 1241QString Addressee::roleLabel()
1194{ 1242{
1195 return i18n("Role"); 1243 return i18n("Role");
1196} 1244}
1197 1245
1198 1246
1199void Addressee::setOrganization( const QString &organization ) 1247void Addressee::setOrganization( const QString &organization )
1200{ 1248{
1201 if ( organization == mData->organization ) return; 1249 if ( organization == mData->organization ) return;
1202 detach(); 1250 detach();
1203 mData->empty = false; 1251 mData->empty = false;
1204 mData->organization = organization; 1252 mData->organization = organization;
1205} 1253}
1206 1254
1207QString Addressee::organization() const 1255QString Addressee::organization() const
1208{ 1256{
1209 return mData->organization; 1257 return mData->organization;
1210} 1258}
1211 1259
1212QString Addressee::organizationLabel() 1260QString Addressee::organizationLabel()
1213{ 1261{
1214 return i18n("Organization"); 1262 return i18n("Organization");
1215} 1263}
1216 1264
1217 1265
1218void Addressee::setNote( const QString &note ) 1266void Addressee::setNote( const QString &note )
1219{ 1267{
1220 if ( note == mData->note ) return; 1268 if ( note == mData->note ) return;
1221 detach(); 1269 detach();
1222 mData->empty = false; 1270 mData->empty = false;
1223 mData->note = note; 1271 mData->note = note;
1224} 1272}
1225 1273
1226QString Addressee::note() const 1274QString Addressee::note() const
1227{ 1275{
1228 return mData->note; 1276 return mData->note;
1229} 1277}
1230 1278
1231QString Addressee::noteLabel() 1279QString Addressee::noteLabel()
1232{ 1280{
1233 return i18n("Note"); 1281 return i18n("Note");
1234} 1282}
1235 1283
1236 1284
1237void Addressee::setProductId( const QString &productId ) 1285void Addressee::setProductId( const QString &productId )
1238{ 1286{
1239 if ( productId == mData->productId ) return; 1287 if ( productId == mData->productId ) return;
1240 detach(); 1288 detach();
1241 mData->empty = false; 1289 mData->empty = false;
1242 mData->productId = productId; 1290 mData->productId = productId;
1243} 1291}
1244 1292
1245QString Addressee::productId() const 1293QString Addressee::productId() const
1246{ 1294{
1247 return mData->productId; 1295 return mData->productId;
1248} 1296}
1249 1297
1250QString Addressee::productIdLabel() 1298QString Addressee::productIdLabel()
1251{ 1299{
1252 return i18n("Product Identifier"); 1300 return i18n("Product Identifier");
1253} 1301}
1254 1302
1255 1303
1256void Addressee::setRevision( const QDateTime &revision ) 1304void Addressee::setRevision( const QDateTime &revision )
1257{ 1305{
1258 if ( revision == mData->revision ) return; 1306 if ( revision == mData->revision ) return;
1259 detach(); 1307 detach();
1260 mData->empty = false; 1308 mData->empty = false;
1261 mData->revision = QDateTime( revision.date(), 1309 mData->revision = QDateTime( revision.date(),
1262 QTime (revision.time().hour(), 1310 QTime (revision.time().hour(),
1263 revision.time().minute(), 1311 revision.time().minute(),
1264 revision.time().second())); 1312 revision.time().second()));
1265} 1313}
1266 1314
1267QDateTime Addressee::revision() const 1315QDateTime Addressee::revision() const
1268{ 1316{
1269 return mData->revision; 1317 return mData->revision;
1270} 1318}
1271 1319
1272QString Addressee::revisionLabel() 1320QString Addressee::revisionLabel()
1273{ 1321{
1274 return i18n("Revision Date"); 1322 return i18n("Revision Date");
1275} 1323}
1276 1324
1277 1325
1278void Addressee::setSortString( const QString &sortString ) 1326void Addressee::setSortString( const QString &sortString )
1279{ 1327{
1280 if ( sortString == mData->sortString ) return; 1328 if ( sortString == mData->sortString ) return;
1281 detach(); 1329 detach();
1282 mData->empty = false; 1330 mData->empty = false;
1283 mData->sortString = sortString; 1331 mData->sortString = sortString;
1284} 1332}
1285 1333
1286QString Addressee::sortString() const 1334QString Addressee::sortString() const
1287{ 1335{
1288 return mData->sortString; 1336 return mData->sortString;
1289} 1337}
1290 1338
1291QString Addressee::sortStringLabel() 1339QString Addressee::sortStringLabel()
1292{ 1340{
1293 return i18n("Sort String"); 1341 return i18n("Sort String");
1294} 1342}
1295 1343
1296 1344
1297void Addressee::setUrl( const KURL &url ) 1345void Addressee::setUrl( const KURL &url )
1298{ 1346{
1299 if ( url == mData->url ) return; 1347 if ( url == mData->url ) return;
1300 detach(); 1348 detach();
1301 mData->empty = false; 1349 mData->empty = false;
1302 mData->url = url; 1350 mData->url = url;
1303} 1351}
1304 1352
1305KURL Addressee::url() const 1353KURL Addressee::url() const
1306{ 1354{
1307 return mData->url; 1355 return mData->url;
1308} 1356}
1309 1357
1310QString Addressee::urlLabel() 1358QString Addressee::urlLabel()
1311{ 1359{
1312 return i18n("URL"); 1360 return i18n("URL");
1313} 1361}
1314 1362
1315 1363
1316void Addressee::setSecrecy( const Secrecy &secrecy ) 1364void Addressee::setSecrecy( const Secrecy &secrecy )
1317{ 1365{
1318 if ( secrecy == mData->secrecy ) return; 1366 if ( secrecy == mData->secrecy ) return;
1319 detach(); 1367 detach();
1320 mData->empty = false; 1368 mData->empty = false;
1321 mData->secrecy = secrecy; 1369 mData->secrecy = secrecy;
1322} 1370}
1323 1371
1324Secrecy Addressee::secrecy() const 1372Secrecy Addressee::secrecy() const
1325{ 1373{
1326 return mData->secrecy; 1374 return mData->secrecy;
1327} 1375}
1328 1376
1329QString Addressee::secrecyLabel() 1377QString Addressee::secrecyLabel()
1330{ 1378{
1331 return i18n("Security Class"); 1379 return i18n("Security Class");
1332} 1380}
1333 1381
1334 1382
1335void Addressee::setLogo( const Picture &logo ) 1383void Addressee::setLogo( const Picture &logo )
1336{ 1384{
1337 if ( logo == mData->logo ) return; 1385 if ( logo == mData->logo ) return;
1338 detach(); 1386 detach();
1339 mData->empty = false; 1387 mData->empty = false;
1340 mData->logo = logo; 1388 mData->logo = logo;
1341} 1389}
1342 1390
1343Picture Addressee::logo() const 1391Picture Addressee::logo() const
1344{ 1392{
1345 return mData->logo; 1393 return mData->logo;
1346} 1394}
1347 1395
1348QString Addressee::logoLabel() 1396QString Addressee::logoLabel()
1349{ 1397{
1350 return i18n("Logo"); 1398 return i18n("Logo");
1351} 1399}
1352 1400
1353 1401
1354void Addressee::setPhoto( const Picture &photo ) 1402void Addressee::setPhoto( const Picture &photo )
1355{ 1403{
1356 if ( photo == mData->photo ) return; 1404 if ( photo == mData->photo ) return;
1357 detach(); 1405 detach();
1358 mData->empty = false; 1406 mData->empty = false;
1359 mData->photo = photo; 1407 mData->photo = photo;
1360} 1408}
1361 1409
1362Picture Addressee::photo() const 1410Picture Addressee::photo() const
1363{ 1411{
1364 return mData->photo; 1412 return mData->photo;
1365} 1413}
1366 1414
1367QString Addressee::photoLabel() 1415QString Addressee::photoLabel()
1368{ 1416{
1369 return i18n("Photo"); 1417 return i18n("Photo");
1370} 1418}
1371 1419
1372 1420
1373void Addressee::setSound( const Sound &sound ) 1421void Addressee::setSound( const Sound &sound )
1374{ 1422{
1375 if ( sound == mData->sound ) return; 1423 if ( sound == mData->sound ) return;
1376 detach(); 1424 detach();
1377 mData->empty = false; 1425 mData->empty = false;
1378 mData->sound = sound; 1426 mData->sound = sound;
1379} 1427}
1380 1428
1381Sound Addressee::sound() const 1429Sound Addressee::sound() const
1382{ 1430{
1383 return mData->sound; 1431 return mData->sound;
1384} 1432}
1385 1433
1386QString Addressee::soundLabel() 1434QString Addressee::soundLabel()
1387{ 1435{
1388 return i18n("Sound"); 1436 return i18n("Sound");
1389} 1437}
1390 1438
1391 1439
1392void Addressee::setAgent( const Agent &agent ) 1440void Addressee::setAgent( const Agent &agent )
1393{ 1441{
1394 if ( agent == mData->agent ) return; 1442 if ( agent == mData->agent ) return;
1395 detach(); 1443 detach();
1396 mData->empty = false; 1444 mData->empty = false;
1397 mData->agent = agent; 1445 mData->agent = agent;
1398} 1446}
1399 1447
1400Agent Addressee::agent() const 1448Agent Addressee::agent() const
1401{ 1449{
1402 return mData->agent; 1450 return mData->agent;
1403} 1451}
1404 1452
1405QString Addressee::agentLabel() 1453QString Addressee::agentLabel()
1406{ 1454{
1407 return i18n("Agent"); 1455 return i18n("Agent");
1408} 1456}
1409 1457
1410 1458
1411 1459
1412void Addressee::setNameFromString( const QString &str ) 1460void Addressee::setNameFromString( const QString &str )
1413{ 1461{
1414 setFormattedName( str ); 1462 setFormattedName( str );
1415 setName( str ); 1463 setName( str );
1416 1464
1417 static bool first = true; 1465 static bool first = true;
1418 static QStringList titles; 1466 static QStringList titles;
1419 static QStringList suffixes; 1467 static QStringList suffixes;
1420 static QStringList prefixes; 1468 static QStringList prefixes;
1421 1469
1422 if ( first ) { 1470 if ( first ) {
1423 first = false; 1471 first = false;
1424 titles += i18n( "Dr." ); 1472 titles += i18n( "Dr." );
1425 titles += i18n( "Miss" ); 1473 titles += i18n( "Miss" );
1426 titles += i18n( "Mr." ); 1474 titles += i18n( "Mr." );
1427 titles += i18n( "Mrs." ); 1475 titles += i18n( "Mrs." );
1428 titles += i18n( "Ms." ); 1476 titles += i18n( "Ms." );
1429 titles += i18n( "Prof." ); 1477 titles += i18n( "Prof." );
1430 1478
1431 suffixes += i18n( "I" ); 1479 suffixes += i18n( "I" );
1432 suffixes += i18n( "II" ); 1480 suffixes += i18n( "II" );
1433 suffixes += i18n( "III" ); 1481 suffixes += i18n( "III" );
1434 suffixes += i18n( "Jr." ); 1482 suffixes += i18n( "Jr." );
1435 suffixes += i18n( "Sr." ); 1483 suffixes += i18n( "Sr." );
1436 1484
1437 prefixes += "van"; 1485 prefixes += "van";
1438 prefixes += "von"; 1486 prefixes += "von";
1439 prefixes += "de"; 1487 prefixes += "de";
1440 1488
1441 KConfig config( locateLocal( "config", "kabcrc") ); 1489 KConfig config( locateLocal( "config", "kabcrc") );
1442 config.setGroup( "General" ); 1490 config.setGroup( "General" );
1443 titles += config.readListEntry( "Prefixes" ); 1491 titles += config.readListEntry( "Prefixes" );
1444 titles.remove( "" ); 1492 titles.remove( "" );
1445 prefixes += config.readListEntry( "Inclusions" ); 1493 prefixes += config.readListEntry( "Inclusions" );
1446 prefixes.remove( "" ); 1494 prefixes.remove( "" );
1447 suffixes += config.readListEntry( "Suffixes" ); 1495 suffixes += config.readListEntry( "Suffixes" );
1448 suffixes.remove( "" ); 1496 suffixes.remove( "" );
1449 } 1497 }
1450 1498
1451 // clear all name parts 1499 // clear all name parts
1452 setPrefix( "" ); 1500 setPrefix( "" );
1453 setGivenName( "" ); 1501 setGivenName( "" );
1454 setAdditionalName( "" ); 1502 setAdditionalName( "" );
1455 setFamilyName( "" ); 1503 setFamilyName( "" );
1456 setSuffix( "" ); 1504 setSuffix( "" );
1457 1505
1458 if ( str.isEmpty() ) 1506 if ( str.isEmpty() )
1459 return; 1507 return;
1460 1508
1461 int i = str.find(','); 1509 int i = str.find(',');
1462 if( i < 0 ) { 1510 if( i < 0 ) {
1463 QStringList parts = QStringList::split( " ", str ); 1511 QStringList parts = QStringList::split( " ", str );
1464 int leftOffset = 0; 1512 int leftOffset = 0;
1465 int rightOffset = parts.count() - 1; 1513 int rightOffset = parts.count() - 1;
1466 1514
1467 QString suffix; 1515 QString suffix;
1468 while ( rightOffset >= 0 ) { 1516 while ( rightOffset >= 0 ) {
1469 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1517 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1470 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1518 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1471 rightOffset--; 1519 rightOffset--;
1472 } else 1520 } else
1473 break; 1521 break;
1474 } 1522 }
1475 setSuffix( suffix ); 1523 setSuffix( suffix );
1476 1524
1477 if ( rightOffset < 0 ) 1525 if ( rightOffset < 0 )
1478 return; 1526 return;
1479 1527
1480 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1528 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1481 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1529 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1482 rightOffset--; 1530 rightOffset--;
1483 } else 1531 } else
1484 setFamilyName( parts[ rightOffset ] ); 1532 setFamilyName( parts[ rightOffset ] );
1485 1533
1486 QString prefix; 1534 QString prefix;
1487 while ( leftOffset < rightOffset ) { 1535 while ( leftOffset < rightOffset ) {
1488 if ( titles.contains( parts[ leftOffset ] ) ) { 1536 if ( titles.contains( parts[ leftOffset ] ) ) {
1489 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1537 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1490 leftOffset++; 1538 leftOffset++;
1491 } else 1539 } else
1492 break; 1540 break;
1493 } 1541 }
1494 setPrefix( prefix ); 1542 setPrefix( prefix );
1495 1543
1496 if ( leftOffset < rightOffset ) { 1544 if ( leftOffset < rightOffset ) {
1497 setGivenName( parts[ leftOffset ] ); 1545 setGivenName( parts[ leftOffset ] );
1498 leftOffset++; 1546 leftOffset++;
1499 } 1547 }
1500 1548
1501 QString additionalName; 1549 QString additionalName;
1502 while ( leftOffset < rightOffset ) { 1550 while ( leftOffset < rightOffset ) {
1503 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1551 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1504 leftOffset++; 1552 leftOffset++;
1505 } 1553 }
1506 setAdditionalName( additionalName ); 1554 setAdditionalName( additionalName );
1507 } else { 1555 } else {
1508 QString part1 = str.left( i ); 1556 QString part1 = str.left( i );
1509 QString part2 = str.mid( i + 1 ); 1557 QString part2 = str.mid( i + 1 );
1510 1558
1511 QStringList parts = QStringList::split( " ", part1 ); 1559 QStringList parts = QStringList::split( " ", part1 );
1512 int leftOffset = 0; 1560 int leftOffset = 0;
1513 int rightOffset = parts.count() - 1; 1561 int rightOffset = parts.count() - 1;
1514 1562
1515 QString suffix; 1563 QString suffix;
1516 while ( rightOffset >= 0 ) { 1564 while ( rightOffset >= 0 ) {
1517 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1565 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1518 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1566 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1519 rightOffset--; 1567 rightOffset--;
1520 } else 1568 } else
1521 break; 1569 break;
1522 } 1570 }
1523 setSuffix( suffix ); 1571 setSuffix( suffix );
1524 1572
1525 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1573 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1526 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1574 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1527 rightOffset--; 1575 rightOffset--;
1528 } else 1576 } else
1529 setFamilyName( parts[ rightOffset ] ); 1577 setFamilyName( parts[ rightOffset ] );
1530 1578
1531 QString prefix; 1579 QString prefix;
1532 while ( leftOffset < rightOffset ) { 1580 while ( leftOffset < rightOffset ) {
1533 if ( titles.contains( parts[ leftOffset ] ) ) { 1581 if ( titles.contains( parts[ leftOffset ] ) ) {
1534 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1582 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1535 leftOffset++; 1583 leftOffset++;
1536 } else 1584 } else
1537 break; 1585 break;
1538 } 1586 }
1539 1587
1540 parts = QStringList::split( " ", part2 ); 1588 parts = QStringList::split( " ", part2 );
1541 1589
1542 leftOffset = 0; 1590 leftOffset = 0;
1543 rightOffset = parts.count(); 1591 rightOffset = parts.count();
1544 1592
1545 while ( leftOffset < rightOffset ) { 1593 while ( leftOffset < rightOffset ) {
1546 if ( titles.contains( parts[ leftOffset ] ) ) { 1594 if ( titles.contains( parts[ leftOffset ] ) ) {
1547 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1595 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1548 leftOffset++; 1596 leftOffset++;
1549 } else 1597 } else
1550 break; 1598 break;
1551 } 1599 }
1552 setPrefix( prefix ); 1600 setPrefix( prefix );
1553 1601
1554 if ( leftOffset < rightOffset ) { 1602 if ( leftOffset < rightOffset ) {
1555 setGivenName( parts[ leftOffset ] ); 1603 setGivenName( parts[ leftOffset ] );
1556 leftOffset++; 1604 leftOffset++;
1557 } 1605 }
1558 1606
1559 QString additionalName; 1607 QString additionalName;
1560 while ( leftOffset < rightOffset ) { 1608 while ( leftOffset < rightOffset ) {
1561 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1609 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1562 leftOffset++; 1610 leftOffset++;
1563 } 1611 }
1564 setAdditionalName( additionalName ); 1612 setAdditionalName( additionalName );
1565 } 1613 }
1566} 1614}
1567 1615
1568QString Addressee::realName() const 1616QString Addressee::realName() const
1569{ 1617{
1570 if ( !formattedName().isEmpty() ) 1618 if ( !formattedName().isEmpty() )
1571 return formattedName(); 1619 return formattedName();
1572 1620
1573 QString n = assembledName(); 1621 QString n = assembledName();
1574 1622
1575 if ( n.isEmpty() ) 1623 if ( n.isEmpty() )
1576 n = name(); 1624 n = name();
1577 if ( n.isEmpty() ) 1625 if ( n.isEmpty() )
1578 n = organization(); 1626 n = organization();
1579 return n; 1627 return n;
1580} 1628}
1581 1629
1582QString Addressee::assembledName() const 1630QString Addressee::assembledName() const
1583{ 1631{
1584 QString name = prefix() + " " + givenName() + " " + additionalName() + " " + 1632 QString name = prefix() + " " + givenName() + " " + additionalName() + " " +
1585 familyName() + " " + suffix(); 1633 familyName() + " " + suffix();
1586 1634
1587 return name.simplifyWhiteSpace(); 1635 return name.simplifyWhiteSpace();
1588} 1636}
1589 1637
1590QString Addressee::fullEmail( const QString &email ) const 1638QString Addressee::fullEmail( const QString &email ) const
1591{ 1639{
1592 QString e; 1640 QString e;
1593 if ( email.isNull() ) { 1641 if ( email.isNull() ) {
1594 e = preferredEmail(); 1642 e = preferredEmail();
1595 } else { 1643 } else {
1596 e = email; 1644 e = email;
1597 } 1645 }
1598 if ( e.isEmpty() ) return QString::null; 1646 if ( e.isEmpty() ) return QString::null;
1599 1647
1600 QString text; 1648 QString text;
1601 if ( realName().isEmpty() ) 1649 if ( realName().isEmpty() )
1602 text = e; 1650 text = e;
1603 else 1651 else
1604 text = assembledName() + " <" + e + ">"; 1652 text = assembledName() + " <" + e + ">";
1605 1653
1606 return text; 1654 return text;
1607} 1655}
1608 1656
1609void Addressee::insertEmail( const QString &email, bool preferred ) 1657void Addressee::insertEmail( const QString &email, bool preferred )
1610{ 1658{
1611 detach(); 1659 detach();
1612 1660
1613 QStringList::Iterator it = mData->emails.find( email ); 1661 QStringList::Iterator it = mData->emails.find( email );
1614 1662
1615 if ( it != mData->emails.end() ) { 1663 if ( it != mData->emails.end() ) {
1616 if ( !preferred || it == mData->emails.begin() ) return; 1664 if ( !preferred || it == mData->emails.begin() ) return;
1617 mData->emails.remove( it ); 1665 mData->emails.remove( it );
1618 mData->emails.prepend( email ); 1666 mData->emails.prepend( email );
1619 } else { 1667 } else {
1620 if ( preferred ) { 1668 if ( preferred ) {
1621 mData->emails.prepend( email ); 1669 mData->emails.prepend( email );
1622 } else { 1670 } else {
1623 mData->emails.append( email ); 1671 mData->emails.append( email );
1624 } 1672 }
1625 } 1673 }
1626} 1674}
1627 1675
1628void Addressee::removeEmail( const QString &email ) 1676void Addressee::removeEmail( const QString &email )
1629{ 1677{
1630 detach(); 1678 detach();
1631 1679
1632 QStringList::Iterator it = mData->emails.find( email ); 1680 QStringList::Iterator it = mData->emails.find( email );
1633 if ( it == mData->emails.end() ) return; 1681 if ( it == mData->emails.end() ) return;
1634 1682
1635 mData->emails.remove( it ); 1683 mData->emails.remove( it );
1636} 1684}
1637 1685
1638QString Addressee::preferredEmail() const 1686QString Addressee::preferredEmail() const
1639{ 1687{
1640 if ( mData->emails.count() == 0 ) return QString::null; 1688 if ( mData->emails.count() == 0 ) return QString::null;
1641 else return mData->emails.first(); 1689 else return mData->emails.first();
1642} 1690}
1643 1691
1644QStringList Addressee::emails() const 1692QStringList Addressee::emails() const
1645{ 1693{
1646 return mData->emails; 1694 return mData->emails;
1647} 1695}
1648void Addressee::setEmails( const QStringList& emails ) { 1696void Addressee::setEmails( const QStringList& emails ) {
1649 detach(); 1697 detach();
1650 mData->emails = emails; 1698 mData->emails = emails;
1651} 1699}
1652void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) 1700void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
1653{ 1701{
1654 detach(); 1702 detach();
1655 mData->empty = false; 1703 mData->empty = false;
1656
1657 PhoneNumber::List::Iterator it; 1704 PhoneNumber::List::Iterator it;
1658 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1705 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1659 if ( (*it).id() == phoneNumber.id() ) { 1706 if ( (*it).id() == phoneNumber.id() ) {
1660 *it = phoneNumber; 1707 *it = phoneNumber;
1661 return; 1708 return;
1662 } 1709 }
1663 } 1710 }
1664 mData->phoneNumbers.append( phoneNumber ); 1711 mData->phoneNumbers.append( phoneNumber );
1665} 1712}
1666 1713
1667void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) 1714void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
1668{ 1715{
1669 detach(); 1716 detach();
1670 1717
1671 PhoneNumber::List::Iterator it; 1718 PhoneNumber::List::Iterator it;
1672 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1719 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1673 if ( (*it).id() == phoneNumber.id() ) { 1720 if ( (*it).id() == phoneNumber.id() ) {
1674 mData->phoneNumbers.remove( it ); 1721 mData->phoneNumbers.remove( it );
1675 return; 1722 return;
1676 } 1723 }
1677 } 1724 }
1678} 1725}
1679 1726
1680PhoneNumber Addressee::phoneNumber( int type ) const 1727PhoneNumber Addressee::phoneNumber( int type ) const
1681{ 1728{
1682 PhoneNumber phoneNumber( "", type ); 1729 PhoneNumber phoneNumber( "", type );
1683 PhoneNumber::List::ConstIterator it; 1730 PhoneNumber::List::ConstIterator it;
1684 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1731 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1685 if ( matchBinaryPatternP( (*it).type(), type ) ) { 1732 if ( matchBinaryPatternP( (*it).type(), type ) ) {
1686 if ( (*it).type() & PhoneNumber::Pref ) 1733 if ( (*it).type() & PhoneNumber::Pref )
1687 return (*it); 1734 return (*it);
1688 else if ( phoneNumber.number().isEmpty() ) 1735 else if ( phoneNumber.number().isEmpty() )
1689 phoneNumber = (*it); 1736 phoneNumber = (*it);
1690 } 1737 }
1691 } 1738 }
1692 1739
1693 return phoneNumber; 1740 return phoneNumber;
1694} 1741}
1695 1742
1696PhoneNumber::List Addressee::phoneNumbers() const 1743PhoneNumber::List Addressee::phoneNumbers() const
1697{ 1744{
1698 return mData->phoneNumbers; 1745 return mData->phoneNumbers;
1699} 1746}
1700 1747
1701int Addressee::hasPhoneNumberType( int type ) 1748int Addressee::hasPhoneNumberType( int type )
1702{ 1749{
1703 int retval = 0; 1750 int retval = 0;
1704 PhoneNumber::List::ConstIterator it; 1751 PhoneNumber::List::ConstIterator it;
1705 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1752 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1706 if ( (*it).type() == type ) 1753 if ( (*it).type() == type )
1707 ++retval; 1754 ++retval;
1708 } 1755 }
1709 return retval; 1756 return retval;
1710} 1757}
1711PhoneNumber::List Addressee::phoneNumbers( int type ) const 1758PhoneNumber::List Addressee::phoneNumbers( int type ) const
1712{ 1759{
1713 PhoneNumber::List list; 1760 PhoneNumber::List list;
1714 1761
1715 PhoneNumber::List::ConstIterator it; 1762 PhoneNumber::List::ConstIterator it;
1716 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1763 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1717 if ( matchBinaryPattern( (*it).type(), type ) ) { 1764 if ( matchBinaryPattern( (*it).type(), type ) ) {
1718 list.append( *it ); 1765 list.append( *it );
1719 } 1766 }
1720 } 1767 }
1721 return list; 1768 return list;
1722} 1769}
1770QString Addressee::phoneNumberString( int type ) const
1771{
1772
1773 PhoneNumber::List::ConstIterator it;
1774 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1775 if ((*it).type() == type ) {
1776 return ( *it ).number();
1777 }
1778 }
1779 return "";
1780}
1723 1781
1724PhoneNumber Addressee::findPhoneNumber( const QString &id ) const 1782PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
1725{ 1783{
1726 PhoneNumber::List::ConstIterator it; 1784 PhoneNumber::List::ConstIterator it;
1727 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1785 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1728 if ( (*it).id() == id ) { 1786 if ( (*it).id() == id ) {
1729 return *it; 1787 return *it;
1730 } 1788 }
1731 } 1789 }
1732 return PhoneNumber(); 1790 return PhoneNumber();
1733} 1791}
1734 1792
1735void Addressee::insertKey( const Key &key ) 1793void Addressee::insertKey( const Key &key )
1736{ 1794{
1737 detach(); 1795 detach();
1738 mData->empty = false; 1796 mData->empty = false;
1739 1797
1740 Key::List::Iterator it; 1798 Key::List::Iterator it;
1741 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1799 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1742 if ( (*it).id() == key.id() ) { 1800 if ( (*it).id() == key.id() ) {
1743 *it = key; 1801 *it = key;
1744 return; 1802 return;
1745 } 1803 }
1746 } 1804 }
1747 mData->keys.append( key ); 1805 mData->keys.append( key );
1748} 1806}
1749 1807
1750void Addressee::removeKey( const Key &key ) 1808void Addressee::removeKey( const Key &key )
1751{ 1809{
1752 detach(); 1810 detach();
1753 1811
1754 Key::List::Iterator it; 1812 Key::List::Iterator it;
1755 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1813 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1756 if ( (*it).id() == key.id() ) { 1814 if ( (*it).id() == key.id() ) {
1757 mData->keys.remove( key ); 1815 mData->keys.remove( key );
1758 return; 1816 return;
1759 } 1817 }
1760 } 1818 }
1761} 1819}
1762 1820
1763Key Addressee::key( int type, QString customTypeString ) const 1821Key Addressee::key( int type, QString customTypeString ) const
1764{ 1822{
1765 Key::List::ConstIterator it; 1823 Key::List::ConstIterator it;
1766 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1824 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1767 if ( (*it).type() == type ) { 1825 if ( (*it).type() == type ) {
1768 if ( type == Key::Custom ) { 1826 if ( type == Key::Custom ) {
1769 if ( customTypeString.isEmpty() ) { 1827 if ( customTypeString.isEmpty() ) {
1770 return *it; 1828 return *it;
1771 } else { 1829 } else {
1772 if ( (*it).customTypeString() == customTypeString ) 1830 if ( (*it).customTypeString() == customTypeString )
1773 return (*it); 1831 return (*it);
1774 } 1832 }
1775 } else { 1833 } else {
1776 return *it; 1834 return *it;
1777 } 1835 }
1778 } 1836 }
1779 } 1837 }
1780 return Key( QString(), type ); 1838 return Key( QString(), type );
1781} 1839}
1782void Addressee::setKeys( const Key::List& list ) { 1840void Addressee::setKeys( const Key::List& list ) {
1783 detach(); 1841 detach();
1784 mData->keys = list; 1842 mData->keys = list;
1785} 1843}
1786 1844
1787Key::List Addressee::keys() const 1845Key::List Addressee::keys() const
1788{ 1846{
1789 return mData->keys; 1847 return mData->keys;
1790} 1848}
1791 1849
1792Key::List Addressee::keys( int type, QString customTypeString ) const 1850Key::List Addressee::keys( int type, QString customTypeString ) const
1793{ 1851{
1794 Key::List list; 1852 Key::List list;
1795 1853
1796 Key::List::ConstIterator it; 1854 Key::List::ConstIterator it;
1797 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1855 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1798 if ( (*it).type() == type ) { 1856 if ( (*it).type() == type ) {
1799 if ( type == Key::Custom ) { 1857 if ( type == Key::Custom ) {
1800 if ( customTypeString.isEmpty() ) { 1858 if ( customTypeString.isEmpty() ) {
1801 list.append(*it); 1859 list.append(*it);
1802 } else { 1860 } else {
1803 if ( (*it).customTypeString() == customTypeString ) 1861 if ( (*it).customTypeString() == customTypeString )
1804 list.append(*it); 1862 list.append(*it);
1805 } 1863 }
1806 } else { 1864 } else {
1807 list.append(*it); 1865 list.append(*it);
1808 } 1866 }
1809 } 1867 }
1810 } 1868 }
1811 return list; 1869 return list;
1812} 1870}
1813 1871
1814Key Addressee::findKey( const QString &id ) const 1872Key Addressee::findKey( const QString &id ) const
1815{ 1873{
1816 Key::List::ConstIterator it; 1874 Key::List::ConstIterator it;
1817 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1875 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1818 if ( (*it).id() == id ) { 1876 if ( (*it).id() == id ) {
1819 return *it; 1877 return *it;
1820 } 1878 }
1821 } 1879 }
1822 return Key(); 1880 return Key();
1823} 1881}
1824 1882
1825QString Addressee::asString() const 1883QString Addressee::asString() const
1826{ 1884{
1827 return "Smith, agent Smith..."; 1885 return "Smith, agent Smith...";
1828} 1886}
1829 1887
1830void Addressee::dump() const 1888void Addressee::dump() const
1831{ 1889{
1832 return; 1890 return;
1833#if 0 1891#if 0
1834 kdDebug(5700) << "Addressee {" << endl; 1892 kdDebug(5700) << "Addressee {" << endl;
1835 1893
1836 kdDebug(5700) << " Uid: '" << uid() << "'" << endl; 1894 kdDebug(5700) << " Uid: '" << uid() << "'" << endl;
1837 1895
1838 kdDebug(5700) << " Name: '" << name() << "'" << endl; 1896 kdDebug(5700) << " Name: '" << name() << "'" << endl;
1839 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; 1897 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl;
1840 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; 1898 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl;
1841 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; 1899 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl;
1842 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; 1900 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl;
1843 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; 1901 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl;
1844 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; 1902 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl;
1845 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; 1903 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl;
1846 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; 1904 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl;
1847 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; 1905 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl;
1848 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; 1906 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl;
1849 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; 1907 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl;
1850 kdDebug(5700) << " Title: '" << title() << "'" << endl; 1908 kdDebug(5700) << " Title: '" << title() << "'" << endl;
1851 kdDebug(5700) << " Role: '" << role() << "'" << endl; 1909 kdDebug(5700) << " Role: '" << role() << "'" << endl;
1852 kdDebug(5700) << " Organization: '" << organization() << "'" << endl; 1910 kdDebug(5700) << " Organization: '" << organization() << "'" << endl;
1853 kdDebug(5700) << " Note: '" << note() << "'" << endl; 1911 kdDebug(5700) << " Note: '" << note() << "'" << endl;
1854 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; 1912 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl;
1855 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; 1913 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl;
1856 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; 1914 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl;
1857 kdDebug(5700) << " Url: '" << url().url() << "'" << endl; 1915 kdDebug(5700) << " Url: '" << url().url() << "'" << endl;
1858 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; 1916 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl;
1859 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; 1917 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl;
1860 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; 1918 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl;
1861 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; 1919 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl;
1862 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; 1920 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl;
1863 1921
1864 kdDebug(5700) << " Emails {" << endl; 1922 kdDebug(5700) << " Emails {" << endl;
1865 QStringList e = emails(); 1923 QStringList e = emails();
1866 QStringList::ConstIterator it; 1924 QStringList::ConstIterator it;
1867 for( it = e.begin(); it != e.end(); ++it ) { 1925 for( it = e.begin(); it != e.end(); ++it ) {
1868 kdDebug(5700) << " " << (*it) << endl; 1926 kdDebug(5700) << " " << (*it) << endl;
1869 } 1927 }
1870 kdDebug(5700) << " }" << endl; 1928 kdDebug(5700) << " }" << endl;
1871 1929
1872 kdDebug(5700) << " PhoneNumbers {" << endl; 1930 kdDebug(5700) << " PhoneNumbers {" << endl;
1873 PhoneNumber::List p = phoneNumbers(); 1931 PhoneNumber::List p = phoneNumbers();
1874 PhoneNumber::List::ConstIterator it2; 1932 PhoneNumber::List::ConstIterator it2;
1875 for( it2 = p.begin(); it2 != p.end(); ++it2 ) { 1933 for( it2 = p.begin(); it2 != p.end(); ++it2 ) {
1876 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; 1934 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl;
1877 } 1935 }
1878 kdDebug(5700) << " }" << endl; 1936 kdDebug(5700) << " }" << endl;
1879 1937
1880 Address::List a = addresses(); 1938 Address::List a = addresses();
1881 Address::List::ConstIterator it3; 1939 Address::List::ConstIterator it3;
1882 for( it3 = a.begin(); it3 != a.end(); ++it3 ) { 1940 for( it3 = a.begin(); it3 != a.end(); ++it3 ) {
1883 (*it3).dump(); 1941 (*it3).dump();
1884 } 1942 }
1885 1943
1886 kdDebug(5700) << " Keys {" << endl; 1944 kdDebug(5700) << " Keys {" << endl;
1887 Key::List k = keys(); 1945 Key::List k = keys();
1888 Key::List::ConstIterator it4; 1946 Key::List::ConstIterator it4;
1889 for( it4 = k.begin(); it4 != k.end(); ++it4 ) { 1947 for( it4 = k.begin(); it4 != k.end(); ++it4 ) {
1890 kdDebug(5700) << " Type: " << int((*it4).type()) << 1948 kdDebug(5700) << " Type: " << int((*it4).type()) <<
1891 " Key: " << (*it4).textData() << 1949 " Key: " << (*it4).textData() <<
1892 " CustomString: " << (*it4).customTypeString() << endl; 1950 " CustomString: " << (*it4).customTypeString() << endl;
1893 } 1951 }
1894 kdDebug(5700) << " }" << endl; 1952 kdDebug(5700) << " }" << endl;
1895 1953
1896 kdDebug(5700) << "}" << endl; 1954 kdDebug(5700) << "}" << endl;
1897#endif 1955#endif
1898} 1956}
1899 1957
1900 1958
1901void Addressee::insertAddress( const Address &address ) 1959void Addressee::insertAddress( const Address &address )
1902{ 1960{
1903 detach(); 1961 detach();
1904 mData->empty = false; 1962 mData->empty = false;
1905 1963
1906 Address::List::Iterator it; 1964 Address::List::Iterator it;
1907 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1965 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1908 if ( (*it).id() == address.id() ) { 1966 if ( (*it).id() == address.id() ) {
1909 *it = address; 1967 *it = address;
1910 return; 1968 return;
1911 } 1969 }
1912 } 1970 }
1913 mData->addresses.append( address ); 1971 mData->addresses.append( address );
1914} 1972}
1915 1973
1916void Addressee::removeAddress( const Address &address ) 1974void Addressee::removeAddress( const Address &address )
1917{ 1975{
1918 detach(); 1976 detach();
1919 1977
1920 Address::List::Iterator it; 1978 Address::List::Iterator it;
1921 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1979 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1922 if ( (*it).id() == address.id() ) { 1980 if ( (*it).id() == address.id() ) {
1923 mData->addresses.remove( it ); 1981 mData->addresses.remove( it );
1924 return; 1982 return;
1925 } 1983 }
1926 } 1984 }
1927} 1985}
1928 1986Address Addressee::otherAddress() const
1987{
1988 Address::List::ConstIterator it;
1989 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1990 if ( matchBinaryPatternA( (*it).type(), KABC::Address::Work ) )
1991 continue;
1992 if ( matchBinaryPatternA( (*it).type(), KABC::Address::Home ) )
1993 continue;
1994 return (*it);
1995 }
1996 return Address();
1997}
1929Address Addressee::address( int type ) const 1998Address Addressee::address( int type ) const
1930{ 1999{
1931 Address address( type ); 2000 Address address( type );
1932 Address::List::ConstIterator it; 2001 Address::List::ConstIterator it;
1933 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 2002 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1934 if ( matchBinaryPatternA( (*it).type(), type ) ) { 2003 if ( matchBinaryPatternA( (*it).type(), type ) ) {
1935 if ( (*it).type() & Address::Pref ) 2004 if ( (*it).type() & Address::Pref )
1936 return (*it); 2005 return (*it);
1937 else if ( address.isEmpty() ) 2006 else if ( address.isEmpty() )
1938 address = (*it); 2007 address = (*it);
1939 } 2008 }
1940 } 2009 }
1941 2010
1942 return address; 2011 return address;
1943} 2012}
1944 2013
1945Address::List Addressee::addresses() const 2014Address::List Addressee::addresses() const
1946{ 2015{
1947 return mData->addresses; 2016 return mData->addresses;
1948} 2017}
1949 2018
1950Address::List Addressee::addresses( int type ) const 2019Address::List Addressee::addresses( int type ) const
1951{ 2020{
1952 Address::List list; 2021 Address::List list;
1953 2022
1954 Address::List::ConstIterator it; 2023 Address::List::ConstIterator it;
1955 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 2024 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1956 if ( matchBinaryPattern( (*it).type(), type ) ) { 2025 if ( matchBinaryPattern( (*it).type(), type ) ) {
1957 list.append( *it ); 2026 list.append( *it );
1958 } 2027 }
1959 } 2028 }
1960 2029
1961 return list; 2030 return list;
1962} 2031}
1963 2032
1964Address Addressee::findAddress( const QString &id ) const 2033Address Addressee::findAddress( const QString &id ) const
1965{ 2034{
1966 Address::List::ConstIterator it; 2035 Address::List::ConstIterator it;
1967 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 2036 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1968 if ( (*it).id() == id ) { 2037 if ( (*it).id() == id ) {
1969 return *it; 2038 return *it;
1970 } 2039 }
1971 } 2040 }
1972 return Address(); 2041 return Address();
1973} 2042}
1974 2043
1975void Addressee::insertCategory( const QString &c ) 2044void Addressee::insertCategory( const QString &c )
1976{ 2045{
1977 detach(); 2046 detach();
1978 mData->empty = false; 2047 mData->empty = false;
1979 2048
1980 if ( mData->categories.contains( c ) ) return; 2049 if ( mData->categories.contains( c ) ) return;
1981 2050
1982 mData->categories.append( c ); 2051 mData->categories.append( c );
1983} 2052}
1984 2053
1985void Addressee::removeCategory( const QString &c ) 2054void Addressee::removeCategory( const QString &c )
1986{ 2055{
1987 detach(); 2056 detach();
1988 2057
1989 QStringList::Iterator it = mData->categories.find( c ); 2058 QStringList::Iterator it = mData->categories.find( c );
1990 if ( it == mData->categories.end() ) return; 2059 if ( it == mData->categories.end() ) return;
1991 2060
1992 mData->categories.remove( it ); 2061 mData->categories.remove( it );
1993} 2062}
1994 2063
1995bool Addressee::hasCategory( const QString &c ) const 2064bool Addressee::hasCategory( const QString &c ) const
1996{ 2065{
1997 return ( mData->categories.contains( c ) ); 2066 return ( mData->categories.contains( c ) );
1998} 2067}
1999 2068
2000void Addressee::setCategories( const QStringList &c ) 2069void Addressee::setCategories( const QStringList &c )
2001{ 2070{
2002 detach(); 2071 detach();
2003 mData->empty = false; 2072 mData->empty = false;
2004 2073
2005 mData->categories = c; 2074 mData->categories = c;
2006} 2075}
2007 2076
2008QStringList Addressee::categories() const 2077QStringList Addressee::categories() const
2009{ 2078{
2010 return mData->categories; 2079 return mData->categories;
2011} 2080}
2012 2081
2013void Addressee::insertCustom( const QString &app, const QString &name, 2082void Addressee::insertCustom( const QString &app, const QString &name,
2014 const QString &value ) 2083 const QString &value )
2015{ 2084{
2016 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; 2085 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return;
2017 2086
2018 detach(); 2087 detach();
2019 mData->empty = false; 2088 mData->empty = false;
2020 2089
2021 QString qualifiedName = app + "-" + name + ":"; 2090 QString qualifiedName = app + "-" + name + ":";
2022 2091
2023 QStringList::Iterator it; 2092 QStringList::Iterator it;
2024 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 2093 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
2025 if ( (*it).startsWith( qualifiedName ) ) { 2094 if ( (*it).startsWith( qualifiedName ) ) {
2026 (*it) = qualifiedName + value; 2095 (*it) = qualifiedName + value;
2027 return; 2096 return;
2028 } 2097 }
2029 } 2098 }
2030 mData->custom.append( qualifiedName + value ); 2099 mData->custom.append( qualifiedName + value );
2031} 2100}
2032 2101
2033void Addressee::removeCustom( const QString &app, const QString &name) 2102void Addressee::removeCustom( const QString &app, const QString &name)
2034{ 2103{
2035 detach(); 2104 detach();
2036 2105
2037 QString qualifiedName = app + "-" + name + ":"; 2106 QString qualifiedName = app + "-" + name + ":";
2038 2107
2039 QStringList::Iterator it; 2108 QStringList::Iterator it;
2040 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 2109 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
2041 if ( (*it).startsWith( qualifiedName ) ) { 2110 if ( (*it).startsWith( qualifiedName ) ) {
2042 mData->custom.remove( it ); 2111 mData->custom.remove( it );
2043 return; 2112 return;
2044 } 2113 }
2045 } 2114 }
2046} 2115}
2047 2116
2048QString Addressee::custom( const QString &app, const QString &name ) const 2117QString Addressee::custom( const QString &app, const QString &name ) const
2049{ 2118{
2050 QString qualifiedName = app + "-" + name + ":"; 2119 QString qualifiedName = app + "-" + name + ":";
2051 QString value; 2120 QString value;
2052 2121
2053 QStringList::ConstIterator it; 2122 QStringList::ConstIterator it;
2054 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 2123 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
2055 if ( (*it).startsWith( qualifiedName ) ) { 2124 if ( (*it).startsWith( qualifiedName ) ) {
2056 value = (*it).mid( (*it).find( ":" ) + 1 ); 2125 value = (*it).mid( (*it).find( ":" ) + 1 );
2057 break; 2126 break;
2058 } 2127 }
2059 } 2128 }
2060 2129
2061 return value; 2130 return value;
2062} 2131}
2063 2132
2064void Addressee::setCustoms( const QStringList &l ) 2133void Addressee::setCustoms( const QStringList &l )
2065{ 2134{
2066 detach(); 2135 detach();
2067 mData->empty = false; 2136 mData->empty = false;
2068 2137
2069 mData->custom = l; 2138 mData->custom = l;
2070} 2139}
2071 2140
2072QStringList Addressee::customs() const 2141QStringList Addressee::customs() const
2073{ 2142{
2074 return mData->custom; 2143 return mData->custom;
2075} 2144}
2076 2145
2077void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, 2146void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName,
2078 QString &email) 2147 QString &email)
2079{ 2148{
2080 int startPos, endPos, len; 2149 int startPos, endPos, len;
2081 QString partA, partB, result; 2150 QString partA, partB, result;
2082 char endCh = '>'; 2151 char endCh = '>';
2083 2152
2084 startPos = rawEmail.find('<'); 2153 startPos = rawEmail.find('<');
2085 if (startPos < 0) 2154 if (startPos < 0)
2086 { 2155 {
2087 startPos = rawEmail.find('('); 2156 startPos = rawEmail.find('(');
2088 endCh = ')'; 2157 endCh = ')';
2089 } 2158 }
2090 if (startPos < 0) 2159 if (startPos < 0)
2091 { 2160 {
2092 // We couldn't find any separators, so we assume the whole string 2161 // We couldn't find any separators, so we assume the whole string
2093 // is the email address 2162 // is the email address
2094 email = rawEmail; 2163 email = rawEmail;
2095 fullName = ""; 2164 fullName = "";
2096 } 2165 }
2097 else 2166 else
2098 { 2167 {
2099 // We have a start position, try to find an end 2168 // We have a start position, try to find an end
2100 endPos = rawEmail.find(endCh, startPos+1); 2169 endPos = rawEmail.find(endCh, startPos+1);
2101 2170
2102 if (endPos < 0) 2171 if (endPos < 0)
2103 { 2172 {
2104 // We couldn't find the end of the email address. We can only 2173 // We couldn't find the end of the email address. We can only
2105 // assume the entire string is the email address. 2174 // assume the entire string is the email address.
2106 email = rawEmail; 2175 email = rawEmail;
2107 fullName = ""; 2176 fullName = "";
2108 } 2177 }
2109 else 2178 else
2110 { 2179 {
2111 // We have a start and end to the email address 2180 // We have a start and end to the email address
2112 2181
2113 // Grab the name part 2182 // Grab the name part
2114 fullName = rawEmail.left(startPos).stripWhiteSpace(); 2183 fullName = rawEmail.left(startPos).stripWhiteSpace();
2115 2184
2116 // grab the email part 2185 // grab the email part
2117 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); 2186 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace();
2118 2187
2119 // Check that we do not have any extra characters on the end of the 2188 // Check that we do not have any extra characters on the end of the
2120 // strings 2189 // strings
2121 len = fullName.length(); 2190 len = fullName.length();
2122 if (fullName[0]=='"' && fullName[len-1]=='"') 2191 if (fullName[0]=='"' && fullName[len-1]=='"')
2123 fullName = fullName.mid(1, len-2); 2192 fullName = fullName.mid(1, len-2);
2124 else if (fullName[0]=='<' && fullName[len-1]=='>') 2193 else if (fullName[0]=='<' && fullName[len-1]=='>')
2125 fullName = fullName.mid(1, len-2); 2194 fullName = fullName.mid(1, len-2);
2126 else if (fullName[0]=='(' && fullName[len-1]==')') 2195 else if (fullName[0]=='(' && fullName[len-1]==')')
2127 fullName = fullName.mid(1, len-2); 2196 fullName = fullName.mid(1, len-2);
2128 } 2197 }
2129 } 2198 }
2130} 2199}
2131 2200
2132void Addressee::setResource( Resource *resource ) 2201void Addressee::setResource( Resource *resource )
2133{ 2202{
2134 detach(); 2203 detach();
2135 mData->resource = resource; 2204 mData->resource = resource;
2136} 2205}
2137 2206
2138Resource *Addressee::resource() const 2207Resource *Addressee::resource() const
2139{ 2208{
2140 return mData->resource; 2209 return mData->resource;
2141} 2210}
2142 2211
2143//US 2212//US
2144QString Addressee::resourceLabel() 2213QString Addressee::resourceLabel()
2145{ 2214{
2146 return i18n("Resource"); 2215 return i18n("Resource");
2147} 2216}
2148QString Addressee::categoryLabel() 2217QString Addressee::categoryLabel()
2149{ 2218{
2150 return i18n("Category"); 2219 return i18n("Category");
2151} 2220}
2152 2221
2153void Addressee::setChanged( bool value ) 2222void Addressee::setChanged( bool value )
2154{ 2223{
2155 detach(); 2224 detach();
2156 mData->changed = value; 2225 mData->changed = value;
2157} 2226}
2158 2227
2159bool Addressee::changed() const 2228bool Addressee::changed() const
2160{ 2229{
2161 return mData->changed; 2230 return mData->changed;
2162} 2231}
2163 2232
2164void Addressee::setTagged( bool value ) 2233void Addressee::setTagged( bool value )
2165{ 2234{
2166 detach(); 2235 detach();
2167 mData->tagged = value; 2236 mData->tagged = value;
2168} 2237}
2169 2238
2170bool Addressee::tagged() const 2239bool Addressee::tagged() const
2171{ 2240{
2172 return mData->tagged; 2241 return mData->tagged;
2173} 2242}
2174 2243
2175QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) 2244QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
2176{ 2245{
2177 if (!a.mData) return s; 2246 if (!a.mData) return s;
2178 2247
2179 s << a.uid(); 2248 s << a.uid();
2180 2249
2181 s << a.mData->name; 2250 s << a.mData->name;
2182 s << a.mData->formattedName; 2251 s << a.mData->formattedName;
2183 s << a.mData->familyName; 2252 s << a.mData->familyName;
2184 s << a.mData->givenName; 2253 s << a.mData->givenName;
2185 s << a.mData->additionalName; 2254 s << a.mData->additionalName;
2186 s << a.mData->prefix; 2255 s << a.mData->prefix;
2187 s << a.mData->suffix; 2256 s << a.mData->suffix;
2188 s << a.mData->nickName; 2257 s << a.mData->nickName;
2189 s << a.mData->birthday; 2258 s << a.mData->birthday;
2190 s << a.mData->mailer; 2259 s << a.mData->mailer;
2191 s << a.mData->timeZone; 2260 s << a.mData->timeZone;
2192 s << a.mData->geo; 2261 s << a.mData->geo;
2193 s << a.mData->title; 2262 s << a.mData->title;
2194 s << a.mData->role; 2263 s << a.mData->role;
2195 s << a.mData->organization; 2264 s << a.mData->organization;
2196 s << a.mData->note; 2265 s << a.mData->note;
2197 s << a.mData->productId; 2266 s << a.mData->productId;
2198 s << a.mData->revision; 2267 s << a.mData->revision;
2199 s << a.mData->sortString; 2268 s << a.mData->sortString;
2200 s << a.mData->url; 2269 s << a.mData->url;
2201 s << a.mData->secrecy; 2270 s << a.mData->secrecy;
2202 s << a.mData->logo; 2271 s << a.mData->logo;
2203 s << a.mData->photo; 2272 s << a.mData->photo;
2204 s << a.mData->sound; 2273 s << a.mData->sound;
2205 s << a.mData->agent; 2274 s << a.mData->agent;
2206 s << a.mData->phoneNumbers; 2275 s << a.mData->phoneNumbers;
2207 s << a.mData->addresses; 2276 s << a.mData->addresses;
2208 s << a.mData->emails; 2277 s << a.mData->emails;
2209 s << a.mData->categories; 2278 s << a.mData->categories;
2210 s << a.mData->custom; 2279 s << a.mData->custom;
2211 s << a.mData->keys; 2280 s << a.mData->keys;
2212 return s; 2281 return s;
2213} 2282}
2214 2283
2215QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) 2284QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
2216{ 2285{
2217 if (!a.mData) return s; 2286 if (!a.mData) return s;
2218 2287
2219 s >> a.mData->uid; 2288 s >> a.mData->uid;
2220 2289
2221 s >> a.mData->name; 2290 s >> a.mData->name;
2222 s >> a.mData->formattedName; 2291 s >> a.mData->formattedName;
2223 s >> a.mData->familyName; 2292 s >> a.mData->familyName;
2224 s >> a.mData->givenName; 2293 s >> a.mData->givenName;
2225 s >> a.mData->additionalName; 2294 s >> a.mData->additionalName;
2226 s >> a.mData->prefix; 2295 s >> a.mData->prefix;
2227 s >> a.mData->suffix; 2296 s >> a.mData->suffix;
2228 s >> a.mData->nickName; 2297 s >> a.mData->nickName;
2229 s >> a.mData->birthday; 2298 s >> a.mData->birthday;
2230 s >> a.mData->mailer; 2299 s >> a.mData->mailer;
2231 s >> a.mData->timeZone; 2300 s >> a.mData->timeZone;
2232 s >> a.mData->geo; 2301 s >> a.mData->geo;
2233 s >> a.mData->title; 2302 s >> a.mData->title;
2234 s >> a.mData->role; 2303 s >> a.mData->role;
2235 s >> a.mData->organization; 2304 s >> a.mData->organization;
2236 s >> a.mData->note; 2305 s >> a.mData->note;
2237 s >> a.mData->productId; 2306 s >> a.mData->productId;
2238 s >> a.mData->revision; 2307 s >> a.mData->revision;
2239 s >> a.mData->sortString; 2308 s >> a.mData->sortString;
2240 s >> a.mData->url; 2309 s >> a.mData->url;
2241 s >> a.mData->secrecy; 2310 s >> a.mData->secrecy;
2242 s >> a.mData->logo; 2311 s >> a.mData->logo;
2243 s >> a.mData->photo; 2312 s >> a.mData->photo;
2244 s >> a.mData->sound; 2313 s >> a.mData->sound;
2245 s >> a.mData->agent; 2314 s >> a.mData->agent;
2246 s >> a.mData->phoneNumbers; 2315 s >> a.mData->phoneNumbers;
2247 s >> a.mData->addresses; 2316 s >> a.mData->addresses;
2248 s >> a.mData->emails; 2317 s >> a.mData->emails;
2249 s >> a.mData->categories; 2318 s >> a.mData->categories;
2250 s >> a.mData->custom; 2319 s >> a.mData->custom;
2251 s >> a.mData->keys; 2320 s >> a.mData->keys;
2252 2321
2253 a.mData->empty = false; 2322 a.mData->empty = false;
2254 2323
2255 return s; 2324 return s;
2256} 2325}
2257bool matchBinaryPattern( int value, int pattern ) 2326bool matchBinaryPattern( int value, int pattern )
2258{ 2327{
2259 /** 2328 /**
2260 We want to match all telephonnumbers/addresses which have the bits in the 2329 We want to match all telephonnumbers/addresses which have the bits in the
2261 pattern set. More are allowed. 2330 pattern set. More are allowed.
2262 if pattern == 0 we have a special handling, then we want only those with 2331 if pattern == 0 we have a special handling, then we want only those with
2263 exactly no bit set. 2332 exactly no bit set.
2264 */ 2333 */
2265 if ( pattern == 0 ) 2334 if ( pattern == 0 )
2266 return ( value == 0 ); 2335 return ( value == 0 );
2267 else 2336 else
2268 return ( pattern == ( pattern & value ) ); 2337 return ( pattern == ( pattern & value ) );
2269} 2338}
2270 2339
2271bool matchBinaryPatternP( int value, int pattern ) 2340bool matchBinaryPatternP( int value, int pattern )
2272{ 2341{
2273 2342
2274 if ( pattern == 0 ) 2343 if ( pattern == 0 )
2275 return ( value == 0 ); 2344 return ( value == 0 );
2276 else 2345 else
2277 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); 2346 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) );
2278} 2347}
2279bool matchBinaryPatternA( int value, int pattern ) 2348bool matchBinaryPatternA( int value, int pattern )
2280{ 2349{
2281 2350
2282 if ( pattern == 0 ) 2351 if ( pattern == 0 )
2283 return ( value == 0 ); 2352 return ( value == 0 );
2284 else 2353 else
2285 return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); 2354 return ( (pattern | Address::Pref) == ( value | Address::Pref ) );
2286} 2355}
diff --git a/kabc/addressee.h b/kabc/addressee.h
index aac78dc..0ea1803 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -1,856 +1,858 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#ifndef KABC_ADDRESSEE_H 29#ifndef KABC_ADDRESSEE_H
30#define KABC_ADDRESSEE_H 30#define KABC_ADDRESSEE_H
31 31
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qstring.h> 33#include <qstring.h>
34#include <qregexp.h> 34#include <qregexp.h>
35#include <qstringlist.h> 35#include <qstringlist.h>
36#include <qvaluelist.h> 36#include <qvaluelist.h>
37 37
38#include <ksharedptr.h> 38#include <ksharedptr.h>
39#include <kurl.h> 39#include <kurl.h>
40 40
41#include "address.h" 41#include "address.h"
42#include "agent.h" 42#include "agent.h"
43#include "geo.h" 43#include "geo.h"
44#include "key.h" 44#include "key.h"
45#include "phonenumber.h" 45#include "phonenumber.h"
46#include "picture.h" 46#include "picture.h"
47#include "secrecy.h" 47#include "secrecy.h"
48#include "sound.h" 48#include "sound.h"
49#include "timezone.h" 49#include "timezone.h"
50 50
51namespace KABC { 51namespace KABC {
52 52
53class Resource; 53class Resource;
54 54
55/** 55/**
56 @short address book entry 56 @short address book entry
57 57
58 This class represents an entry in the address book. 58 This class represents an entry in the address book.
59 59
60 The data of this class is implicitly shared. You can pass this class by value. 60 The data of this class is implicitly shared. You can pass this class by value.
61 61
62 If you need the name of a field for presenting it to the user you should use 62 If you need the name of a field for presenting it to the user you should use
63 the functions ending in Label(). They return a translated string which can be 63 the functions ending in Label(). They return a translated string which can be
64 used as label for the corresponding field. 64 used as label for the corresponding field.
65 65
66 About the name fields: 66 About the name fields:
67 67
68 givenName() is the first name and familyName() the last name. In some 68 givenName() is the first name and familyName() the last name. In some
69 countries the family name comes first, that's the reason for the 69 countries the family name comes first, that's the reason for the
70 naming. formattedName() is the full name with the correct formatting. 70 naming. formattedName() is the full name with the correct formatting.
71 It is used as an override, when the correct formatting can't be generated 71 It is used as an override, when the correct formatting can't be generated
72 from the other name fields automatically. 72 from the other name fields automatically.
73 73
74 realName() returns a fully formatted name(). It uses formattedName, if set, 74 realName() returns a fully formatted name(). It uses formattedName, if set,
75 otherwise it constucts the name from the name fields. As fallback, if 75 otherwise it constucts the name from the name fields. As fallback, if
76 nothing else is set it uses name(). 76 nothing else is set it uses name().
77 77
78 name() is the NAME type of RFC2426. It can be used as internal name for the 78 name() is the NAME type of RFC2426. It can be used as internal name for the
79 data enty, but shouldn't be used for displaying the data to the user. 79 data enty, but shouldn't be used for displaying the data to the user.
80 */ 80 */
81class Addressee 81class Addressee
82{ 82{
83 friend QDataStream &operator<<( QDataStream &, const Addressee & ); 83 friend QDataStream &operator<<( QDataStream &, const Addressee & );
84 friend QDataStream &operator>>( QDataStream &, Addressee & ); 84 friend QDataStream &operator>>( QDataStream &, Addressee & );
85 85
86 public: 86 public:
87 typedef QValueList<Addressee> List; 87 typedef QValueList<Addressee> List;
88 88
89 /** 89 /**
90 Construct an empty address book entry. 90 Construct an empty address book entry.
91 */ 91 */
92 Addressee(); 92 Addressee();
93 ~Addressee(); 93 ~Addressee();
94 94
95 Addressee( const Addressee & ); 95 Addressee( const Addressee & );
96 Addressee &operator=( const Addressee & ); 96 Addressee &operator=( const Addressee & );
97 97
98 bool operator==( const Addressee & ) const; 98 bool operator==( const Addressee & ) const;
99 bool operator!=( const Addressee & ) const; 99 bool operator!=( const Addressee & ) const;
100 // sync stuff 100 // sync stuff
101 void setTempSyncStat(int id); 101 void setTempSyncStat(int id);
102 int tempSyncStat() const; 102 int tempSyncStat() const;
103 void setIDStr( const QString & ); 103 void setIDStr( const QString & );
104 const QString IDStr() const; 104 const QString IDStr() const;
105 void setID( const QString &, const QString & ); 105 void setID( const QString &, const QString & );
106 const QString getID( const QString & ) const; 106 const QString getID( const QString & ) const;
107 void setCsum( const QString &, const QString & ); 107 void setCsum( const QString &, const QString & );
108 const QString getCsum( const QString & ) const ; 108 const QString getCsum( const QString & ) const ;
109 void removeID(const QString &); 109 void removeID(const QString &);
110 void computeCsum(const QString &dev); 110 void computeCsum(const QString &dev);
111 ulong getCsum4List( const QStringList & attList); 111 ulong getCsum4List( const QStringList & attList);
112 /** 112 /**
113 Return, if the address book entry is empty. 113 Return, if the address book entry is empty.
114 */ 114 */
115 bool isEmpty() const; 115 bool isEmpty() const;
116 void setExternalUID( const QString &id ); 116 void setExternalUID( const QString &id );
117 const QString externalUID() const; 117 const QString externalUID() const;
118 void setOriginalExternalUID( const QString &id ); 118 void setOriginalExternalUID( const QString &id );
119 QString originalExternalUID() const; 119 QString originalExternalUID() const;
120 void mergeContact( const Addressee& ad, bool isSubSet ); 120 void mergeContact( const Addressee& ad, bool isSubSet );
121 void mergeOLContact( const Addressee& ad );
121 void simplifyEmails(); 122 void simplifyEmails();
122 void simplifyAddresses(); 123 void simplifyAddresses();
123 void simplifyPhoneNumbers(); 124 void simplifyPhoneNumbers();
124 void simplifyPhoneNumberTypes(); 125 void simplifyPhoneNumberTypes();
125 void makePhoneNumbersOLcompatible(); 126 void makePhoneNumbersOLcompatible();
126 int hasPhoneNumberType( int type ); 127 int hasPhoneNumberType( int type );
127 bool removeVoice(); 128 bool removeVoice();
128 bool containsAdr(const Addressee& addr ); 129 bool containsAdr(const Addressee& addr );
129 130
130 /** 131 /**
131 Set unique identifier. 132 Set unique identifier.
132 */ 133 */
133 void setUid( const QString &uid ); 134 void setUid( const QString &uid );
134 /** 135 /**
135 Return unique identifier. 136 Return unique identifier.
136 */ 137 */
137 const QString uid() const; 138 const QString uid() const;
138 /** 139 /**
139 Return translated label for uid field. 140 Return translated label for uid field.
140 */ 141 */
141 static QString uidLabel(); 142 static QString uidLabel();
142 143
143 /** 144 /**
144 Set name. 145 Set name.
145 */ 146 */
146 void setName( const QString &name ); 147 void setName( const QString &name );
147 /** 148 /**
148 Return name. 149 Return name.
149 */ 150 */
150 QString name() const; 151 QString name() const;
151 /** 152 /**
152 Return translated label for name field. 153 Return translated label for name field.
153 */ 154 */
154 static QString nameLabel(); 155 static QString nameLabel();
155 156
156 /** 157 /**
157 Set formatted name. 158 Set formatted name.
158 */ 159 */
159 void setFormattedName( const QString &formattedName ); 160 void setFormattedName( const QString &formattedName );
160 /** 161 /**
161 Return formatted name. 162 Return formatted name.
162 */ 163 */
163 QString formattedName() const; 164 QString formattedName() const;
164 /** 165 /**
165 Return translated label for formattedName field. 166 Return translated label for formattedName field.
166 */ 167 */
167 static QString formattedNameLabel(); 168 static QString formattedNameLabel();
168 169
169 /** 170 /**
170 Set family name. 171 Set family name.
171 */ 172 */
172 void setFamilyName( const QString &familyName ); 173 void setFamilyName( const QString &familyName );
173 /** 174 /**
174 Return family name. 175 Return family name.
175 */ 176 */
176 QString familyName() const; 177 QString familyName() const;
177 /** 178 /**
178 Return translated label for familyName field. 179 Return translated label for familyName field.
179 */ 180 */
180 static QString familyNameLabel(); 181 static QString familyNameLabel();
181 182
182 /** 183 /**
183 Set given name. 184 Set given name.
184 */ 185 */
185 void setGivenName( const QString &givenName ); 186 void setGivenName( const QString &givenName );
186 /** 187 /**
187 Return given name. 188 Return given name.
188 */ 189 */
189 QString givenName() const; 190 QString givenName() const;
190 /** 191 /**
191 Return translated label for givenName field. 192 Return translated label for givenName field.
192 */ 193 */
193 static QString givenNameLabel(); 194 static QString givenNameLabel();
194 195
195 /** 196 /**
196 Set additional names. 197 Set additional names.
197 */ 198 */
198 void setAdditionalName( const QString &additionalName ); 199 void setAdditionalName( const QString &additionalName );
199 /** 200 /**
200 Return additional names. 201 Return additional names.
201 */ 202 */
202 QString additionalName() const; 203 QString additionalName() const;
203 /** 204 /**
204 Return translated label for additionalName field. 205 Return translated label for additionalName field.
205 */ 206 */
206 static QString additionalNameLabel(); 207 static QString additionalNameLabel();
207 208
208 /** 209 /**
209 Set honorific prefixes. 210 Set honorific prefixes.
210 */ 211 */
211 void setPrefix( const QString &prefix ); 212 void setPrefix( const QString &prefix );
212 /** 213 /**
213 Return honorific prefixes. 214 Return honorific prefixes.
214 */ 215 */
215 QString prefix() const; 216 QString prefix() const;
216 /** 217 /**
217 Return translated label for prefix field. 218 Return translated label for prefix field.
218 */ 219 */
219 static QString prefixLabel(); 220 static QString prefixLabel();
220 221
221 /** 222 /**
222 Set honorific suffixes. 223 Set honorific suffixes.
223 */ 224 */
224 void setSuffix( const QString &suffix ); 225 void setSuffix( const QString &suffix );
225 /** 226 /**
226 Return honorific suffixes. 227 Return honorific suffixes.
227 */ 228 */
228 QString suffix() const; 229 QString suffix() const;
229 /** 230 /**
230 Return translated label for suffix field. 231 Return translated label for suffix field.
231 */ 232 */
232 static QString suffixLabel(); 233 static QString suffixLabel();
233 234
234 /** 235 /**
235 Set nick name. 236 Set nick name.
236 */ 237 */
237 void setNickName( const QString &nickName ); 238 void setNickName( const QString &nickName );
238 /** 239 /**
239 Return nick name. 240 Return nick name.
240 */ 241 */
241 QString nickName() const; 242 QString nickName() const;
242 /** 243 /**
243 Return translated label for nickName field. 244 Return translated label for nickName field.
244 */ 245 */
245 static QString nickNameLabel(); 246 static QString nickNameLabel();
246 247
247 /** 248 /**
248 Set birthday. 249 Set birthday.
249 */ 250 */
250 void setBirthday( const QDateTime &birthday ); 251 void setBirthday( const QDateTime &birthday );
251 /** 252 /**
252 Return birthday. 253 Return birthday.
253 */ 254 */
254 QDateTime birthday() const; 255 QDateTime birthday() const;
255 /** 256 /**
256 Return translated label for birthday field. 257 Return translated label for birthday field.
257 */ 258 */
258 static QString birthdayLabel(); 259 static QString birthdayLabel();
259 260
260 /** 261 /**
261 Return translated label for homeAddressStreet field. 262 Return translated label for homeAddressStreet field.
262 */ 263 */
263 static QString homeAddressStreetLabel(); 264 static QString homeAddressStreetLabel();
264 265
265 /** 266 /**
266 Return translated label for homeAddressLocality field. 267 Return translated label for homeAddressLocality field.
267 */ 268 */
268 static QString homeAddressLocalityLabel(); 269 static QString homeAddressLocalityLabel();
269 270
270 /** 271 /**
271 Return translated label for homeAddressRegion field. 272 Return translated label for homeAddressRegion field.
272 */ 273 */
273 static QString homeAddressRegionLabel(); 274 static QString homeAddressRegionLabel();
274 275
275 /** 276 /**
276 Return translated label for homeAddressPostalCode field. 277 Return translated label for homeAddressPostalCode field.
277 */ 278 */
278 static QString homeAddressPostalCodeLabel(); 279 static QString homeAddressPostalCodeLabel();
279 280
280 /** 281 /**
281 Return translated label for homeAddressCountry field. 282 Return translated label for homeAddressCountry field.
282 */ 283 */
283 static QString homeAddressCountryLabel(); 284 static QString homeAddressCountryLabel();
284 285
285 /** 286 /**
286 Return translated label for homeAddressLabel field. 287 Return translated label for homeAddressLabel field.
287 */ 288 */
288 static QString homeAddressLabelLabel(); 289 static QString homeAddressLabelLabel();
289 290
290 /** 291 /**
291 Return translated label for businessAddressStreet field. 292 Return translated label for businessAddressStreet field.
292 */ 293 */
293 static QString businessAddressStreetLabel(); 294 static QString businessAddressStreetLabel();
294 295
295 /** 296 /**
296 Return translated label for businessAddressLocality field. 297 Return translated label for businessAddressLocality field.
297 */ 298 */
298 static QString businessAddressLocalityLabel(); 299 static QString businessAddressLocalityLabel();
299 300
300 /** 301 /**
301 Return translated label for businessAddressRegion field. 302 Return translated label for businessAddressRegion field.
302 */ 303 */
303 static QString businessAddressRegionLabel(); 304 static QString businessAddressRegionLabel();
304 305
305 /** 306 /**
306 Return translated label for businessAddressPostalCode field. 307 Return translated label for businessAddressPostalCode field.
307 */ 308 */
308 static QString businessAddressPostalCodeLabel(); 309 static QString businessAddressPostalCodeLabel();
309 310
310 /** 311 /**
311 Return translated label for businessAddressCountry field. 312 Return translated label for businessAddressCountry field.
312 */ 313 */
313 static QString businessAddressCountryLabel(); 314 static QString businessAddressCountryLabel();
314 315
315 /** 316 /**
316 Return translated label for businessAddressLabel field. 317 Return translated label for businessAddressLabel field.
317 */ 318 */
318 static QString businessAddressLabelLabel(); 319 static QString businessAddressLabelLabel();
319 320
320 /** 321 /**
321 Return translated label for homePhone field. 322 Return translated label for homePhone field.
322 */ 323 */
323 static QString homePhoneLabel(); 324 static QString homePhoneLabel();
324 325
325 /** 326 /**
326 Return translated label for businessPhone field. 327 Return translated label for businessPhone field.
327 */ 328 */
328 static QString businessPhoneLabel(); 329 static QString businessPhoneLabel();
329 330
330 /** 331 /**
331 Return translated label for mobilePhone field. 332 Return translated label for mobilePhone field.
332 */ 333 */
333 static QString mobilePhoneLabel(); 334 static QString mobilePhoneLabel();
334 static QString mobileWorkPhoneLabel(); 335 static QString mobileWorkPhoneLabel();
335 336
336 /** 337 /**
337 Return translated label for homeFax field. 338 Return translated label for homeFax field.
338 */ 339 */
339 static QString homeFaxLabel(); 340 static QString homeFaxLabel();
340 341
341 /** 342 /**
342 Return translated label for businessFax field. 343 Return translated label for businessFax field.
343 */ 344 */
344 static QString businessFaxLabel(); 345 static QString businessFaxLabel();
345 346
346 347
347 /** 348 /**
348 Return translated label for isdn field. 349 Return translated label for isdn field.
349 */ 350 */
350 static QString isdnLabel(); 351 static QString isdnLabel();
351 352
352 /** 353 /**
353 Return translated label for pager field. 354 Return translated label for pager field.
354 */ 355 */
355 static QString pagerLabel(); 356 static QString pagerLabel();
356 static QString otherPhoneLabel(); 357 static QString otherPhoneLabel();
357 /** 358 /**
358 Return translated label for sip field. 359 Return translated label for sip field.
359 */ 360 */
360 static QString sipLabel(); 361 static QString sipLabel();
361 362
362 /** 363 /**
363 Return translated label for email field. 364 Return translated label for email field.
364 */ 365 */
365 static QString emailLabel(); 366 static QString emailLabel();
366 367
367 /** 368 /**
368 Set mail client. 369 Set mail client.
369 */ 370 */
370 void setMailer( const QString &mailer ); 371 void setMailer( const QString &mailer );
371 /** 372 /**
372 Return mail client. 373 Return mail client.
373 */ 374 */
374 QString mailer() const; 375 QString mailer() const;
375 /** 376 /**
376 Return translated label for mailer field. 377 Return translated label for mailer field.
377 */ 378 */
378 static QString mailerLabel(); 379 static QString mailerLabel();
379 380
380 /** 381 /**
381 Set time zone. 382 Set time zone.
382 */ 383 */
383 void setTimeZone( const TimeZone &timeZone ); 384 void setTimeZone( const TimeZone &timeZone );
384 /** 385 /**
385 Return time zone. 386 Return time zone.
386 */ 387 */
387 TimeZone timeZone() const; 388 TimeZone timeZone() const;
388 /** 389 /**
389 Return translated label for timeZone field. 390 Return translated label for timeZone field.
390 */ 391 */
391 static QString timeZoneLabel(); 392 static QString timeZoneLabel();
392 393
393 /** 394 /**
394 Set geographic position. 395 Set geographic position.
395 */ 396 */
396 void setGeo( const Geo &geo ); 397 void setGeo( const Geo &geo );
397 /** 398 /**
398 Return geographic position. 399 Return geographic position.
399 */ 400 */
400 Geo geo() const; 401 Geo geo() const;
401 /** 402 /**
402 Return translated label for geo field. 403 Return translated label for geo field.
403 */ 404 */
404 static QString geoLabel(); 405 static QString geoLabel();
405 406
406 /** 407 /**
407 Set title. 408 Set title.
408 */ 409 */
409 void setTitle( const QString &title ); 410 void setTitle( const QString &title );
410 /** 411 /**
411 Return title. 412 Return title.
412 */ 413 */
413 QString title() const; 414 QString title() const;
414 /** 415 /**
415 Return translated label for title field. 416 Return translated label for title field.
416 */ 417 */
417 static QString titleLabel(); 418 static QString titleLabel();
418 419
419 /** 420 /**
420 Set role. 421 Set role.
421 */ 422 */
422 void setRole( const QString &role ); 423 void setRole( const QString &role );
423 /** 424 /**
424 Return role. 425 Return role.
425 */ 426 */
426 QString role() const; 427 QString role() const;
427 /** 428 /**
428 Return translated label for role field. 429 Return translated label for role field.
429 */ 430 */
430 static QString roleLabel(); 431 static QString roleLabel();
431 432
432 /** 433 /**
433 Set organization. 434 Set organization.
434 */ 435 */
435 void setOrganization( const QString &organization ); 436 void setOrganization( const QString &organization );
436 /** 437 /**
437 Return organization. 438 Return organization.
438 */ 439 */
439 QString organization() const; 440 QString organization() const;
440 /** 441 /**
441 Return translated label for organization field. 442 Return translated label for organization field.
442 */ 443 */
443 static QString organizationLabel(); 444 static QString organizationLabel();
444 445
445 /** 446 /**
446 Set note. 447 Set note.
447 */ 448 */
448 void setNote( const QString &note ); 449 void setNote( const QString &note );
449 /** 450 /**
450 Return note. 451 Return note.
451 */ 452 */
452 QString note() const; 453 QString note() const;
453 /** 454 /**
454 Return translated label for note field. 455 Return translated label for note field.
455 */ 456 */
456 static QString noteLabel(); 457 static QString noteLabel();
457 458
458 /** 459 /**
459 Set product identifier. 460 Set product identifier.
460 */ 461 */
461 void setProductId( const QString &productId ); 462 void setProductId( const QString &productId );
462 /** 463 /**
463 Return product identifier. 464 Return product identifier.
464 */ 465 */
465 QString productId() const; 466 QString productId() const;
466 /** 467 /**
467 Return translated label for productId field. 468 Return translated label for productId field.
468 */ 469 */
469 static QString productIdLabel(); 470 static QString productIdLabel();
470 471
471 /** 472 /**
472 Set revision date. 473 Set revision date.
473 */ 474 */
474 void setRevision( const QDateTime &revision ); 475 void setRevision( const QDateTime &revision );
475 /** 476 /**
476 Return revision date. 477 Return revision date.
477 */ 478 */
478 QDateTime revision() const; 479 QDateTime revision() const;
479 /** 480 /**
480 Return translated label for revision field. 481 Return translated label for revision field.
481 */ 482 */
482 static QString revisionLabel(); 483 static QString revisionLabel();
483 484
484 /** 485 /**
485 Set sort string. 486 Set sort string.
486 */ 487 */
487 void setSortString( const QString &sortString ); 488 void setSortString( const QString &sortString );
488 /** 489 /**
489 Return sort string. 490 Return sort string.
490 */ 491 */
491 QString sortString() const; 492 QString sortString() const;
492 /** 493 /**
493 Return translated label for sortString field. 494 Return translated label for sortString field.
494 */ 495 */
495 static QString sortStringLabel(); 496 static QString sortStringLabel();
496 497
497 /** 498 /**
498 Set URL. 499 Set URL.
499 */ 500 */
500 void setUrl( const KURL &url ); 501 void setUrl( const KURL &url );
501 /** 502 /**
502 Return URL. 503 Return URL.
503 */ 504 */
504 KURL url() const; 505 KURL url() const;
505 /** 506 /**
506 Return translated label for url field. 507 Return translated label for url field.
507 */ 508 */
508 static QString urlLabel(); 509 static QString urlLabel();
509 510
510 /** 511 /**
511 Set security class. 512 Set security class.
512 */ 513 */
513 void setSecrecy( const Secrecy &secrecy ); 514 void setSecrecy( const Secrecy &secrecy );
514 /** 515 /**
515 Return security class. 516 Return security class.
516 */ 517 */
517 Secrecy secrecy() const; 518 Secrecy secrecy() const;
518 /** 519 /**
519 Return translated label for secrecy field. 520 Return translated label for secrecy field.
520 */ 521 */
521 static QString secrecyLabel(); 522 static QString secrecyLabel();
522 523
523 /** 524 /**
524 Set logo. 525 Set logo.
525 */ 526 */
526 void setLogo( const Picture &logo ); 527 void setLogo( const Picture &logo );
527 /** 528 /**
528 Return logo. 529 Return logo.
529 */ 530 */
530 Picture logo() const; 531 Picture logo() const;
531 /** 532 /**
532 Return translated label for logo field. 533 Return translated label for logo field.
533 */ 534 */
534 static QString logoLabel(); 535 static QString logoLabel();
535 536
536 /** 537 /**
537 Set photo. 538 Set photo.
538 */ 539 */
539 void setPhoto( const Picture &photo ); 540 void setPhoto( const Picture &photo );
540 /** 541 /**
541 Return photo. 542 Return photo.
542 */ 543 */
543 Picture photo() const; 544 Picture photo() const;
544 /** 545 /**
545 Return translated label for photo field. 546 Return translated label for photo field.
546 */ 547 */
547 static QString photoLabel(); 548 static QString photoLabel();
548 549
549 /** 550 /**
550 Set sound. 551 Set sound.
551 */ 552 */
552 void setSound( const Sound &sound ); 553 void setSound( const Sound &sound );
553 /** 554 /**
554 Return sound. 555 Return sound.
555 */ 556 */
556 Sound sound() const; 557 Sound sound() const;
557 /** 558 /**
558 Return translated label for sound field. 559 Return translated label for sound field.
559 */ 560 */
560 static QString soundLabel(); 561 static QString soundLabel();
561 562
562 /** 563 /**
563 Set agent. 564 Set agent.
564 */ 565 */
565 void setAgent( const Agent &agent ); 566 void setAgent( const Agent &agent );
566 /** 567 /**
567 Return agent. 568 Return agent.
568 */ 569 */
569 Agent agent() const; 570 Agent agent() const;
570 /** 571 /**
571 Return translated label for agent field. 572 Return translated label for agent field.
572 */ 573 */
573 static QString agentLabel(); 574 static QString agentLabel();
574 575
575 /** 576 /**
576 Set name fields by parsing the given string and trying to associate the 577 Set name fields by parsing the given string and trying to associate the
577 parts of the string with according fields. This function should probably 578 parts of the string with according fields. This function should probably
578 be a bit more clever. 579 be a bit more clever.
579 */ 580 */
580 void setNameFromString( const QString & ); 581 void setNameFromString( const QString & );
581 582
582 /** 583 /**
583 Return the name of the addressee. This is calculated from all the name 584 Return the name of the addressee. This is calculated from all the name
584 fields. 585 fields.
585 */ 586 */
586 QString realName() const; 587 QString realName() const;
587 588
588 /** 589 /**
589 Return the name that consists of all name parts. 590 Return the name that consists of all name parts.
590 */ 591 */
591 QString assembledName() const; 592 QString assembledName() const;
592 593
593 /** 594 /**
594 Return email address including real name. 595 Return email address including real name.
595 596
596 @param email Email address to be used to construct the full email string. 597 @param email Email address to be used to construct the full email string.
597 If this is QString::null the preferred email address is used. 598 If this is QString::null the preferred email address is used.
598 */ 599 */
599 QString fullEmail( const QString &email=QString::null ) const; 600 QString fullEmail( const QString &email=QString::null ) const;
600 601
601 /** 602 /**
602 Insert an email address. If the email address already exists in this 603 Insert an email address. If the email address already exists in this
603 addressee it is not duplicated. 604 addressee it is not duplicated.
604 605
605 @param email Email address 606 @param email Email address
606 @param preferred Set to true, if this is the preferred email address of 607 @param preferred Set to true, if this is the preferred email address of
607 the addressee. 608 the addressee.
608 */ 609 */
609 void insertEmail( const QString &email, bool preferred=false ); 610 void insertEmail( const QString &email, bool preferred=false );
610 611
611 /** 612 /**
612 Remove email address. If the email address doesn't exist, nothing happens. 613 Remove email address. If the email address doesn't exist, nothing happens.
613 */ 614 */
614 void removeEmail( const QString &email ); 615 void removeEmail( const QString &email );
615 616
616 /** 617 /**
617 Return preferred email address. This is the first email address or the 618 Return preferred email address. This is the first email address or the
618 last one added with @ref insertEmail() with a set preferred parameter. 619 last one added with @ref insertEmail() with a set preferred parameter.
619 */ 620 */
620 QString preferredEmail() const; 621 QString preferredEmail() const;
621 622
622 /** 623 /**
623 Return list of all email addresses. 624 Return list of all email addresses.
624 */ 625 */
625 QStringList emails() const; 626 QStringList emails() const;
626 627
627 /** 628 /**
628 Set the emails to @param. 629 Set the emails to @param.
629 The first email address gets the preferred one! 630 The first email address gets the preferred one!
630 @param list The list of email addresses. 631 @param list The list of email addresses.
631 */ 632 */
632 void setEmails( const QStringList& list); 633 void setEmails( const QStringList& list);
633 634
634 /** 635 /**
635 Insert a phone number. If a phone number with the same id already exists 636 Insert a phone number. If a phone number with the same id already exists
636 in this addressee it is not duplicated. 637 in this addressee it is not duplicated.
637 */ 638 */
638 void insertPhoneNumber( const PhoneNumber &phoneNumber ); 639 void insertPhoneNumber( const PhoneNumber &phoneNumber );
639 640
640 /** 641 /**
641 Remove phone number. If no phone number with the given id exists for this 642 Remove phone number. If no phone number with the given id exists for this
642 addresse nothing happens. 643 addresse nothing happens.
643 */ 644 */
644 void removePhoneNumber( const PhoneNumber &phoneNumber ); 645 void removePhoneNumber( const PhoneNumber &phoneNumber );
645 646
646 /** 647 /**
647 Return phone number, which matches the given type. 648 Return phone number, which matches the given type.
648 */ 649 */
649 PhoneNumber phoneNumber( int type ) const; 650 PhoneNumber phoneNumber( int type ) const;
651 QString phoneNumberString( int type ) const;
650 652
651 bool matchPhoneNumber( QRegExp* searchExp ) const; 653 bool matchPhoneNumber( QRegExp* searchExp ) const;
652 bool matchAddress( QRegExp* searchExp ) const; 654 bool matchAddress( QRegExp* searchExp ) const;
653 655
654 /** 656 /**
655 Return list of all phone numbers. 657 Return list of all phone numbers.
656 */ 658 */
657 PhoneNumber::List phoneNumbers() const; 659 PhoneNumber::List phoneNumbers() const;
658 660
659 /** 661 /**
660 Return list of phone numbers with a special type. 662 Return list of phone numbers with a special type.
661 */ 663 */
662 PhoneNumber::List phoneNumbers( int type ) const; 664 PhoneNumber::List phoneNumbers( int type ) const;
663 665
664 /** 666 /**
665 Return phone number with the given id. 667 Return phone number with the given id.
666 */ 668 */
667 PhoneNumber findPhoneNumber( const QString &id ) const; 669 PhoneNumber findPhoneNumber( const QString &id ) const;
668 670
669 /** 671 /**
670 Insert a key. If a key with the same id already exists 672 Insert a key. If a key with the same id already exists
671 in this addressee it is not duplicated. 673 in this addressee it is not duplicated.
672 */ 674 */
673 void insertKey( const Key &key ); 675 void insertKey( const Key &key );
674 676
675 /** 677 /**
676 Remove a key. If no key with the given id exists for this 678 Remove a key. If no key with the given id exists for this
677 addresse nothing happens. 679 addresse nothing happens.
678 */ 680 */
679 void removeKey( const Key &key ); 681 void removeKey( const Key &key );
680 682
681 /** 683 /**
682 Return key, which matches the given type. 684 Return key, which matches the given type.
683 If @p type == Key::Custom you can specify a string 685 If @p type == Key::Custom you can specify a string
684 that should match. If you leave the string empty, the first 686 that should match. If you leave the string empty, the first
685 key with a custom value is returned. 687 key with a custom value is returned.
686 */ 688 */
687 Key key( int type, QString customTypeString = QString::null ) const; 689 Key key( int type, QString customTypeString = QString::null ) const;
688 690
689 /** 691 /**
690 Return list of all keys. 692 Return list of all keys.
691 */ 693 */
692 Key::List keys() const; 694 Key::List keys() const;
693 695
694 /** 696 /**
695 Set the list of keys 697 Set the list of keys
696 @param keys The keys to be set. 698 @param keys The keys to be set.
697 */ 699 */
698 void setKeys( const Key::List& keys); 700 void setKeys( const Key::List& keys);
699 701
700 /** 702 /**
701 Return list of keys with a special type. 703 Return list of keys with a special type.
702 If @p type == Key::Custom you can specify a string 704 If @p type == Key::Custom you can specify a string
703 that should match. If you leave the string empty, all custom 705 that should match. If you leave the string empty, all custom
704 keys will be returned. 706 keys will be returned.
705 */ 707 */
706 Key::List keys( int type, QString customTypeString = QString::null ) const; 708 Key::List keys( int type, QString customTypeString = QString::null ) const;
707 709
708 /** 710 /**
709 Return key with the given id. 711 Return key with the given id.
710 */ 712 */
711 Key findKey( const QString &id ) const; 713 Key findKey( const QString &id ) const;
712 714
713 /** 715 /**
714 Insert an address. If an address with the same id already exists 716 Insert an address. If an address with the same id already exists
715 in this addressee it is not duplicated. 717 in this addressee it is not duplicated.
716 */ 718 */
717 void insertAddress( const Address &address ); 719 void insertAddress( const Address &address );
718 720
719 /** 721 /**
720 Remove address. If no address with the given id exists for this 722 Remove address. If no address with the given id exists for this
721 addresse nothing happens. 723 addresse nothing happens.
722 */ 724 */
723 void removeAddress( const Address &address ); 725 void removeAddress( const Address &address );
724 726
725 /** 727 /**
726 Return address, which matches the given type. 728 Return address, which matches the given type.
727 */ 729 */
728 Address address( int type ) const; 730 Address address( int type ) const;
729 731
730 /** 732 /**
731 Return list of all addresses. 733 Return list of all addresses.
732 */ 734 */
733 Address::List addresses() const; 735 Address::List addresses() const;
734 736 Address otherAddress() const;
735 /** 737 /**
736 Return list of addresses with a special type. 738 Return list of addresses with a special type.
737 */ 739 */
738 Address::List addresses( int type ) const; 740 Address::List addresses( int type ) const;
739 741
740 /** 742 /**
741 Return address with the given id. 743 Return address with the given id.
742 */ 744 */
743 Address findAddress( const QString &id ) const; 745 Address findAddress( const QString &id ) const;
744 746
745 /** 747 /**
746 Insert category. If the category already exists it is not duplicated. 748 Insert category. If the category already exists it is not duplicated.
747 */ 749 */
748 void insertCategory( const QString & ); 750 void insertCategory( const QString & );
749 751
750 /** 752 /**
751 Remove category. 753 Remove category.
752 */ 754 */
753 void removeCategory( const QString & ); 755 void removeCategory( const QString & );
754 756
755 /** 757 /**
756 Return, if addressee has the given category. 758 Return, if addressee has the given category.
757 */ 759 */
758 bool hasCategory( const QString & ) const; 760 bool hasCategory( const QString & ) const;
759 761
760 /** 762 /**
761 Set categories to given value. 763 Set categories to given value.
762 */ 764 */
763 void setCategories( const QStringList & ); 765 void setCategories( const QStringList & );
764 766
765 /** 767 /**
766 Return list of all set categories. 768 Return list of all set categories.
767 */ 769 */
768 QStringList categories() const; 770 QStringList categories() const;
769 771
770 /** 772 /**
771 Insert custom entry. The entry is identified by the name of the inserting 773 Insert custom entry. The entry is identified by the name of the inserting
772 application and a unique name. If an entry with the given app and name 774 application and a unique name. If an entry with the given app and name
773 already exists its value is replaced with the new given value. 775 already exists its value is replaced with the new given value.
774 */ 776 */
775 void insertCustom( const QString &app, const QString &name, 777 void insertCustom( const QString &app, const QString &name,
776 const QString &value ); 778 const QString &value );
777 779
778 /** 780 /**
779 Remove custom entry. 781 Remove custom entry.
780 */ 782 */
781 void removeCustom( const QString &app, const QString &name ); 783 void removeCustom( const QString &app, const QString &name );
782 784
783 /** 785 /**
784 Return value of custom entry, identified by app and entry name. 786 Return value of custom entry, identified by app and entry name.
785 */ 787 */
786 QString custom( const QString &app, const QString &name ) const; 788 QString custom( const QString &app, const QString &name ) const;
787 789
788 /** 790 /**
789 Set all custom entries. 791 Set all custom entries.
790 */ 792 */
791 void setCustoms( const QStringList & ); 793 void setCustoms( const QStringList & );
792 794
793 /** 795 /**
794 Return list of all custom entries. 796 Return list of all custom entries.
795 */ 797 */
796 QStringList customs() const; 798 QStringList customs() const;
797 799
798 /** 800 /**
799 Parse full email address. The result is given back in fullName and email. 801 Parse full email address. The result is given back in fullName and email.
800 */ 802 */
801 static void parseEmailAddress( const QString &rawEmail, QString &fullName, 803 static void parseEmailAddress( const QString &rawEmail, QString &fullName,
802 QString &email ); 804 QString &email );
803 805
804 /** 806 /**
805 Debug output. 807 Debug output.
806 */ 808 */
807 void dump() const; 809 void dump() const;
808 810
809 /** 811 /**
810 Returns string representation of the addressee. 812 Returns string representation of the addressee.
811 */ 813 */
812 QString asString() const; 814 QString asString() const;
813 815
814 /** 816 /**
815 Set resource where the addressee is from. 817 Set resource where the addressee is from.
816 */ 818 */
817 void setResource( Resource *resource ); 819 void setResource( Resource *resource );
818 820
819 /** 821 /**
820 Return pointer to resource. 822 Return pointer to resource.
821 */ 823 */
822 Resource *resource() const; 824 Resource *resource() const;
823 825
824 /** 826 /**
825 Return resourcelabel. 827 Return resourcelabel.
826 */ 828 */
827 //US 829 //US
828 static QString resourceLabel(); 830 static QString resourceLabel();
829 static QString categoryLabel(); 831 static QString categoryLabel();
830 /** 832 /**
831 Mark addressee as changed. 833 Mark addressee as changed.
832 */ 834 */
833 void setChanged( bool value ); 835 void setChanged( bool value );
834 836
835 /** 837 /**
836 Return whether the addressee is changed. 838 Return whether the addressee is changed.
837 */ 839 */
838 bool changed() const; 840 bool changed() const;
839 841
840 void setTagged( bool value ); 842 void setTagged( bool value );
841 bool tagged() const; 843 bool tagged() const;
842 844
843 private: 845 private:
844 Addressee copy(); 846 Addressee copy();
845 void detach(); 847 void detach();
846 848
847 struct AddresseeData; 849 struct AddresseeData;
848 mutable KSharedPtr<AddresseeData> mData; 850 mutable KSharedPtr<AddresseeData> mData;
849}; 851};
850 852
851QDataStream &operator<<( QDataStream &, const Addressee & ); 853QDataStream &operator<<( QDataStream &, const Addressee & );
852QDataStream &operator>>( QDataStream &, Addressee & ); 854QDataStream &operator>>( QDataStream &, Addressee & );
853 855
854} 856}
855 857
856#endif 858#endif
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp
index 12b9b09..1752745 100644
--- a/kabc/phonenumber.cpp
+++ b/kabc/phonenumber.cpp
@@ -1,374 +1,398 @@
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#include <kapplication.h> 28#include <kapplication.h>
29#include <klocale.h> 29#include <klocale.h>
30 30
31#include "phonenumber.h" 31#include "phonenumber.h"
32 32
33using namespace KABC; 33using namespace KABC;
34 34
35PhoneNumber::PhoneNumber() : 35PhoneNumber::PhoneNumber() :
36 mType( Home ) 36 mType( Home )
37{ 37{
38 init(); 38 init();
39} 39}
40 40
41PhoneNumber::PhoneNumber( const QString &number, int type ) : 41PhoneNumber::PhoneNumber( const QString &number, int type ) :
42 mType( type ), mNumber( number ) 42 mType( type ), mNumber( number )
43{ 43{
44 init(); 44 init();
45} 45}
46 46
47PhoneNumber::~PhoneNumber() 47PhoneNumber::~PhoneNumber()
48{ 48{
49} 49}
50 50
51void PhoneNumber::init() 51void PhoneNumber::init()
52{ 52{
53 mId = KApplication::randomString( 8 ); 53 mId = KApplication::randomString( 8 );
54} 54}
55 55
56bool PhoneNumber::operator==( const PhoneNumber &p ) const 56bool PhoneNumber::operator==( const PhoneNumber &p ) const
57{ 57{
58 if ( mNumber != p.mNumber ) return false; 58 if ( mNumber != p.mNumber ) return false;
59 if ( mType != p.mType ) return false; 59 if ( mType != p.mType ) return false;
60 60
61 return true; 61 return true;
62} 62}
63 63
64bool PhoneNumber::operator!=( const PhoneNumber &p ) const 64bool PhoneNumber::operator!=( const PhoneNumber &p ) const
65{ 65{
66 return !( p == *this ); 66 return !( p == *this );
67} 67}
68void PhoneNumber::makeCompat() 68void PhoneNumber::makeCompat()
69{ 69{
70 mType = getCompatType( mType ); 70 mType = getCompatType( mType );
71} 71}
72int PhoneNumber::getCompatType( int type ) 72int PhoneNumber::getCompatType( int type )
73{ 73{
74 74
75 if ((type & Cell) == Cell) { 75 if ((type & Cell) == Cell) {
76 if ((type & Work) == Work) 76 if ((type & Work) == Work)
77 return Car; 77 return Car;
78 return Cell; 78 return Cell;
79 } 79 }
80 if ((type & Home) == Home) { 80 if ((type & Home) == Home) {
81 if ((type & Pref) == Pref) 81 if ((type & Pref) == Pref)
82 return (Home | Pref); 82 return (Home | Pref);
83 if ((type & Fax) == Fax) 83 if ((type & Fax) == Fax)
84 return (Home | Fax); 84 return (Home | Fax);
85 return (Home); 85 return (Home);
86 } 86 }
87 if ((type & Work) == Work) { 87 if ((type & Work) == Work) {
88 if ((type & Pref) == Pref) 88 if ((type & Pref) == Pref)
89 return (Work| Pref); 89 return (Work| Pref);
90 if ((type & Fax) == Fax) 90 if ((type & Fax) == Fax)
91 return (Fax |Work); 91 return (Fax |Work);
92 if ((type & Msg) == Msg) { 92 if ((type & Msg) == Msg) {
93 if ((type & Voice) == Voice) 93 if ((type & Voice) == Voice)
94 return ( Msg | Voice |Work); 94 return ( Msg | Voice |Work);
95 return ( Msg | Work); 95 return ( Msg | Work);
96 } 96 }
97 return Work; 97 return Work;
98 } 98 }
99 if ((type & Pcs) == Pcs) { 99 if ((type & Pcs) == Pcs) {
100 if ((type & Pref) == Pref) 100 if ((type & Pref) == Pref)
101 return Pcs | Pref; 101 return Pcs | Pref;
102 if ((type & Voice) == Voice) 102 if ((type & Voice) == Voice)
103 return Pcs | Voice; 103 return Pcs | Voice;
104 return Pcs; 104 return Pcs;
105 } 105 }
106 if ((type & Car) == Car) 106 if ((type & Car) == Car)
107 return Car; 107 return Car;
108 if ((type & Pager) == Pager) 108 if ((type & Pager) == Pager)
109 return Pager; 109 return Pager;
110 if ((type & Isdn) == Isdn) 110 if ((type & Isdn) == Isdn)
111 return Isdn; 111 return Isdn;
112#if 0 112#if 0
113 if ((type & Video) == Video) 113 if ((type & Video) == Video)
114 return Video; 114 return Video;
115#endif 115#endif
116 if ((type & Msg) == Msg) 116 if ((type & Msg) == Msg)
117 return Msg; 117 return Msg;
118 if ((type & Fax) == Fax) 118 if ((type & Fax) == Fax)
119 return Fax; 119 return Fax;
120 120
121 if ((type & Pref) == Pref) 121 if ((type & Pref) == Pref)
122 return Pref; 122 return Pref;
123 123
124 return Voice; 124 return Voice;
125 125
126} 126}
127bool PhoneNumber::simplifyNumber() 127bool PhoneNumber::simplifyNumber()
128{ 128{
129 QString Number; 129 QString Number;
130 int i; 130 int i;
131 Number = mNumber.stripWhiteSpace (); 131 Number = mNumber.stripWhiteSpace ();
132 mNumber = ""; 132 mNumber = "";
133 for ( i = 0; i < Number.length(); ++i) { 133 for ( i = 0; i < Number.length(); ++i) {
134 if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' ) 134 if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' )
135 mNumber += Number.at(i); 135 mNumber += Number.at(i);
136 } 136 }
137 return ( mNumber.length() > 0 ); 137 return ( mNumber.length() > 0 );
138} 138}
139// make cellphone compatible 139// make cellphone compatible
140void PhoneNumber::simplifyType() 140void PhoneNumber::simplifyType()
141{ 141{
142 if ( mType & Fax ) mType = Fax; 142 if ( mType & Fax ) mType = Fax;
143 else if ( mType & Cell ) mType = Cell; 143 else if ( mType & Cell ) mType = Cell;
144 else if ( mType & Work ) mType = Work ; 144 else if ( mType & Work ) mType = Work ;
145 else if ( mType & Home ) mType = Home; 145 else if ( mType & Home ) mType = Home;
146 else mType = Pref; 146 else mType = Pref;
147} 147}
148bool PhoneNumber::contains( const PhoneNumber &p ) 148bool PhoneNumber::contains( const PhoneNumber &p )
149{ 149{
150 PhoneNumber myself; 150 PhoneNumber myself;
151 PhoneNumber other; 151 PhoneNumber other;
152 myself = *this; 152 myself = *this;
153 other = p; 153 other = p;
154 myself.simplifyNumber(); 154 myself.simplifyNumber();
155 other.simplifyNumber(); 155 other.simplifyNumber();
156 if ( myself.number() != other.number ()) 156 if ( myself.number() != other.number ())
157 return false; 157 return false;
158 myself.simplifyType(); 158 myself.simplifyType();
159 other.simplifyType(); 159 other.simplifyType();
160 if ( myself.type() == other.type()) 160 if ( myself.type() == other.type())
161 return true; 161 return true;
162 return false; 162 return false;
163} 163}
164 164
165void PhoneNumber::setId( const QString &id ) 165void PhoneNumber::setId( const QString &id )
166{ 166{
167 mId = id; 167 mId = id;
168} 168}
169 169
170QString PhoneNumber::id() const 170QString PhoneNumber::id() const
171{ 171{
172 return mId; 172 return mId;
173} 173}
174 174
175void PhoneNumber::setNumber( const QString &number ) 175void PhoneNumber::setNumber( const QString &number )
176{ 176{
177 mNumber = number; 177 mNumber = number;
178} 178}
179 179
180QString PhoneNumber::number() const 180QString PhoneNumber::number() const
181{ 181{
182 return mNumber; 182 return mNumber;
183} 183}
184 184
185void PhoneNumber::setType( int type ) 185void PhoneNumber::setType( int type )
186{ 186{
187 mType = type; 187 mType = type;
188} 188}
189 189
190int PhoneNumber::type() const 190int PhoneNumber::type() const
191{ 191{
192 return mType; 192 return mType;
193} 193}
194 194
195QString PhoneNumber::typeLabel() const 195QString PhoneNumber::typeLabel() const
196{ 196{
197 QString label; 197 QString label;
198 bool first = true; 198 bool first = true;
199 199
200 TypeList list = typeList(); 200 TypeList list = typeList();
201 201
202 TypeList::Iterator it; 202 TypeList::Iterator it;
203 for ( it = list.begin(); it != list.end(); ++it ) { 203 for ( it = list.begin(); it != list.end(); ++it ) {
204 if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { 204 if ( ( type() & (*it) ) && ( (*it) != Pref ) ) {
205 label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); 205 label.append( ( first ? "" : "/" ) + typeLabel( *it ) );
206 if ( first ) 206 if ( first )
207 first = false; 207 first = false;
208 } 208 }
209 } 209 }
210 210
211 return label; 211 return label;
212} 212}
213 213
214QString PhoneNumber::label() const 214QString PhoneNumber::label() const
215{ 215{
216 return typeLabel( type() ); 216 return typeLabel( type() );
217} 217}
218 218
219PhoneNumber::TypeList PhoneNumber::typeList() 219PhoneNumber::TypeList PhoneNumber::typeList()
220{ 220{
221 TypeList list; 221 TypeList list;
222 222
223 list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video 223 list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video
224 << Bbs << Modem << Car << Isdn << Pcs << Pager; 224 << Bbs << Modem << Car << Isdn << Pcs << Pager;
225 225
226 return list; 226 return list;
227} 227}
228PhoneNumber::TypeList PhoneNumber::supportedTypeList() 228PhoneNumber::TypeList PhoneNumber::supportedTypeList()
229{ 229{
230 static TypeList list; 230 static TypeList list;
231 if ( list.count() == 0 ) 231 if ( list.count() == 0 )
232 list << (Home| Pref) << (Work| Pref) << Cell <<(Pcs|Pref)<< (Pcs|Voice)<< Home << Work << Car << Pcs <<(Work| Msg | Voice) << (Work| Msg) << (Home | Fax) << (Work| Fax) << Fax<< Pager << Isdn << Msg << Pref << Voice; 232 list << (Home| Pref) << (Work| Pref) << Cell <<(Pcs|Pref)<< (Pcs|Voice)<< Home << Work << Car << Pcs <<(Work| Msg | Voice) << (Work| Msg) << (Home | Fax) << (Work| Fax) << Fax<< Pager << Isdn << Msg << Pref << Voice;
233 return list; 233 return list;
234} 234}
235
236#if 0
237Home| Pref i18n("Home") Home
238Work| Pref i18n("Work") Business
239Cell i18n("Mobile") Mobile
240Pcs|Pref i18n("SiP") Radio
241Pcs|Voice i18n("VoIP") TTY/TTD
242Home i18n("Home2") Home 2
243Work i18n("Work2") Business 2
244Car i18n("Mobile2") Car
245Pcs i18n("SiP2") Telex
246Work| Msg | Voice i18n("Assistent") Assistent
247Work| Msg i18n("Company") Company
248Home | Fax i18n("Fax (Home)") Home Fax
249Work| Fax i18n("Fax (Work)") Business Fax
250Fax i18n("Fax (Other)") Other Fax
251Pager i18n("Pager") Pager
252Isdn i18n("ISDN") Isdn
253Msg i18n("Callback") Callback
254Pref i18n("Primary") Primary
255Voice; i18n("Other") Other
256
257#endif
258
235QStringList PhoneNumber::supportedTypeListNames() 259QStringList PhoneNumber::supportedTypeListNames()
236{ 260{
237 static QStringList list; 261 static QStringList list;
238 if ( list.count() == 0 ) 262 if ( list.count() == 0 )
239 list << i18n("Home") << i18n("Work") << i18n("Mobile") << i18n("SiP") << i18n("VoIP") <<i18n("Home2")<< i18n("Work2") << i18n("Mobile2") << i18n("SiP2") << i18n("Assistent") << i18n("Company") << i18n("Fax (Home)") << i18n("Fax (Work)") << i18n("Fax (Other)") << i18n("Pager") << i18n("ISDN") << i18n("Callback") << i18n("Primary")<< i18n("Other"); 263 list << i18n("Home") << i18n("Work") << i18n("Mobile") << i18n("SiP") << i18n("VoIP") <<i18n("Home2")<< i18n("Work2") << i18n("Mobile2") << i18n("SiP2") << i18n("Assistent") << i18n("Company") << i18n("Fax (Home)") << i18n("Fax (Work)") << i18n("Fax (Other)") << i18n("Pager") << i18n("ISDN") << i18n("Callback") << i18n("Primary")<< i18n("Other");
240 return list; 264 return list;
241} 265}
242 266
243int PhoneNumber::typeListIndex4Type(int type ) 267int PhoneNumber::typeListIndex4Type(int type )
244{ 268{
245 TypeList list = supportedTypeList(); 269 TypeList list = supportedTypeList();
246 int i = 0; 270 int i = 0;
247 while ( i < list.count() ) { 271 while ( i < list.count() ) {
248 if ( list [i] == type ) 272 if ( list [i] == type )
249 return i; 273 return i;
250 ++i; 274 ++i;
251 } 275 }
252 return list.count()-1; 276 return list.count()-1;
253} 277}
254 278
255QString PhoneNumber::label( int type ) 279QString PhoneNumber::label( int type )
256{ 280{
257 return typeLabel( type ); 281 return typeLabel( type );
258} 282}
259 283
260QString PhoneNumber::typeLabel( int type ) 284QString PhoneNumber::typeLabel( int type )
261{ 285{
262 if ((type & Cell) == Cell) 286 if ((type & Cell) == Cell)
263 return i18n("Mobile"); 287 return i18n("Mobile");
264 if ((type & Home) == Home) { 288 if ((type & Home) == Home) {
265 if ((type & Pref) == Pref) 289 if ((type & Pref) == Pref)
266 return i18n("Home"); 290 return i18n("Home");
267 if ((type & Fax) == Fax) 291 if ((type & Fax) == Fax)
268 return i18n("Fax (Home)"); 292 return i18n("Fax (Home)");
269 return i18n("Home2"); 293 return i18n("Home2");
270 } 294 }
271 295
272 if ((type & Work) == Work) { 296 if ((type & Work) == Work) {
273 if ((type & Pref) == Pref) 297 if ((type & Pref) == Pref)
274 return i18n("Work"); 298 return i18n("Work");
275 if ((type & Fax) == Fax) 299 if ((type & Fax) == Fax)
276 return i18n("Fax (Work)"); 300 return i18n("Fax (Work)");
277 if ((type & Msg) == Msg) { 301 if ((type & Msg) == Msg) {
278 if ((type & Voice) == Voice) 302 if ((type & Voice) == Voice)
279 return i18n("Assistent"); 303 return i18n("Assistent");
280 return i18n("Company"); 304 return i18n("Company");
281 } 305 }
282 return i18n("Work2"); 306 return i18n("Work2");
283 } 307 }
284 if ((type & Pcs) == Pcs) { 308 if ((type & Pcs) == Pcs) {
285 if ((type & Pref) == Pref) 309 if ((type & Pref) == Pref)
286 return i18n("SiP"); 310 return i18n("SiP");
287 if ((type & Voice) == Voice) 311 if ((type & Voice) == Voice)
288 return i18n("VoIP"); 312 return i18n("VoIP");
289 return i18n("SiP2"); 313 return i18n("SiP2");
290 } 314 }
291 if ((type & Car) == Car) 315 if ((type & Car) == Car)
292 return i18n("Mobile2"); 316 return i18n("Mobile2");
293 if ((type & Pager) == Pager) 317 if ((type & Pager) == Pager)
294 return i18n("Pager"); 318 return i18n("Pager");
295 if ((type & Isdn) == Isdn) 319 if ((type & Isdn) == Isdn)
296 return i18n("ISDN"); 320 return i18n("ISDN");
297 if ((type & Video) == Video) 321 if ((type & Video) == Video)
298 return i18n("Video"); 322 return i18n("Video");
299 323
300 if ((type & Msg) == Msg) 324 if ((type & Msg) == Msg)
301 return i18n("Callback"); 325 return i18n("Callback");
302 if ((type & Fax) == Fax) 326 if ((type & Fax) == Fax)
303 return i18n("Fax (Other)"); 327 return i18n("Fax (Other)");
304 328
305 if ((type & Pref) == Pref) 329 if ((type & Pref) == Pref)
306 return i18n("Primary"); 330 return i18n("Primary");
307 331
308 332
309 return i18n("Other"); 333 return i18n("Other");
310 334
311 335
312#if 0 336#if 0
313 337
314 338
315 339
316 QString typeString; 340 QString typeString;
317 341
318 342
319 if ((type & Cell) == Cell) 343 if ((type & Cell) == Cell)
320 typeString += i18n("Mobile") +" "; 344 typeString += i18n("Mobile") +" ";
321 if ((type & Home) == Home) 345 if ((type & Home) == Home)
322 typeString += i18n("Home")+" "; 346 typeString += i18n("Home")+" ";
323 else if ((type & Work) == Work) 347 else if ((type & Work) == Work)
324 typeString += i18n("Work")+" "; 348 typeString += i18n("Work")+" ";
325 349
326 if ((type & Sip) == Sip) 350 if ((type & Sip) == Sip)
327 typeString += i18n("SIP")+" "; 351 typeString += i18n("SIP")+" ";
328 if ((type & Car) == Car) 352 if ((type & Car) == Car)
329 typeString += i18n("Car")+" "; 353 typeString += i18n("Car")+" ";
330 354
331 if ((type & Fax) == Fax) 355 if ((type & Fax) == Fax)
332 typeString += i18n("Fax"); 356 typeString += i18n("Fax");
333 else if ((type & Msg) == Msg) 357 else if ((type & Msg) == Msg)
334 typeString += i18n("Messenger"); 358 typeString += i18n("Messenger");
335 else if ((type & Video) == Video) 359 else if ((type & Video) == Video)
336 typeString += i18n("Video"); 360 typeString += i18n("Video");
337 else if ((type & Bbs) == Bbs) 361 else if ((type & Bbs) == Bbs)
338 typeString += i18n("Mailbox"); 362 typeString += i18n("Mailbox");
339 else if ((type & Modem) == Modem) 363 else if ((type & Modem) == Modem)
340 typeString += i18n("Modem"); 364 typeString += i18n("Modem");
341 else if ((type & Isdn) == Isdn) 365 else if ((type & Isdn) == Isdn)
342 typeString += i18n("ISDN"); 366 typeString += i18n("ISDN");
343 else if ((type & Pcs) == Pcs) 367 else if ((type & Pcs) == Pcs)
344 typeString += i18n("PCS"); 368 typeString += i18n("PCS");
345 else if ((type & Pager) == Pager) 369 else if ((type & Pager) == Pager)
346 typeString += i18n("Pager"); 370 typeString += i18n("Pager");
347 // add the prefered flag 371 // add the prefered flag
348 /* 372 /*
349 if ((type & Pref) == Pref) 373 if ((type & Pref) == Pref)
350 typeString += i18n("(p)"); 374 typeString += i18n("(p)");
351 */ 375 */
352 //if we still have no match, return "other" 376 //if we still have no match, return "other"
353 if (typeString.isEmpty()) { 377 if (typeString.isEmpty()) {
354 if ((type & Voice) == Voice) 378 if ((type & Voice) == Voice)
355 return i18n("Voice"); 379 return i18n("Voice");
356 else 380 else
357 return i18n("Other"); 381 return i18n("Other");
358 } 382 }
359 383
360 return typeString.stripWhiteSpace(); 384 return typeString.stripWhiteSpace();
361#endif 385#endif
362} 386}
363 387
364QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) 388QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone )
365{ 389{
366 return s << phone.mId << phone.mType << phone.mNumber; 390 return s << phone.mId << phone.mType << phone.mNumber;
367} 391}
368 392
369QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) 393QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone )
370{ 394{
371 s >> phone.mId >> phone.mType >> phone.mNumber; 395 s >> phone.mId >> phone.mType >> phone.mNumber;
372 396
373 return s; 397 return s;
374} 398}
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 7d8586a..ab2824c 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,3500 +1,3586 @@
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 Async a special exception, permission is given to link this program 19 Async a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/*s 24/*s
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 "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99#include <kprefsdialog.h> 99#include <kprefsdialog.h>
100 100
101 101
102//#include <qlabel.h> 102//#include <qlabel.h>
103 103
104 104
105#ifndef DESKTOP_VERSION 105#ifndef DESKTOP_VERSION
106#include <qpe/ir.h> 106#include <qpe/ir.h>
107#include <qpe/qpemenubar.h> 107#include <qpe/qpemenubar.h>
108#include <qtopia/qcopenvelope_qws.h> 108#include <qtopia/qcopenvelope_qws.h>
109#else 109#else
110 110
111#include <qmenubar.h> 111#include <qmenubar.h>
112#endif 112#endif
113 113
114#endif // KAB_EMBEDDED 114#endif // KAB_EMBEDDED
115#include "kcmconfigs/kcmkabconfig.h" 115#include "kcmconfigs/kcmkabconfig.h"
116#include "kcmconfigs/kcmkdepimconfig.h" 116#include "kcmconfigs/kcmkdepimconfig.h"
117#include "kpimglobalprefs.h" 117#include "kpimglobalprefs.h"
118#include "externalapphandler.h" 118#include "externalapphandler.h"
119#include "xxportselectdialog.h" 119#include "xxportselectdialog.h"
120 120
121 121
122#include <kresources/selectdialog.h> 122#include <kresources/selectdialog.h>
123#include <kmessagebox.h> 123#include <kmessagebox.h>
124 124
125#include <picture.h> 125#include <picture.h>
126#include <resource.h> 126#include <resource.h>
127 127
128//US#include <qsplitter.h> 128//US#include <qsplitter.h>
129#include <qmap.h> 129#include <qmap.h>
130#include <qdir.h> 130#include <qdir.h>
131#include <qfile.h> 131#include <qfile.h>
132#include <qvbox.h> 132#include <qvbox.h>
133#include <qlayout.h> 133#include <qlayout.h>
134#include <qclipboard.h> 134#include <qclipboard.h>
135#include <qtextstream.h> 135#include <qtextstream.h>
136#include <qradiobutton.h> 136#include <qradiobutton.h>
137#include <qbuttongroup.h> 137#include <qbuttongroup.h>
138 138
139#include <libkdepim/categoryselectdialog.h> 139#include <libkdepim/categoryselectdialog.h>
140#include <libkdepim/categoryeditdialog.h> 140#include <libkdepim/categoryeditdialog.h>
141#include <kabc/vcardconverter.h> 141#include <kabc/vcardconverter.h>
142 142
143 143
144#include "addresseeutil.h" 144#include "addresseeutil.h"
145#include "undocmds.h" 145#include "undocmds.h"
146#include "addresseeeditordialog.h" 146#include "addresseeeditordialog.h"
147#include "viewmanager.h" 147#include "viewmanager.h"
148#include "details/detailsviewcontainer.h" 148#include "details/detailsviewcontainer.h"
149#include "kabprefs.h" 149#include "kabprefs.h"
150#include "xxportmanager.h" 150#include "xxportmanager.h"
151#include "incsearchwidget.h" 151#include "incsearchwidget.h"
152#include "jumpbuttonbar.h" 152#include "jumpbuttonbar.h"
153#include "extensionmanager.h" 153#include "extensionmanager.h"
154#include "addresseeconfig.h" 154#include "addresseeconfig.h"
155#include "nameeditdialog.h" 155#include "nameeditdialog.h"
156#include <kcmultidialog.h> 156#include <kcmultidialog.h>
157 157
158#ifdef _WIN32_ 158#ifdef _WIN32_
159#ifdef _OL_IMPORT_ 159#ifdef _OL_IMPORT_
160#include "kaimportoldialog.h" 160#include "kaimportoldialog.h"
161#include <libkdepim/ol_access.h>
161#endif 162#endif
162#else 163#else
163#include <unistd.h> 164#include <unistd.h>
164#endif 165#endif
165// sync includes 166// sync includes
166#include <libkdepim/ksyncprofile.h> 167#include <libkdepim/ksyncprofile.h>
167#include <libkdepim/ksyncprefsdialog.h> 168#include <libkdepim/ksyncprefsdialog.h>
168 169
169 170
170class KABCatPrefs : public QDialog 171class KABCatPrefs : public QDialog
171{ 172{
172 public: 173 public:
173 KABCatPrefs( QWidget *parent=0, const char *name=0 ) : 174 KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
174 QDialog( parent, name, true ) 175 QDialog( parent, name, true )
175 { 176 {
176 setCaption( i18n("Manage new Categories") ); 177 setCaption( i18n("Manage new Categories") );
177 QVBoxLayout* lay = new QVBoxLayout( this ); 178 QVBoxLayout* lay = new QVBoxLayout( this );
178 lay->setSpacing( 3 ); 179 lay->setSpacing( 3 );
179 lay->setMargin( 3 ); 180 lay->setMargin( 3 );
180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 181 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
181 lay->addWidget( lab ); 182 lay->addWidget( lab );
182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 183 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
183 lay->addWidget( format ); 184 lay->addWidget( format );
184 format->setExclusive ( true ) ; 185 format->setExclusive ( true ) ;
185 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 186 addCatBut = new QRadioButton(i18n("Add to category list"), format );
186 new QRadioButton(i18n("Remove from addressees"), format ); 187 new QRadioButton(i18n("Remove from addressees"), format );
187 addCatBut->setChecked( true ); 188 addCatBut->setChecked( true );
188 QPushButton * ok = new QPushButton( i18n("OK"), this ); 189 QPushButton * ok = new QPushButton( i18n("OK"), this );
189 lay->addWidget( ok ); 190 lay->addWidget( ok );
190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 191 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
191 lay->addWidget( cancel ); 192 lay->addWidget( cancel );
192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 193 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 194 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
194 resize( 200, 200 ); 195 resize( 200, 200 );
195 } 196 }
196 197
197 bool addCat() { return addCatBut->isChecked(); } 198 bool addCat() { return addCatBut->isChecked(); }
198private: 199private:
199 QRadioButton* addCatBut; 200 QRadioButton* addCatBut;
200}; 201};
201 202
202class KABFormatPrefs : public QDialog 203class KABFormatPrefs : public QDialog
203{ 204{
204 public: 205 public:
205 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : 206 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) :
206 QDialog( parent, name, true ) 207 QDialog( parent, name, true )
207 { 208 {
208 setCaption( i18n("Set formatted name") ); 209 setCaption( i18n("Set formatted name") );
209 QVBoxLayout* lay = new QVBoxLayout( this ); 210 QVBoxLayout* lay = new QVBoxLayout( this );
210 lay->setSpacing( 3 ); 211 lay->setSpacing( 3 );
211 lay->setMargin( 3 ); 212 lay->setMargin( 3 );
212 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); 213 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this );
213 lay->addWidget( lab ); 214 lay->addWidget( lab );
214 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); 215 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this );
215 lay->addWidget( format ); 216 lay->addWidget( format );
216 format->setExclusive ( true ) ; 217 format->setExclusive ( true ) ;
217 simple = new QRadioButton(i18n("Simple: James Bond"), format ); 218 simple = new QRadioButton(i18n("Simple: James Bond"), format );
218 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); 219 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format );
219 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); 220 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format );
220 company = new QRadioButton(i18n("Organization: MI6"), format ); 221 company = new QRadioButton(i18n("Organization: MI6"), format );
221 simple->setChecked( true ); 222 simple->setChecked( true );
222 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); 223 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this);
223 lay->addWidget( setCompany ); 224 lay->addWidget( setCompany );
224 QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); 225 QPushButton * ok = new QPushButton( i18n("Select contact list"), this );
225 lay->addWidget( ok ); 226 lay->addWidget( ok );
226 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 227 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
227 lay->addWidget( cancel ); 228 lay->addWidget( cancel );
228 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 229 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
229 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 230 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
230 //resize( 200, 200 ); 231 //resize( 200, 200 );
231 232
232 } 233 }
233public: 234public:
234 QRadioButton* simple, *full, *reverse, *company; 235 QRadioButton* simple, *full, *reverse, *company;
235 QCheckBox* setCompany; 236 QCheckBox* setCompany;
236}; 237};
237 238
238 239
239 240
240class KAex2phonePrefs : public QDialog 241class KAex2phonePrefs : public QDialog
241{ 242{
242 public: 243 public:
243 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 244 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
244 QDialog( parent, name, true ) 245 QDialog( parent, name, true )
245 { 246 {
246 setCaption( i18n("Export to phone options") ); 247 setCaption( i18n("Export to phone options") );
247 QVBoxLayout* lay = new QVBoxLayout( this ); 248 QVBoxLayout* lay = new QVBoxLayout( this );
248 lay->setSpacing( 3 ); 249 lay->setSpacing( 3 );
249 lay->setMargin( 3 ); 250 lay->setMargin( 3 );
250 QLabel *lab; 251 QLabel *lab;
251 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 252 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
252 lab->setAlignment (AlignHCenter ); 253 lab->setAlignment (AlignHCenter );
253 QHBox* temphb; 254 QHBox* temphb;
254 temphb = new QHBox( this ); 255 temphb = new QHBox( this );
255 new QLabel( i18n("I/O device: "), temphb ); 256 new QLabel( i18n("I/O device: "), temphb );
256 mPhoneDevice = new QLineEdit( temphb); 257 mPhoneDevice = new QLineEdit( temphb);
257 lay->addWidget( temphb ); 258 lay->addWidget( temphb );
258 temphb = new QHBox( this ); 259 temphb = new QHBox( this );
259 new QLabel( i18n("Connection: "), temphb ); 260 new QLabel( i18n("Connection: "), temphb );
260 mPhoneConnection = new QLineEdit( temphb); 261 mPhoneConnection = new QLineEdit( temphb);
261 lay->addWidget( temphb ); 262 lay->addWidget( temphb );
262 temphb = new QHBox( this ); 263 temphb = new QHBox( this );
263 new QLabel( i18n("Model(opt.): "), temphb ); 264 new QLabel( i18n("Model(opt.): "), temphb );
264 mPhoneModel = new QLineEdit( temphb); 265 mPhoneModel = new QLineEdit( temphb);
265 lay->addWidget( temphb ); 266 lay->addWidget( temphb );
266 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 267 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
267 // lay->addWidget( mWriteToSim ); 268 // lay->addWidget( mWriteToSim );
268 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 269 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
269 lab->setAlignment (AlignHCenter); 270 lab->setAlignment (AlignHCenter);
270 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 271 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
271 lay->addWidget( ok ); 272 lay->addWidget( ok );
272 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 273 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
273 lay->addWidget( cancel ); 274 lay->addWidget( cancel );
274 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 275 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
275 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 276 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
276 resize( 220, 240 ); 277 resize( 220, 240 );
277 278
278 } 279 }
279 280
280public: 281public:
281 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 282 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
282 QCheckBox* mWriteToSim; 283 QCheckBox* mWriteToSim;
283}; 284};
284 285
285 286
286bool pasteWithNewUid = true; 287bool pasteWithNewUid = true;
287 288
288#ifdef KAB_EMBEDDED 289#ifdef KAB_EMBEDDED
289KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 290KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
290 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 291 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
291 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 292 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
292 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 293 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
293#else //KAB_EMBEDDED 294#else //KAB_EMBEDDED
294KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 295KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
295 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 296 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
296 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 297 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
297 mReadWrite( readWrite ), mModified( false ) 298 mReadWrite( readWrite ), mModified( false )
298#endif //KAB_EMBEDDED 299#endif //KAB_EMBEDDED
299{ 300{
300 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 301 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
301 // syncManager->setBlockSave(false); 302 // syncManager->setBlockSave(false);
302 mIncSearchWidget = 0; 303 mIncSearchWidget = 0;
303 mMiniSplitter = 0; 304 mMiniSplitter = 0;
304 mExtensionBarSplitter = 0; 305 mExtensionBarSplitter = 0;
305 mIsPart = !parent->inherits( "KAddressBookMain" ); 306 mIsPart = !parent->inherits( "KAddressBookMain" );
306 mAddressBook = KABC::StdAddressBook::selfNoLoad(); 307 mAddressBook = KABC::StdAddressBook::selfNoLoad();
307 KABC::StdAddressBook::setAutomaticSave( false ); 308 KABC::StdAddressBook::setAutomaticSave( false );
308 309
309#ifndef KAB_EMBEDDED 310#ifndef KAB_EMBEDDED
310 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 311 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
311#endif //KAB_EMBEDDED 312#endif //KAB_EMBEDDED
312 313
313 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 314 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
314 SLOT( addressBookChanged() ) ); 315 SLOT( addressBookChanged() ) );
315 316
316#if 0 317#if 0
317 // LR moved to addressbook init method 318 // LR moved to addressbook init method
318 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 319 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
319 "X-Department", "KADDRESSBOOK" ); 320 "X-Department", "KADDRESSBOOK" );
320 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 321 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
321 "X-Profession", "KADDRESSBOOK" ); 322 "X-Profession", "KADDRESSBOOK" );
322 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 323 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
323 "X-AssistantsName", "KADDRESSBOOK" ); 324 "X-AssistantsName", "KADDRESSBOOK" );
324 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 325 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
325 "X-ManagersName", "KADDRESSBOOK" ); 326 "X-ManagersName", "KADDRESSBOOK" );
326 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 327 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
327 "X-SpousesName", "KADDRESSBOOK" ); 328 "X-SpousesName", "KADDRESSBOOK" );
328 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 329 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
329 "X-Office", "KADDRESSBOOK" ); 330 "X-Office", "KADDRESSBOOK" );
330 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 331 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
331 "X-IMAddress", "KADDRESSBOOK" ); 332 "X-IMAddress", "KADDRESSBOOK" );
332 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 333 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
333 "X-Anniversary", "KADDRESSBOOK" ); 334 "X-Anniversary", "KADDRESSBOOK" );
334 335
335 //US added this field to become compatible with Opie/qtopia addressbook 336 //US added this field to become compatible with Opie/qtopia addressbook
336 // values can be "female" or "male" or "". An empty field represents undefined. 337 // values can be "female" or "male" or "". An empty field represents undefined.
337 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 338 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
338 "X-Gender", "KADDRESSBOOK" ); 339 "X-Gender", "KADDRESSBOOK" );
339 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 340 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
340 "X-Children", "KADDRESSBOOK" ); 341 "X-Children", "KADDRESSBOOK" );
341 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 342 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
342 "X-FreeBusyUrl", "KADDRESSBOOK" ); 343 "X-FreeBusyUrl", "KADDRESSBOOK" );
343#endif 344#endif
344 initGUI(); 345 initGUI();
345 346
346 mIncSearchWidget->setFocus(); 347 mIncSearchWidget->setFocus();
347 348
348 349
349 connect( mViewManager, SIGNAL( selected( const QString& ) ), 350 connect( mViewManager, SIGNAL( selected( const QString& ) ),
350 SLOT( setContactSelected( const QString& ) ) ); 351 SLOT( setContactSelected( const QString& ) ) );
351 connect( mViewManager, SIGNAL( executed( const QString& ) ), 352 connect( mViewManager, SIGNAL( executed( const QString& ) ),
352 SLOT( executeContact( const QString& ) ) ); 353 SLOT( executeContact( const QString& ) ) );
353 354
354 connect( mViewManager, SIGNAL( deleteRequest( ) ), 355 connect( mViewManager, SIGNAL( deleteRequest( ) ),
355 SLOT( deleteContacts( ) ) ); 356 SLOT( deleteContacts( ) ) );
356 connect( mViewManager, SIGNAL( modified() ), 357 connect( mViewManager, SIGNAL( modified() ),
357 SLOT( setModified() ) ); 358 SLOT( setModified() ) );
358 359
359 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 360 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
360 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 361 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
361 362
362 connect( mXXPortManager, SIGNAL( modified() ), 363 connect( mXXPortManager, SIGNAL( modified() ),
363 SLOT( setModified() ) ); 364 SLOT( setModified() ) );
364 365
365 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 366 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
366 SLOT( incrementalSearchJump( const QString& ) ) ); 367 SLOT( incrementalSearchJump( const QString& ) ) );
367 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 368 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
368 mJumpButtonBar, SLOT( recreateButtons() ) ); 369 mJumpButtonBar, SLOT( recreateButtons() ) );
369 370
370 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 371 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
371 SLOT( sendMail( const QString& ) ) ); 372 SLOT( sendMail( const QString& ) ) );
372 373
373 374
374 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 375 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
375 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 376 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
376 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 377 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
377 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 378 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
378 connect( ExternalAppHandler::instance(), SIGNAL (doRingSync()),this, SLOT( doRingSync())); 379 connect( ExternalAppHandler::instance(), SIGNAL (doRingSync()),this, SLOT( doRingSync()));
379 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog())); 380 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog()));
380 381
381 382
382#ifndef KAB_EMBEDDED 383#ifndef KAB_EMBEDDED
383 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 384 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
384 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 385 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
385 386
386 connect( mDetails, SIGNAL( browse( const QString& ) ), 387 connect( mDetails, SIGNAL( browse( const QString& ) ),
387 SLOT( browse( const QString& ) ) ); 388 SLOT( browse( const QString& ) ) );
388 389
389 390
390 mAddressBookService = new KAddressBookService( this ); 391 mAddressBookService = new KAddressBookService( this );
391 392
392#endif //KAB_EMBEDDED 393#endif //KAB_EMBEDDED
393 394
394 mMessageTimer = new QTimer( this ); 395 mMessageTimer = new QTimer( this );
395 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 396 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
396 mEditorDialog = 0; 397 mEditorDialog = 0;
397 createAddresseeEditorDialog( this ); 398 createAddresseeEditorDialog( this );
398 setModified( false ); 399 setModified( false );
399 mBRdisabled = false; 400 mBRdisabled = false;
400#ifndef DESKTOP_VERSION 401#ifndef DESKTOP_VERSION
401 infrared = 0; 402 infrared = 0;
402#endif 403#endif
403 //toggleBeamReceive( ); 404 //toggleBeamReceive( );
404 mMainWindow->toolBar()->show(); 405 mMainWindow->toolBar()->show();
405 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 406 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
406 //QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 407 //QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
407 QTimer::singleShot( 100, this, SLOT ( loadDataAfterStart() )); 408 QTimer::singleShot( 100, this, SLOT ( loadDataAfterStart() ));
408} 409}
409void KABCore::receiveStart( const QCString& cmsg, const QByteArray& data ) 410void KABCore::receiveStart( const QCString& cmsg, const QByteArray& data )
410{ 411{
411 //qDebug("KO: QCOP start message received: %s ", cmsg.data() ); 412 //qDebug("KO: QCOP start message received: %s ", cmsg.data() );
412 mCStringMess = cmsg; 413 mCStringMess = cmsg;
413 mByteData = data; 414 mByteData = data;
414} 415}
415 416
416void KABCore::loadDataAfterStart() 417void KABCore::loadDataAfterStart()
417{ 418{
418 //qDebug("KABCore::loadDataAfterStart() "); 419 //qDebug("KABCore::loadDataAfterStart() ");
419 ((StdAddressBook*)mAddressBook)->init( true ); 420 ((StdAddressBook*)mAddressBook)->init( true );
420 mViewManager->refreshView(); 421 mViewManager->refreshView();
421 422
422#ifndef DESKTOP_VERSION 423#ifndef DESKTOP_VERSION
423 disconnect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT (receiveStart ( const QCString &, const QByteArray & ))); 424 disconnect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT (receiveStart ( const QCString &, const QByteArray & )));
424 425
425 QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 426 QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
426 if ( !mCStringMess.isEmpty() ) 427 if ( !mCStringMess.isEmpty() )
427 ExternalAppHandler::instance()->appMessage( mCStringMess, mByteData ); 428 ExternalAppHandler::instance()->appMessage( mCStringMess, mByteData );
428#endif 429#endif
429 // QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 430 // QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
430 setCaptionBack(); 431 setCaptionBack();
431} 432}
432void KABCore::updateToolBar() 433void KABCore::updateToolBar()
433{ 434{
434 static int iii = 0; 435 static int iii = 0;
435 ++iii; 436 ++iii;
436 mMainWindow->toolBar()->repaintMe(); 437 mMainWindow->toolBar()->repaintMe();
437 if ( iii < 4 ) 438 if ( iii < 4 )
438 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); 439 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar()));
439} 440}
440KABCore::~KABCore() 441KABCore::~KABCore()
441{ 442{
442 // save(); 443 // save();
443 //saveSettings(); 444 //saveSettings();
444 //KABPrefs::instance()->writeConfig(); 445 //KABPrefs::instance()->writeConfig();
445 delete AddresseeConfig::instance(); 446 delete AddresseeConfig::instance();
446 mAddressBook = 0; 447 mAddressBook = 0;
447 KABC::StdAddressBook::close(); 448 KABC::StdAddressBook::close();
448 449
449 delete syncManager; 450 delete syncManager;
450#ifndef DESKTOP_VERSION 451#ifndef DESKTOP_VERSION
451 if ( infrared ) 452 if ( infrared )
452 delete infrared; 453 delete infrared;
453#endif 454#endif
454} 455}
455void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 456void KABCore::receive( const QCString& cmsg, const QByteArray& data )
456{ 457{
457 //qDebug("KA: QCOP message received: %s ", cmsg.data() ); 458 //qDebug("KA: QCOP message received: %s ", cmsg.data() );
458 if ( cmsg == "setDocument(QString)" ) { 459 if ( cmsg == "setDocument(QString)" ) {
459 QDataStream stream( data, IO_ReadOnly ); 460 QDataStream stream( data, IO_ReadOnly );
460 QString fileName; 461 QString fileName;
461 stream >> fileName; 462 stream >> fileName;
462 recieve( fileName ); 463 recieve( fileName );
463 return; 464 return;
464 } 465 }
465} 466}
466void KABCore::toggleBeamReceive( ) 467void KABCore::toggleBeamReceive( )
467{ 468{
468 if ( mBRdisabled ) 469 if ( mBRdisabled )
469 return; 470 return;
470#ifndef DESKTOP_VERSION 471#ifndef DESKTOP_VERSION
471 if ( infrared ) { 472 if ( infrared ) {
472 qDebug("KA: AB disable BeamReceive "); 473 qDebug("KA: AB disable BeamReceive ");
473 delete infrared; 474 delete infrared;
474 infrared = 0; 475 infrared = 0;
475 mActionBR->setChecked(false); 476 mActionBR->setChecked(false);
476 return; 477 return;
477 } 478 }
478 qDebug("KA: AB enable BeamReceive "); 479 qDebug("KA: AB enable BeamReceive ");
479 mActionBR->setChecked(true); 480 mActionBR->setChecked(true);
480 481
481 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 482 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
482 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 483 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
483#endif 484#endif
484} 485}
485 486
486 487
487void KABCore::disableBR(bool b) 488void KABCore::disableBR(bool b)
488{ 489{
489#ifndef DESKTOP_VERSION 490#ifndef DESKTOP_VERSION
490 if ( b ) { 491 if ( b ) {
491 if ( infrared ) { 492 if ( infrared ) {
492 toggleBeamReceive( ); 493 toggleBeamReceive( );
493 } 494 }
494 mBRdisabled = true; 495 mBRdisabled = true;
495 } else { 496 } else {
496 if ( mBRdisabled ) { 497 if ( mBRdisabled ) {
497 mBRdisabled = false; 498 mBRdisabled = false;
498 //toggleBeamReceive( ); 499 //toggleBeamReceive( );
499 } 500 }
500 } 501 }
501#endif 502#endif
502 503
503} 504}
504void KABCore::recieve( QString fn ) 505void KABCore::recieve( QString fn )
505{ 506{
506 //qDebug("KABCore::recieve "); 507 //qDebug("KABCore::recieve ");
507 int count = mAddressBook->importFromFile( fn, true ); 508 int count = mAddressBook->importFromFile( fn, true );
508 if ( count ) 509 if ( count )
509 setModified( true ); 510 setModified( true );
510 mViewManager->refreshView(); 511 mViewManager->refreshView();
511 message(i18n("%1 contact(s) received!").arg( count )); 512 message(i18n("%1 contact(s) received!").arg( count ));
512 topLevelWidget()->showMaximized(); 513 topLevelWidget()->showMaximized();
513 topLevelWidget()->raise(); 514 topLevelWidget()->raise();
514} 515}
515void KABCore::restoreSettings() 516void KABCore::restoreSettings()
516{ 517{
517 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 518 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
518 519
519 bool state; 520 bool state;
520 521
521 if (mMultipleViewsAtOnce) 522 if (mMultipleViewsAtOnce)
522 state = KABPrefs::instance()->mDetailsPageVisible; 523 state = KABPrefs::instance()->mDetailsPageVisible;
523 else 524 else
524 state = false; 525 state = false;
525 526
526 mActionDetails->setChecked( state ); 527 mActionDetails->setChecked( state );
527 setDetailsVisible( state ); 528 setDetailsVisible( state );
528 529
529 state = KABPrefs::instance()->mJumpButtonBarVisible; 530 state = KABPrefs::instance()->mJumpButtonBarVisible;
530 531
531 mActionJumpBar->setChecked( state ); 532 mActionJumpBar->setChecked( state );
532 setJumpButtonBarVisible( state ); 533 setJumpButtonBarVisible( state );
533/*US 534/*US
534 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 535 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
535 if ( splitterSize.count() == 0 ) { 536 if ( splitterSize.count() == 0 ) {
536 splitterSize.append( width() / 2 ); 537 splitterSize.append( width() / 2 );
537 splitterSize.append( width() / 2 ); 538 splitterSize.append( width() / 2 );
538 } 539 }
539 mMiniSplitter->setSizes( splitterSize ); 540 mMiniSplitter->setSizes( splitterSize );
540 if ( mExtensionBarSplitter ) { 541 if ( mExtensionBarSplitter ) {
541 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 542 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
542 if ( splitterSize.count() == 0 ) { 543 if ( splitterSize.count() == 0 ) {
543 splitterSize.append( width() / 2 ); 544 splitterSize.append( width() / 2 );
544 splitterSize.append( width() / 2 ); 545 splitterSize.append( width() / 2 );
545 } 546 }
546 mExtensionBarSplitter->setSizes( splitterSize ); 547 mExtensionBarSplitter->setSizes( splitterSize );
547 548
548 } 549 }
549*/ 550*/
550 mViewManager->restoreSettings(); 551 mViewManager->restoreSettings();
551 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 552 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
552 mExtensionManager->restoreSettings(); 553 mExtensionManager->restoreSettings();
553#ifdef DESKTOP_VERSION 554#ifdef DESKTOP_VERSION
554 int wid = width(); 555 int wid = width();
555 if ( wid < 10 ) 556 if ( wid < 10 )
556 wid = 400; 557 wid = 400;
557#else 558#else
558 int wid = QApplication::desktop()->width(); 559 int wid = QApplication::desktop()->width();
559 if ( wid < 640 ) 560 if ( wid < 640 )
560 wid = QApplication::desktop()->height(); 561 wid = QApplication::desktop()->height();
561#endif 562#endif
562 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 563 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
563 if ( true /*splitterSize.count() == 0*/ ) { 564 if ( true /*splitterSize.count() == 0*/ ) {
564 splitterSize.append( wid / 2 ); 565 splitterSize.append( wid / 2 );
565 splitterSize.append( wid / 2 ); 566 splitterSize.append( wid / 2 );
566 } 567 }
567 mMiniSplitter->setSizes( splitterSize ); 568 mMiniSplitter->setSizes( splitterSize );
568 if ( mExtensionBarSplitter ) { 569 if ( mExtensionBarSplitter ) {
569 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 570 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
570 if ( true /*splitterSize.count() == 0*/ ) { 571 if ( true /*splitterSize.count() == 0*/ ) {
571 splitterSize.append( wid / 2 ); 572 splitterSize.append( wid / 2 );
572 splitterSize.append( wid / 2 ); 573 splitterSize.append( wid / 2 );
573 } 574 }
574 mExtensionBarSplitter->setSizes( splitterSize ); 575 mExtensionBarSplitter->setSizes( splitterSize );
575 576
576 } 577 }
577#ifdef DESKTOP_VERSION 578#ifdef DESKTOP_VERSION
578 KConfig *config = KABPrefs::instance()->getConfig(); 579 KConfig *config = KABPrefs::instance()->getConfig();
579 config->setGroup("WidgetLayout"); 580 config->setGroup("WidgetLayout");
580 QStringList list; 581 QStringList list;
581 list = config->readListEntry("MainLayout"); 582 list = config->readListEntry("MainLayout");
582 int x,y,w,h; 583 int x,y,w,h;
583 if ( ! list.isEmpty() ) { 584 if ( ! list.isEmpty() ) {
584 x = list[0].toInt(); 585 x = list[0].toInt();
585 y = list[1].toInt(); 586 y = list[1].toInt();
586 w = list[2].toInt(); 587 w = list[2].toInt();
587 h = list[3].toInt(); 588 h = list[3].toInt();
588 KApplication::testCoords( &x,&y,&w,&h ); 589 KApplication::testCoords( &x,&y,&w,&h );
589 topLevelWidget()->setGeometry(x,y,w,h); 590 topLevelWidget()->setGeometry(x,y,w,h);
590 591
591 } else { 592 } else {
592 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 593 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
593 } 594 }
594#endif 595#endif
595} 596}
596 597
597void KABCore::saveSettings() 598void KABCore::saveSettings()
598{ 599{
599 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 600 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
600 if ( mExtensionBarSplitter ) 601 if ( mExtensionBarSplitter )
601 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 602 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
602 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 603 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
603 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 604 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
604#ifndef KAB_EMBEDDED 605#ifndef KAB_EMBEDDED
605 606
606 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 607 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
607 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 608 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
608#endif //KAB_EMBEDDED 609#endif //KAB_EMBEDDED
609 mExtensionManager->saveSettings(); 610 mExtensionManager->saveSettings();
610 mViewManager->saveSettings(); 611 mViewManager->saveSettings();
611 612
612 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 613 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
613 614
614 KABPrefs::instance()->writeConfig(); 615 KABPrefs::instance()->writeConfig();
615 //qDebug("KA: KABCore::saveSettings() "); 616 //qDebug("KA: KABCore::saveSettings() ");
616} 617}
617 618
618KABC::AddressBook *KABCore::addressBook() const 619KABC::AddressBook *KABCore::addressBook() const
619{ 620{
620 return mAddressBook; 621 return mAddressBook;
621} 622}
622 623
623KConfig *KABCore::config() 624KConfig *KABCore::config()
624{ 625{
625#ifndef KAB_EMBEDDED 626#ifndef KAB_EMBEDDED
626 return KABPrefs::instance()->config(); 627 return KABPrefs::instance()->config();
627#else //KAB_EMBEDDED 628#else //KAB_EMBEDDED
628 return KABPrefs::instance()->getConfig(); 629 return KABPrefs::instance()->getConfig();
629#endif //KAB_EMBEDDED 630#endif //KAB_EMBEDDED
630} 631}
631 632
632KActionCollection *KABCore::actionCollection() const 633KActionCollection *KABCore::actionCollection() const
633{ 634{
634 return mGUIClient->actionCollection(); 635 return mGUIClient->actionCollection();
635} 636}
636 637
637KABC::Field *KABCore::currentSearchField() const 638KABC::Field *KABCore::currentSearchField() const
638{ 639{
639 if (mIncSearchWidget) 640 if (mIncSearchWidget)
640 return mIncSearchWidget->currentField(); 641 return mIncSearchWidget->currentField();
641 else 642 else
642 return 0; 643 return 0;
643} 644}
644 645
645QStringList KABCore::selectedUIDs() const 646QStringList KABCore::selectedUIDs() const
646{ 647{
647 return mViewManager->selectedUids(); 648 return mViewManager->selectedUids();
648} 649}
649 650
650KABC::Resource *KABCore::requestResource( QWidget *parent ) 651KABC::Resource *KABCore::requestResource( QWidget *parent )
651{ 652{
652 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 653 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
653 654
654 QPtrList<KRES::Resource> kresResources; 655 QPtrList<KRES::Resource> kresResources;
655 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 656 QPtrListIterator<KABC::Resource> resIt( kabcResources );
656 KABC::Resource *resource; 657 KABC::Resource *resource;
657 while ( ( resource = resIt.current() ) != 0 ) { 658 while ( ( resource = resIt.current() ) != 0 ) {
658 ++resIt; 659 ++resIt;
659 if ( !resource->readOnly() ) { 660 if ( !resource->readOnly() ) {
660 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 661 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
661 if ( res ) 662 if ( res )
662 kresResources.append( res ); 663 kresResources.append( res );
663 } 664 }
664 } 665 }
665 666
666 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 667 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
667 return static_cast<KABC::Resource*>( res ); 668 return static_cast<KABC::Resource*>( res );
668} 669}
669 670
670#ifndef KAB_EMBEDDED 671#ifndef KAB_EMBEDDED
671KAboutData *KABCore::createAboutData() 672KAboutData *KABCore::createAboutData()
672#else //KAB_EMBEDDED 673#else //KAB_EMBEDDED
673void KABCore::createAboutData() 674void KABCore::createAboutData()
674#endif //KAB_EMBEDDED 675#endif //KAB_EMBEDDED
675{ 676{
676 677
677 678
678 QString version; 679 QString version;
679#include <../version> 680#include <../version>
680 QMessageBox::about( this, "About KAddressbook/Pi", 681 QMessageBox::about( this, "About KAddressbook/Pi",
681 "KAddressbook/Platform-independent\n" 682 "KAddressbook/Platform-independent\n"
682 "(KA/Pi) " +version + " - " + 683 "(KA/Pi) " +version + " - " +
683#ifdef DESKTOP_VERSION 684#ifdef DESKTOP_VERSION
684 "Desktop Edition\n" 685 "Desktop Edition\n"
685#else 686#else
686 "PDA-Edition\n" 687 "PDA-Edition\n"
687 "for: Zaurus 5500 / 7x0 / 8x0\n" 688 "for: Zaurus 5500 / 7x0 / 8x0\n"
688#endif 689#endif
689 690
690 "(c) 2004 Ulf Schenk\n" 691 "(c) 2004 Ulf Schenk\n"
691 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" 692 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n"
692 "(c) 1997-2003, The KDE PIM Team\n" 693 "(c) 1997-2003, The KDE PIM Team\n"
693 "Tobias Koenig Maintainer\n" 694 "Tobias Koenig Maintainer\n"
694 "Don Sanders Original author\n" 695 "Don Sanders Original author\n"
695 "Cornelius Schumacher Co-maintainer\n" 696 "Cornelius Schumacher Co-maintainer\n"
696 "Mike Pilone GUI and framework redesign\n" 697 "Mike Pilone GUI and framework redesign\n"
697 "Greg Stern DCOP interface\n" 698 "Greg Stern DCOP interface\n"
698 "Mark Westcot Contact pinning\n" 699 "Mark Westcot Contact pinning\n"
699 "Michel Boyer de la Giroday LDAP Lookup\n" 700 "Michel Boyer de la Giroday LDAP Lookup\n"
700 "Steffen Hansen LDAP Lookup" 701 "Steffen Hansen LDAP Lookup"
701#ifdef _WIN32_ 702#ifdef _WIN32_
702 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 703 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
703#endif 704#endif
704 ); 705 );
705} 706}
706 707
707void KABCore::setContactSelected( const QString &uid ) 708void KABCore::setContactSelected( const QString &uid )
708{ 709{
709 KABC::Addressee addr = mAddressBook->findByUid( uid ); 710 KABC::Addressee addr = mAddressBook->findByUid( uid );
710 if ( !mDetails->isHidden() ) 711 if ( !mDetails->isHidden() )
711 mDetails->setAddressee( addr ); 712 mDetails->setAddressee( addr );
712 713
713 if ( !addr.isEmpty() ) { 714 if ( !addr.isEmpty() ) {
714 emit contactSelected( addr.formattedName() ); 715 emit contactSelected( addr.formattedName() );
715 KABC::Picture pic = addr.photo(); 716 KABC::Picture pic = addr.photo();
716 if ( pic.isIntern() ) { 717 if ( pic.isIntern() ) {
717//US emit contactSelected( pic.data() ); 718//US emit contactSelected( pic.data() );
718//US instead use: 719//US instead use:
719 QPixmap px; 720 QPixmap px;
720 if (pic.data().isNull() != true) 721 if (pic.data().isNull() != true)
721 { 722 {
722 px.convertFromImage(pic.data()); 723 px.convertFromImage(pic.data());
723 } 724 }
724 725
725 emit contactSelected( px ); 726 emit contactSelected( px );
726 } 727 }
727 } 728 }
728 729
729 730
730 mExtensionManager->setSelectionChanged(); 731 mExtensionManager->setSelectionChanged();
731 732
732 // update the actions 733 // update the actions
733 bool selected = !uid.isEmpty(); 734 bool selected = !uid.isEmpty();
734 735
735 if ( mReadWrite ) { 736 if ( mReadWrite ) {
736 mActionCut->setEnabled( selected ); 737 mActionCut->setEnabled( selected );
737 mActionPaste->setEnabled( selected ); 738 mActionPaste->setEnabled( selected );
738 } 739 }
739 740
740 mActionCopy->setEnabled( selected ); 741 mActionCopy->setEnabled( selected );
741 mActionDelete->setEnabled( selected ); 742 mActionDelete->setEnabled( selected );
742 mActionEditAddressee->setEnabled( selected ); 743 mActionEditAddressee->setEnabled( selected );
743 mActionMail->setEnabled( selected ); 744 mActionMail->setEnabled( selected );
744 mActionMailVCard->setEnabled( selected ); 745 mActionMailVCard->setEnabled( selected );
745 //if (mActionBeam) 746 //if (mActionBeam)
746 //mActionBeam->setEnabled( selected ); 747 //mActionBeam->setEnabled( selected );
747 mActionWhoAmI->setEnabled( selected ); 748 mActionWhoAmI->setEnabled( selected );
748} 749}
749 750
750void KABCore::sendMail() 751void KABCore::sendMail()
751{ 752{
752 sendMail( mViewManager->selectedEmails().join( ", " ) ); 753 sendMail( mViewManager->selectedEmails().join( ", " ) );
753} 754}
754 755
755void KABCore::sendMail( const QString& emaillist ) 756void KABCore::sendMail( const QString& emaillist )
756{ 757{
757 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 758 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
758 if (emaillist.contains(",") > 0) 759 if (emaillist.contains(",") > 0)
759 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 760 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
760 else 761 else
761 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 762 ExternalAppHandler::instance()->mailToOneContact( emaillist );
762} 763}
763 764
764 765
765 766
766void KABCore::mailVCard() 767void KABCore::mailVCard()
767{ 768{
768 QStringList uids = mViewManager->selectedUids(); 769 QStringList uids = mViewManager->selectedUids();
769 if ( !uids.isEmpty() ) 770 if ( !uids.isEmpty() )
770 mailVCard( uids ); 771 mailVCard( uids );
771} 772}
772 773
773void KABCore::mailVCard( const QStringList& uids ) 774void KABCore::mailVCard( const QStringList& uids )
774{ 775{
775 QStringList urls; 776 QStringList urls;
776 777
777// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 778// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
778 779
779 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 780 QString dirName = "/tmp/" + KApplication::randomString( 8 );
780 781
781 782
782 783
783 QDir().mkdir( dirName, true ); 784 QDir().mkdir( dirName, true );
784 785
785 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 786 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
786 KABC::Addressee a = mAddressBook->findByUid( *it ); 787 KABC::Addressee a = mAddressBook->findByUid( *it );
787 788
788 if ( a.isEmpty() ) 789 if ( a.isEmpty() )
789 continue; 790 continue;
790 791
791 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 792 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
792 793
793 QString fileName = dirName + "/" + name; 794 QString fileName = dirName + "/" + name;
794 795
795 QFile outFile(fileName); 796 QFile outFile(fileName);
796 797
797 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 798 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
798 KABC::VCardConverter converter; 799 KABC::VCardConverter converter;
799 QString vcard; 800 QString vcard;
800 801
801 converter.addresseeToVCard( a, vcard ); 802 converter.addresseeToVCard( a, vcard );
802 803
803 QTextStream t( &outFile ); // use a text stream 804 QTextStream t( &outFile ); // use a text stream
804 t.setEncoding( QTextStream::UnicodeUTF8 ); 805 t.setEncoding( QTextStream::UnicodeUTF8 );
805 t << vcard; 806 t << vcard;
806 807
807 outFile.close(); 808 outFile.close();
808 809
809 urls.append( fileName ); 810 urls.append( fileName );
810 } 811 }
811 } 812 }
812 813
813 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 814 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
814 815
815 816
816/*US 817/*US
817 kapp->invokeMailer( QString::null, QString::null, QString::null, 818 kapp->invokeMailer( QString::null, QString::null, QString::null,
818 QString::null, // subject 819 QString::null, // subject
819 QString::null, // body 820 QString::null, // body
820 QString::null, 821 QString::null,
821 urls ); // attachments 822 urls ); // attachments
822*/ 823*/
823 824
824} 825}
825 826
826/** 827/**
827 Beams the "WhoAmI contact. 828 Beams the "WhoAmI contact.
828*/ 829*/
829void KABCore::beamMySelf() 830void KABCore::beamMySelf()
830{ 831{
831 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 832 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
832 if (!a.isEmpty()) 833 if (!a.isEmpty())
833 { 834 {
834 QStringList uids; 835 QStringList uids;
835 uids << a.uid(); 836 uids << a.uid();
836 837
837 beamVCard(uids); 838 beamVCard(uids);
838 } else { 839 } else {
839 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 840 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
840 841
841 842
842 } 843 }
843} 844}
844void KABCore::updateMainWindow() 845void KABCore::updateMainWindow()
845{ 846{
846 mMainWindow->showMaximized(); 847 mMainWindow->showMaximized();
847 //mMainWindow->repaint(); 848 //mMainWindow->repaint();
848} 849}
849void KABCore::resizeEvent(QResizeEvent* e ) 850void KABCore::resizeEvent(QResizeEvent* e )
850{ 851{
851 if ( !mMiniSplitter ) { 852 if ( !mMiniSplitter ) {
852 QWidget::resizeEvent( e ); 853 QWidget::resizeEvent( e );
853 return; 854 return;
854 } 855 }
855#ifndef DESKTOP_VERSION 856#ifndef DESKTOP_VERSION
856 static int desktop_width = 0; 857 static int desktop_width = 0;
857 //qDebug("KABCore::resizeEvent %d %d ",desktop_width,QApplication::desktop()->width() ); 858 //qDebug("KABCore::resizeEvent %d %d ",desktop_width,QApplication::desktop()->width() );
858 if ( desktop_width != QApplication::desktop()->width() ) 859 if ( desktop_width != QApplication::desktop()->width() )
859 if ( QApplication::desktop()->width() >= 480 ) { 860 if ( QApplication::desktop()->width() >= 480 ) {
860 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 861 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
861 //qDebug("640 "); 862 //qDebug("640 ");
862 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 863 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
863 //qDebug("switch V->H "); 864 //qDebug("switch V->H ");
864 mMiniSplitter->setOrientation( Qt::Horizontal); 865 mMiniSplitter->setOrientation( Qt::Horizontal);
865 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 866 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
866 } 867 }
867 if ( QApplication::desktop()->width() <= 640 ) { 868 if ( QApplication::desktop()->width() <= 640 ) {
868 bool shot = mMainWindow->isVisible(); 869 bool shot = mMainWindow->isVisible();
869 mMainWindow->showMinimized(); 870 mMainWindow->showMinimized();
870 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 871 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
871 mViewManager->getFilterAction()->setComboWidth( 150 ); 872 mViewManager->getFilterAction()->setComboWidth( 150 );
872 if ( mIncSearchWidget ) 873 if ( mIncSearchWidget )
873 mIncSearchWidget->setSize(); 874 mIncSearchWidget->setSize();
874 if ( shot ) 875 if ( shot )
875 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 876 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
876 } 877 }
877 878
878 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 879 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
879 //qDebug("480 "); 880 //qDebug("480 ");
880 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 881 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
881 //qDebug("switch H->V "); 882 //qDebug("switch H->V ");
882 mMiniSplitter->setOrientation( Qt::Vertical ); 883 mMiniSplitter->setOrientation( Qt::Vertical );
883 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 884 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
884 } 885 }
885 if ( QApplication::desktop()->width() <= 640 ) { 886 if ( QApplication::desktop()->width() <= 640 ) {
886 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 887 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
887 bool shot = mMainWindow->isVisible(); 888 bool shot = mMainWindow->isVisible();
888 mMainWindow->showMinimized(); 889 mMainWindow->showMinimized();
889 if ( KABPrefs::instance()->mHideSearchOnSwitch ) { 890 if ( KABPrefs::instance()->mHideSearchOnSwitch ) {
890 if ( mIncSearchWidget ) { 891 if ( mIncSearchWidget ) {
891 mIncSearchWidget->setSize(); 892 mIncSearchWidget->setSize();
892 } 893 }
893 } else { 894 } else {
894 mViewManager->getFilterAction()->setComboWidth( 0 ); 895 mViewManager->getFilterAction()->setComboWidth( 0 );
895 } 896 }
896 if ( shot ) 897 if ( shot )
897 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 898 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
898 } 899 }
899 } 900 }
900 } 901 }
901 desktop_width = QApplication::desktop()->width(); 902 desktop_width = QApplication::desktop()->width();
902#endif 903#endif
903 QWidget::resizeEvent( e ); 904 QWidget::resizeEvent( e );
904 905
905} 906}
906void KABCore::export2phone() 907void KABCore::export2phone()
907{ 908{
908 909
909 QStringList uids; 910 QStringList uids;
910 XXPortSelectDialog dlg( this, false, this ); 911 XXPortSelectDialog dlg( this, false, this );
911 if ( dlg.exec() ) 912 if ( dlg.exec() )
912 uids = dlg.uids(); 913 uids = dlg.uids();
913 else 914 else
914 return; 915 return;
915 if ( uids.isEmpty() ) 916 if ( uids.isEmpty() )
916 return; 917 return;
917 // qDebug("count %d ", uids.count()); 918 // qDebug("count %d ", uids.count());
918 919
919 KAex2phonePrefs ex2phone; 920 KAex2phonePrefs ex2phone;
920 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 921 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
921 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 922 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
922 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 923 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
923 924
924 if ( !ex2phone.exec() ) { 925 if ( !ex2phone.exec() ) {
925 return; 926 return;
926 } 927 }
927 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 928 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
928 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 929 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
929 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 930 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
930 931
931 932
932 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 933 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
933 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 934 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
934 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 935 KPimGlobalPrefs::instance()->mEx2PhoneModel );
935 936
936 QString fileName = getPhoneFile(); 937 QString fileName = getPhoneFile();
937 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 938 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
938 return; 939 return;
939 940
940 message(i18n("Exporting to phone...")); 941 message(i18n("Exporting to phone..."));
941 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 942 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
942 943
943} 944}
944QString KABCore::getPhoneFile() 945QString KABCore::getPhoneFile()
945{ 946{
946#ifdef DESKTOP_VERSION 947#ifdef DESKTOP_VERSION
947 return locateLocal("tmp", "phonefile.vcf"); 948 return locateLocal("tmp", "phonefile.vcf");
948#else 949#else
949 return "/tmp/phonefile.vcf"; 950 return "/tmp/phonefile.vcf";
950#endif 951#endif
951 952
952} 953}
953void KABCore::writeToPhone( ) 954void KABCore::writeToPhone( )
954{ 955{
955 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 956 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
956 message(i18n("Export to phone finished!")); 957 message(i18n("Export to phone finished!"));
957 else 958 else
958 qDebug(i18n("KA: Error exporting to phone")); 959 qDebug(i18n("KA: Error exporting to phone"));
959} 960}
960void KABCore::beamVCard() 961void KABCore::beamVCard()
961{ 962{
962 QStringList uids; 963 QStringList uids;
963 XXPortSelectDialog dlg( this, false, this ); 964 XXPortSelectDialog dlg( this, false, this );
964 if ( dlg.exec() ) 965 if ( dlg.exec() )
965 uids = dlg.uids(); 966 uids = dlg.uids();
966 else 967 else
967 return; 968 return;
968 if ( uids.isEmpty() ) 969 if ( uids.isEmpty() )
969 return; 970 return;
970 beamVCard( uids ); 971 beamVCard( uids );
971} 972}
972 973
973 974
974void KABCore::beamVCard(const QStringList& uids) 975void KABCore::beamVCard(const QStringList& uids)
975{ 976{
976 977
977 // LR: we should use the /tmp dir on the Zaurus, 978 // LR: we should use the /tmp dir on the Zaurus,
978 // because: /tmp = RAM, (HOME)/kdepim = flash memory 979 // because: /tmp = RAM, (HOME)/kdepim = flash memory
979 980
980#ifdef DESKTOP_VERSION 981#ifdef DESKTOP_VERSION
981 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 982 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
982#else 983#else
983 QString fileName = "/tmp/kapibeamfile.vcf"; 984 QString fileName = "/tmp/kapibeamfile.vcf";
984#endif 985#endif
985 986
986 KABC::VCardConverter converter; 987 KABC::VCardConverter converter;
987 QString description; 988 QString description;
988 QString datastream; 989 QString datastream;
989 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 990 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
990 KABC::Addressee a = mAddressBook->findByUid( *it ); 991 KABC::Addressee a = mAddressBook->findByUid( *it );
991 992
992 if ( a.isEmpty() ) 993 if ( a.isEmpty() )
993 continue; 994 continue;
994 995
995 if (description.isEmpty()) 996 if (description.isEmpty())
996 description = a.formattedName(); 997 description = a.formattedName();
997 998
998 QString vcard; 999 QString vcard;
999 converter.addresseeToVCard( a, vcard ); 1000 converter.addresseeToVCard( a, vcard );
1000 int start = 0; 1001 int start = 0;
1001 int next; 1002 int next;
1002 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 1003 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
1003 int semi = vcard.find(";", next); 1004 int semi = vcard.find(";", next);
1004 int dopp = vcard.find(":", next); 1005 int dopp = vcard.find(":", next);
1005 int sep; 1006 int sep;
1006 if ( semi < dopp && semi >= 0 ) 1007 if ( semi < dopp && semi >= 0 )
1007 sep = semi ; 1008 sep = semi ;
1008 else 1009 else
1009 sep = dopp; 1010 sep = dopp;
1010 datastream +=vcard.mid( start, next - start); 1011 datastream +=vcard.mid( start, next - start);
1011 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 1012 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
1012 start = sep; 1013 start = sep;
1013 } 1014 }
1014 datastream += vcard.mid( start,vcard.length() ); 1015 datastream += vcard.mid( start,vcard.length() );
1015 } 1016 }
1016#ifndef DESKTOP_VERSION 1017#ifndef DESKTOP_VERSION
1017 QFile outFile(fileName); 1018 QFile outFile(fileName);
1018 if ( outFile.open(IO_WriteOnly) ) { 1019 if ( outFile.open(IO_WriteOnly) ) {
1019 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 1020 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
1020 QTextStream t( &outFile ); // use a text stream 1021 QTextStream t( &outFile ); // use a text stream
1021 //t.setEncoding( QTextStream::UnicodeUTF8 ); 1022 //t.setEncoding( QTextStream::UnicodeUTF8 );
1022 t.setEncoding( QTextStream::Latin1 ); 1023 t.setEncoding( QTextStream::Latin1 );
1023 t <<datastream.latin1(); 1024 t <<datastream.latin1();
1024 outFile.close(); 1025 outFile.close();
1025 Ir *ir = new Ir( this ); 1026 Ir *ir = new Ir( this );
1026 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 1027 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
1027 ir->send( fileName, description, "text/x-vCard" ); 1028 ir->send( fileName, description, "text/x-vCard" );
1028 } else { 1029 } else {
1029 qDebug("KA: Error open temp beam file "); 1030 qDebug("KA: Error open temp beam file ");
1030 return; 1031 return;
1031 } 1032 }
1032#endif 1033#endif
1033 1034
1034} 1035}
1035 1036
1036void KABCore::beamDone( Ir *ir ) 1037void KABCore::beamDone( Ir *ir )
1037{ 1038{
1038#ifndef DESKTOP_VERSION 1039#ifndef DESKTOP_VERSION
1039 delete ir; 1040 delete ir;
1040#endif 1041#endif
1041 topLevelWidget()->raise(); 1042 topLevelWidget()->raise();
1042 message( i18n("Beaming finished!") ); 1043 message( i18n("Beaming finished!") );
1043} 1044}
1044 1045
1045 1046
1046void KABCore::browse( const QString& url ) 1047void KABCore::browse( const QString& url )
1047{ 1048{
1048#ifndef KAB_EMBEDDED 1049#ifndef KAB_EMBEDDED
1049 kapp->invokeBrowser( url ); 1050 kapp->invokeBrowser( url );
1050#else //KAB_EMBEDDED 1051#else //KAB_EMBEDDED
1051 qDebug("KABCore::browse must be fixed"); 1052 qDebug("KABCore::browse must be fixed");
1052#endif //KAB_EMBEDDED 1053#endif //KAB_EMBEDDED
1053} 1054}
1054 1055
1055void KABCore::selectAllContacts() 1056void KABCore::selectAllContacts()
1056{ 1057{
1057 mViewManager->setSelected( QString::null, true ); 1058 mViewManager->setSelected( QString::null, true );
1058} 1059}
1059 1060
1060void KABCore::deleteContacts() 1061void KABCore::deleteContacts()
1061{ 1062{
1062 QStringList uidList = mViewManager->selectedUids(); 1063 QStringList uidList = mViewManager->selectedUids();
1063 deleteContacts( uidList ); 1064 deleteContacts( uidList );
1064} 1065}
1065 1066
1066void KABCore::deleteContacts( const QStringList &uids ) 1067void KABCore::deleteContacts( const QStringList &uids )
1067{ 1068{
1068 1069
1069 if ( uids.count() > 0 ) { 1070 if ( uids.count() > 0 ) {
1070 1071
1071 if ( KABPrefs::instance()->mAskForDelete ) { 1072 if ( KABPrefs::instance()->mAskForDelete ) {
1072 int count = uids.count(); 1073 int count = uids.count();
1073 if ( count > 5 ) count = 5; 1074 if ( count > 5 ) count = 5;
1074 QString cNames; 1075 QString cNames;
1075 int i; 1076 int i;
1076 for ( i = 0; i < count ; ++i ) { 1077 for ( i = 0; i < count ; ++i ) {
1077 cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n"; 1078 cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n";
1078 } 1079 }
1079 if ( uids.count() > 5 ) 1080 if ( uids.count() > 5 )
1080 cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 ); 1081 cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 );
1081 QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ; 1082 QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ;
1082 if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes ) 1083 if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes )
1083 return; 1084 return;
1084 } 1085 }
1085 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 1086 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
1086 UndoStack::instance()->push( command ); 1087 UndoStack::instance()->push( command );
1087 RedoStack::instance()->clear(); 1088 RedoStack::instance()->clear();
1088 1089
1089 // now if we deleted anything, refresh 1090 // now if we deleted anything, refresh
1090 setContactSelected( QString::null ); 1091 setContactSelected( QString::null );
1091 setModified( true ); 1092 setModified( true );
1092 } 1093 }
1093} 1094}
1094 1095
1095void KABCore::copyContacts() 1096void KABCore::copyContacts()
1096{ 1097{
1097 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1098 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1098 1099
1099 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 1100 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
1100 1101
1101 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 1102 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
1102 1103
1103 QClipboard *cb = QApplication::clipboard(); 1104 QClipboard *cb = QApplication::clipboard();
1104 cb->setText( clipText ); 1105 cb->setText( clipText );
1105} 1106}
1106 1107
1107void KABCore::cutContacts() 1108void KABCore::cutContacts()
1108{ 1109{
1109 QStringList uidList = mViewManager->selectedUids(); 1110 QStringList uidList = mViewManager->selectedUids();
1110 1111
1111//US if ( uidList.size() > 0 ) { 1112//US if ( uidList.size() > 0 ) {
1112 if ( uidList.count() > 0 ) { 1113 if ( uidList.count() > 0 ) {
1113 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1114 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1114 UndoStack::instance()->push( command ); 1115 UndoStack::instance()->push( command );
1115 RedoStack::instance()->clear(); 1116 RedoStack::instance()->clear();
1116 1117
1117 setModified( true ); 1118 setModified( true );
1118 } 1119 }
1119} 1120}
1120 1121
1121void KABCore::pasteContacts() 1122void KABCore::pasteContacts()
1122{ 1123{
1123 QClipboard *cb = QApplication::clipboard(); 1124 QClipboard *cb = QApplication::clipboard();
1124 1125
1125 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1126 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1126 1127
1127 pasteContacts( list ); 1128 pasteContacts( list );
1128} 1129}
1129 1130
1130void KABCore::pasteContacts( KABC::Addressee::List &list ) 1131void KABCore::pasteContacts( KABC::Addressee::List &list )
1131{ 1132{
1132 KABC::Resource *resource = requestResource( this ); 1133 KABC::Resource *resource = requestResource( this );
1133 KABC::Addressee::List::Iterator it; 1134 KABC::Addressee::List::Iterator it;
1134 for ( it = list.begin(); it != list.end(); ++it ) 1135 for ( it = list.begin(); it != list.end(); ++it )
1135 (*it).setResource( resource ); 1136 (*it).setResource( resource );
1136 1137
1137 PwPasteCommand *command = new PwPasteCommand( this, list ); 1138 PwPasteCommand *command = new PwPasteCommand( this, list );
1138 UndoStack::instance()->push( command ); 1139 UndoStack::instance()->push( command );
1139 RedoStack::instance()->clear(); 1140 RedoStack::instance()->clear();
1140 1141
1141 setModified( true ); 1142 setModified( true );
1142} 1143}
1143 1144
1144void KABCore::setWhoAmI() 1145void KABCore::setWhoAmI()
1145{ 1146{
1146 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1147 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1147 1148
1148 if ( addrList.count() > 1 ) { 1149 if ( addrList.count() > 1 ) {
1149 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1150 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1150 return; 1151 return;
1151 } 1152 }
1152 1153
1153 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1154 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1154 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes ) 1155 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes )
1155 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1156 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1156} 1157}
1157void KABCore::editCategories() 1158void KABCore::editCategories()
1158{ 1159{
1159 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1160 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1160 dlg.exec(); 1161 dlg.exec();
1161} 1162}
1162void KABCore::setCategories() 1163void KABCore::setCategories()
1163{ 1164{
1164 1165
1165 QStringList uids; 1166 QStringList uids;
1166 XXPortSelectDialog dlgx( this, false, this ); 1167 XXPortSelectDialog dlgx( this, false, this );
1167 if ( dlgx.exec() ) 1168 if ( dlgx.exec() )
1168 uids = dlgx.uids(); 1169 uids = dlgx.uids();
1169 else 1170 else
1170 return; 1171 return;
1171 if ( uids.isEmpty() ) 1172 if ( uids.isEmpty() )
1172 return; 1173 return;
1173 // qDebug("count %d ", uids.count()); 1174 // qDebug("count %d ", uids.count());
1174 1175
1175 1176
1176 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1177 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1177 if ( !dlg.exec() ) { 1178 if ( !dlg.exec() ) {
1178 message( i18n("Setting categories cancelled") ); 1179 message( i18n("Setting categories cancelled") );
1179 return; 1180 return;
1180 } 1181 }
1181 bool merge = false; 1182 bool merge = false;
1182 QString msg = i18n( "Merge with existing categories?" ); 1183 QString msg = i18n( "Merge with existing categories?" );
1183 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1184 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1184 merge = true; 1185 merge = true;
1185 1186
1186 message( i18n("Setting categories ... please wait!") ); 1187 message( i18n("Setting categories ... please wait!") );
1187 QStringList categories = dlg.selectedCategories(); 1188 QStringList categories = dlg.selectedCategories();
1188 1189
1189 //QStringList uids = mViewManager->selectedUids(); 1190 //QStringList uids = mViewManager->selectedUids();
1190 QStringList::Iterator it; 1191 QStringList::Iterator it;
1191 for ( it = uids.begin(); it != uids.end(); ++it ) { 1192 for ( it = uids.begin(); it != uids.end(); ++it ) {
1192 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1193 KABC::Addressee addr = mAddressBook->findByUid( *it );
1193 if ( !addr.isEmpty() ) { 1194 if ( !addr.isEmpty() ) {
1194 if ( !merge ) 1195 if ( !merge )
1195 addr.setCategories( categories ); 1196 addr.setCategories( categories );
1196 else { 1197 else {
1197 QStringList addrCategories = addr.categories(); 1198 QStringList addrCategories = addr.categories();
1198 QStringList::Iterator catIt; 1199 QStringList::Iterator catIt;
1199 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1200 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1200 if ( !addrCategories.contains( *catIt ) ) 1201 if ( !addrCategories.contains( *catIt ) )
1201 addrCategories.append( *catIt ); 1202 addrCategories.append( *catIt );
1202 } 1203 }
1203 addr.setCategories( addrCategories ); 1204 addr.setCategories( addrCategories );
1204 } 1205 }
1205 mAddressBook->insertAddressee( addr ); 1206 mAddressBook->insertAddressee( addr );
1206 } 1207 }
1207 } 1208 }
1208 1209
1209 if ( uids.count() > 0 ) 1210 if ( uids.count() > 0 )
1210 setModified( true ); 1211 setModified( true );
1211 message( i18n("Setting categories completed!") ); 1212 message( i18n("Setting categories completed!") );
1212} 1213}
1213 1214
1214void KABCore::setSearchFields( const KABC::Field::List &fields ) 1215void KABCore::setSearchFields( const KABC::Field::List &fields )
1215{ 1216{
1216 mIncSearchWidget->setFields( fields ); 1217 mIncSearchWidget->setFields( fields );
1217} 1218}
1218 1219
1219void KABCore::incrementalSearch( const QString& text ) 1220void KABCore::incrementalSearch( const QString& text )
1220{ 1221{
1221 QString stext; 1222 QString stext;
1222 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { 1223 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) {
1223 stext = "*" + text; 1224 stext = "*" + text;
1224 } else { 1225 } else {
1225 stext = text; 1226 stext = text;
1226 } 1227 }
1227 mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); 1228 mViewManager->doSearch( stext, mIncSearchWidget->currentField() );
1228} 1229}
1229void KABCore::incrementalSearchJump( const QString& text ) 1230void KABCore::incrementalSearchJump( const QString& text )
1230{ 1231{
1231 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1232 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1232} 1233}
1233 1234
1234void KABCore::setModified() 1235void KABCore::setModified()
1235{ 1236{
1236 setModified( true ); 1237 setModified( true );
1237} 1238}
1238 1239
1239void KABCore::setModifiedWOrefresh() 1240void KABCore::setModifiedWOrefresh()
1240{ 1241{
1241 // qDebug("KABCore::setModifiedWOrefresh() "); 1242 // qDebug("KABCore::setModifiedWOrefresh() ");
1242 mModified = true; 1243 mModified = true;
1243 mActionSave->setEnabled( mModified ); 1244 mActionSave->setEnabled( mModified );
1244 1245
1245 1246
1246} 1247}
1247void KABCore::setModified( bool modified ) 1248void KABCore::setModified( bool modified )
1248{ 1249{
1249 mModified = modified; 1250 mModified = modified;
1250 mActionSave->setEnabled( mModified ); 1251 mActionSave->setEnabled( mModified );
1251 1252
1252 if ( modified ) 1253 if ( modified )
1253 mJumpButtonBar->recreateButtons(); 1254 mJumpButtonBar->recreateButtons();
1254 1255
1255 mViewManager->refreshView(); 1256 mViewManager->refreshView();
1256 1257
1257} 1258}
1258 1259
1259bool KABCore::modified() const 1260bool KABCore::modified() const
1260{ 1261{
1261 return mModified; 1262 return mModified;
1262} 1263}
1263 1264
1264void KABCore::contactModified( const KABC::Addressee &addr ) 1265void KABCore::contactModified( const KABC::Addressee &addr )
1265{ 1266{
1266 addrModified( addr ); 1267 addrModified( addr );
1267#if 0 // debug only 1268#if 0 // debug only
1268 KABC::Addressee ad = addr; 1269 KABC::Addressee ad = addr;
1269 ad.computeCsum( "123"); 1270 ad.computeCsum( "123");
1270#endif 1271#endif
1271} 1272}
1272 1273
1273void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) 1274void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
1274{ 1275{
1275 1276
1276 Command *command = 0; 1277 Command *command = 0;
1277 QString uid; 1278 QString uid;
1278 1279
1279 // check if it exists already 1280 // check if it exists already
1280 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1281 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1281 if ( origAddr.isEmpty() ) 1282 if ( origAddr.isEmpty() )
1282 command = new PwNewCommand( mAddressBook, addr ); 1283 command = new PwNewCommand( mAddressBook, addr );
1283 else { 1284 else {
1284 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1285 command = new PwEditCommand( mAddressBook, origAddr, addr );
1285 uid = addr.uid(); 1286 uid = addr.uid();
1286 } 1287 }
1287 1288
1288 UndoStack::instance()->push( command ); 1289 UndoStack::instance()->push( command );
1289 RedoStack::instance()->clear(); 1290 RedoStack::instance()->clear();
1290 if ( updateDetails ) 1291 if ( updateDetails )
1291 mDetails->setAddressee( addr ); 1292 mDetails->setAddressee( addr );
1292 setModified( true ); 1293 setModified( true );
1293} 1294}
1294 1295
1295void KABCore::newContact() 1296void KABCore::newContact()
1296{ 1297{
1297 1298
1298 1299
1299 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1300 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1300 1301
1301 QPtrList<KRES::Resource> kresResources; 1302 QPtrList<KRES::Resource> kresResources;
1302 QPtrListIterator<KABC::Resource> it( kabcResources ); 1303 QPtrListIterator<KABC::Resource> it( kabcResources );
1303 KABC::Resource *resource; 1304 KABC::Resource *resource;
1304 while ( ( resource = it.current() ) != 0 ) { 1305 while ( ( resource = it.current() ) != 0 ) {
1305 ++it; 1306 ++it;
1306 if ( !resource->readOnly() ) { 1307 if ( !resource->readOnly() ) {
1307 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1308 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1308 if ( res ) 1309 if ( res )
1309 kresResources.append( res ); 1310 kresResources.append( res );
1310 } 1311 }
1311 } 1312 }
1312 1313
1313 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1314 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1314 resource = static_cast<KABC::Resource*>( res ); 1315 resource = static_cast<KABC::Resource*>( res );
1315 1316
1316 if ( resource ) { 1317 if ( resource ) {
1317 KABC::Addressee addr; 1318 KABC::Addressee addr;
1318 addr.setResource( resource ); 1319 addr.setResource( resource );
1319 mEditorDialog->setAddressee( addr ); 1320 mEditorDialog->setAddressee( addr );
1320 mEditorDialog->setCaption( i18n("Edit new contact")); 1321 mEditorDialog->setCaption( i18n("Edit new contact"));
1321 KApplication::execDialog ( mEditorDialog ); 1322 KApplication::execDialog ( mEditorDialog );
1322 1323
1323 } else 1324 } else
1324 return; 1325 return;
1325 1326
1326 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1327 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1327 1328
1328 1329
1329} 1330}
1330 1331
1331void KABCore::addEmail( QString aStr ) 1332void KABCore::addEmail( QString aStr )
1332{ 1333{
1333#ifndef KAB_EMBEDDED 1334#ifndef KAB_EMBEDDED
1334 QString fullName, email; 1335 QString fullName, email;
1335 1336
1336 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1337 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1337 1338
1338 // Try to lookup the addressee matching the email address 1339 // Try to lookup the addressee matching the email address
1339 bool found = false; 1340 bool found = false;
1340 QStringList emailList; 1341 QStringList emailList;
1341 KABC::AddressBook::Iterator it; 1342 KABC::AddressBook::Iterator it;
1342 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1343 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1343 emailList = (*it).emails(); 1344 emailList = (*it).emails();
1344 if ( emailList.contains( email ) > 0 ) { 1345 if ( emailList.contains( email ) > 0 ) {
1345 found = true; 1346 found = true;
1346 (*it).setNameFromString( fullName ); 1347 (*it).setNameFromString( fullName );
1347 editContact( (*it).uid() ); 1348 editContact( (*it).uid() );
1348 } 1349 }
1349 } 1350 }
1350 1351
1351 if ( !found ) { 1352 if ( !found ) {
1352 KABC::Addressee addr; 1353 KABC::Addressee addr;
1353 addr.setNameFromString( fullName ); 1354 addr.setNameFromString( fullName );
1354 addr.insertEmail( email, true ); 1355 addr.insertEmail( email, true );
1355 1356
1356 mAddressBook->insertAddressee( addr ); 1357 mAddressBook->insertAddressee( addr );
1357 mViewManager->refreshView( addr.uid() ); 1358 mViewManager->refreshView( addr.uid() );
1358 editContact( addr.uid() ); 1359 editContact( addr.uid() );
1359 } 1360 }
1360#else //KAB_EMBEDDED 1361#else //KAB_EMBEDDED
1361 qDebug("KABCore::addEmail finsih method"); 1362 qDebug("KABCore::addEmail finsih method");
1362#endif //KAB_EMBEDDED 1363#endif //KAB_EMBEDDED
1363} 1364}
1364 1365
1365void KABCore::importVCard( const KURL &url, bool showPreview ) 1366void KABCore::importVCard( const KURL &url, bool showPreview )
1366{ 1367{
1367 mXXPortManager->importVCard( url, showPreview ); 1368 mXXPortManager->importVCard( url, showPreview );
1368} 1369}
1369void KABCore::importFromOL() 1370void KABCore::importFromOL()
1370{ 1371{
1371#ifdef _OL_IMPORT_ 1372#ifdef _OL_IMPORT_
1372 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1373 KABC::Addressee::List list = OL_access::instance()->importOLcontacts();
1373 idgl->exec(); 1374 if ( list.count() > 0 ) {
1374 KABC::Addressee::List list = idgl->getAddressList(); 1375 KABC::Addressee::List listNew;
1375 if ( list.count() > 0 ) { 1376 KABC::Addressee::List listExisting;
1376 KABC::Addressee::List listNew; 1377 KABC::Addressee::List::Iterator it;
1377 KABC::Addressee::List listExisting; 1378 KABC::AddressBook::Iterator iter;
1378 KABC::Addressee::List::Iterator it; 1379 for ( it = list.begin(); it != list.end(); ++it ) {
1379 KABC::AddressBook::Iterator iter; 1380 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1380 for ( it = list.begin(); it != list.end(); ++it ) { 1381 listNew.append( (*it) );
1381 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1382 else
1382 listNew.append( (*it) ); 1383 listExisting.append( (*it) );
1383 else 1384 }
1384 listExisting.append( (*it) ); 1385 QString mess = i18n("%1 contacts read from OL.\n\n%2 contacts added to addressbook!").arg( list.count()).arg( listNew.count() );
1385 } 1386 if ( listExisting.count() > 0 )
1386 if ( listExisting.count() > 0 ) 1387 mess += "\n\n"+ i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() );
1387 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1388
1388 if ( listNew.count() > 0 ) { 1389 KMessageBox::information( this, mess );
1389 pasteWithNewUid = false; 1390 if ( listNew.count() > 0 ) {
1390 pasteContacts( listNew ); 1391 pasteWithNewUid = false;
1391 pasteWithNewUid = true; 1392 pasteContacts( listNew );
1393 pasteWithNewUid = true;
1394 }
1392 } 1395 }
1393 }
1394 delete idgl;
1395#endif 1396#endif
1396} 1397}
1397 1398
1399bool KABCore::readOLdata( KABC::AddressBook* local )
1400{
1401#ifdef _OL_IMPORT_
1402 QStringList folderList = OL_access::instance()->getFolderSelection( OL_CONTACT_DATA , i18n("Select Folder to sync"));
1403 KABC::Addressee::List list;
1404 if ( folderList.count() ) {
1405 OL_access::instance()->readContactData( OL_access::instance()->getFolderFromID( 0, folderList[1] ) , &list, true );
1406 KABC::Addressee::List::Iterator it;
1407 for ( it = list.begin(); it != list.end(); ++it ) {
1408 (*it).setExternalUID( (*it).uid() );
1409 (*it).setOriginalExternalUID( (*it).uid() );
1410 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
1411 local->insertAddressee( (*it) , false, false );
1412 }
1413 mOLsyncFolderID = folderList[1];
1414 //KMessageBox::information( this, i18n("OLsync folder ID ") + mOLsyncFolderID );
1415 }
1416 return list.count() > 0;
1417#else
1418 return false;
1419#endif
1420}
1421bool KABCore::writeOLdata( KABC::AddressBook* aBook )
1422{
1423#ifdef _OL_IMPORT_
1424 if ( !OL_access::instance()->setSelectedFolder( mOLsyncFolderID ) )
1425 return false;
1426 KABC::AddressBook::Iterator it;
1427 for ( it = aBook->begin(); it != aBook->end(); ++it ) {
1428 if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
1429 KABC::Addressee addressee = (*it);
1430 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) {
1431 (*it) = OL_access::instance()->addAddressee( (*it) );
1432 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
1433 } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
1434 OL_access::instance()->deleteAddressee( (*it) );
1435 } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
1436 //changed
1437 (*it) = OL_access::instance()->changeAddressee( (*it) );
1438 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM );
1439 }
1440 }
1441 }
1442 return true;
1443#else
1444 return false;
1445#endif
1446}
1398void KABCore::importVCard( const QString &vCard, bool showPreview ) 1447void KABCore::importVCard( const QString &vCard, bool showPreview )
1399{ 1448{
1400 mXXPortManager->importVCard( vCard, showPreview ); 1449 mXXPortManager->importVCard( vCard, showPreview );
1401} 1450}
1402 1451
1403//US added a second method without defaultparameter 1452//US added a second method without defaultparameter
1404void KABCore::editContact2() { 1453void KABCore::editContact2() {
1405 editContact( QString::null ); 1454 editContact( QString::null );
1406} 1455}
1407 1456
1408void KABCore::editContact( const QString &uid ) 1457void KABCore::editContact( const QString &uid )
1409{ 1458{
1410 1459
1411 if ( mExtensionManager->isQuickEditVisible() ) 1460 if ( mExtensionManager->isQuickEditVisible() )
1412 return; 1461 return;
1413 1462
1414 // First, locate the contact entry 1463 // First, locate the contact entry
1415 QString localUID = uid; 1464 QString localUID = uid;
1416 if ( localUID.isNull() ) { 1465 if ( localUID.isNull() ) {
1417 QStringList uidList = mViewManager->selectedUids(); 1466 QStringList uidList = mViewManager->selectedUids();
1418 if ( uidList.count() > 0 ) 1467 if ( uidList.count() > 0 )
1419 localUID = *( uidList.at( 0 ) ); 1468 localUID = *( uidList.at( 0 ) );
1420 } 1469 }
1421 1470
1422 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1471 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1423 if ( !addr.isEmpty() ) { 1472 if ( !addr.isEmpty() ) {
1424 mEditorDialog->setAddressee( addr ); 1473 mEditorDialog->setAddressee( addr );
1425 KApplication::execDialog ( mEditorDialog ); 1474 KApplication::execDialog ( mEditorDialog );
1426 } 1475 }
1427} 1476}
1428 1477
1429/** 1478/**
1430 Shows or edits the detail view for the given uid. If the uid is QString::null, 1479 Shows or edits the detail view for the given uid. If the uid is QString::null,
1431 the method will try to find a selected addressee in the view. 1480 the method will try to find a selected addressee in the view.
1432 */ 1481 */
1433void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1482void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1434{ 1483{
1435 if ( mMultipleViewsAtOnce ) 1484 if ( mMultipleViewsAtOnce )
1436 { 1485 {
1437 editContact( uid ); 1486 editContact( uid );
1438 } 1487 }
1439 else 1488 else
1440 { 1489 {
1441 setDetailsVisible( true ); 1490 setDetailsVisible( true );
1442 mActionDetails->setChecked(true); 1491 mActionDetails->setChecked(true);
1443 } 1492 }
1444 1493
1445} 1494}
1446 1495
1447void KABCore::save() 1496void KABCore::save()
1448{ 1497{
1449 if (syncManager->blockSave()) 1498 if (syncManager->blockSave())
1450 return; 1499 return;
1451 if ( !mModified ) 1500 if ( !mModified )
1452 return; 1501 return;
1453 1502
1454 syncManager->setBlockSave(true); 1503 syncManager->setBlockSave(true);
1455 QString text = i18n( "There was an error while attempting to save\n the " 1504 QString text = i18n( "There was an error while attempting to save\n the "
1456 "address book. Please check that some \nother application is " 1505 "address book. Please check that some \nother application is "
1457 "not using it. " ); 1506 "not using it. " );
1458 message(i18n("Saving ... please wait! "), false); 1507 message(i18n("Saving ... please wait! "), false);
1459 //qApp->processEvents(); 1508 //qApp->processEvents();
1460#ifndef KAB_EMBEDDED 1509#ifndef KAB_EMBEDDED
1461 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1510 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1462 if ( !b || !b->save() ) { 1511 if ( !b || !b->save() ) {
1463 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1512 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1464 } 1513 }
1465#else //KAB_EMBEDDED 1514#else //KAB_EMBEDDED
1466 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1515 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1467 if ( !b || !b->save() ) { 1516 if ( !b || !b->save() ) {
1468 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1517 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1469 } 1518 }
1470#endif //KAB_EMBEDDED 1519#endif //KAB_EMBEDDED
1471 1520
1472 message(i18n("Addressbook saved!")); 1521 message(i18n("Addressbook saved!"));
1473 setModified( false ); 1522 setModified( false );
1474 syncManager->setBlockSave(false); 1523 syncManager->setBlockSave(false);
1475} 1524}
1476 1525
1477 1526
1478void KABCore::undo() 1527void KABCore::undo()
1479{ 1528{
1480 UndoStack::instance()->undo(); 1529 UndoStack::instance()->undo();
1481 1530
1482 // Refresh the view 1531 // Refresh the view
1483 mViewManager->refreshView(); 1532 mViewManager->refreshView();
1484} 1533}
1485 1534
1486void KABCore::redo() 1535void KABCore::redo()
1487{ 1536{
1488 RedoStack::instance()->redo(); 1537 RedoStack::instance()->redo();
1489 1538
1490 // Refresh the view 1539 // Refresh the view
1491 mViewManager->refreshView(); 1540 mViewManager->refreshView();
1492} 1541}
1493void KABCore::setJumpButtonBar( bool visible ) 1542void KABCore::setJumpButtonBar( bool visible )
1494{ 1543{
1495 setJumpButtonBarVisible(visible ); 1544 setJumpButtonBarVisible(visible );
1496 saveSettings(); 1545 saveSettings();
1497} 1546}
1498void KABCore::setJumpButtonBarVisible( bool visible ) 1547void KABCore::setJumpButtonBarVisible( bool visible )
1499{ 1548{
1500 if (mMultipleViewsAtOnce) 1549 if (mMultipleViewsAtOnce)
1501 { 1550 {
1502 if ( visible ) 1551 if ( visible )
1503 mJumpButtonBar->show(); 1552 mJumpButtonBar->show();
1504 else 1553 else
1505 mJumpButtonBar->hide(); 1554 mJumpButtonBar->hide();
1506 } 1555 }
1507 else 1556 else
1508 { 1557 {
1509 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1558 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1510 if (mViewManager->isVisible()) 1559 if (mViewManager->isVisible())
1511 { 1560 {
1512 if ( visible ) 1561 if ( visible )
1513 mJumpButtonBar->show(); 1562 mJumpButtonBar->show();
1514 else 1563 else
1515 mJumpButtonBar->hide(); 1564 mJumpButtonBar->hide();
1516 } 1565 }
1517 else 1566 else
1518 { 1567 {
1519 mJumpButtonBar->hide(); 1568 mJumpButtonBar->hide();
1520 } 1569 }
1521 } 1570 }
1522 if ( visible ) { 1571 if ( visible ) {
1523 if ( mIncSearchWidget->currentItem() == 0 ) { 1572 if ( mIncSearchWidget->currentItem() == 0 ) {
1524 message( i18n("Change search field enable jump bar") ); 1573 message( i18n("Change search field enable jump bar") );
1525 } 1574 }
1526 } 1575 }
1527} 1576}
1528 1577
1529 1578
1530void KABCore::setDetailsToState() 1579void KABCore::setDetailsToState()
1531{ 1580{
1532 setDetailsVisible( mActionDetails->isChecked() ); 1581 setDetailsVisible( mActionDetails->isChecked() );
1533} 1582}
1534void KABCore::setDetailsToggle() 1583void KABCore::setDetailsToggle()
1535{ 1584{
1536 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1585 mActionDetails->setChecked( !mActionDetails->isChecked() );
1537 setDetailsToState(); 1586 setDetailsToState();
1538} 1587}
1539 1588
1540 1589
1541 1590
1542void KABCore::setDetailsVisible( bool visible ) 1591void KABCore::setDetailsVisible( bool visible )
1543{ 1592{
1544 if (visible && mDetails->isHidden()) 1593 if (visible && mDetails->isHidden())
1545 { 1594 {
1546 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1595 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1547 if ( addrList.count() > 0 ) 1596 if ( addrList.count() > 0 )
1548 mDetails->setAddressee( addrList[ 0 ] ); 1597 mDetails->setAddressee( addrList[ 0 ] );
1549 } 1598 }
1550 1599
1551 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1600 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1552 // the listview and the detailview. We do that by changing the splitbar size. 1601 // the listview and the detailview. We do that by changing the splitbar size.
1553 if (mMultipleViewsAtOnce) 1602 if (mMultipleViewsAtOnce)
1554 { 1603 {
1555 if ( visible ) 1604 if ( visible )
1556 mDetails->show(); 1605 mDetails->show();
1557 else 1606 else
1558 mDetails->hide(); 1607 mDetails->hide();
1559 } 1608 }
1560 else 1609 else
1561 { 1610 {
1562 if ( visible ) { 1611 if ( visible ) {
1563 mViewManager->hide(); 1612 mViewManager->hide();
1564 mDetails->show(); 1613 mDetails->show();
1565 mIncSearchWidget->setFocus(); 1614 mIncSearchWidget->setFocus();
1566 } 1615 }
1567 else { 1616 else {
1568 mViewManager->show(); 1617 mViewManager->show();
1569 mDetails->hide(); 1618 mDetails->hide();
1570 mViewManager->setFocusAV(); 1619 mViewManager->setFocusAV();
1571 } 1620 }
1572 setJumpButtonBarVisible( !visible ); 1621 setJumpButtonBarVisible( !visible );
1573 } 1622 }
1574 1623
1575} 1624}
1576 1625
1577void KABCore::extensionChanged( int id ) 1626void KABCore::extensionChanged( int id )
1578{ 1627{
1579 //change the details view only for non desktop systems 1628 //change the details view only for non desktop systems
1580#ifndef DESKTOP_VERSION 1629#ifndef DESKTOP_VERSION
1581 1630
1582 if (id == 0) 1631 if (id == 0)
1583 { 1632 {
1584 //the user disabled the extension. 1633 //the user disabled the extension.
1585 1634
1586 if (mMultipleViewsAtOnce) 1635 if (mMultipleViewsAtOnce)
1587 { // enable detailsview again 1636 { // enable detailsview again
1588 setDetailsVisible( true ); 1637 setDetailsVisible( true );
1589 mActionDetails->setChecked( true ); 1638 mActionDetails->setChecked( true );
1590 } 1639 }
1591 else 1640 else
1592 { //go back to the listview 1641 { //go back to the listview
1593 setDetailsVisible( false ); 1642 setDetailsVisible( false );
1594 mActionDetails->setChecked( false ); 1643 mActionDetails->setChecked( false );
1595 mActionDetails->setEnabled(true); 1644 mActionDetails->setEnabled(true);
1596 } 1645 }
1597 1646
1598 } 1647 }
1599 else 1648 else
1600 { 1649 {
1601 //the user enabled the extension. 1650 //the user enabled the extension.
1602 setDetailsVisible( false ); 1651 setDetailsVisible( false );
1603 mActionDetails->setChecked( false ); 1652 mActionDetails->setChecked( false );
1604 1653
1605 if (!mMultipleViewsAtOnce) 1654 if (!mMultipleViewsAtOnce)
1606 { 1655 {
1607 mActionDetails->setEnabled(false); 1656 mActionDetails->setEnabled(false);
1608 } 1657 }
1609 1658
1610 mExtensionManager->setSelectionChanged(); 1659 mExtensionManager->setSelectionChanged();
1611 1660
1612 } 1661 }
1613 1662
1614#endif// DESKTOP_VERSION 1663#endif// DESKTOP_VERSION
1615 1664
1616} 1665}
1617 1666
1618 1667
1619void KABCore::extensionModified( const KABC::Addressee::List &list ) 1668void KABCore::extensionModified( const KABC::Addressee::List &list )
1620{ 1669{
1621 1670
1622 if ( list.count() != 0 ) { 1671 if ( list.count() != 0 ) {
1623 KABC::Addressee::List::ConstIterator it; 1672 KABC::Addressee::List::ConstIterator it;
1624 for ( it = list.begin(); it != list.end(); ++it ) 1673 for ( it = list.begin(); it != list.end(); ++it )
1625 mAddressBook->insertAddressee( *it ); 1674 mAddressBook->insertAddressee( *it );
1626 if ( list.count() > 1 ) 1675 if ( list.count() > 1 )
1627 setModified(); 1676 setModified();
1628 else 1677 else
1629 setModifiedWOrefresh(); 1678 setModifiedWOrefresh();
1630 } 1679 }
1631 if ( list.count() == 0 ) 1680 if ( list.count() == 0 )
1632 mViewManager->refreshView(); 1681 mViewManager->refreshView();
1633 else 1682 else
1634 mViewManager->refreshView( list[ 0 ].uid() ); 1683 mViewManager->refreshView( list[ 0 ].uid() );
1635 1684
1636 1685
1637 1686
1638} 1687}
1639 1688
1640QString KABCore::getNameByPhone( const QString &phone ) 1689QString KABCore::getNameByPhone( const QString &phone )
1641{ 1690{
1642#ifndef KAB_EMBEDDED 1691#ifndef KAB_EMBEDDED
1643 QRegExp r( "[/*/-/ ]" ); 1692 QRegExp r( "[/*/-/ ]" );
1644 QString localPhone( phone ); 1693 QString localPhone( phone );
1645 1694
1646 bool found = false; 1695 bool found = false;
1647 QString ownerName = ""; 1696 QString ownerName = "";
1648 KABC::AddressBook::Iterator iter; 1697 KABC::AddressBook::Iterator iter;
1649 KABC::PhoneNumber::List::Iterator phoneIter; 1698 KABC::PhoneNumber::List::Iterator phoneIter;
1650 KABC::PhoneNumber::List phoneList; 1699 KABC::PhoneNumber::List phoneList;
1651 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1700 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1652 phoneList = (*iter).phoneNumbers(); 1701 phoneList = (*iter).phoneNumbers();
1653 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1702 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1654 ++phoneIter) { 1703 ++phoneIter) {
1655 // Get rid of separator chars so just the numbers are compared. 1704 // Get rid of separator chars so just the numbers are compared.
1656 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1705 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1657 ownerName = (*iter).formattedName(); 1706 ownerName = (*iter).formattedName();
1658 found = true; 1707 found = true;
1659 } 1708 }
1660 } 1709 }
1661 } 1710 }
1662 1711
1663 return ownerName; 1712 return ownerName;
1664#else //KAB_EMBEDDED 1713#else //KAB_EMBEDDED
1665 qDebug("KABCore::getNameByPhone finsih method"); 1714 qDebug("KABCore::getNameByPhone finsih method");
1666 return ""; 1715 return "";
1667#endif //KAB_EMBEDDED 1716#endif //KAB_EMBEDDED
1668 1717
1669} 1718}
1670void KABCore::openConfigGlobalDialog() 1719void KABCore::openConfigGlobalDialog()
1671{ 1720{
1672 KPimPrefsGlobalDialog gc ( this ); 1721 KPimPrefsGlobalDialog gc ( this );
1673 gc.exec(); 1722 gc.exec();
1674} 1723}
1675void KABCore::openConfigDialog() 1724void KABCore::openConfigDialog()
1676{ 1725{
1677 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true); 1726 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true);
1678 1727
1679 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" ); 1728 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" );
1680 ConfigureDialog->setMainWidget( kabcfg ); 1729 ConfigureDialog->setMainWidget( kabcfg );
1681 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1730 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1682 this, SLOT( configurationChanged() ) ); 1731 this, SLOT( configurationChanged() ) );
1683 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1732 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1684 kabcfg, SLOT( save() ) ); 1733 kabcfg, SLOT( save() ) );
1685 connect( ConfigureDialog, SIGNAL( acceptClicked() ), 1734 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
1686 this, SLOT( configurationChanged() ) ); 1735 this, SLOT( configurationChanged() ) );
1687 connect( ConfigureDialog, SIGNAL( acceptClicked() ), 1736 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
1688 kabcfg, SLOT( save() ) ); 1737 kabcfg, SLOT( save() ) );
1689 connect( ConfigureDialog, SIGNAL( defaultClicked() ), 1738 connect( ConfigureDialog, SIGNAL( defaultClicked() ),
1690 kabcfg, SLOT( defaults() ) ); 1739 kabcfg, SLOT( defaults() ) );
1691 saveSettings(); 1740 saveSettings();
1692 kabcfg->load(); 1741 kabcfg->load();
1693#ifndef DESKTOP_VERSION 1742#ifndef DESKTOP_VERSION
1694 if ( QApplication::desktop()->height() <= 480 ) 1743 if ( QApplication::desktop()->height() <= 480 )
1695 ConfigureDialog->hideButtons(); 1744 ConfigureDialog->hideButtons();
1696 ConfigureDialog->showMaximized(); 1745 ConfigureDialog->showMaximized();
1697#endif 1746#endif
1698 if ( ConfigureDialog->exec() ) 1747 if ( ConfigureDialog->exec() )
1699 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1748 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1700 delete ConfigureDialog; 1749 delete ConfigureDialog;
1701} 1750}
1702 1751
1703void KABCore::openLDAPDialog() 1752void KABCore::openLDAPDialog()
1704{ 1753{
1705#ifndef KAB_EMBEDDED 1754#ifndef KAB_EMBEDDED
1706 if ( !mLdapSearchDialog ) { 1755 if ( !mLdapSearchDialog ) {
1707 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1756 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1708 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1757 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1709 SLOT( refreshView() ) ); 1758 SLOT( refreshView() ) );
1710 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1759 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1711 SLOT( setModified() ) ); 1760 SLOT( setModified() ) );
1712 } else 1761 } else
1713 mLdapSearchDialog->restoreSettings(); 1762 mLdapSearchDialog->restoreSettings();
1714 1763
1715 if ( mLdapSearchDialog->isOK() ) 1764 if ( mLdapSearchDialog->isOK() )
1716 mLdapSearchDialog->exec(); 1765 mLdapSearchDialog->exec();
1717#else //KAB_EMBEDDED 1766#else //KAB_EMBEDDED
1718 qDebug("KABCore::openLDAPDialog() finsih method"); 1767 qDebug("KABCore::openLDAPDialog() finsih method");
1719#endif //KAB_EMBEDDED 1768#endif //KAB_EMBEDDED
1720} 1769}
1721 1770
1722void KABCore::print() 1771void KABCore::print()
1723{ 1772{
1724#ifndef KAB_EMBEDDED 1773#ifndef KAB_EMBEDDED
1725 KPrinter printer; 1774 KPrinter printer;
1726 if ( !printer.setup( this ) ) 1775 if ( !printer.setup( this ) )
1727 return; 1776 return;
1728 1777
1729 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1778 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1730 mViewManager->selectedUids(), this ); 1779 mViewManager->selectedUids(), this );
1731 1780
1732 wizard.exec(); 1781 wizard.exec();
1733#else //KAB_EMBEDDED 1782#else //KAB_EMBEDDED
1734 qDebug("KABCore::print() finsih method"); 1783 qDebug("KABCore::print() finsih method");
1735#endif //KAB_EMBEDDED 1784#endif //KAB_EMBEDDED
1736 1785
1737} 1786}
1738 1787
1739 1788
1740void KABCore::addGUIClient( KXMLGUIClient *client ) 1789void KABCore::addGUIClient( KXMLGUIClient *client )
1741{ 1790{
1742 if ( mGUIClient ) 1791 if ( mGUIClient )
1743 mGUIClient->insertChildClient( client ); 1792 mGUIClient->insertChildClient( client );
1744 else 1793 else
1745 KMessageBox::error( this, "no KXMLGUICLient"); 1794 KMessageBox::error( this, "no KXMLGUICLient");
1746} 1795}
1747 1796
1748 1797
1749void KABCore::configurationChanged() 1798void KABCore::configurationChanged()
1750{ 1799{
1751 mExtensionManager->reconfigure(); 1800 mExtensionManager->reconfigure();
1752} 1801}
1753 1802
1754void KABCore::addressBookChanged() 1803void KABCore::addressBookChanged()
1755{ 1804{
1756/*US 1805/*US
1757 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1806 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1758 while ( it.current() ) { 1807 while ( it.current() ) {
1759 if ( it.current()->dirty() ) { 1808 if ( it.current()->dirty() ) {
1760 QString text = i18n( "Data has been changed externally. Unsaved " 1809 QString text = i18n( "Data has been changed externally. Unsaved "
1761 "changes will be lost." ); 1810 "changes will be lost." );
1762 KMessageBox::information( this, text ); 1811 KMessageBox::information( this, text );
1763 } 1812 }
1764 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1813 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1765 ++it; 1814 ++it;
1766 } 1815 }
1767*/ 1816*/
1768 if (mEditorDialog) 1817 if (mEditorDialog)
1769 { 1818 {
1770 if (mEditorDialog->dirty()) 1819 if (mEditorDialog->dirty())
1771 { 1820 {
1772 QString text = i18n( "Data has been changed externally. Unsaved " 1821 QString text = i18n( "Data has been changed externally. Unsaved "
1773 "changes will be lost." ); 1822 "changes will be lost." );
1774 KMessageBox::information( this, text ); 1823 KMessageBox::information( this, text );
1775 } 1824 }
1776 QString currentuid = mEditorDialog->addressee().uid(); 1825 QString currentuid = mEditorDialog->addressee().uid();
1777 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1826 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1778 } 1827 }
1779 mViewManager->refreshView(); 1828 mViewManager->refreshView();
1780 1829
1781 1830
1782} 1831}
1783 1832
1784AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1833AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1785 const char *name ) 1834 const char *name )
1786{ 1835{
1787 1836
1788 if ( mEditorDialog == 0 ) { 1837 if ( mEditorDialog == 0 ) {
1789 mEditorDialog = new AddresseeEditorDialog( this, parent, 1838 mEditorDialog = new AddresseeEditorDialog( this, parent,
1790 name ? name : "editorDialog" ); 1839 name ? name : "editorDialog" );
1791 1840
1792 1841
1793 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1842 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1794 SLOT( contactModified( const KABC::Addressee& ) ) ); 1843 SLOT( contactModified( const KABC::Addressee& ) ) );
1795 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1844 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1796 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1845 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1797 } 1846 }
1798 1847
1799 return mEditorDialog; 1848 return mEditorDialog;
1800} 1849}
1801 1850
1802void KABCore::slotEditorDestroyed( const QString &uid ) 1851void KABCore::slotEditorDestroyed( const QString &uid )
1803{ 1852{
1804 //mEditorDict.remove( uid ); 1853 //mEditorDict.remove( uid );
1805} 1854}
1806 1855
1807void KABCore::initGUI() 1856void KABCore::initGUI()
1808{ 1857{
1809#ifndef KAB_EMBEDDED 1858#ifndef KAB_EMBEDDED
1810 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1859 QHBoxLayout *topLayout = new QHBoxLayout( this );
1811 topLayout->setSpacing( KDialogBase::spacingHint() ); 1860 topLayout->setSpacing( KDialogBase::spacingHint() );
1812 1861
1813 mExtensionBarSplitter = new QSplitter( this ); 1862 mExtensionBarSplitter = new QSplitter( this );
1814 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1863 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1815 1864
1816 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1865 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1817 1866
1818 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1867 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1819 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1868 mIncSearchWidget = new IncSearchWidget( viewSpace );
1820 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1869 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1821 SLOT( incrementalSearch( const QString& ) ) ); 1870 SLOT( incrementalSearch( const QString& ) ) );
1822 1871
1823 mViewManager = new ViewManager( this, viewSpace ); 1872 mViewManager = new ViewManager( this, viewSpace );
1824 viewSpace->setStretchFactor( mViewManager, 1 ); 1873 viewSpace->setStretchFactor( mViewManager, 1 );
1825 1874
1826 mDetails = new ViewContainer( mDetailsSplitter ); 1875 mDetails = new ViewContainer( mDetailsSplitter );
1827 1876
1828 mJumpButtonBar = new JumpButtonBar( this, this ); 1877 mJumpButtonBar = new JumpButtonBar( this, this );
1829 1878
1830 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1879 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1831 1880
1832 topLayout->addWidget( mExtensionBarSplitter ); 1881 topLayout->addWidget( mExtensionBarSplitter );
1833 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1882 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1834 topLayout->addWidget( mJumpButtonBar ); 1883 topLayout->addWidget( mJumpButtonBar );
1835 //topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1884 //topLayout->setStretchFactor( mJumpButtonBar, 1 );
1836 1885
1837 mXXPortManager = new XXPortManager( this, this ); 1886 mXXPortManager = new XXPortManager( this, this );
1838 1887
1839#else //KAB_EMBEDDED 1888#else //KAB_EMBEDDED
1840 //US initialize viewMenu before settingup viewmanager. 1889 //US initialize viewMenu before settingup viewmanager.
1841 // Viewmanager needs this menu to plugin submenues. 1890 // Viewmanager needs this menu to plugin submenues.
1842 viewMenu = new QPopupMenu( this ); 1891 viewMenu = new QPopupMenu( this );
1843 settingsMenu = new QPopupMenu( this ); 1892 settingsMenu = new QPopupMenu( this );
1844 //filterMenu = new QPopupMenu( this ); 1893 //filterMenu = new QPopupMenu( this );
1845 ImportMenu = new QPopupMenu( this ); 1894 ImportMenu = new QPopupMenu( this );
1846 ExportMenu = new QPopupMenu( this ); 1895 ExportMenu = new QPopupMenu( this );
1847 syncMenu = new QPopupMenu( this ); 1896 syncMenu = new QPopupMenu( this );
1848 changeMenu= new QPopupMenu( this ); 1897 changeMenu= new QPopupMenu( this );
1849 beamMenu= new QPopupMenu( this ); 1898 beamMenu= new QPopupMenu( this );
1850 1899
1851//US since we have no splitter for the embedded system, setup 1900//US since we have no splitter for the embedded system, setup
1852// a layout with two frames. One left and one right. 1901// a layout with two frames. One left and one right.
1853 1902
1854 QBoxLayout *topLayout; 1903 QBoxLayout *topLayout;
1855 1904
1856 // = new QHBoxLayout( this ); 1905 // = new QHBoxLayout( this );
1857// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1906// QBoxLayout *topLayout = (QBoxLayout*)layout();
1858 1907
1859// QWidget *mainBox = new QWidget( this ); 1908// QWidget *mainBox = new QWidget( this );
1860// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1909// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1861 1910
1862#ifdef DESKTOP_VERSION 1911#ifdef DESKTOP_VERSION
1863 topLayout = new QHBoxLayout( this ); 1912 topLayout = new QHBoxLayout( this );
1864 1913
1865 1914
1866 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1915 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1867 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1916 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1868 1917
1869 topLayout->addWidget(mMiniSplitter ); 1918 topLayout->addWidget(mMiniSplitter );
1870 1919
1871 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1920 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1872 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1921 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1873 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1922 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1874 mDetails = new ViewContainer( mMiniSplitter ); 1923 mDetails = new ViewContainer( mMiniSplitter );
1875 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1924 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1876#else 1925#else
1877 if ( QApplication::desktop()->width() > 480 ) { 1926 if ( QApplication::desktop()->width() > 480 ) {
1878 topLayout = new QHBoxLayout( this ); 1927 topLayout = new QHBoxLayout( this );
1879 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1928 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1880 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1929 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1881 } else { 1930 } else {
1882 1931
1883 topLayout = new QHBoxLayout( this ); 1932 topLayout = new QHBoxLayout( this );
1884 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1933 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1885 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1934 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1886 } 1935 }
1887 1936
1888 topLayout->addWidget(mMiniSplitter ); 1937 topLayout->addWidget(mMiniSplitter );
1889 mViewManager = new ViewManager( this, mMiniSplitter ); 1938 mViewManager = new ViewManager( this, mMiniSplitter );
1890 mDetails = new ViewContainer( mMiniSplitter ); 1939 mDetails = new ViewContainer( mMiniSplitter );
1891 1940
1892 1941
1893 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1942 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1894#endif 1943#endif
1895 //eh->hide(); 1944 //eh->hide();
1896 // topLayout->addWidget(mExtensionManager ); 1945 // topLayout->addWidget(mExtensionManager );
1897 1946
1898 1947
1899/*US 1948/*US
1900#ifndef KAB_NOSPLITTER 1949#ifndef KAB_NOSPLITTER
1901 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1950 QHBoxLayout *topLayout = new QHBoxLayout( this );
1902//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1951//US topLayout->setSpacing( KDialogBase::spacingHint() );
1903 topLayout->setSpacing( 10 ); 1952 topLayout->setSpacing( 10 );
1904 1953
1905 mDetailsSplitter = new QSplitter( this ); 1954 mDetailsSplitter = new QSplitter( this );
1906 1955
1907 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1956 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1908 1957
1909 mViewManager = new ViewManager( this, viewSpace ); 1958 mViewManager = new ViewManager( this, viewSpace );
1910 viewSpace->setStretchFactor( mViewManager, 1 ); 1959 viewSpace->setStretchFactor( mViewManager, 1 );
1911 1960
1912 mDetails = new ViewContainer( mDetailsSplitter ); 1961 mDetails = new ViewContainer( mDetailsSplitter );
1913 1962
1914 topLayout->addWidget( mDetailsSplitter ); 1963 topLayout->addWidget( mDetailsSplitter );
1915 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1964 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1916#else //KAB_NOSPLITTER 1965#else //KAB_NOSPLITTER
1917 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1966 QHBoxLayout *topLayout = new QHBoxLayout( this );
1918//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1967//US topLayout->setSpacing( KDialogBase::spacingHint() );
1919 topLayout->setSpacing( 10 ); 1968 topLayout->setSpacing( 10 );
1920 1969
1921// mDetailsSplitter = new QSplitter( this ); 1970// mDetailsSplitter = new QSplitter( this );
1922 1971
1923 QVBox *viewSpace = new QVBox( this ); 1972 QVBox *viewSpace = new QVBox( this );
1924 1973
1925 mViewManager = new ViewManager( this, viewSpace ); 1974 mViewManager = new ViewManager( this, viewSpace );
1926 viewSpace->setStretchFactor( mViewManager, 1 ); 1975 viewSpace->setStretchFactor( mViewManager, 1 );
1927 1976
1928 mDetails = new ViewContainer( this ); 1977 mDetails = new ViewContainer( this );
1929 1978
1930 topLayout->addWidget( viewSpace ); 1979 topLayout->addWidget( viewSpace );
1931// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1980// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1932 topLayout->addWidget( mDetails ); 1981 topLayout->addWidget( mDetails );
1933#endif //KAB_NOSPLITTER 1982#endif //KAB_NOSPLITTER
1934*/ 1983*/
1935 1984
1936 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1985 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1937 syncManager->setBlockSave(false); 1986 syncManager->setBlockSave(false);
1938 1987
1939 connect(syncManager , SIGNAL( request_file(const QString &) ), this, SLOT( syncFileRequest(const QString &) ) ); 1988 connect(syncManager , SIGNAL( request_file(const QString &) ), this, SLOT( syncFileRequest(const QString &) ) );
1940 connect(syncManager , SIGNAL( getFile( bool ,const QString &)), this, SLOT(getFile( bool ,const QString &) ) ); 1989 connect(syncManager , SIGNAL( getFile( bool ,const QString &)), this, SLOT(getFile( bool ,const QString &) ) );
1941 QString sync_file = sentSyncFile(); 1990 QString sync_file = sentSyncFile();
1942 //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); 1991 //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1());
1943 syncManager->setDefaultFileName( sync_file ); 1992 syncManager->setDefaultFileName( sync_file );
1944 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1993 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1945 1994
1946#endif //KAB_EMBEDDED 1995#endif //KAB_EMBEDDED
1947 initActions(); 1996 initActions();
1948 1997
1949#ifdef KAB_EMBEDDED 1998#ifdef KAB_EMBEDDED
1950 addActionsManually(); 1999 addActionsManually();
1951 //US make sure the export and import menues are initialized before creating the xxPortManager. 2000 //US make sure the export and import menues are initialized before creating the xxPortManager.
1952 mXXPortManager = new XXPortManager( this, this ); 2001 mXXPortManager = new XXPortManager( this, this );
1953 2002
1954 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 2003 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1955 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 2004 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1956 // mActionQuit->plug ( mMainWindow->toolBar()); 2005 // mActionQuit->plug ( mMainWindow->toolBar());
1957 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 2006 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1958 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 2007 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1959 // mIncSearchWidget->hide(); 2008 // mIncSearchWidget->hide();
1960 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2009 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1961 SLOT( incrementalSearch( const QString& ) ) ); 2010 SLOT( incrementalSearch( const QString& ) ) );
1962 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 2011 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1963 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 2012 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1964 2013
1965 mJumpButtonBar = new JumpButtonBar( this, this ); 2014 mJumpButtonBar = new JumpButtonBar( this, this );
1966 2015
1967 topLayout->addWidget( mJumpButtonBar ); 2016 topLayout->addWidget( mJumpButtonBar );
1968//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 2017//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1969 2018
1970// mMainWindow->getIconToolBar()->raise(); 2019// mMainWindow->getIconToolBar()->raise();
1971 2020
1972#endif //KAB_EMBEDDED 2021#endif //KAB_EMBEDDED
1973 2022
1974} 2023}
1975void KABCore::initActions() 2024void KABCore::initActions()
1976{ 2025{
1977//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2026//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1978 2027
1979#ifndef KAB_EMBEDDED 2028#ifndef KAB_EMBEDDED
1980 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 2029 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1981 SLOT( clipboardDataChanged() ) ); 2030 SLOT( clipboardDataChanged() ) );
1982#endif //KAB_EMBEDDED 2031#endif //KAB_EMBEDDED
1983 2032
1984 // file menu 2033 // file menu
1985 2034
1986 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 2035 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1987 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 2036 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1988 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, 2037 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager,
1989 SLOT( printView() ), actionCollection(), "kaddressbook_print" ); 2038 SLOT( printView() ), actionCollection(), "kaddressbook_print" );
1990 2039
1991 2040
1992 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, 2041 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails,
1993 SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); 2042 SLOT( printView() ), actionCollection(), "kaddressbook_print2" );
1994 2043
1995 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 2044 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1996 SLOT( save() ), actionCollection(), "file_sync" ); 2045 SLOT( save() ), actionCollection(), "file_sync" );
1997 2046
1998 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 2047 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1999 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 2048 SLOT( newContact() ), actionCollection(), "file_new_contact" );
2000 2049
2001 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 2050 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
2002 this, SLOT( mailVCard() ), 2051 this, SLOT( mailVCard() ),
2003 actionCollection(), "file_mail_vcard"); 2052 actionCollection(), "file_mail_vcard");
2004 2053
2005 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 2054 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
2006 SLOT( export2phone() ), actionCollection(), 2055 SLOT( export2phone() ), actionCollection(),
2007 "kaddressbook_ex2phone" ); 2056 "kaddressbook_ex2phone" );
2008 2057
2009 mActionBeamVCard = 0; 2058 mActionBeamVCard = 0;
2010 mActionBeam = 0; 2059 mActionBeam = 0;
2011 2060
2012#ifndef DESKTOP_VERSION 2061#ifndef DESKTOP_VERSION
2013 if ( Ir::supported() ) { 2062 if ( Ir::supported() ) {
2014 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, 2063 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this,
2015 SLOT( beamVCard() ), actionCollection(), 2064 SLOT( beamVCard() ), actionCollection(),
2016 "kaddressbook_beam_vcard" ); 2065 "kaddressbook_beam_vcard" );
2017 2066
2018 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 2067 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
2019 SLOT( beamMySelf() ), actionCollection(), 2068 SLOT( beamMySelf() ), actionCollection(),
2020 "kaddressbook_beam_myself" ); 2069 "kaddressbook_beam_myself" );
2021 } 2070 }
2022#endif 2071#endif
2023 2072
2024 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 2073 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
2025 this, SLOT( editContact2() ), 2074 this, SLOT( editContact2() ),
2026 actionCollection(), "file_properties" ); 2075 actionCollection(), "file_properties" );
2027 2076
2028#ifdef KAB_EMBEDDED 2077#ifdef KAB_EMBEDDED
2029 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 2078 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
2030 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 2079 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
2031 mMainWindow, SLOT( exit() ), 2080 mMainWindow, SLOT( exit() ),
2032 actionCollection(), "quit" ); 2081 actionCollection(), "quit" );
2033#endif //KAB_EMBEDDED 2082#endif //KAB_EMBEDDED
2034 2083
2035 // edit menu 2084 // edit menu
2036 if ( mIsPart ) { 2085 if ( mIsPart ) {
2037 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 2086 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
2038 SLOT( copyContacts() ), actionCollection(), 2087 SLOT( copyContacts() ), actionCollection(),
2039 "kaddressbook_copy" ); 2088 "kaddressbook_copy" );
2040 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 2089 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
2041 SLOT( cutContacts() ), actionCollection(), 2090 SLOT( cutContacts() ), actionCollection(),
2042 "kaddressbook_cut" ); 2091 "kaddressbook_cut" );
2043 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 2092 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
2044 SLOT( pasteContacts() ), actionCollection(), 2093 SLOT( pasteContacts() ), actionCollection(),
2045 "kaddressbook_paste" ); 2094 "kaddressbook_paste" );
2046 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 2095 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
2047 SLOT( selectAllContacts() ), actionCollection(), 2096 SLOT( selectAllContacts() ), actionCollection(),
2048 "kaddressbook_select_all" ); 2097 "kaddressbook_select_all" );
2049 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 2098 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
2050 SLOT( undo() ), actionCollection(), 2099 SLOT( undo() ), actionCollection(),
2051 "kaddressbook_undo" ); 2100 "kaddressbook_undo" );
2052 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 2101 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
2053 this, SLOT( redo() ), actionCollection(), 2102 this, SLOT( redo() ), actionCollection(),
2054 "kaddressbook_redo" ); 2103 "kaddressbook_redo" );
2055 } else { 2104 } else {
2056 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 2105 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
2057 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 2106 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
2058 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 2107 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
2059 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 2108 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
2060 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 2109 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
2061 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 2110 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
2062 } 2111 }
2063 2112
2064 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 2113 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
2065 Key_Delete, this, SLOT( deleteContacts() ), 2114 Key_Delete, this, SLOT( deleteContacts() ),
2066 actionCollection(), "edit_delete" ); 2115 actionCollection(), "edit_delete" );
2067 2116
2068 mActionUndo->setEnabled( false ); 2117 mActionUndo->setEnabled( false );
2069 mActionRedo->setEnabled( false ); 2118 mActionRedo->setEnabled( false );
2070 2119
2071 // settings menu 2120 // settings menu
2072#ifdef KAB_EMBEDDED 2121#ifdef KAB_EMBEDDED
2073//US special menuentry to configure the addressbook resources. On KDE 2122//US special menuentry to configure the addressbook resources. On KDE
2074// you do that through the control center !!! 2123// you do that through the control center !!!
2075 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 2124 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
2076 SLOT( configureResources() ), actionCollection(), 2125 SLOT( configureResources() ), actionCollection(),
2077 "kaddressbook_configure_resources" ); 2126 "kaddressbook_configure_resources" );
2078#endif //KAB_EMBEDDED 2127#endif //KAB_EMBEDDED
2079 2128
2080 if ( mIsPart ) { 2129 if ( mIsPart ) {
2081 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 2130 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
2082 SLOT( openConfigDialog() ), actionCollection(), 2131 SLOT( openConfigDialog() ), actionCollection(),
2083 "kaddressbook_configure" ); 2132 "kaddressbook_configure" );
2084 2133
2085 //US not implemented yet 2134 //US not implemented yet
2086 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 2135 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
2087 // this, SLOT( configureKeyBindings() ), actionCollection(), 2136 // this, SLOT( configureKeyBindings() ), actionCollection(),
2088 // "kaddressbook_configure_shortcuts" ); 2137 // "kaddressbook_configure_shortcuts" );
2089#ifdef KAB_EMBEDDED 2138#ifdef KAB_EMBEDDED
2090 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 2139 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
2091 mActionConfigureToolbars->setEnabled( false ); 2140 mActionConfigureToolbars->setEnabled( false );
2092#endif //KAB_EMBEDDED 2141#endif //KAB_EMBEDDED
2093 2142
2094 } else { 2143 } else {
2095 mActionConfigKAddressbook = new KAction( i18n( "&Configure KA/Pi..." ), "configure", 0, this, 2144 mActionConfigKAddressbook = new KAction( i18n( "&Configure KA/Pi..." ), "configure", 0, this,
2096 SLOT( openConfigDialog() ), actionCollection(), 2145 SLOT( openConfigDialog() ), actionCollection(),
2097 "kaddressbook_configure" ); 2146 "kaddressbook_configure" );
2098 mActionConfigGlobal = new KAction( i18n( "Global Settings..." ), "configure", 0, this, 2147 mActionConfigGlobal = new KAction( i18n( "Global Settings..." ), "configure", 0, this,
2099 SLOT( openConfigGlobalDialog() ), actionCollection(), 2148 SLOT( openConfigGlobalDialog() ), actionCollection(),
2100 "kaddressbook_configure" ); 2149 "kaddressbook_configure" );
2101 } 2150 }
2102 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 2151 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
2103 actionCollection(), "options_show_jump_bar" ); 2152 actionCollection(), "options_show_jump_bar" );
2104 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); 2153 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) );
2105 2154
2106 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 2155 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
2107 actionCollection(), "options_show_details" ); 2156 actionCollection(), "options_show_details" );
2108 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 2157 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
2109 2158
2110 2159
2111 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 2160 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
2112 SLOT( toggleBeamReceive() ), actionCollection(), 2161 SLOT( toggleBeamReceive() ), actionCollection(),
2113 "kaddressbook_beam_rec" ); 2162 "kaddressbook_beam_rec" );
2114 2163
2115 2164
2116 // misc 2165 // misc
2117 // only enable LDAP lookup if we can handle the protocol 2166 // only enable LDAP lookup if we can handle the protocol
2118#ifndef KAB_EMBEDDED 2167#ifndef KAB_EMBEDDED
2119 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 2168 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
2120 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 2169 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
2121 this, SLOT( openLDAPDialog() ), actionCollection(), 2170 this, SLOT( openLDAPDialog() ), actionCollection(),
2122 "ldap_lookup" ); 2171 "ldap_lookup" );
2123 } 2172 }
2124#else //KAB_EMBEDDED 2173#else //KAB_EMBEDDED
2125 //qDebug("KABCore::initActions() LDAP has to be implemented"); 2174 //qDebug("KABCore::initActions() LDAP has to be implemented");
2126#endif //KAB_EMBEDDED 2175#endif //KAB_EMBEDDED
2127 2176
2128 2177
2129 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 2178 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
2130 SLOT( setWhoAmI() ), actionCollection(), 2179 SLOT( setWhoAmI() ), actionCollection(),
2131 "set_personal" ); 2180 "set_personal" );
2132 2181
2133 2182
2134 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, 2183 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this,
2135 SLOT( setCategories() ), actionCollection(), 2184 SLOT( setCategories() ), actionCollection(),
2136 "edit_set_categories" ); 2185 "edit_set_categories" );
2137 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, 2186 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this,
2138 SLOT( editCategories() ), actionCollection(), 2187 SLOT( editCategories() ), actionCollection(),
2139 "edit__categories" ); 2188 "edit__categories" );
2140 2189
2141 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 2190 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
2142 SLOT( removeVoice() ), actionCollection(), 2191 SLOT( removeVoice() ), actionCollection(),
2143 "remove_voice" ); 2192 "remove_voice" );
2144 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, 2193 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this,
2145 SLOT( setFormattedName() ), actionCollection(), 2194 SLOT( setFormattedName() ), actionCollection(),
2146 "set_formatted" ); 2195 "set_formatted" );
2147 2196
2148 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2197 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2149 SLOT( manageCategories() ), actionCollection(), 2198 SLOT( manageCategories() ), actionCollection(),
2150 "remove_voice" ); 2199 "remove_voice" );
2151 2200
2152 2201
2153 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2202 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2154 SLOT( importFromOL() ), actionCollection(), 2203 SLOT( importFromOL() ), actionCollection(),
2155 "import_OL" ); 2204 "import_OL" );
2156#ifdef KAB_EMBEDDED 2205#ifdef KAB_EMBEDDED
2157 mActionLicence = new KAction( i18n( "Licence" ), 0, 2206 mActionLicence = new KAction( i18n( "Licence" ), 0,
2158 this, SLOT( showLicence() ), actionCollection(), 2207 this, SLOT( showLicence() ), actionCollection(),
2159 "licence_about_data" ); 2208 "licence_about_data" );
2160 mActionFaq = new KAction( i18n( "Faq" ), 0, 2209 mActionFaq = new KAction( i18n( "Faq" ), 0,
2161 this, SLOT( faq() ), actionCollection(), 2210 this, SLOT( faq() ), actionCollection(),
2162 "faq_about_data" ); 2211 "faq_about_data" );
2163 mActionWN = new KAction( i18n( "What's New?" ), 0, 2212 mActionWN = new KAction( i18n( "What's New?" ), 0,
2164 this, SLOT( whatsnew() ), actionCollection(), 2213 this, SLOT( whatsnew() ), actionCollection(),
2165 "wn" ); 2214 "wn" );
2166 2215
2167 2216
2168 2217
2169 mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0, 2218 mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0,
2170 this, SLOT( storagehowto() ), actionCollection(), 2219 this, SLOT( storagehowto() ), actionCollection(),
2171 "storage" ); 2220 "storage" );
2172 2221
2173 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2222 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2174 this, SLOT( synchowto() ), actionCollection(), 2223 this, SLOT( synchowto() ), actionCollection(),
2175 "sync" ); 2224 "sync" );
2176 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2225 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2177 this, SLOT( kdesynchowto() ), actionCollection(), 2226 this, SLOT( kdesynchowto() ), actionCollection(),
2178 "kdesync" ); 2227 "kdesync" );
2179 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2228 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2180 this, SLOT( multisynchowto() ), actionCollection(), 2229 this, SLOT( multisynchowto() ), actionCollection(),
2181 "multisync" ); 2230 "multisync" );
2182 2231
2183 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2232 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2184 this, SLOT( createAboutData() ), actionCollection(), 2233 this, SLOT( createAboutData() ), actionCollection(),
2185 "kaddressbook_about_data" ); 2234 "kaddressbook_about_data" );
2186#endif //KAB_EMBEDDED 2235#endif //KAB_EMBEDDED
2187 2236
2188 clipboardDataChanged(); 2237 clipboardDataChanged();
2189 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2238 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2190 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2239 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2191} 2240}
2192 2241
2193//US we need this function, to plug all actions into the correct menues. 2242//US we need this function, to plug all actions into the correct menues.
2194// KDE uses a XML format to plug the actions, but we work her without this overhead. 2243// KDE uses a XML format to plug the actions, but we work her without this overhead.
2195void KABCore::addActionsManually() 2244void KABCore::addActionsManually()
2196{ 2245{
2197//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2246//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2198 2247
2199#ifdef KAB_EMBEDDED 2248#ifdef KAB_EMBEDDED
2200 QPopupMenu *fileMenu = new QPopupMenu( this ); 2249 QPopupMenu *fileMenu = new QPopupMenu( this );
2201 QPopupMenu *editMenu = new QPopupMenu( this ); 2250 QPopupMenu *editMenu = new QPopupMenu( this );
2202 QPopupMenu *helpMenu = new QPopupMenu( this ); 2251 QPopupMenu *helpMenu = new QPopupMenu( this );
2203 2252
2204 KToolBar* tb = mMainWindow->toolBar(); 2253 KToolBar* tb = mMainWindow->toolBar();
2205 mMainWindow->setToolBarsMovable (false ); 2254 mMainWindow->setToolBarsMovable (false );
2206#ifndef DESKTOP_VERSION 2255#ifndef DESKTOP_VERSION
2207 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2256 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
2208#endif 2257#endif
2209 QMenuBar* mb = mMainWindow->menuBar(); 2258 QMenuBar* mb = mMainWindow->menuBar();
2210 2259
2211 //US setup menubar. 2260 //US setup menubar.
2212 //Disable the following block if you do not want to have a menubar. 2261 //Disable the following block if you do not want to have a menubar.
2213 mb->insertItem( i18n("&File"), fileMenu ); 2262 mb->insertItem( i18n("&File"), fileMenu );
2214 mb->insertItem( i18n("&Edit"), editMenu ); 2263 mb->insertItem( i18n("&Edit"), editMenu );
2215 mb->insertItem( i18n("&View"), viewMenu ); 2264 mb->insertItem( i18n("&View"), viewMenu );
2216 mb->insertItem( i18n("&Settings"), settingsMenu ); 2265 mb->insertItem( i18n("&Settings"), settingsMenu );
2217#ifdef DESKTOP_VERSION 2266#ifdef DESKTOP_VERSION
2218 mb->insertItem( i18n("Synchronize"), syncMenu ); 2267 mb->insertItem( i18n("Synchronize"), syncMenu );
2219#else 2268#else
2220 mb->insertItem( i18n("Sync"), syncMenu ); 2269 mb->insertItem( i18n("Sync"), syncMenu );
2221#endif 2270#endif
2222 //mb->insertItem( i18n("&Change"), changeMenu ); 2271 //mb->insertItem( i18n("&Change"), changeMenu );
2223 mb->insertItem( i18n("&Help"), helpMenu ); 2272 mb->insertItem( i18n("&Help"), helpMenu );
2224 mIncSearchWidget = new IncSearchWidget( tb ); 2273 mIncSearchWidget = new IncSearchWidget( tb );
2225 // tb->insertWidget(-1, 0, mIncSearchWidget); 2274 // tb->insertWidget(-1, 0, mIncSearchWidget);
2226#ifndef DESKTOP_VERSION 2275#ifndef DESKTOP_VERSION
2227 } else { 2276 } else {
2228 //US setup toolbar 2277 //US setup toolbar
2229 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2278 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2230 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2279 QPopupMenu *popupBarTB = new QPopupMenu( this );
2231 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); 2280 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB);
2232 tb->insertWidget(-1, 0, menuBarTB); 2281 tb->insertWidget(-1, 0, menuBarTB);
2233 mIncSearchWidget = new IncSearchWidget( tb ); 2282 mIncSearchWidget = new IncSearchWidget( tb );
2234 tb->enableMoving(false); 2283 tb->enableMoving(false);
2235 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2284 popupBarTB->insertItem( i18n("&File"), fileMenu );
2236 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2285 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2237 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2286 popupBarTB->insertItem( i18n("&View"), viewMenu );
2238 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2287 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2239 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2288 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2240 mViewManager->getFilterAction()->plug ( popupBarTB); 2289 mViewManager->getFilterAction()->plug ( popupBarTB);
2241 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2290 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2242 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2291 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2243 if (QApplication::desktop()->width() > 320 ) { 2292 if (QApplication::desktop()->width() > 320 ) {
2244 // mViewManager->getFilterAction()->plug ( tb); 2293 // mViewManager->getFilterAction()->plug ( tb);
2245 } 2294 }
2246 } 2295 }
2247#endif 2296#endif
2248 mIncSearchWidget->setSize(); 2297 mIncSearchWidget->setSize();
2249 // mActionQuit->plug ( mMainWindow->toolBar()); 2298 // mActionQuit->plug ( mMainWindow->toolBar());
2250 2299
2251 2300
2252 2301
2253 //US Now connect the actions with the menue entries. 2302 //US Now connect the actions with the menue entries.
2254#ifdef DESKTOP_VERSION 2303#ifdef DESKTOP_VERSION
2255 mActionPrint->plug( fileMenu ); 2304 mActionPrint->plug( fileMenu );
2256 mActionPrintDetails->plug( fileMenu ); 2305 mActionPrintDetails->plug( fileMenu );
2257 fileMenu->insertSeparator(); 2306 fileMenu->insertSeparator();
2258#endif 2307#endif
2259 mActionMail->plug( fileMenu ); 2308 mActionMail->plug( fileMenu );
2260 fileMenu->insertSeparator(); 2309 fileMenu->insertSeparator();
2261 2310
2262 mActionNewContact->plug( editMenu ); 2311 mActionNewContact->plug( editMenu );
2263 mActionNewContact->plug( tb ); 2312 mActionNewContact->plug( tb );
2264 2313
2265 mActionEditAddressee->plug( editMenu ); 2314 mActionEditAddressee->plug( editMenu );
2266 editMenu->insertSeparator(); 2315 editMenu->insertSeparator();
2267 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2316 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2268 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2317 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2269 mActionEditAddressee->plug( tb ); 2318 mActionEditAddressee->plug( tb );
2270 2319
2271 // fileMenu->insertSeparator(); 2320 // fileMenu->insertSeparator();
2272 mActionSave->plug( fileMenu ); 2321 mActionSave->plug( fileMenu );
2273 fileMenu->insertItem( "&Import", ImportMenu ); 2322 fileMenu->insertItem( "&Import", ImportMenu );
2274 fileMenu->insertItem( "&Export", ExportMenu ); 2323 fileMenu->insertItem( "&Export", ExportMenu );
2275 editMenu->insertItem( i18n("&Change"), changeMenu ); 2324 editMenu->insertItem( i18n("&Change"), changeMenu );
2276 editMenu->insertSeparator(); 2325 editMenu->insertSeparator();
2277#ifndef DESKTOP_VERSION 2326#ifndef DESKTOP_VERSION
2278 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); 2327 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu );
2279#endif 2328#endif
2280#if 0 2329#if 0
2281 // PENDING fix MailVCard 2330 // PENDING fix MailVCard
2282 fileMenu->insertSeparator(); 2331 fileMenu->insertSeparator();
2283 mActionMailVCard->plug( fileMenu ); 2332 mActionMailVCard->plug( fileMenu );
2284#endif 2333#endif
2285#ifndef DESKTOP_VERSION 2334#ifndef DESKTOP_VERSION
2286 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2335 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2287 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2336 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2288 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2337 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2289#endif 2338#endif
2290 fileMenu->insertSeparator(); 2339 fileMenu->insertSeparator();
2291 mActionQuit->plug( fileMenu ); 2340 mActionQuit->plug( fileMenu );
2292#ifdef _OL_IMPORT_ 2341#ifdef _OL_IMPORT_
2293 mActionImportOL->plug( ImportMenu ); 2342 mActionImportOL->plug( ImportMenu );
2294#endif 2343#endif
2295 // edit menu 2344 // edit menu
2296 mActionUndo->plug( editMenu ); 2345 mActionUndo->plug( editMenu );
2297 mActionRedo->plug( editMenu ); 2346 mActionRedo->plug( editMenu );
2298 editMenu->insertSeparator(); 2347 editMenu->insertSeparator();
2299 mActionCut->plug( editMenu ); 2348 mActionCut->plug( editMenu );
2300 mActionCopy->plug( editMenu ); 2349 mActionCopy->plug( editMenu );
2301 mActionPaste->plug( editMenu ); 2350 mActionPaste->plug( editMenu );
2302 mActionDelete->plug( editMenu ); 2351 mActionDelete->plug( editMenu );
2303 editMenu->insertSeparator(); 2352 editMenu->insertSeparator();
2304 mActionSelectAll->plug( editMenu ); 2353 mActionSelectAll->plug( editMenu );
2305 2354
2306 mActionSetFormattedName->plug( changeMenu ); 2355 mActionSetFormattedName->plug( changeMenu );
2307 mActionRemoveVoice->plug( changeMenu ); 2356 mActionRemoveVoice->plug( changeMenu );
2308 // settingsmings menu 2357 // settingsmings menu
2309//US special menuentry to configure the addressbook resources. On KDE 2358//US special menuentry to configure the addressbook resources. On KDE
2310// you do that through the control center !!! 2359// you do that through the control center !!!
2311 // settingsMenu->insertSeparator(); 2360 // settingsMenu->insertSeparator();
2312 2361
2313 mActionConfigKAddressbook->plug( settingsMenu, 0 ); 2362 mActionConfigKAddressbook->plug( settingsMenu, 0 );
2314 mActionConfigGlobal->plug( settingsMenu, 1 ); 2363 mActionConfigGlobal->plug( settingsMenu, 1 );
2315 mActionConfigResources->plug( settingsMenu,2 ); 2364 mActionConfigResources->plug( settingsMenu,2 );
2316 settingsMenu->insertSeparator(3); 2365 settingsMenu->insertSeparator(3);
2317 2366
2318 if ( mIsPart ) { 2367 if ( mIsPart ) {
2319 //US not implemented yet 2368 //US not implemented yet
2320 //mActionConfigShortcuts->plug( settingsMenu ); 2369 //mActionConfigShortcuts->plug( settingsMenu );
2321 //mActionConfigureToolbars->plug( settingsMenu ); 2370 //mActionConfigureToolbars->plug( settingsMenu );
2322 2371
2323 } else { 2372 } else {
2324 //US not implemented yet 2373 //US not implemented yet
2325 //mActionKeyBindings->plug( settingsMenu ); 2374 //mActionKeyBindings->plug( settingsMenu );
2326 } 2375 }
2327 2376
2328 mActionEditCategories->plug( settingsMenu ); 2377 mActionEditCategories->plug( settingsMenu );
2329 mActionManageCategories->plug( settingsMenu ); 2378 mActionManageCategories->plug( settingsMenu );
2330 mActionJumpBar->plug( viewMenu,0 ); 2379 mActionJumpBar->plug( viewMenu,0 );
2331 mActionDetails->plug( viewMenu,0 ); 2380 mActionDetails->plug( viewMenu,0 );
2332 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2381 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2333 mActionDetails->plug( tb ); 2382 mActionDetails->plug( tb );
2334 settingsMenu->insertSeparator(); 2383 settingsMenu->insertSeparator();
2335#ifndef DESKTOP_VERSION 2384#ifndef DESKTOP_VERSION
2336 if ( Ir::supported() ) mActionBR->plug(settingsMenu ); 2385 if ( Ir::supported() ) mActionBR->plug(settingsMenu );
2337 settingsMenu->insertSeparator(); 2386 settingsMenu->insertSeparator();
2338#endif 2387#endif
2339 2388
2340 mActionWhoAmI->plug( settingsMenu ); 2389 mActionWhoAmI->plug( settingsMenu );
2341 //mActionEditCategories->plug( changeMenu ); 2390 //mActionEditCategories->plug( changeMenu );
2342 mActionCategories->plug( changeMenu ); 2391 mActionCategories->plug( changeMenu );
2343 //mActionManageCategories->plug( changeMenu ); 2392 //mActionManageCategories->plug( changeMenu );
2344 2393
2345 //mActionCategories->plug( settingsMenu ); 2394 //mActionCategories->plug( settingsMenu );
2346 2395
2347 2396
2348 mActionWN->plug( helpMenu ); 2397 mActionWN->plug( helpMenu );
2349 mActionStorageHowto->plug( helpMenu ); 2398 mActionStorageHowto->plug( helpMenu );
2350 mActionSyncHowto->plug( helpMenu ); 2399 mActionSyncHowto->plug( helpMenu );
2351 mActionKdeSyncHowto->plug( helpMenu ); 2400 mActionKdeSyncHowto->plug( helpMenu );
2352 mActionMultiSyncHowto->plug( helpMenu ); 2401 mActionMultiSyncHowto->plug( helpMenu );
2353 mActionFaq->plug( helpMenu ); 2402 mActionFaq->plug( helpMenu );
2354 mActionLicence->plug( helpMenu ); 2403 mActionLicence->plug( helpMenu );
2355 mActionAboutKAddressbook->plug( helpMenu ); 2404 mActionAboutKAddressbook->plug( helpMenu );
2356 2405
2357 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2406 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2358 2407
2359 mActionSave->plug( tb ); 2408 mActionSave->plug( tb );
2360 mViewManager->getFilterAction()->plug ( tb); 2409 mViewManager->getFilterAction()->plug ( tb);
2361 //LR hide filteraction on started in 480x640 2410 //LR hide filteraction on started in 480x640
2362 if (QApplication::desktop()->width() == 480 ) { 2411 if (QApplication::desktop()->width() == 480 ) {
2363 mViewManager->getFilterAction()->setComboWidth( 0 ); 2412 mViewManager->getFilterAction()->setComboWidth( 0 );
2364 } 2413 }
2365 mActionUndo->plug( tb ); 2414 mActionUndo->plug( tb );
2366 mActionDelete->plug( tb ); 2415 mActionDelete->plug( tb );
2367 mActionRedo->plug( tb ); 2416 mActionRedo->plug( tb );
2368 } else { 2417 } else {
2369 mActionSave->plug( tb ); 2418 mActionSave->plug( tb );
2370 tb->enableMoving(false); 2419 tb->enableMoving(false);
2371 } 2420 }
2372 //mActionQuit->plug ( tb ); 2421 //mActionQuit->plug ( tb );
2373 //tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2422 //tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2374 2423
2375 //US link the searchwidget first to this. 2424 //US link the searchwidget first to this.
2376 // The real linkage to the toolbar happens later. 2425 // The real linkage to the toolbar happens later.
2377//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2426//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2378//US tb->insertItem( mIncSearchWidget ); 2427//US tb->insertItem( mIncSearchWidget );
2379/*US 2428/*US
2380 mIncSearchWidget = new IncSearchWidget( tb ); 2429 mIncSearchWidget = new IncSearchWidget( tb );
2381 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2430 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2382 SLOT( incrementalSearch( const QString& ) ) ); 2431 SLOT( incrementalSearch( const QString& ) ) );
2383 2432
2384 mJumpButtonBar = new JumpButtonBar( this, this ); 2433 mJumpButtonBar = new JumpButtonBar( this, this );
2385 2434
2386//US topLayout->addWidget( mJumpButtonBar ); 2435//US topLayout->addWidget( mJumpButtonBar );
2387 this->layout()->add( mJumpButtonBar ); 2436 this->layout()->add( mJumpButtonBar );
2388*/ 2437*/
2389 2438
2390#endif //KAB_EMBEDDED 2439#endif //KAB_EMBEDDED
2391 2440
2392 mActionExport2phone->plug( ExportMenu ); 2441 mActionExport2phone->plug( ExportMenu );
2393 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2442 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2394 syncManager->fillSyncMenu(); 2443 syncManager->fillSyncMenu();
2395 2444
2396} 2445}
2397void KABCore::showLicence() 2446void KABCore::showLicence()
2398{ 2447{
2399 KApplication::showLicence(); 2448 KApplication::showLicence();
2400} 2449}
2401 2450
2402void KABCore::manageCategories( ) 2451void KABCore::manageCategories( )
2403{ 2452{
2404 KABCatPrefs* cp = new KABCatPrefs(); 2453 KABCatPrefs* cp = new KABCatPrefs();
2405 cp->show(); 2454 cp->show();
2406 int w =cp->sizeHint().width() ; 2455 int w =cp->sizeHint().width() ;
2407 int h = cp->sizeHint().height() ; 2456 int h = cp->sizeHint().height() ;
2408 int dw = QApplication::desktop()->width(); 2457 int dw = QApplication::desktop()->width();
2409 int dh = QApplication::desktop()->height(); 2458 int dh = QApplication::desktop()->height();
2410 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2459 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2411 if ( !cp->exec() ) { 2460 if ( !cp->exec() ) {
2412 delete cp; 2461 delete cp;
2413 return; 2462 return;
2414 } 2463 }
2415 int count = 0; 2464 int count = 0;
2416 int cc = 0; 2465 int cc = 0;
2417 message( i18n("Please wait, processing categories...")); 2466 message( i18n("Please wait, processing categories..."));
2418 if ( cp->addCat() ) { 2467 if ( cp->addCat() ) {
2419 KABC::AddressBook::Iterator it; 2468 KABC::AddressBook::Iterator it;
2420 QStringList catList = KABPrefs::instance()->mCustomCategories; 2469 QStringList catList = KABPrefs::instance()->mCustomCategories;
2421 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2470 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2422 ++cc; 2471 ++cc;
2423 if ( cc %10 == 0) 2472 if ( cc %10 == 0)
2424 message(i18n("Processing contact #%1").arg(cc)); 2473 message(i18n("Processing contact #%1").arg(cc));
2425 QStringList catIncList = (*it).categories(); 2474 QStringList catIncList = (*it).categories();
2426 int i; 2475 int i;
2427 for( i = 0; i< catIncList.count(); ++i ) { 2476 for( i = 0; i< catIncList.count(); ++i ) {
2428 if ( !catList.contains (catIncList[i])) { 2477 if ( !catList.contains (catIncList[i])) {
2429 catList.append( catIncList[i] ); 2478 catList.append( catIncList[i] );
2430 //qDebug("add cat %s ", catIncList[i].latin1()); 2479 //qDebug("add cat %s ", catIncList[i].latin1());
2431 ++count; 2480 ++count;
2432 } 2481 }
2433 } 2482 }
2434 } 2483 }
2435 catList.sort(); 2484 catList.sort();
2436 KABPrefs::instance()->mCustomCategories = catList; 2485 KABPrefs::instance()->mCustomCategories = catList;
2437 KABPrefs::instance()->writeConfig(); 2486 KABPrefs::instance()->writeConfig();
2438 message(QString::number( count )+ i18n(" categories added to list! ")); 2487 message(QString::number( count )+ i18n(" categories added to list! "));
2439 } else { 2488 } else {
2440 QStringList catList = KABPrefs::instance()->mCustomCategories; 2489 QStringList catList = KABPrefs::instance()->mCustomCategories;
2441 QStringList catIncList; 2490 QStringList catIncList;
2442 QStringList newCatList; 2491 QStringList newCatList;
2443 KABC::AddressBook::Iterator it; 2492 KABC::AddressBook::Iterator it;
2444 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2493 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2445 ++cc; 2494 ++cc;
2446 if ( cc %10 == 0) 2495 if ( cc %10 == 0)
2447 message(i18n("Processing contact #%1").arg(cc)); 2496 message(i18n("Processing contact #%1").arg(cc));
2448 QStringList catIncList = (*it).categories(); 2497 QStringList catIncList = (*it).categories();
2449 int i; 2498 int i;
2450 if ( catIncList.count() ) { 2499 if ( catIncList.count() ) {
2451 newCatList.clear(); 2500 newCatList.clear();
2452 for( i = 0; i< catIncList.count(); ++i ) { 2501 for( i = 0; i< catIncList.count(); ++i ) {
2453 if ( catList.contains (catIncList[i])) { 2502 if ( catList.contains (catIncList[i])) {
2454 newCatList.append( catIncList[i] ); 2503 newCatList.append( catIncList[i] );
2455 } 2504 }
2456 } 2505 }
2457 newCatList.sort(); 2506 newCatList.sort();
2458 (*it).setCategories( newCatList ); 2507 (*it).setCategories( newCatList );
2459 mAddressBook->insertAddressee( (*it) ); 2508 mAddressBook->insertAddressee( (*it) );
2460 } 2509 }
2461 } 2510 }
2462 setModified( true ); 2511 setModified( true );
2463 mViewManager->refreshView(); 2512 mViewManager->refreshView();
2464 message( i18n("Removing categories done!")); 2513 message( i18n("Removing categories done!"));
2465 } 2514 }
2466 delete cp; 2515 delete cp;
2467} 2516}
2468void KABCore::removeVoice() 2517void KABCore::removeVoice()
2469{ 2518{
2470 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2519 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2471 return; 2520 return;
2472 XXPortSelectDialog dlg( this, false, this ); 2521 XXPortSelectDialog dlg( this, false, this );
2473 if ( !dlg.exec() ) 2522 if ( !dlg.exec() )
2474 return; 2523 return;
2475 mAddressBook->setUntagged(); 2524 mAddressBook->setUntagged();
2476 dlg.tagSelected(); 2525 dlg.tagSelected();
2477 message(i18n("Removing voice..."), false ); 2526 message(i18n("Removing voice..."), false );
2478 KABC::AddressBook::Iterator it; 2527 KABC::AddressBook::Iterator it;
2479 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2528 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2480 if ( (*it).tagged() ) { 2529 if ( (*it).tagged() ) {
2481 (*it).removeVoice(); 2530 (*it).removeVoice();
2482 } 2531 }
2483 } 2532 }
2484 message(i18n("Refreshing view...") ); 2533 message(i18n("Refreshing view...") );
2485 mViewManager->refreshView( "" ); 2534 mViewManager->refreshView( "" );
2486 Addressee add; 2535 Addressee add;
2487 mDetails->setAddressee( add ); 2536 mDetails->setAddressee( add );
2488 message(i18n("Remove voice completed!") ); 2537 message(i18n("Remove voice completed!") );
2489 2538
2490 2539
2491 2540
2492} 2541}
2493 2542
2494void KABCore::setFormattedName() 2543void KABCore::setFormattedName()
2495{ 2544{
2496 KABFormatPrefs setpref; 2545 KABFormatPrefs setpref;
2497 if ( !setpref.exec() ) { 2546 if ( !setpref.exec() ) {
2498 return; 2547 return;
2499 } 2548 }
2500 XXPortSelectDialog dlg( this, false, this ); 2549 XXPortSelectDialog dlg( this, false, this );
2501 if ( !dlg.exec() ) 2550 if ( !dlg.exec() )
2502 return; 2551 return;
2503 mAddressBook->setUntagged(); 2552 mAddressBook->setUntagged();
2504 dlg.tagSelected(); 2553 dlg.tagSelected();
2505 int count = 0; 2554 int count = 0;
2506 KABC::AddressBook::Iterator it; 2555 KABC::AddressBook::Iterator it;
2507 bool modified = false; 2556 bool modified = false;
2508 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2557 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2509 if ( (*it).tagged() ) { 2558 if ( (*it).tagged() ) {
2510 if ( (*it).uid().left( 2 ) == "la" ) 2559 if ( (*it).uid().left( 2 ) == "la" )
2511 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) 2560 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") )
2512 continue; 2561 continue;
2513 ++count; 2562 ++count;
2514 if ( count %10 == 0 ) 2563 if ( count %10 == 0 )
2515 message(i18n("Changing contact #%1").arg( count ) ); 2564 message(i18n("Changing contact #%1").arg( count ) );
2516 QString fName; 2565 QString fName;
2517 if ( setpref.simple->isChecked() ) 2566 if ( setpref.simple->isChecked() )
2518 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); 2567 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName );
2519 else if ( setpref.full->isChecked() ) 2568 else if ( setpref.full->isChecked() )
2520 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); 2569 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName );
2521 else if ( setpref.reverse->isChecked() ) 2570 else if ( setpref.reverse->isChecked() )
2522 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); 2571 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName );
2523 else 2572 else
2524 fName = (*it).organization(); 2573 fName = (*it).organization();
2525 if ( setpref.setCompany->isChecked() ) 2574 if ( setpref.setCompany->isChecked() )
2526 if ( fName.isEmpty() || fName =="," ) 2575 if ( fName.isEmpty() || fName =="," )
2527 fName = (*it).organization(); 2576 fName = (*it).organization();
2528 (*it).setFormattedName( fName ); 2577 (*it).setFormattedName( fName );
2529 (*it).setChanged( true ); 2578 (*it).setChanged( true );
2530 modified = true; 2579 modified = true;
2531 (*it).setRevision( QDateTime::currentDateTime() ); 2580 (*it).setRevision( QDateTime::currentDateTime() );
2532 } 2581 }
2533 } 2582 }
2534 message(i18n("Refreshing view...") ); 2583 message(i18n("Refreshing view...") );
2535 if ( modified ) 2584 if ( modified )
2536 setModified( true ); 2585 setModified( true );
2537 Addressee add; 2586 Addressee add;
2538 mDetails->setAddressee( add ); 2587 mDetails->setAddressee( add );
2539 if ( count == 0 ) 2588 if ( count == 0 )
2540 message(i18n("No contact changed!") ); 2589 message(i18n("No contact changed!") );
2541 else 2590 else
2542 message(i18n("%1 contacts changed!").arg( count ) ); 2591 message(i18n("%1 contacts changed!").arg( count ) );
2543} 2592}
2544 2593
2545void KABCore::clipboardDataChanged() 2594void KABCore::clipboardDataChanged()
2546{ 2595{
2547 2596
2548 if ( mReadWrite ) 2597 if ( mReadWrite )
2549 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2598 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2550 2599
2551} 2600}
2552 2601
2553void KABCore::updateActionMenu() 2602void KABCore::updateActionMenu()
2554{ 2603{
2555 UndoStack *undo = UndoStack::instance(); 2604 UndoStack *undo = UndoStack::instance();
2556 RedoStack *redo = RedoStack::instance(); 2605 RedoStack *redo = RedoStack::instance();
2557 2606
2558 if ( undo->isEmpty() ) 2607 if ( undo->isEmpty() )
2559 mActionUndo->setText( i18n( "Undo" ) ); 2608 mActionUndo->setText( i18n( "Undo" ) );
2560 else 2609 else
2561 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2610 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2562 2611
2563 mActionUndo->setEnabled( !undo->isEmpty() ); 2612 mActionUndo->setEnabled( !undo->isEmpty() );
2564 2613
2565 if ( !redo->top() ) 2614 if ( !redo->top() )
2566 mActionRedo->setText( i18n( "Redo" ) ); 2615 mActionRedo->setText( i18n( "Redo" ) );
2567 else 2616 else
2568 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2617 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2569 2618
2570 mActionRedo->setEnabled( !redo->isEmpty() ); 2619 mActionRedo->setEnabled( !redo->isEmpty() );
2571} 2620}
2572 2621
2573void KABCore::configureKeyBindings() 2622void KABCore::configureKeyBindings()
2574{ 2623{
2575#ifndef KAB_EMBEDDED 2624#ifndef KAB_EMBEDDED
2576 KKeyDialog::configure( actionCollection(), true ); 2625 KKeyDialog::configure( actionCollection(), true );
2577#else //KAB_EMBEDDED 2626#else //KAB_EMBEDDED
2578 qDebug("KABCore::configureKeyBindings() not implemented"); 2627 qDebug("KABCore::configureKeyBindings() not implemented");
2579#endif //KAB_EMBEDDED 2628#endif //KAB_EMBEDDED
2580} 2629}
2581 2630
2582#ifdef KAB_EMBEDDED 2631#ifdef KAB_EMBEDDED
2583void KABCore::configureResources() 2632void KABCore::configureResources()
2584{ 2633{
2585 KRES::KCMKResources dlg( this, "" , 0 ); 2634 KRES::KCMKResources dlg( this, "" , 0 );
2586 2635
2587 if ( !dlg.exec() ) 2636 if ( !dlg.exec() )
2588 return; 2637 return;
2589 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2638 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2590} 2639}
2591#endif //KAB_EMBEDDED 2640#endif //KAB_EMBEDDED
2592 2641
2593 2642
2594/* this method will be called through the QCop interface from Ko/Pi to select addresses 2643/* this method will be called through the QCop interface from Ko/Pi to select addresses
2595 * for the attendees list of an event. 2644 * for the attendees list of an event.
2596 */ 2645 */
2597void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2646void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2598{ 2647{
2599 qDebug("KABCore::requestForNameEmailUidList "); 2648 qDebug("KABCore::requestForNameEmailUidList ");
2600 bool ok = false; 2649 bool ok = false;
2601 mEmailSourceChannel = sourceChannel; 2650 mEmailSourceChannel = sourceChannel;
2602 mEmailSourceUID = uid; 2651 mEmailSourceUID = uid;
2603 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); 2652 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) );
2604 //callContactdialog(); 2653 //callContactdialog();
2605#if 0 2654#if 0
2606 int wid = uid.toInt( &ok ); 2655 int wid = uid.toInt( &ok );
2607 qDebug("UID %s ", uid.latin1()); 2656 qDebug("UID %s ", uid.latin1());
2608 if ( ok ) { 2657 if ( ok ) {
2609 if ( wid != QApplication::desktop()->width() ) { 2658 if ( wid != QApplication::desktop()->width() ) {
2610 qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); 2659 qDebug("KA/Pi: Request from different desktop geometry. Resizing ...");
2611 message( i18n("Resizing, please wait...") ); 2660 message( i18n("Resizing, please wait...") );
2612 mMainWindow->showMinimized(); 2661 mMainWindow->showMinimized();
2613 /* 2662 /*
2614 { 2663 {
2615 QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); 2664 QCopEnvelope e("QPE/Application/kapi", "callContactdialog()");
2616 } 2665 }
2617 */ 2666 */
2618 QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) ); 2667 QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) );
2619 return; 2668 return;
2620 } 2669 }
2621 2670
2622 } else { 2671 } else {
2623 qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); 2672 qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid ");
2624 } 2673 }
2625 callContactdialog(); 2674 callContactdialog();
2626 //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); 2675 //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()");
2627#endif 2676#endif
2628} 2677}
2629void KABCore::resizeAndCallContactdialog() 2678void KABCore::resizeAndCallContactdialog()
2630{ 2679{
2631 updateMainWindow(); 2680 updateMainWindow();
2632 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); 2681 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) );
2633} 2682}
2634 2683
2635void KABCore::doRingSync() 2684void KABCore::doRingSync()
2636{ 2685{
2637 topLevelWidget()->raise(); 2686 topLevelWidget()->raise();
2638 syncManager->multiSync( false ); 2687 syncManager->multiSync( false );
2639} 2688}
2640void KABCore::callContactdialog() 2689void KABCore::callContactdialog()
2641{ 2690{
2642 static bool running = false; 2691 static bool running = false;
2643 if (running) return; 2692 if (running) return;
2644 running = true; 2693 running = true;
2645 QStringList nameList; 2694 QStringList nameList;
2646 QStringList emailList; 2695 QStringList emailList;
2647 QStringList uidList; 2696 QStringList uidList;
2648 qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() ); 2697 qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() );
2649 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2698 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2650 uint i=0; 2699 uint i=0;
2651 for (i=0; i < list.count(); i++) 2700 for (i=0; i < list.count(); i++)
2652 { 2701 {
2653 nameList.append(list[i].realName()); 2702 nameList.append(list[i].realName());
2654 emailList.append(list[i].preferredEmail()); 2703 emailList.append(list[i].preferredEmail());
2655 uidList.append(list[i].uid()); 2704 uidList.append(list[i].uid());
2656 } 2705 }
2657 QString uid = mEmailSourceUID; 2706 QString uid = mEmailSourceUID;
2658 //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); 2707 //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1());
2659 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList); 2708 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList);
2660 running = false; 2709 running = false;
2661} 2710}
2662/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2711/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2663 * to put them into the calendar. 2712 * to put them into the calendar.
2664 */ 2713 */
2665void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2714void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2666{ 2715{
2667 // qDebug("KABCore::requestForBirthdayList"); 2716 // qDebug("KABCore::requestForBirthdayList");
2668 QStringList birthdayList; 2717 QStringList birthdayList;
2669 QStringList anniversaryList; 2718 QStringList anniversaryList;
2670 QStringList realNameList; 2719 QStringList realNameList;
2671 QStringList preferredEmailList; 2720 QStringList preferredEmailList;
2672 QStringList assembledNameList; 2721 QStringList assembledNameList;
2673 QStringList uidList; 2722 QStringList uidList;
2674 2723
2675 KABC::AddressBook::Iterator it; 2724 KABC::AddressBook::Iterator it;
2676 2725
2677 int count = 0; 2726 int count = 0;
2678 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2727 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2679 ++count; 2728 ++count;
2680 } 2729 }
2681 QProgressBar bar(count,0 ); 2730 QProgressBar bar(count,0 );
2682 int w = 300; 2731 int w = 300;
2683 if ( QApplication::desktop()->width() < 320 ) 2732 if ( QApplication::desktop()->width() < 320 )
2684 w = 220; 2733 w = 220;
2685 int h = bar.sizeHint().height() ; 2734 int h = bar.sizeHint().height() ;
2686 int dw = QApplication::desktop()->width(); 2735 int dw = QApplication::desktop()->width();
2687 int dh = QApplication::desktop()->height(); 2736 int dh = QApplication::desktop()->height();
2688 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2737 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2689 bar.show(); 2738 bar.show();
2690 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2739 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2691 qApp->processEvents(); 2740 qApp->processEvents();
2692 2741
2693 QDate bday; 2742 QDate bday;
2694 QString anni; 2743 QString anni;
2695 QString formattedbday; 2744 QString formattedbday;
2696 2745
2697 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2746 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2698 { 2747 {
2699 if ( ! bar.isVisible() ) 2748 if ( ! bar.isVisible() )
2700 return; 2749 return;
2701 bar.setProgress( count++ ); 2750 bar.setProgress( count++ );
2702 qApp->processEvents(); 2751 qApp->processEvents();
2703 bday = (*it).birthday().date(); 2752 bday = (*it).birthday().date();
2704 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2753 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2705 2754
2706 if ( bday.isValid() || !anni.isEmpty()) 2755 if ( bday.isValid() || !anni.isEmpty())
2707 { 2756 {
2708 if (bday.isValid()) 2757 if (bday.isValid())
2709 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2758 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2710 else 2759 else
2711 formattedbday = "NOTVALID"; 2760 formattedbday = "NOTVALID";
2712 if (anni.isEmpty()) 2761 if (anni.isEmpty())
2713 anni = "INVALID"; 2762 anni = "INVALID";
2714 2763
2715 birthdayList.append(formattedbday); 2764 birthdayList.append(formattedbday);
2716 anniversaryList.append(anni); //should be ISODate 2765 anniversaryList.append(anni); //should be ISODate
2717 realNameList.append((*it).realName()); 2766 realNameList.append((*it).realName());
2718 preferredEmailList.append((*it).preferredEmail()); 2767 preferredEmailList.append((*it).preferredEmail());
2719 assembledNameList.append((*it).realName()); 2768 assembledNameList.append((*it).realName());
2720 uidList.append((*it).uid()); 2769 uidList.append((*it).uid());
2721 2770
2722 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2771 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2723 } 2772 }
2724 } 2773 }
2725 2774
2726 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2775 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2727 2776
2728} 2777}
2729 2778
2730/* this method will be called through the QCop interface from other apps to show details of a contact. 2779/* this method will be called through the QCop interface from other apps to show details of a contact.
2731 */ 2780 */
2732void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2781void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2733{ 2782{
2734 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2783 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2735 2784
2736 QString foundUid = QString::null; 2785 QString foundUid = QString::null;
2737 if ( ! uid.isEmpty() ) { 2786 if ( ! uid.isEmpty() ) {
2738 Addressee adrr = mAddressBook->findByUid( uid ); 2787 Addressee adrr = mAddressBook->findByUid( uid );
2739 if ( !adrr.isEmpty() ) { 2788 if ( !adrr.isEmpty() ) {
2740 foundUid = uid; 2789 foundUid = uid;
2741 } 2790 }
2742 if ( email == "sendbacklist" ) { 2791 if ( email == "sendbacklist" ) {
2743 //qDebug("ssssssssssssssssssssssend "); 2792 //qDebug("ssssssssssssssssssssssend ");
2744 QStringList nameList; 2793 QStringList nameList;
2745 QStringList emailList; 2794 QStringList emailList;
2746 QStringList uidList; 2795 QStringList uidList;
2747 nameList.append(adrr.realName()); 2796 nameList.append(adrr.realName());
2748 emailList = adrr.emails(); 2797 emailList = adrr.emails();
2749 uidList.append( adrr.preferredEmail()); 2798 uidList.append( adrr.preferredEmail());
2750 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2799 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2751 return; 2800 return;
2752 } 2801 }
2753 2802
2754 } 2803 }
2755 2804
2756 if ( email == "sendbacklist" ) 2805 if ( email == "sendbacklist" )
2757 return; 2806 return;
2758 if (foundUid.isEmpty()) 2807 if (foundUid.isEmpty())
2759 { 2808 {
2760 //find the uid of the person first 2809 //find the uid of the person first
2761 Addressee::List namelist; 2810 Addressee::List namelist;
2762 Addressee::List emaillist; 2811 Addressee::List emaillist;
2763 2812
2764 if (!name.isEmpty()) 2813 if (!name.isEmpty())
2765 namelist = mAddressBook->findByName( name ); 2814 namelist = mAddressBook->findByName( name );
2766 2815
2767 if (!email.isEmpty()) 2816 if (!email.isEmpty())
2768 emaillist = mAddressBook->findByEmail( email ); 2817 emaillist = mAddressBook->findByEmail( email );
2769 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2818 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2770 //check if we have a match in Namelist and Emaillist 2819 //check if we have a match in Namelist and Emaillist
2771 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2820 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2772 foundUid = emaillist[0].uid(); 2821 foundUid = emaillist[0].uid();
2773 } 2822 }
2774 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2823 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2775 foundUid = namelist[0].uid(); 2824 foundUid = namelist[0].uid();
2776 else 2825 else
2777 { 2826 {
2778 for (int i = 0; i < namelist.count(); i++) 2827 for (int i = 0; i < namelist.count(); i++)
2779 { 2828 {
2780 for (int j = 0; j < emaillist.count(); j++) 2829 for (int j = 0; j < emaillist.count(); j++)
2781 { 2830 {
2782 if (namelist[i] == emaillist[j]) 2831 if (namelist[i] == emaillist[j])
2783 { 2832 {
2784 foundUid = namelist[i].uid(); 2833 foundUid = namelist[i].uid();
2785 } 2834 }
2786 } 2835 }
2787 } 2836 }
2788 } 2837 }
2789 } 2838 }
2790 else 2839 else
2791 { 2840 {
2792 foundUid = uid; 2841 foundUid = uid;
2793 } 2842 }
2794 2843
2795 if (!foundUid.isEmpty()) 2844 if (!foundUid.isEmpty())
2796 { 2845 {
2797 2846
2798 // raise Ka/Pi if it is in the background 2847 // raise Ka/Pi if it is in the background
2799#ifndef DESKTOP_VERSION 2848#ifndef DESKTOP_VERSION
2800#ifndef KORG_NODCOP 2849#ifndef KORG_NODCOP
2801 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2850 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2802#endif 2851#endif
2803#endif 2852#endif
2804 2853
2805 mMainWindow->showMaximized(); 2854 mMainWindow->showMaximized();
2806 mMainWindow-> raise(); 2855 mMainWindow-> raise();
2807 2856
2808 mViewManager->setSelected( "", false); 2857 mViewManager->setSelected( "", false);
2809 mViewManager->refreshView( "" ); 2858 mViewManager->refreshView( "" );
2810 mViewManager->setSelected( foundUid, true ); 2859 mViewManager->setSelected( foundUid, true );
2811 mViewManager->refreshView( foundUid ); 2860 mViewManager->refreshView( foundUid );
2812 2861
2813 if ( !mMultipleViewsAtOnce ) 2862 if ( !mMultipleViewsAtOnce )
2814 { 2863 {
2815 setDetailsVisible( true ); 2864 setDetailsVisible( true );
2816 mActionDetails->setChecked(true); 2865 mActionDetails->setChecked(true);
2817 } 2866 }
2818 } 2867 }
2819} 2868}
2820void KABCore::storagehowto() 2869void KABCore::storagehowto()
2821{ 2870{
2822 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 2871 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
2823} 2872}
2824void KABCore::whatsnew() 2873void KABCore::whatsnew()
2825{ 2874{
2826 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2875 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2827} 2876}
2828void KABCore::synchowto() 2877void KABCore::synchowto()
2829{ 2878{
2830 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2879 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2831} 2880}
2832void KABCore::kdesynchowto() 2881void KABCore::kdesynchowto()
2833{ 2882{
2834 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2883 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2835} 2884}
2836void KABCore::multisynchowto() 2885void KABCore::multisynchowto()
2837{ 2886{
2838 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2887 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2839} 2888}
2840void KABCore::faq() 2889void KABCore::faq()
2841{ 2890{
2842 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2891 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2843} 2892}
2844 2893
2845#include <libkcal/syncdefines.h> 2894#include <libkcal/syncdefines.h>
2846 2895
2847KABC::Addressee KABCore::getLastSyncAddressee() 2896KABC::Addressee KABCore::getLastSyncAddressee()
2848{ 2897{
2849 Addressee lse; 2898 Addressee lse;
2850 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2899 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2851 2900
2852 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2901 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2853 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2902 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2854 if (lse.isEmpty()) { 2903 if (lse.isEmpty()) {
2855 qDebug("KA: Creating new last-syncAddressee "); 2904 qDebug("KA: Creating new last-syncAddressee ");
2856 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2905 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2857 QString sum = ""; 2906 QString sum = "";
2858 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2907 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2859 sum = "E: "; 2908 sum = "E: ";
2860 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2909 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2861 lse.setRevision( mLastAddressbookSync ); 2910 lse.setRevision( mLastAddressbookSync );
2862 lse.setCategories( i18n("SyncEvent") ); 2911 lse.setCategories( i18n("SyncEvent") );
2863 mAddressBook->insertAddressee( lse ); 2912 mAddressBook->insertAddressee( lse );
2864 } 2913 }
2865 return lse; 2914 return lse;
2866} 2915}
2867int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2916int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2868{ 2917{
2869 2918
2870 //void setZaurusId(int id); 2919 //void setZaurusId(int id);
2871 // int zaurusId() const; 2920 // int zaurusId() const;
2872 // void setZaurusUid(int id); 2921 // void setZaurusUid(int id);
2873 // int zaurusUid() const; 2922 // int zaurusUid() const;
2874 // void setZaurusStat(int id); 2923 // void setZaurusStat(int id);
2875 // int zaurusStat() const; 2924 // int zaurusStat() const;
2876 // 0 equal 2925 // 0 equal
2877 // 1 take local 2926 // 1 take local
2878 // 2 take remote 2927 // 2 take remote
2879 // 3 cancel 2928 // 3 cancel
2880 QDateTime lastSync = mLastAddressbookSync; 2929 QDateTime lastSync = mLastAddressbookSync;
2881 QDateTime localMod = local->revision(); 2930 QDateTime localMod = local->revision();
2882 QDateTime remoteMod = remote->revision(); 2931 QDateTime remoteMod = remote->revision();
2883 2932
2884 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2933 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2885 2934
2886 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2935 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2887 bool remCh, locCh; 2936 bool remCh, locCh;
2888 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2937 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2889 //if ( remCh ) 2938 //if ( remCh )
2890 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2939 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2891 locCh = ( localMod > mLastAddressbookSync ); 2940 locCh = ( localMod > mLastAddressbookSync );
2892 //qDebug("cahnged rem %d loc %d",remCh, locCh ); 2941 //qDebug("cahnged rem %d loc %d",remCh, locCh );
2893 if ( !remCh && ! locCh ) { 2942 if ( !remCh && ! locCh ) {
2894 //qDebug("both not changed "); 2943 //qDebug("both not changed ");
2895 lastSync = localMod.addDays(1); 2944 lastSync = localMod.addDays(1);
2896 if ( mode <= SYNC_PREF_ASK ) 2945 if ( mode <= SYNC_PREF_ASK )
2897 return 0; 2946 return 0;
2898 } else { 2947 } else {
2899 if ( locCh ) { 2948 if ( locCh ) {
2900 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2949 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2901 lastSync = localMod.addDays( -1 ); 2950 lastSync = localMod.addDays( -1 );
2902 if ( !remCh ) 2951 if ( !remCh )
2903 remoteMod =( lastSync.addDays( -1 ) ); 2952 remoteMod =( lastSync.addDays( -1 ) );
2904 } else { 2953 } else {
2905 //qDebug(" not loc changed "); 2954 //qDebug(" not loc changed ");
2906 lastSync = localMod.addDays( 1 ); 2955 lastSync = localMod.addDays( 1 );
2907 if ( remCh ) { 2956 if ( remCh ) {
2908 //qDebug("rem changed "); 2957 //qDebug("rem changed ");
2909 remoteMod =( lastSync.addDays( 1 ) ); 2958 remoteMod =( lastSync.addDays( 1 ) );
2910 } 2959 }
2911 2960
2912 } 2961 }
2913 } 2962 }
2914 full = true; 2963 full = true;
2915 if ( mode < SYNC_PREF_ASK ) 2964 if ( mode < SYNC_PREF_ASK )
2916 mode = SYNC_PREF_ASK; 2965 mode = SYNC_PREF_ASK;
2917 } else { 2966 } else {
2918 if ( localMod == remoteMod ) 2967 if ( localMod == remoteMod )
2919 return 0; 2968 return 0;
2920 2969
2921 } 2970 }
2922 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2971 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2923 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2972 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2924 //full = true; //debug only 2973 //full = true; //debug only
2925 if ( full ) { 2974 if ( full ) {
2926 bool equ = ( (*local) == (*remote) ); 2975 bool equ = ( (*local) == (*remote) );
2927 if ( equ ) { 2976 if ( equ ) {
2928 //qDebug("equal "); 2977 //qDebug("equal ");
2929 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2978 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2930 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2979 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2931 } 2980 }
2932 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2981 if ( mode < SYNC_PREF_FORCE_LOCAL )
2933 return 0; 2982 return 0;
2934 2983
2935 }//else //debug only 2984 }//else //debug only
2936 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2985 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2937 } 2986 }
2938 int result; 2987 int result;
2939 bool localIsNew; 2988 bool localIsNew;
2940 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2989 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2941 2990
2942 if ( full && mode < SYNC_PREF_NEWEST ) 2991 if ( full && mode < SYNC_PREF_NEWEST )
2943 mode = SYNC_PREF_ASK; 2992 mode = SYNC_PREF_ASK;
2944 2993
2945 switch( mode ) { 2994 switch( mode ) {
2946 case SYNC_PREF_LOCAL: 2995 case SYNC_PREF_LOCAL:
2947 if ( lastSync > remoteMod ) 2996 if ( lastSync > remoteMod )
2948 return 1; 2997 return 1;
2949 if ( lastSync > localMod ) 2998 if ( lastSync > localMod )
2950 return 2; 2999 return 2;
2951 return 1; 3000 return 1;
2952 break; 3001 break;
2953 case SYNC_PREF_REMOTE: 3002 case SYNC_PREF_REMOTE:
2954 if ( lastSync > localMod ) 3003 if ( lastSync > localMod )
2955 return 2; 3004 return 2;
2956 if ( lastSync > remoteMod ) 3005 if ( lastSync > remoteMod )
2957 return 1; 3006 return 1;
2958 return 2; 3007 return 2;
2959 break; 3008 break;
2960 case SYNC_PREF_NEWEST: 3009 case SYNC_PREF_NEWEST:
2961 if ( localMod > remoteMod ) 3010 if ( localMod > remoteMod )
2962 return 1; 3011 return 1;
2963 else 3012 else
2964 return 2; 3013 return 2;
2965 break; 3014 break;
2966 case SYNC_PREF_ASK: 3015 case SYNC_PREF_ASK:
2967 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 3016 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2968 if ( lastSync > remoteMod && lastSync > localMod) 3017 if ( lastSync > remoteMod && lastSync > localMod)
2969 return 0; 3018 return 0;
2970 if ( lastSync > remoteMod ) 3019 if ( lastSync > remoteMod )
2971 return 1; 3020 return 1;
2972 if ( lastSync > localMod ) { 3021 if ( lastSync > localMod ) {
2973 return 2; 3022 return 2;
2974 } 3023 }
2975 localIsNew = localMod >= remoteMod; 3024 localIsNew = localMod >= remoteMod;
2976 //qDebug("conflict! ************************************** "); 3025 //qDebug("conflict! ************************************** ");
2977 { 3026 {
2978 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 3027 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2979 result = acd.executeD(localIsNew); 3028 result = acd.executeD(localIsNew);
2980 return result; 3029 return result;
2981 } 3030 }
2982 break; 3031 break;
2983 case SYNC_PREF_FORCE_LOCAL: 3032 case SYNC_PREF_FORCE_LOCAL:
2984 return 1; 3033 return 1;
2985 break; 3034 break;
2986 case SYNC_PREF_FORCE_REMOTE: 3035 case SYNC_PREF_FORCE_REMOTE:
2987 return 2; 3036 return 2;
2988 break; 3037 break;
2989 3038
2990 default: 3039 default:
2991 // SYNC_PREF_TAKE_BOTH not implemented 3040 // SYNC_PREF_TAKE_BOTH not implemented
2992 break; 3041 break;
2993 } 3042 }
2994 return 0; 3043 return 0;
2995} 3044}
2996 3045
2997 3046
2998bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 3047bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2999{ 3048{
3000 bool syncOK = true; 3049 bool syncOK = true;
3001 int addedAddressee = 0; 3050 int addedAddressee = 0;
3002 int addedAddresseeR = 0; 3051 int addedAddresseeR = 0;
3003 int deletedAddresseeR = 0; 3052 int deletedAddresseeR = 0;
3004 int deletedAddresseeL = 0; 3053 int deletedAddresseeL = 0;
3005 int changedLocal = 0; 3054 int changedLocal = 0;
3006 int changedRemote = 0; 3055 int changedRemote = 0;
3007 int filteredIN = 0; 3056 int filteredIN = 0;
3008 int filteredOUT = 0; 3057 int filteredOUT = 0;
3009 3058
3010 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 3059 QString mCurrentSyncName = syncManager->getCurrentSyncName();
3011 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3060 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3012 3061
3013 //QPtrList<Addressee> el = local->rawAddressees(); 3062 //QPtrList<Addressee> el = local->rawAddressees();
3014 Addressee addresseeR; 3063 Addressee addresseeR;
3015 QString uid; 3064 QString uid;
3016 int take; 3065 int take;
3017 Addressee addresseeL; 3066 Addressee addresseeL;
3018 Addressee addresseeRSync; 3067 Addressee addresseeRSync;
3019 Addressee addresseeLSync; 3068 Addressee addresseeLSync;
3020 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 3069 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
3021 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 3070 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
3022 bool fullDateRange = false; 3071 bool fullDateRange = false;
3023 local->resetTempSyncStat(); 3072 local->resetTempSyncStat();
3024 mLastAddressbookSync = QDateTime::currentDateTime(); 3073 mLastAddressbookSync = QDateTime::currentDateTime();
3025 if ( syncManager->syncWithDesktop() ) { 3074 if ( syncManager->syncWithDesktop() ) {
3026 // remote->removeSyncInfo( QString());//remove all info 3075 // remote->removeSyncInfo( QString());//remove all info
3027 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 3076 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
3028 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 3077 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
3029 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 3078 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
3030 } else { 3079 } else {
3031 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime "); 3080 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime ");
3032 } 3081 }
3033 } 3082 }
3034 QDateTime modifiedCalendar = mLastAddressbookSync; 3083 QDateTime modifiedCalendar = mLastAddressbookSync;
3035 addresseeLSync = getLastSyncAddressee(); 3084 addresseeLSync = getLastSyncAddressee();
3036 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1()); 3085 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1());
3037 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 3086 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
3038 if ( !addresseeR.isEmpty() ) { 3087 if ( !addresseeR.isEmpty() ) {
3039 addresseeRSync = addresseeR; 3088 addresseeRSync = addresseeR;
3040 remote->removeAddressee(addresseeR ); 3089 remote->removeAddressee(addresseeR );
3041 3090
3042 } else { 3091 } else {
3043 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3092 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3044 addresseeRSync = addresseeLSync ; 3093 addresseeRSync = addresseeLSync ;
3045 } else { 3094 } else {
3046 //qDebug("FULLDATE 1"); 3095 //qDebug("FULLDATE 1");
3047 fullDateRange = true; 3096 fullDateRange = true;
3048 Addressee newAdd; 3097 Addressee newAdd;
3049 addresseeRSync = newAdd; 3098 addresseeRSync = newAdd;
3050 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 3099 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
3051 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 3100 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
3052 addresseeRSync.setRevision( mLastAddressbookSync ); 3101 addresseeRSync.setRevision( mLastAddressbookSync );
3053 addresseeRSync.setCategories( i18n("SyncAddressee") ); 3102 addresseeRSync.setCategories( i18n("SyncAddressee") );
3054 } 3103 }
3055 } 3104 }
3056 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 3105 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
3057 // qDebug("FULLDATE 2"); 3106 // qDebug("FULLDATE 2");
3058 fullDateRange = true; 3107 fullDateRange = true;
3059 } 3108 }
3060 if ( ! fullDateRange ) { 3109 if ( ! fullDateRange ) {
3061 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 3110 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
3062 3111
3063 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 3112 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
3064 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 3113 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
3065 fullDateRange = true; 3114 fullDateRange = true;
3066 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 3115 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
3067 } 3116 }
3068 } 3117 }
3069 // fullDateRange = true; // debug only! 3118 // fullDateRange = true; // debug only!
3070 if ( fullDateRange ) 3119 if ( fullDateRange )
3071 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 3120 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
3072 else 3121 else
3073 mLastAddressbookSync = addresseeLSync.revision(); 3122 mLastAddressbookSync = addresseeLSync.revision();
3074 // for resyncing if own file has changed 3123 // for resyncing if own file has changed
3075 // PENDING fixme later when implemented 3124 // PENDING fixme later when implemented
3076#if 0 3125#if 0
3077 if ( mCurrentSyncDevice == "deleteaftersync" ) { 3126 if ( mCurrentSyncDevice == "deleteaftersync" ) {
3078 mLastAddressbookSync = loadedFileVersion; 3127 mLastAddressbookSync = loadedFileVersion;
3079 qDebug("setting mLastAddressbookSync "); 3128 qDebug("setting mLastAddressbookSync ");
3080 } 3129 }
3081#endif 3130#endif
3082 3131
3083 3132
3084 // ********** setting filters **************** 3133 // ********** setting filters ****************
3085 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); 3134 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB );
3086 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); 3135 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB );
3087 3136
3088 //qDebug("*************************** "); 3137 //qDebug("*************************** ");
3089 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 3138 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
3090 QStringList er = remote->uidList(); 3139 QStringList er = remote->uidList();
3091 Addressee inR ;//= er.first(); 3140 Addressee inR ;//= er.first();
3092 Addressee inL; 3141 Addressee inL;
3093 3142
3094 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 3143 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
3095 3144
3096 int modulo = (er.count()/10)+1; 3145 int modulo = (er.count()/10)+1;
3097 int incCounter = 0; 3146 int incCounter = 0;
3098 while ( incCounter < er.count()) { 3147 while ( incCounter < er.count()) {
3099 if (syncManager->isProgressBarCanceled()) 3148 if (syncManager->isProgressBarCanceled())
3100 return false; 3149 return false;
3101 if ( incCounter % modulo == 0 ) 3150 if ( incCounter % modulo == 0 )
3102 syncManager->showProgressBar(incCounter); 3151 syncManager->showProgressBar(incCounter);
3103 3152
3104 uid = er[ incCounter ]; 3153 uid = er[ incCounter ];
3105 bool skipIncidence = false; 3154 bool skipIncidence = false;
3106 if ( uid.left(19) == QString("last-syncAddressee-") ) 3155 if ( uid.left(19) == QString("last-syncAddressee-") )
3107 skipIncidence = true; 3156 skipIncidence = true;
3108 QString idS,OidS; 3157 QString idS,OidS;
3109 qApp->processEvents(); 3158 qApp->processEvents();
3110 if ( !skipIncidence ) { 3159 if ( !skipIncidence ) {
3111 inL = local->findByUid( uid ); 3160 inL = local->findByUid( uid );
3112 inR = remote->findByUid( uid ); 3161 inR = remote->findByUid( uid );
3113 //inL.setResource( 0 ); 3162 //inL.setResource( 0 );
3114 //inR.setResource( 0 ); 3163 //inR.setResource( 0 );
3115 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 3164 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
3116 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3165 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3117 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 3166 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
3118 //qDebug("take %d %s ", take, inL.summary().latin1()); 3167 //qDebug("take %d %s ", take, inL.summary().latin1());
3119 if ( take == 3 ) 3168 if ( take == 3 )
3120 return false; 3169 return false;
3121 if ( take == 1 ) {// take local ********************** 3170 if ( take == 1 ) {// take local **********************
3122 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3171 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3123 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3172 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3124 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3173 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3125 local->insertAddressee( inL, false ); 3174 local->insertAddressee( inL, false );
3126 idS = inR.externalUID(); 3175 idS = inR.externalUID();
3127 OidS = inR.originalExternalUID(); 3176 OidS = inR.originalExternalUID();
3128 } 3177 }
3129 else 3178 else
3130 idS = inR.IDStr(); 3179 idS = inR.IDStr();
3131 remote->removeAddressee( inR ); 3180 remote->removeAddressee( inR );
3132 inR = inL; 3181 inR = inL;
3133 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 3182 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
3134 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3183 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3135 inR.setOriginalExternalUID( OidS ); 3184 inR.setOriginalExternalUID( OidS );
3136 inR.setExternalUID( idS ); 3185 inR.setExternalUID( idS );
3137 if ( syncManager->syncWithDesktop() ) { 3186 if ( syncManager->syncWithDesktop() ) {
3138 inR.setIDStr("changed" ); 3187 inR.setIDStr("changed" );
3139 } 3188 }
3140 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 3189 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
3141 } else { 3190 } else {
3142 inR.setIDStr( idS ); 3191 inR.setIDStr( idS );
3143 } 3192 }
3144 inR.setResource( 0 ); 3193 inR.setResource( 0 );
3145 remote->insertAddressee( inR , false); 3194 remote->insertAddressee( inR , false);
3146 ++changedRemote; 3195 ++changedRemote;
3147 } else { // take == 2 take remote ********************** 3196 } else { // take == 2 take remote **********************
3148 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3197 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3149 if ( inR.revision().date().year() < 2004 ) 3198 if ( inR.revision().date().year() < 2004 )
3150 inR.setRevision( modifiedCalendar ); 3199 inR.setRevision( modifiedCalendar );
3151 } 3200 }
3152 idS = inL.IDStr(); 3201 idS = inL.IDStr();
3153 local->removeAddressee( inL ); 3202 local->removeAddressee( inL );
3154 inL = inR; 3203 inL = inR;
3155 inL.setIDStr( idS ); 3204 inL.setIDStr( idS );
3156 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3205 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3157 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3206 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3158 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3207 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3159 } 3208 }
3160 inL.setResource( 0 ); 3209 inL.setResource( 0 );
3161 local->insertAddressee( inL , false ); 3210 local->insertAddressee( inL , false );
3162 ++changedLocal; 3211 ++changedLocal;
3163 } 3212 }
3164 } 3213 }
3165 } 3214 }
3166 } else { // no conflict ********** add or delete remote 3215 } else { // no conflict ********** add or delete remote
3167 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { 3216 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
3168 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3217 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3169 QString des = addresseeLSync.note(); 3218 QString des = addresseeLSync.note();
3170 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 3219 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
3171 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 3220 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
3172 remote->insertAddressee( inR, false ); 3221 remote->insertAddressee( inR, false );
3173 ++deletedAddresseeR; 3222 ++deletedAddresseeR;
3174 } else { 3223 } else {
3175 inR.setRevision( modifiedCalendar ); 3224 inR.setRevision( modifiedCalendar );
3176 remote->insertAddressee( inR, false ); 3225 remote->insertAddressee( inR, false );
3177 inL = inR; 3226 inL = inR;
3178 inL.setIDStr( ":" ); 3227 inL.setIDStr( ":" );
3179 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3228 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3180 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3229 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3181 inL.setResource( 0 ); 3230 inL.setResource( 0 );
3182 local->insertAddressee( inL , false); 3231 local->insertAddressee( inL , false);
3183 ++addedAddressee; 3232 ++addedAddressee;
3184 } 3233 }
3185 } else { 3234 } else {
3186 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 3235 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
3187 inR.setRevision( modifiedCalendar ); 3236 inR.setRevision( modifiedCalendar );
3188 remote->insertAddressee( inR, false ); 3237 remote->insertAddressee( inR, false );
3189 inR.setResource( 0 ); 3238 inR.setResource( 0 );
3190 local->insertAddressee( inR, false ); 3239 local->insertAddressee( inR, false );
3191 ++addedAddressee; 3240 ++addedAddressee;
3192 } else { 3241 } else {
3193 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 3242 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
3194 remote->removeAddressee( inR ); 3243 remote->removeAddressee( inR );
3195 ++deletedAddresseeR; 3244 ++deletedAddresseeR;
3196 } 3245 }
3197 } 3246 }
3198 } else { 3247 } else {
3199 ++filteredIN; 3248 ++filteredIN;
3200 } 3249 }
3201 } 3250 }
3202 } 3251 }
3203 ++incCounter; 3252 ++incCounter;
3204 } 3253 }
3205 er.clear(); 3254 er.clear();
3206 QStringList el = local->uidList(); 3255 QStringList el = local->uidList();
3207 modulo = (el.count()/10)+1; 3256 modulo = (el.count()/10)+1;
3208 3257
3209 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3258 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3210 incCounter = 0; 3259 incCounter = 0;
3211 while ( incCounter < el.count()) { 3260 while ( incCounter < el.count()) {
3212 qApp->processEvents(); 3261 qApp->processEvents();
3213 if (syncManager->isProgressBarCanceled()) 3262 if (syncManager->isProgressBarCanceled())
3214 return false; 3263 return false;
3215 if ( incCounter % modulo == 0 ) 3264 if ( incCounter % modulo == 0 )
3216 syncManager->showProgressBar(incCounter); 3265 syncManager->showProgressBar(incCounter);
3217 uid = el[ incCounter ]; 3266 uid = el[ incCounter ];
3218 bool skipIncidence = false; 3267 bool skipIncidence = false;
3219 if ( uid.left(19) == QString("last-syncAddressee-") ) 3268 if ( uid.left(19) == QString("last-syncAddressee-") )
3220 skipIncidence = true; 3269 skipIncidence = true;
3221 if ( !skipIncidence ) { 3270 if ( !skipIncidence ) {
3222 inL = local->findByUid( uid ); 3271 inL = local->findByUid( uid );
3223 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3272 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3224 inR = remote->findByUid( uid ); 3273 inR = remote->findByUid( uid );
3225 if ( inR.isEmpty() ){ 3274 if ( inR.isEmpty() ){
3226 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { 3275 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) {
3227 // no conflict ********** add or delete local 3276 // no conflict ********** add or delete local
3228 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3277 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3229 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3278 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
3230 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3279 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3231 local->removeAddressee( inL ); 3280 local->removeAddressee( inL );
3232 ++deletedAddresseeL; 3281 ++deletedAddresseeL;
3233 } else { 3282 } else {
3234 if ( ! syncManager->mWriteBackExistingOnly ) { 3283 if ( ! syncManager->mWriteBackExistingOnly ) {
3235 inL.removeID(mCurrentSyncDevice ); 3284 inL.removeID(mCurrentSyncDevice );
3236 ++addedAddresseeR; 3285 ++addedAddresseeR;
3237 inL.setRevision( modifiedCalendar ); 3286 inL.setRevision( modifiedCalendar );
3238 local->insertAddressee( inL, false ); 3287 local->insertAddressee( inL, false );
3239 inR = inL; 3288 inR = inL;
3240 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3289 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
3241 inR.setResource( 0 ); 3290 inR.setResource( 0 );
3242 remote->insertAddressee( inR, false ); 3291 remote->insertAddressee( inR, false );
3243 } 3292 }
3244 } 3293 }
3245 } else { 3294 } else {
3246 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3295 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
3247 //qDebug("data %s ", inL.revision().toString().latin1()); 3296 //qDebug("data %s ", inL.revision().toString().latin1());
3248 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3297 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3249 local->removeAddressee( inL ); 3298 local->removeAddressee( inL );
3250 ++deletedAddresseeL; 3299 ++deletedAddresseeL;
3251 } else { 3300 } else {
3252 if ( ! syncManager->mWriteBackExistingOnly ) { 3301 if ( ! syncManager->mWriteBackExistingOnly ) {
3253 ++addedAddresseeR; 3302 ++addedAddresseeR;
3254 inL.setRevision( modifiedCalendar ); 3303 inL.setRevision( modifiedCalendar );
3255 local->insertAddressee( inL, false ); 3304 local->insertAddressee( inL, false );
3256 inR = inL; 3305 inR = inL;
3257 inR.setIDStr( ":" ); 3306 inR.setIDStr( ":" );
3258 inR.setResource( 0 ); 3307 inR.setResource( 0 );
3259 remote->insertAddressee( inR, false ); 3308 remote->insertAddressee( inR, false );
3260 } 3309 }
3261 } 3310 }
3262 } 3311 }
3263 } else { 3312 } else {
3264 ++filteredOUT; 3313 ++filteredOUT;
3265 } 3314 }
3266 } 3315 }
3267 } 3316 }
3268 } 3317 }
3269 ++incCounter; 3318 ++incCounter;
3270 } 3319 }
3271 el.clear(); 3320 el.clear();
3272 syncManager->hideProgressBar(); 3321 syncManager->hideProgressBar();
3273 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3322 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
3274 // get rid of micro seconds 3323 // get rid of micro seconds
3275 QTime t = mLastAddressbookSync.time(); 3324 QTime t = mLastAddressbookSync.time();
3276 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3325 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3277 addresseeLSync.setRevision( mLastAddressbookSync ); 3326 addresseeLSync.setRevision( mLastAddressbookSync );
3278 addresseeRSync.setRevision( mLastAddressbookSync ); 3327 addresseeRSync.setRevision( mLastAddressbookSync );
3279 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3328 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
3280 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3329 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
3281 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3330 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
3282 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3331 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
3283 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3332 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
3284 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3333 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
3285 addresseeRSync.setNote( "" ) ; 3334 addresseeRSync.setNote( "" ) ;
3286 addresseeLSync.setNote( "" ); 3335 addresseeLSync.setNote( "" );
3287 3336
3288 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3337 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
3289 remote->insertAddressee( addresseeRSync, false ); 3338 remote->insertAddressee( addresseeRSync, false );
3290 local->insertAddressee( addresseeLSync, false ); 3339 local->insertAddressee( addresseeLSync, false );
3291 QString mes; 3340 QString mes;
3292 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); 3341 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT );
3293 qDebug( mes ); 3342 qDebug( mes );
3294 mes = i18n("Local addressbook changed!\n") +mes; 3343 mes = i18n("Local addressbook changed!\n") +mes;
3295 if ( syncManager->mShowSyncSummary ) { 3344 if ( syncManager->mShowSyncSummary ) {
3296 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 3345 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
3297 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 3346 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
3298 qDebug("KA: WB cancelled "); 3347 qDebug("KA: WB cancelled ");
3299 syncManager->mWriteBackFile = false; 3348 syncManager->mWriteBackFile = false;
3300 return syncOK; 3349 return syncOK;
3301 } 3350 }
3302 } 3351 }
3303 return syncOK; 3352 return syncOK;
3304} 3353}
3305 3354
3306 3355
3307//this is a overwritten callbackmethods from the syncinterface 3356//this is a overwritten callbackmethods from the syncinterface
3308bool KABCore::sync(KSyncManager* manager, QString filename, int mode,QString resource) 3357bool KABCore::sync(KSyncManager* manager, QString filename, int mode,QString resource)
3309{ 3358{
3310 3359
3311 //pending prepare addresseeview for output 3360 //pending prepare addresseeview for output
3312 //pending detect, if remote file has REV field. if not switch to external sync 3361 //pending detect, if remote file has REV field. if not switch to external sync
3313 mGlobalSyncMode = SYNC_MODE_NORMAL; 3362 mGlobalSyncMode = SYNC_MODE_NORMAL;
3314 if ( manager != syncManager ) 3363 if ( manager != syncManager )
3315 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3364 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3316 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3365 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3317 3366
3318 AddressBook abLocal(filename,"syncContact"); 3367 AddressBook abLocal(filename,"syncContact");
3319 bool syncOK = false; 3368 bool syncOK = false;
3320 if ( abLocal.load() ) { 3369 if ( abLocal.load() ) {
3321 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); 3370 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode );
3322 bool external = false; 3371 bool external = false;
3323 bool isXML = false; 3372 bool isXML = false;
3324 if ( filename.right(4) == ".xml") { 3373 if ( filename.right(4) == ".xml") {
3325 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3374 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3326 isXML = true; 3375 isXML = true;
3327 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3376 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3328 } else { 3377 } else {
3329 external = !manager->mIsKapiFile; 3378 external = !manager->mIsKapiFile;
3330 if ( external ) { 3379 if ( external ) {
3331 qDebug("KA: Sync::Setting vcf mode to external "); 3380 qDebug("KA: Sync::Setting vcf mode to external ");
3332 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3381 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3333 AddressBook::Iterator it; 3382 AddressBook::Iterator it;
3334 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3383 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3335 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3384 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3336 (*it).computeCsum( mCurrentSyncDevice ); 3385 (*it).computeCsum( mCurrentSyncDevice );
3337 } 3386 }
3338 } 3387 }
3339 } 3388 }
3340 //AddressBook::Iterator it; 3389 //AddressBook::Iterator it;
3341 //QStringList vcards; 3390 //QStringList vcards;
3342 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3391 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3343 // qDebug("Name %s ", (*it).familyName().latin1()); 3392 // qDebug("Name %s ", (*it).familyName().latin1());
3344 //} 3393 //}
3345 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3394 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3346 syncManager->hideProgressBar(); 3395 syncManager->hideProgressBar();
3347 if ( syncOK ) { 3396 if ( syncOK ) {
3348 if ( syncManager->mWriteBackFile ) 3397 if ( syncManager->mWriteBackFile )
3349 { 3398 {
3350 if ( external ) 3399 if ( external )
3351 abLocal.removeSyncAddressees( !isXML); 3400 abLocal.removeSyncAddressees( !isXML);
3352 qDebug("KA: Sync::Saving remote AB "); 3401 qDebug("KA: Sync::Saving remote AB ");
3353 if ( ! abLocal.saveAB()) 3402 if ( ! abLocal.saveAB())
3354 qDebug("KA: sync::Error writing back AB to file "); 3403 qDebug("KA: sync::Error writing back AB to file ");
3355 if ( external ) { 3404 if ( external ) {
3356 // afterwrite processing 3405 // afterwrite processing
3357 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3406 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3358 } 3407 }
3359 } 3408 }
3360 } 3409 }
3361 setModified(); 3410 setModified();
3362 3411
3363 } 3412 }
3364 abLocal.removeResources(); 3413 abLocal.removeResources();
3365 if ( syncOK ) 3414 if ( syncOK )
3366 mViewManager->refreshView(); 3415 mViewManager->refreshView();
3367 return syncOK; 3416 return syncOK;
3368 3417
3369} 3418}
3370void KABCore::removeSyncInfo( QString syncProfile) 3419void KABCore::removeSyncInfo( QString syncProfile)
3371{ 3420{
3372 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3421 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3373 mAddressBook->removeSyncInfo( syncProfile ); 3422 mAddressBook->removeSyncInfo( syncProfile );
3374 setModified(); 3423 setModified();
3375} 3424}
3376 3425
3426bool KABCore::syncOL()
3427{
3428 disableBR( true );
3429 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3430 AddressBook abLocal;
3431 if ( ! readOLdata( &abLocal ) )
3432 return false;
3433 bool syncOK = false;
3434 message(i18n("Data from OL loaded..."), false);
3435 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3436 message(i18n("Sync preprocessing..."),false);
3437 abLocal.preOLSync( mAddressBook ,mCurrentSyncDevice );
3438 message(i18n("Synchronizing..."),false);
3439 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3440 syncManager->hideProgressBar();
3441 if ( syncOK ) {
3442 if ( syncManager->mWriteBackFile ) {
3443 abLocal.removeSyncAddressees( false );
3444 message(i18n("Saving address data to OL..."),false);
3445 //abLocal.saveAB();
3446 writeOLdata( &abLocal );
3447 message(i18n("Sync postprocessing..."),false);
3448 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3449 }
3450 } else
3451 message( i18n("Sync cancelled or failed.") );
3452 setModified();
3453 abLocal.removeResources();
3454 if ( syncOK ) {
3455 mViewManager->refreshView();
3456 message(i18n("OL syncing finished."));
3457 }
3458 disableBR( false );
3459 return syncOK;
3460}
3377 3461
3378//this is a overwritten callbackmethods from the syncinterface 3462//this is a overwritten callbackmethods from the syncinterface
3379bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3463bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3380{ 3464{
3381 if ( resource == "phone" ) 3465 if ( resource == "phone" )
3382 return syncPhone(); 3466 return syncPhone();
3467 if ( resource == "ol" )
3468 return syncOL();
3383 disableBR( true ); 3469 disableBR( true );
3384 if ( manager != syncManager ) 3470 if ( manager != syncManager )
3385 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3471 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3386 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3472 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3387 3473
3388 AddressBook abLocal( resource,"syncContact"); 3474 AddressBook abLocal( resource,"syncContact");
3389 bool syncOK = false; 3475 bool syncOK = false;
3390 message(i18n("Loading DTM address data..."), false); 3476 message(i18n("Loading DTM address data..."), false);
3391 if ( abLocal.load() ) { 3477 if ( abLocal.load() ) {
3392 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3478 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3393 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3479 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3394 message(i18n("Sync preprocessing..."),false); 3480 message(i18n("Sync preprocessing..."),false);
3395 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3481 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3396 message(i18n("Synchronizing..."),false); 3482 message(i18n("Synchronizing..."),false);
3397 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3483 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3398 syncManager->hideProgressBar(); 3484 syncManager->hideProgressBar();
3399 if ( syncOK ) { 3485 if ( syncOK ) {
3400 if ( syncManager->mWriteBackFile ) { 3486 if ( syncManager->mWriteBackFile ) {
3401 abLocal.removeSyncAddressees( false ); 3487 abLocal.removeSyncAddressees( false );
3402 message(i18n("Saving DTM address data..."),false); 3488 message(i18n("Saving DTM address data..."),false);
3403 abLocal.saveAB(); 3489 abLocal.saveAB();
3404 message(i18n("Sync postprocessing..."),false); 3490 message(i18n("Sync postprocessing..."),false);
3405 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3491 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3406 } 3492 }
3407 } else 3493 } else
3408 message( i18n("Sync cancelled or failed.") ); 3494 message( i18n("Sync cancelled or failed.") );
3409 setModified(); 3495 setModified();
3410 } 3496 }
3411 abLocal.removeResources(); 3497 abLocal.removeResources();
3412 if ( syncOK ) { 3498 if ( syncOK ) {
3413 mViewManager->refreshView(); 3499 mViewManager->refreshView();
3414 message(i18n("DTM syncing finished.")); 3500 message(i18n("DTM syncing finished."));
3415 } 3501 }
3416 disableBR( false ); 3502 disableBR( false );
3417 return syncOK; 3503 return syncOK;
3418 3504
3419} 3505}
3420void KABCore::message( QString m, bool startTimer) 3506void KABCore::message( QString m, bool startTimer)
3421{ 3507{
3422 topLevelWidget()->setCaption( m ); 3508 topLevelWidget()->setCaption( m );
3423 qApp->processEvents(); 3509 qApp->processEvents();
3424 if ( startTimer ) 3510 if ( startTimer )
3425 mMessageTimer->start( 15000, true ); 3511 mMessageTimer->start( 15000, true );
3426 else 3512 else
3427 mMessageTimer->stop(); 3513 mMessageTimer->stop();
3428} 3514}
3429bool KABCore::syncPhone() 3515bool KABCore::syncPhone()
3430{ 3516{
3431 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3517 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3432 QString fileName = getPhoneFile(); 3518 QString fileName = getPhoneFile();
3433 if ( !PhoneAccess::readFromPhone( fileName) ) { 3519 if ( !PhoneAccess::readFromPhone( fileName) ) {
3434 message(i18n("Phone access failed!")); 3520 message(i18n("Phone access failed!"));
3435 return false; 3521 return false;
3436 } 3522 }
3437 AddressBook abLocal( fileName,"syncContact"); 3523 AddressBook abLocal( fileName,"syncContact");
3438 bool syncOK = false; 3524 bool syncOK = false;
3439 { 3525 {
3440 abLocal.importFromFile( fileName ); 3526 abLocal.importFromFile( fileName );
3441 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3527 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3442 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3528 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3443 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3529 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3444 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3530 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3445 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3531 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3446 syncManager->hideProgressBar(); 3532 syncManager->hideProgressBar();
3447 if ( syncOK ) { 3533 if ( syncOK ) {
3448 if ( syncManager->mWriteBackFile ) { 3534 if ( syncManager->mWriteBackFile ) {
3449 abLocal.removeSyncAddressees( true ); 3535 abLocal.removeSyncAddressees( true );
3450 abLocal.saveABphone( fileName ); 3536 abLocal.saveABphone( fileName );
3451 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3537 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3452 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3538 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3453 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3539 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3454 } 3540 }
3455 } 3541 }
3456 setModified(); 3542 setModified();
3457 } 3543 }
3458 abLocal.removeResources(); 3544 abLocal.removeResources();
3459 if ( syncOK ) 3545 if ( syncOK )
3460 mViewManager->refreshView(); 3546 mViewManager->refreshView();
3461 return syncOK; 3547 return syncOK;
3462} 3548}
3463void KABCore::getFile( bool success ,const QString & resource) 3549void KABCore::getFile( bool success ,const QString & resource)
3464{ 3550{
3465 if ( ! success ) { 3551 if ( ! success ) {
3466 message( i18n("Error receiving file. Nothing changed!") ); 3552 message( i18n("Error receiving file. Nothing changed!") );
3467 return; 3553 return;
3468 } 3554 }
3469 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ,resource); 3555 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ,resource);
3470 if ( count ) 3556 if ( count )
3471 setModified( true ); 3557 setModified( true );
3472 message( i18n("Pi-Sync successful!") ); 3558 message( i18n("Pi-Sync successful!") );
3473 mViewManager->refreshView(); 3559 mViewManager->refreshView();
3474} 3560}
3475void KABCore::syncFileRequest(const QString & resource) 3561void KABCore::syncFileRequest(const QString & resource)
3476{ 3562{
3477 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3563 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3478 syncManager->slotSyncMenu( 999 ); 3564 syncManager->slotSyncMenu( 999 );
3479 } 3565 }
3480 3566
3481 if ( resource == "ALL" ) { 3567 if ( resource == "ALL" ) {
3482 mAddressBook->export2File( sentSyncFile() ); 3568 mAddressBook->export2File( sentSyncFile() );
3483 } 3569 }
3484 else 3570 else
3485 mAddressBook->export2File( sentSyncFile(), resource); 3571 mAddressBook->export2File( sentSyncFile(), resource);
3486} 3572}
3487QString KABCore::sentSyncFile() 3573QString KABCore::sentSyncFile()
3488{ 3574{
3489#ifdef DESKTOP_VERSION 3575#ifdef DESKTOP_VERSION
3490 return locateLocal( "tmp", "copysyncab.vcf" ); 3576 return locateLocal( "tmp", "copysyncab.vcf" );
3491#else 3577#else
3492 return QString( "/tmp/copysyncab.vcf" ); 3578 return QString( "/tmp/copysyncab.vcf" );
3493#endif 3579#endif
3494} 3580}
3495 3581
3496void KABCore::setCaptionBack() 3582void KABCore::setCaptionBack()
3497{ 3583{
3498 mMessageTimer->stop(); 3584 mMessageTimer->stop();
3499 topLevelWidget()->setCaption( i18n("KA/Pi") ); 3585 topLevelWidget()->setCaption( i18n("KA/Pi") );
3500} 3586}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index e69cb60..ec6a9ec 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -1,535 +1,540 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KABCORE_H 24#ifndef KABCORE_H
25#define KABCORE_H 25#define KABCORE_H
26 26
27#include <kabc/field.h> 27#include <kabc/field.h>
28 28
29#ifndef KAB_EMBEDDED 29#ifndef KAB_EMBEDDED
30#endif //KAB_EMBEDDED 30#endif //KAB_EMBEDDED
31#include <qdict.h> 31#include <qdict.h>
32#include <qtimer.h> 32#include <qtimer.h>
33 33
34#include <qwidget.h> 34#include <qwidget.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <ksyncmanager.h> 36#include <ksyncmanager.h>
37#ifndef DESKTOP_VERSION 37#ifndef DESKTOP_VERSION
38#include <qcopchannel_qws.h> 38#include <qcopchannel_qws.h>
39#endif 39#endif
40 40
41namespace KABC { 41namespace KABC {
42class AddressBook; 42class AddressBook;
43} 43}
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46class KAboutData; 46class KAboutData;
47class KConfig; 47class KConfig;
48 48
49class KAddressBookService; 49class KAddressBookService;
50class LDAPSearchDialog; 50class LDAPSearchDialog;
51#else //KAB_EMBEDDED 51#else //KAB_EMBEDDED
52class KAddressBookMain; 52class KAddressBookMain;
53//US class QAction; 53//US class QAction;
54#endif //KAB_EMBEDDED 54#endif //KAB_EMBEDDED
55class KCMultiDialog; 55class KCMultiDialog;
56class KXMLGUIClient; 56class KXMLGUIClient;
57class ExtensionManager; 57class ExtensionManager;
58class XXPortManager; 58class XXPortManager;
59class JumpButtonBar; 59class JumpButtonBar;
60class IncSearchWidget; 60class IncSearchWidget;
61class KDGanttMinimizeSplitter; 61class KDGanttMinimizeSplitter;
62class KAction; 62class KAction;
63class KActionCollection; 63class KActionCollection;
64class KToggleAction; 64class KToggleAction;
65class KSyncProfile; 65class KSyncProfile;
66 66
67class QAction; 67class QAction;
68class QMenuBar; 68class QMenuBar;
69class QSplitter; 69class QSplitter;
70class ViewContainer; 70class ViewContainer;
71class ViewManager; 71class ViewManager;
72class AddresseeEditorDialog; 72class AddresseeEditorDialog;
73class Ir; 73class Ir;
74 74
75class KABCore : public QWidget, public KSyncInterface 75class KABCore : public QWidget, public KSyncInterface
76{ 76{
77 Q_OBJECT 77 Q_OBJECT
78 78
79 public: 79 public:
80 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); 80 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 );
81 81
82 82
83 ~KABCore(); 83 ~KABCore();
84 84
85 85
86#ifdef KAB_EMBEDDED 86#ifdef KAB_EMBEDDED
87 //US added functionality 87 //US added functionality
88 QPopupMenu* getViewMenu() {return viewMenu;} 88 QPopupMenu* getViewMenu() {return viewMenu;}
89 QPopupMenu* getFilterMenu() {return filterMenu;} 89 QPopupMenu* getFilterMenu() {return filterMenu;}
90 QPopupMenu* getSettingsMenu() {return settingsMenu;} 90 QPopupMenu* getSettingsMenu() {return settingsMenu;}
91 void addActionsManually(); 91 void addActionsManually();
92#endif //KAB_EMBEDDED 92#endif //KAB_EMBEDDED
93 /** 93 /**
94 Restores the global settings. 94 Restores the global settings.
95 */ 95 */
96 void restoreSettings(); 96 void restoreSettings();
97 97
98 98
99 99
100 /** 100 /**
101 Returns a pointer to the StdAddressBook of the application. 101 Returns a pointer to the StdAddressBook of the application.
102 */ 102 */
103 KABC::AddressBook *addressBook() const; 103 KABC::AddressBook *addressBook() const;
104 104
105 /** 105 /**
106 Returns a pointer to the KConfig object of the application. 106 Returns a pointer to the KConfig object of the application.
107 */ 107 */
108 static KConfig *config(); 108 static KConfig *config();
109 109
110 /** 110 /**
111 Returns a pointer to the global KActionCollection object. So 111 Returns a pointer to the global KActionCollection object. So
112 other classes can register their actions easily. 112 other classes can register their actions easily.
113 */ 113 */
114 KActionCollection *actionCollection() const; 114 KActionCollection *actionCollection() const;
115 115
116 /** 116 /**
117 Returns the current search field of the Incremental Search Widget. 117 Returns the current search field of the Incremental Search Widget.
118 */ 118 */
119 KABC::Field *currentSearchField() const; 119 KABC::Field *currentSearchField() const;
120 120
121 /** 121 /**
122 Returns the uid list of the currently selected contacts. 122 Returns the uid list of the currently selected contacts.
123 */ 123 */
124 QStringList selectedUIDs() const; 124 QStringList selectedUIDs() const;
125 125
126 /** 126 /**
127 Displays the ResourceSelectDialog and returns the selected 127 Displays the ResourceSelectDialog and returns the selected
128 resource or a null pointer if no resource was selected by 128 resource or a null pointer if no resource was selected by
129 the user. 129 the user.
130 */ 130 */
131 KABC::Resource *requestResource( QWidget *parent ); 131 KABC::Resource *requestResource( QWidget *parent );
132 132
133#ifndef KAB_EMBEDDED 133#ifndef KAB_EMBEDDED
134 static KAboutData *createAboutData(); 134 static KAboutData *createAboutData();
135#endif //KAB_EMBEDDED 135#endif //KAB_EMBEDDED
136 136
137#ifdef KAB_EMBEDDED 137#ifdef KAB_EMBEDDED
138 inline QPopupMenu* getImportMenu() { return ImportMenu;} 138 inline QPopupMenu* getImportMenu() { return ImportMenu;}
139 inline QPopupMenu* getExportMenu() { return ExportMenu;} 139 inline QPopupMenu* getExportMenu() { return ExportMenu;}
140#endif //KAB_EMBEDDED 140#endif //KAB_EMBEDDED
141 141
142 public slots: 142 public slots:
143#ifdef KAB_EMBEDDED 143#ifdef KAB_EMBEDDED
144 void createAboutData(); 144 void createAboutData();
145#endif //KAB_EMBEDDED 145#endif //KAB_EMBEDDED
146 void setDetailsToggle(); 146 void setDetailsToggle();
147 147
148 void showLicence(); 148 void showLicence();
149 void faq(); 149 void faq();
150 void whatsnew() ; 150 void whatsnew() ;
151 void synchowto() ; 151 void synchowto() ;
152 void storagehowto() ; 152 void storagehowto() ;
153 void multisynchowto() ; 153 void multisynchowto() ;
154 void kdesynchowto() ; 154 void kdesynchowto() ;
155 void writeToPhone(); 155 void writeToPhone();
156 156
157 /** 157 /**
158 Is called whenever a contact is selected in the view. 158 Is called whenever a contact is selected in the view.
159 */ 159 */
160 void setContactSelected( const QString &uid ); 160 void setContactSelected( const QString &uid );
161 161
162 /** 162 /**
163 Opens the preferred mail composer with all selected contacts as 163 Opens the preferred mail composer with all selected contacts as
164 arguments. 164 arguments.
165 */ 165 */
166 void sendMail(); 166 void sendMail();
167 167
168 /** 168 /**
169 Opens the preferred mail composer with the given contacts as 169 Opens the preferred mail composer with the given contacts as
170 arguments. 170 arguments.
171 */ 171 */
172 void sendMail( const QString& email ); 172 void sendMail( const QString& email );
173 173
174 174
175 void mailVCard(); 175 void mailVCard();
176 void mailVCard(const QStringList& uids); 176 void mailVCard(const QStringList& uids);
177 177
178 /** 178 /**
179 Beams the "WhoAmI contact. 179 Beams the "WhoAmI contact.
180 */ 180 */
181 void beamMySelf(); 181 void beamMySelf();
182 182
183 void beamVCard(); 183 void beamVCard();
184 void export2phone(); 184 void export2phone();
185 void beamVCard(const QStringList& uids); 185 void beamVCard(const QStringList& uids);
186 void beamDone( Ir *ir ); 186 void beamDone( Ir *ir );
187 187
188 188
189 /** 189 /**
190 Starts the preferred web browser with the given URL as argument. 190 Starts the preferred web browser with the given URL as argument.
191 */ 191 */
192 void browse( const QString& url ); 192 void browse( const QString& url );
193 193
194 /** 194 /**
195 Select all contacts in the view. 195 Select all contacts in the view.
196 */ 196 */
197 void selectAllContacts(); 197 void selectAllContacts();
198 198
199 /** 199 /**
200 Deletes all selected contacts from the address book. 200 Deletes all selected contacts from the address book.
201 */ 201 */
202 void deleteContacts(); 202 void deleteContacts();
203 203
204 /** 204 /**
205 Deletes given contacts from the address book. 205 Deletes given contacts from the address book.
206 206
207 @param uids The uids of the contacts, which shall be deleted. 207 @param uids The uids of the contacts, which shall be deleted.
208 */ 208 */
209 void deleteContacts( const QStringList &uids ); 209 void deleteContacts( const QStringList &uids );
210 210
211 /** 211 /**
212 Copys the selected contacts into clipboard for later pasting. 212 Copys the selected contacts into clipboard for later pasting.
213 */ 213 */
214 void copyContacts(); 214 void copyContacts();
215 215
216 /** 216 /**
217 Cuts the selected contacts and stores them for later pasting. 217 Cuts the selected contacts and stores them for later pasting.
218 */ 218 */
219 void cutContacts(); 219 void cutContacts();
220 220
221 /** 221 /**
222 Paste contacts from clipboard into the address book. 222 Paste contacts from clipboard into the address book.
223 */ 223 */
224 void pasteContacts(); 224 void pasteContacts();
225 225
226 /** 226 /**
227 Paste given contacts into the address book. 227 Paste given contacts into the address book.
228 228
229 @param list The list of addressee, which shall be pasted. 229 @param list The list of addressee, which shall be pasted.
230 */ 230 */
231 void pasteContacts( KABC::Addressee::List &list ); 231 void pasteContacts( KABC::Addressee::List &list );
232 232
233 /** 233 /**
234 Sets the whoAmI contact, that is used by many other programs to 234 Sets the whoAmI contact, that is used by many other programs to
235 get personal information about the current user. 235 get personal information about the current user.
236 */ 236 */
237 void setWhoAmI(); 237 void setWhoAmI();
238 238
239 /** 239 /**
240 Displays the category dialog and applies the result to all 240 Displays the category dialog and applies the result to all
241 selected contacts. 241 selected contacts.
242 */ 242 */
243 void setCategories(); 243 void setCategories();
244 void manageCategories(); 244 void manageCategories();
245 void editCategories(); 245 void editCategories();
246 246
247 /** 247 /**
248 Sets the field list of the Incremental Search Widget. 248 Sets the field list of the Incremental Search Widget.
249 */ 249 */
250 void setSearchFields( const KABC::Field::List &fields ); 250 void setSearchFields( const KABC::Field::List &fields );
251 251
252 /** 252 /**
253 Search with the current search field for a contact, that matches 253 Search with the current search field for a contact, that matches
254 the given text, and selects it in the view. 254 the given text, and selects it in the view.
255 */ 255 */
256 void incrementalSearch( const QString& text ); 256 void incrementalSearch( const QString& text );
257 void incrementalSearchJump( const QString& text ); 257 void incrementalSearchJump( const QString& text );
258 258
259 /** 259 /**
260 Marks the address book as modified. 260 Marks the address book as modified.
261 */ 261 */
262 void setModified(); 262 void setModified();
263 /** 263 /**
264 Marks the address book as modified without refreshing the view. 264 Marks the address book as modified without refreshing the view.
265 */ 265 */
266 void setModifiedWOrefresh(); 266 void setModifiedWOrefresh();
267 267
268 /** 268 /**
269 Marks the address book as modified concerning the argument. 269 Marks the address book as modified concerning the argument.
270 */ 270 */
271 void setModified( bool modified ); 271 void setModified( bool modified );
272 272
273 /** 273 /**
274 Returns whether the address book is modified. 274 Returns whether the address book is modified.
275 */ 275 */
276 bool modified() const; 276 bool modified() const;
277 277
278 /** 278 /**
279 Called whenever an contact is modified in the contact editor 279 Called whenever an contact is modified in the contact editor
280 dialog or the quick edit. 280 dialog or the quick edit.
281 */ 281 */
282 void contactModified( const KABC::Addressee &addr ); 282 void contactModified( const KABC::Addressee &addr );
283 void addrModified( const KABC::Addressee &addr, bool updateDetails = true ); 283 void addrModified( const KABC::Addressee &addr, bool updateDetails = true );
284 284
285 /** 285 /**
286 DCOP METHODS. 286 DCOP METHODS.
287 */ 287 */
288 void addEmail( QString addr ); 288 void addEmail( QString addr );
289 void importVCard( const KURL& url, bool showPreview ); 289 void importVCard( const KURL& url, bool showPreview );
290 void importVCard( const QString& vCard, bool showPreview ); 290 void importVCard( const QString& vCard, bool showPreview );
291 void newContact(); 291 void newContact();
292 QString getNameByPhone( const QString& phone ); 292 QString getNameByPhone( const QString& phone );
293 /** 293 /**
294 END DCOP METHODS 294 END DCOP METHODS
295 */ 295 */
296 296
297 /** 297 /**
298 Saves the contents of the AddressBook back to disk. 298 Saves the contents of the AddressBook back to disk.
299 */ 299 */
300 void save(); 300 void save();
301 301
302 /** 302 /**
303 Undos the last command using the undo stack. 303 Undos the last command using the undo stack.
304 */ 304 */
305 void undo(); 305 void undo();
306 306
307 /** 307 /**
308 Redos the last command that was undone, using the redo stack. 308 Redos the last command that was undone, using the redo stack.
309 */ 309 */
310 void redo(); 310 void redo();
311 311
312 /** 312 /**
313 Shows the edit dialog for the given uid. If the uid is QString::null, 313 Shows the edit dialog for the given uid. If the uid is QString::null,
314 the method will try to find a selected addressee in the view. 314 the method will try to find a selected addressee in the view.
315 */ 315 */
316 void editContact( const QString &uid /*US = QString::null*/ ); 316 void editContact( const QString &uid /*US = QString::null*/ );
317//US added a second method without defaultparameter 317//US added a second method without defaultparameter
318 void editContact2(); 318 void editContact2();
319 319
320 /** 320 /**
321 Shows or edits the detail view for the given uid. If the uid is QString::null, 321 Shows or edits the detail view for the given uid. If the uid is QString::null,
322 the method will try to find a selected addressee in the view. 322 the method will try to find a selected addressee in the view.
323 */ 323 */
324 void executeContact( const QString &uid /*US = QString::null*/ ); 324 void executeContact( const QString &uid /*US = QString::null*/ );
325 325
326 /** 326 /**
327 Launches the configuration dialog. 327 Launches the configuration dialog.
328 */ 328 */
329 void openConfigDialog(); 329 void openConfigDialog();
330 void openConfigGlobalDialog(); 330 void openConfigGlobalDialog();
331 331
332 /** 332 /**
333 Launches the ldap search dialog. 333 Launches the ldap search dialog.
334 */ 334 */
335 void openLDAPDialog(); 335 void openLDAPDialog();
336 336
337 /** 337 /**
338 Creates a KAddressBookPrinter, which will display the print 338 Creates a KAddressBookPrinter, which will display the print
339 dialog and do the printing. 339 dialog and do the printing.
340 */ 340 */
341 void print(); 341 void print();
342 342
343 /** 343 /**
344 Registers a new GUI client, so plugins can register its actions. 344 Registers a new GUI client, so plugins can register its actions.
345 */ 345 */
346 void addGUIClient( KXMLGUIClient *client ); 346 void addGUIClient( KXMLGUIClient *client );
347 347
348 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); 348 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
349 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 349 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
350 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); 350 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid);
351 351
352 352
353 signals: 353 signals:
354 void contactSelected( const QString &name ); 354 void contactSelected( const QString &name );
355 void contactSelected( const QPixmap &pixmap ); 355 void contactSelected( const QPixmap &pixmap );
356 public slots: 356 public slots:
357 void loadDataAfterStart(); 357 void loadDataAfterStart();
358 void recieve(QString cmsg ); 358 void recieve(QString cmsg );
359 void getFile( bool success,const QString & ); 359 void getFile( bool success,const QString & );
360 void syncFileRequest(const QString &); 360 void syncFileRequest(const QString &);
361 void setDetailsVisible( bool visible ); 361 void setDetailsVisible( bool visible );
362 void setDetailsToState(); 362 void setDetailsToState();
363 363
364 void saveSettings(); 364 void saveSettings();
365 365
366 private slots: 366 private slots:
367 void updateToolBar(); 367 void updateToolBar();
368 void updateMainWindow(); 368 void updateMainWindow();
369 void receive( const QCString& cmsg, const QByteArray& data ); 369 void receive( const QCString& cmsg, const QByteArray& data );
370 void receiveStart( const QCString& cmsg, const QByteArray& data ); 370 void receiveStart( const QCString& cmsg, const QByteArray& data );
371 void toggleBeamReceive( ); 371 void toggleBeamReceive( );
372 void disableBR(bool); 372 void disableBR(bool);
373 void setJumpButtonBarVisible( bool visible ); 373 void setJumpButtonBarVisible( bool visible );
374 void setJumpButtonBar( bool visible ); 374 void setJumpButtonBar( bool visible );
375 void setCaptionBack(); 375 void setCaptionBack();
376 void resizeAndCallContactdialog(); 376 void resizeAndCallContactdialog();
377 void callContactdialog(); 377 void callContactdialog();
378 void doRingSync(); 378 void doRingSync();
379 379
380 void importFromOL(); 380 void importFromOL();
381 void extensionModified( const KABC::Addressee::List &list ); 381 void extensionModified( const KABC::Addressee::List &list );
382 void extensionChanged( int id ); 382 void extensionChanged( int id );
383 void clipboardDataChanged(); 383 void clipboardDataChanged();
384 void updateActionMenu(); 384 void updateActionMenu();
385 void configureKeyBindings(); 385 void configureKeyBindings();
386 void removeVoice(); 386 void removeVoice();
387 void setFormattedName(); 387 void setFormattedName();
388#ifdef KAB_EMBEDDED 388#ifdef KAB_EMBEDDED
389 void configureResources(); 389 void configureResources();
390#endif //KAB_EMBEDDED 390#endif //KAB_EMBEDDED
391 391
392 void slotEditorDestroyed( const QString &uid ); 392 void slotEditorDestroyed( const QString &uid );
393 void configurationChanged(); 393 void configurationChanged();
394 void addressBookChanged(); 394 void addressBookChanged();
395 395
396 private: 396 private:
397 QCString mCStringMess; 397 QCString mCStringMess;
398 QByteArray mByteData; 398 QByteArray mByteData;
399 QString mEmailSourceChannel; 399 QString mEmailSourceChannel;
400 QString mEmailSourceUID; 400 QString mEmailSourceUID;
401 void resizeEvent(QResizeEvent* e ); 401 void resizeEvent(QResizeEvent* e );
402 bool mBRdisabled; 402 bool mBRdisabled;
403#ifndef DESKTOP_VERSION 403#ifndef DESKTOP_VERSION
404 QCopChannel* infrared; 404 QCopChannel* infrared;
405#endif 405#endif
406 QTimer *mMessageTimer; 406 QTimer *mMessageTimer;
407 void initGUI(); 407 void initGUI();
408 void initActions(); 408 void initActions();
409 QString getPhoneFile(); 409 QString getPhoneFile();
410 410
411 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 411 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
412 const char *name = 0 ); 412 const char *name = 0 );
413 413
414 KXMLGUIClient *mGUIClient; 414 KXMLGUIClient *mGUIClient;
415 415
416 KABC::AddressBook *mAddressBook; 416 KABC::AddressBook *mAddressBook;
417 417
418 ViewManager *mViewManager; 418 ViewManager *mViewManager;
419 // QSplitter *mDetailsSplitter; 419 // QSplitter *mDetailsSplitter;
420 KDGanttMinimizeSplitter *mExtensionBarSplitter; 420 KDGanttMinimizeSplitter *mExtensionBarSplitter;
421 ViewContainer *mDetails; 421 ViewContainer *mDetails;
422 KDGanttMinimizeSplitter* mMiniSplitter; 422 KDGanttMinimizeSplitter* mMiniSplitter;
423 XXPortManager *mXXPortManager; 423 XXPortManager *mXXPortManager;
424 JumpButtonBar *mJumpButtonBar; 424 JumpButtonBar *mJumpButtonBar;
425 IncSearchWidget *mIncSearchWidget; 425 IncSearchWidget *mIncSearchWidget;
426 ExtensionManager *mExtensionManager; 426 ExtensionManager *mExtensionManager;
427 427
428 KCMultiDialog *mConfigureDialog; 428 KCMultiDialog *mConfigureDialog;
429 429
430#ifndef KAB_EMBEDDED 430#ifndef KAB_EMBEDDED
431 LDAPSearchDialog *mLdapSearchDialog; 431 LDAPSearchDialog *mLdapSearchDialog;
432#endif //KAB_EMBEDDED 432#endif //KAB_EMBEDDED
433 // QDict<AddresseeEditorDialog> mEditorDict; 433 // QDict<AddresseeEditorDialog> mEditorDict;
434 AddresseeEditorDialog *mEditorDialog; 434 AddresseeEditorDialog *mEditorDialog;
435 bool mReadWrite; 435 bool mReadWrite;
436 bool mModified; 436 bool mModified;
437 bool mIsPart; 437 bool mIsPart;
438 bool mMultipleViewsAtOnce; 438 bool mMultipleViewsAtOnce;
439 439
440 440
441 //US file menu 441 //US file menu
442 KAction *mActionMail; 442 KAction *mActionMail;
443 KAction *mActionBeam; 443 KAction *mActionBeam;
444 KToggleAction *mActionBR; 444 KToggleAction *mActionBR;
445 KAction *mActionExport2phone; 445 KAction *mActionExport2phone;
446 KAction* mActionPrint; 446 KAction* mActionPrint;
447 KAction* mActionPrintDetails; 447 KAction* mActionPrintDetails;
448 KAction* mActionNewContact; 448 KAction* mActionNewContact;
449 KAction *mActionSave; 449 KAction *mActionSave;
450 KAction *mActionEditAddressee; 450 KAction *mActionEditAddressee;
451 KAction *mActionMailVCard; 451 KAction *mActionMailVCard;
452 KAction *mActionBeamVCard; 452 KAction *mActionBeamVCard;
453 453
454 KAction *mActionQuit; 454 KAction *mActionQuit;
455 455
456 //US edit menu 456 //US edit menu
457 KAction *mActionCopy; 457 KAction *mActionCopy;
458 KAction *mActionCut; 458 KAction *mActionCut;
459 KAction *mActionPaste; 459 KAction *mActionPaste;
460 KAction *mActionSelectAll; 460 KAction *mActionSelectAll;
461 KAction *mActionUndo; 461 KAction *mActionUndo;
462 KAction *mActionRedo; 462 KAction *mActionRedo;
463 KAction *mActionDelete; 463 KAction *mActionDelete;
464 464
465 //US settings menu 465 //US settings menu
466 KAction *mActionConfigResources; 466 KAction *mActionConfigResources;
467 KAction *mActionConfigGlobal; 467 KAction *mActionConfigGlobal;
468 KAction *mActionConfigKAddressbook; 468 KAction *mActionConfigKAddressbook;
469 KAction *mActionConfigShortcuts; 469 KAction *mActionConfigShortcuts;
470 KAction *mActionConfigureToolbars; 470 KAction *mActionConfigureToolbars;
471 KAction *mActionKeyBindings; 471 KAction *mActionKeyBindings;
472 KToggleAction *mActionJumpBar; 472 KToggleAction *mActionJumpBar;
473 KToggleAction *mActionDetails; 473 KToggleAction *mActionDetails;
474 KAction *mActionWhoAmI; 474 KAction *mActionWhoAmI;
475 KAction *mActionCategories; 475 KAction *mActionCategories;
476 KAction *mActionEditCategories; 476 KAction *mActionEditCategories;
477 KAction *mActionManageCategories; 477 KAction *mActionManageCategories;
478 KAction *mActionAboutKAddressbook; 478 KAction *mActionAboutKAddressbook;
479 KAction *mActionLicence; 479 KAction *mActionLicence;
480 KAction *mActionFaq; 480 KAction *mActionFaq;
481 KAction *mActionWN; 481 KAction *mActionWN;
482 KAction *mActionSyncHowto; 482 KAction *mActionSyncHowto;
483 KAction *mActionStorageHowto; 483 KAction *mActionStorageHowto;
484 KAction *mActionKdeSyncHowto; 484 KAction *mActionKdeSyncHowto;
485 KAction *mActionMultiSyncHowto; 485 KAction *mActionMultiSyncHowto;
486 486
487 KAction *mActionDeleteView; 487 KAction *mActionDeleteView;
488 488
489 QPopupMenu *viewMenu; 489 QPopupMenu *viewMenu;
490 QPopupMenu *filterMenu; 490 QPopupMenu *filterMenu;
491 QPopupMenu *settingsMenu; 491 QPopupMenu *settingsMenu;
492 QPopupMenu *changeMenu; 492 QPopupMenu *changeMenu;
493 QPopupMenu *beamMenu; 493 QPopupMenu *beamMenu;
494//US QAction *mActionSave; 494//US QAction *mActionSave;
495 QPopupMenu *ImportMenu; 495 QPopupMenu *ImportMenu;
496 QPopupMenu *ExportMenu; 496 QPopupMenu *ExportMenu;
497 //LR additional methods 497 //LR additional methods
498 KAction *mActionRemoveVoice; 498 KAction *mActionRemoveVoice;
499 KAction *mActionSetFormattedName; 499 KAction *mActionSetFormattedName;
500 KAction * mActionImportOL; 500 KAction * mActionImportOL;
501 501
502#ifndef KAB_EMBEDDED 502#ifndef KAB_EMBEDDED
503 KAddressBookService *mAddressBookService; 503 KAddressBookService *mAddressBookService;
504#endif //KAB_EMBEDDED 504#endif //KAB_EMBEDDED
505 505
506 class KABCorePrivate; 506 class KABCorePrivate;
507 KABCorePrivate *d; 507 KABCorePrivate *d;
508 //US bool mBlockSaveFlag; 508 //US bool mBlockSaveFlag;
509 509
510#ifdef KAB_EMBEDDED 510#ifdef KAB_EMBEDDED
511 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 511 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
512#endif //KAB_EMBEDDED 512#endif //KAB_EMBEDDED
513 513
514 //this are the overwritten callbackmethods from the syncinterface 514 //this are the overwritten callbackmethods from the syncinterface
515 virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource); 515 virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource);
516 virtual bool syncExternal(KSyncManager* manager, QString resource); 516 virtual bool syncExternal(KSyncManager* manager, QString resource);
517 virtual void removeSyncInfo( QString syncProfile); 517 virtual void removeSyncInfo( QString syncProfile);
518 bool readOLdata( KABC::AddressBook* local );
519 bool writeOLdata( KABC::AddressBook* local );
520 bool syncOL();
518 bool syncPhone(); 521 bool syncPhone();
519 void message( QString m , bool startTimer = true); 522 void message( QString m , bool startTimer = true);
520 523
521 // LR ******************************* 524 // LR *******************************
522 // sync stuff! 525 // sync stuff!
523 QString sentSyncFile(); 526 QString sentSyncFile();
524 QPopupMenu *syncMenu; 527 QPopupMenu *syncMenu;
525 KSyncManager* syncManager; 528 KSyncManager* syncManager;
526 int mGlobalSyncMode; 529 int mGlobalSyncMode;
527 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 530 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
528 KABC::Addressee getLastSyncAddressee(); 531 KABC::Addressee getLastSyncAddressee();
529 QDateTime mLastAddressbookSync; 532 QDateTime mLastAddressbookSync;
530 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); 533 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
531 // ********************* 534 // *********************
535 //OL sync stuff
536 QString mOLsyncFolderID;
532 537
533}; 538};
534 539
535#endif 540#endif
diff --git a/kaddressbook/kaimportoldialog.cpp b/kaddressbook/kaimportoldialog.cpp
index 2f794d6..6afc288 100644
--- a/kaddressbook/kaimportoldialog.cpp
+++ b/kaddressbook/kaimportoldialog.cpp
@@ -1,735 +1,23 @@
1/* 1/*
2 This file is part of KAddressbook/Pi. 2 This file is part of KAddressbook/Pi.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qtooltip.h>
25#include <qframe.h>
26#include <qpixmap.h>
27#include <qlayout.h>
28#include <qprogressbar.h>
29#include <qprogressdialog.h>
30#include <qwidgetstack.h>
31#include <qdatetime.h>
32#include <qdir.h>
33#include <qregexp.h>
34#include <qapplication.h>
35#include <qhbox.h>
36#include <qheader.h>
37#include <qdatetime.h>
38#include <qlistview.h>
39
40#include <kdebug.h>
41#include <klocale.h>
42#include <kstandarddirs.h>
43#include <kmessagebox.h>
44#include <kfiledialog.h>
45
46#include <libkdepim/categoryselectdialog.h>
47#include <libkdepim/kinputdialog.h>
48
49#include <libkcal/calendarlocal.h>
50#include <libkcal/icalformat.h>
51
52#include <kabc/addresseelist.h>
53#include <kabc/phonenumber.h>
54
55#include "kaimportoldialog.h"
56
57#include "../outport/msoutl9.h"
58#include <ole2.h>
59#include <comutil.h>
60_Application gOlAppAB;
61
62QDateTime mDdate2Qdtr( DATE dt)
63{
64 COleDateTime odt;
65 SYSTEMTIME st;
66 odt = dt;
67 if ( odt.GetStatus() != 0 )
68 return QDateTime();
69 odt.GetAsSystemTime(st);
70 if ( st.wYear > 4000 ) // this program as a year 4000 bug!
71 return QDateTime();
72 // it seems so, that 1.1.4501 indicates: DATE invalid
73 QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) );
74 return qdt;
75}
76
77class OLEListViewItem : public QCheckListItem
78{
79 public:
80 OLEListViewItem( QListView *parent, QString text ) :
81 QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; };
82 OLEListViewItem( QListViewItem *after, QString text ) :
83 QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; };
84 ~OLEListViewItem() {};
85 void setData( DWORD data ) {mData= data; };
86 DWORD data() { return mData ;};
87 private:
88 DWORD mData;
89};
90
91KAImportOLdialog::KAImportOLdialog( const QString &caption,
92 KABC::AddressBook * aBook, QWidget *parent ) :
93 KDialogBase( Plain, caption, User1 | Close, Ok,
94 parent, caption, true, false, i18n("Import!") )
95{
96 QHBox * mw = new QHBox( this );
97 setMainWidget( mw );
98 mListView = new QListView( mw );
99 mListView->addColumn(i18n("Select Folder to import"));
100 mListView->addColumn(i18n("Content Type"));
101 mABook = aBook;
102 connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply()));
103 setupFolderView();
104 resize( sizeHint().width()+50, sizeHint().height()+50 );
105}
106
107KAImportOLdialog::~KAImportOLdialog()
108{
109
110}
111
112KABC::Addressee::List KAImportOLdialog::getAddressList()
113{
114 return mAList;
115}
116void KAImportOLdialog::setupFolderView()
117{
118 SCODE sc = ::OleInitialize(NULL);
119 if ( FAILED ( sc ) ) {
120 KMessageBox::information(this,"OLE initialisation failed");
121 return;
122 }
123
124 if(!gOlAppAB.CreateDispatch(_T("Outlook.Application"),NULL)){
125 KMessageBox::information(this,"Sorry, cannot access Outlook");
126 return ;
127 }
128 MAPIFolder mfInbox;
129 MAPIFolder mfRoot;
130 CString szName;
131 _NameSpace olNS;
132 olNS = gOlAppAB.GetNamespace(_T("MAPI"));
133 mfInbox = olNS.GetDefaultFolder(6);
134 mfRoot = mfInbox.GetParent();
135 szName = mfRoot.GetName();
136 long iType = mfRoot.GetDefaultItemType();
137 QString mes;
138 mes = QString::fromUcs2( szName.GetBuffer() );
139 OLEListViewItem * root = new OLEListViewItem( mListView, mes );
140 mfRoot.m_lpDispatch->AddRef();
141 addFolder( root, mfRoot.m_lpDispatch );
142 root->setOpen( true );
143 mListView->setSortColumn( 0 );
144 mListView->sort( );
145}
146
147
148void KAImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent)
149{
150 MAPIFolder mfParent(dispParent), mfChild;
151 _Folders folders;
152 _variant_t fndx((long)0);
153 CString szName;
154 long iType;
155 OLEListViewItem* hChild;
156
157 folders = mfParent.GetFolders();
158 for(int i=1; i <= folders.GetCount(); ++i)
159 {
160 fndx = (long)i;
161 mfChild = folders.Item(fndx.Detach());
162 mfChild.m_lpDispatch->AddRef();
163 szName = mfChild.GetName();
164 iType = mfChild.GetDefaultItemType();
165 hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) );
166 if ( iType != 2)
167 hChild->setEnabled( false );
168 QString ts;
169 switch( iType ) {
170 case 0:
171 ts = i18n("Mail");
172 break;
173 case 1:
174 ts = i18n("Calendar");
175 break;
176 case 2:
177 ts = i18n("Contacts");
178 break;
179 case 3:
180 ts = i18n("Todos");
181 break;
182 case 4:
183 ts = i18n("Journals");
184 break;
185 case 5:
186 ts = i18n("Notes");
187 break;
188 default:
189 ts = i18n("Unknown");
190 }
191 hChild->setText( 1,ts);
192 hChild->setData( (DWORD) mfChild.m_lpDispatch );
193 mfChild.m_lpDispatch->AddRef();
194 addFolder(hChild, mfChild.m_lpDispatch);
195 }
196}
197
198void KAImportOLdialog::slotApply()
199{
200 importedItems = 0;
201 OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild();
202 while ( child ) {
203 if ( child->isOn() )
204 readContactData( child->data() );
205 child = (OLEListViewItem*) child->itemBelow();
206 }
207 QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems);
208 KMessageBox::information(this,mes);
209}
210void KAImportOLdialog::readContactData( DWORD folder )
211{
212
213 LPDISPATCH dispItem = (LPDISPATCH)folder;
214 dispItem->AddRef();
215 MAPIFolder mf(dispItem);
216 mf.m_lpDispatch->AddRef();
217 _Items folderItems;
218 _variant_t indx((long)0);
219 LPDISPATCH itm;
220 int i;
221 folderItems = mf.GetItems();
222 QProgressDialog bar( i18n("Importing contact data"),i18n("Abort"), folderItems.GetCount(),this);
223 bar.setCaption (i18n("Importing!") );
224 int h = bar.sizeHint().height() ;
225 int w = 300;
226 int dw = QApplication::desktop()->width();
227 int dh = QApplication::desktop()->height();
228 //bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
229 bar.show();
230 for(i=1; i <= folderItems.GetCount(); ++i)
231 {
232 qApp->processEvents();
233 if ( ! bar.isVisible() )
234 return ;
235 bar.setProgress( i );
236 indx = (long)i;
237 itm = folderItems.Item(indx.Detach());
238 _ContactItem * pItem = (_ContactItem *)&itm;
239 ol2kapiContact( pItem );
240 itm->Release();
241 }
242}
243void KAImportOLdialog::slotOk()
244{
245 QDialog::accept();
246}
247
248void KAImportOLdialog::ol2kapiContact( _ContactItem * aItem )
249{
250 KABC::Addressee addressee;
251
252 addressee.setUid( QString::fromUcs2(aItem->GetEntryID().GetBuffer()));
253 //GetLastModificationTime()
254 //addressee.setName( const QString &name );
255 //addressee.setFormattedName( const QString &formattedName );
256 addressee.setFamilyName( QString::fromUcs2(aItem->GetLastName().GetBuffer()) );
257 addressee.setGivenName( QString::fromUcs2(aItem->GetFirstName().GetBuffer()) );
258 addressee.setAdditionalName( QString::fromUcs2(aItem->GetMiddleName().GetBuffer()) );
259 addressee.setPrefix(QString::fromUcs2(aItem->GetTitle().GetBuffer()) );
260 addressee.setSuffix( QString::fromUcs2(aItem->GetSuffix().GetBuffer()) );
261 addressee.setNickName( QString::fromUcs2(aItem->GetNickName().GetBuffer()) );
262 QDateTime dtb = mDdate2Qdtr(aItem->GetBirthday());
263 if ( dtb.isValid() )
264 addressee.setBirthday( mDdate2Qdtr(aItem->GetBirthday()));
265
266 //QString::fromUcs2(aItem->.GetBuffer())
267 //addressee.setMailer( const QString &mailer );
268 //addressee.setTimeZone( const TimeZone &timeZone );
269 //addressee.setGeo( const Geo &geo );
270 //addressee.setTitle( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );// titel is the prefix
271 addressee.setRole( QString::fromUcs2(aItem->GetJobTitle().GetBuffer()) );
272 addressee.setOrganization( QString::fromUcs2(aItem->GetCompanyName().GetBuffer()).replace( QRegExp("\\r"), "") );
273 QString notesStr = QString::fromUcs2(aItem->GetBody().GetBuffer());
274 notesStr.replace( QRegExp("\\r"), "");
275
276 addressee.setProductId( QString::fromUcs2(aItem->GetCustomerID().GetBuffer()) );
277 //addressee.setRevision( const QDateTime &revision );
278 // addressee.setSortString( const QString &sortString );
279 addressee.setUrl( QString::fromUcs2(aItem->GetWebPage().GetBuffer()) );
280
281 QString tempS;
282 tempS = QString::fromUcs2(aItem->GetNetMeetingAlias().GetBuffer())+" AT SERVER: " +QString::fromUcs2(aItem->GetNetMeetingServer().GetBuffer());
283 if ( tempS.length() > 12 )
284 addressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", tempS );
285 tempS = QString::fromUcs2(aItem->GetSpouse().GetBuffer());
286 if ( !tempS.isEmpty() )
287 addressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", tempS );
288 tempS = QString::fromUcs2(aItem->GetManagerName().GetBuffer());
289 if ( !tempS.isEmpty() )
290 addressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", tempS );
291 tempS = QString::fromUcs2(aItem->GetAssistantName().GetBuffer());
292 if ( !tempS.isEmpty() )
293 addressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", tempS );
294 tempS = QString::fromUcs2(aItem->GetDepartment().GetBuffer());
295 if ( !tempS.isEmpty() )
296 addressee.insertCustom( "KADDRESSBOOK", "X-Department", tempS );
297 tempS = QString::fromUcs2(aItem->GetOfficeLocation().GetBuffer()).replace( QRegExp("\\r"), "");
298 if ( !tempS.isEmpty() )
299 addressee.insertCustom( "KADDRESSBOOK", "X-Office",tempS );
300 tempS = QString::fromUcs2(aItem->GetProfession().GetBuffer());
301 if ( !tempS.isEmpty() )
302 addressee.insertCustom( "KADDRESSBOOK", "X-Profession", tempS );
303 dtb = mDdate2Qdtr(aItem->GetAnniversary());
304 if (dtb.isValid() ) {
305 QString dt = KGlobal::locale()->formatDate( dtb.date() , true, KLocale::ISODate);
306 addressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
307 }
308 int sec = aItem->GetSensitivity() ;
309 if ( sec > 1 )// mapping pers -> private
310 --sec;
311 addressee.setSecrecy( sec );
312 //addressee.setLogo( const Picture &logo );
313 //addressee.setPhoto( const Picture &photo );
314 //addressee.setSound( const Sound &sound );
315 //addressee.setAgent( const Agent &agent );
316 QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()).replace( QRegExp("\\r"), "");
317 cat = cat.replace( QRegExp("; "), ";");
318 addressee.setCategories( QStringList::split( ";", cat ));
319
320 QString phoneS;
321
322 phoneS = QString::fromUcs2( aItem->GetAssistantTelephoneNumber().GetBuffer());
323 if ( ! phoneS.isEmpty())
324 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Voice ) );
325 phoneS = QString::fromUcs2( aItem->GetBusinessTelephoneNumber().GetBuffer());
326 if ( ! phoneS.isEmpty())
327 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) );
328 phoneS = QString::fromUcs2( aItem->GetBusiness2TelephoneNumber().GetBuffer());
329 if ( ! phoneS.isEmpty())
330 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work ) );
331 phoneS = QString::fromUcs2( aItem->GetBusinessFaxNumber().GetBuffer());
332 if ( ! phoneS.isEmpty())
333 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Fax ) );
334 phoneS = QString::fromUcs2( aItem->GetCarTelephoneNumber().GetBuffer());
335 if ( ! phoneS.isEmpty())
336 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Car ) );
337 phoneS = QString::fromUcs2( aItem->GetHomeTelephoneNumber().GetBuffer());
338 if ( ! phoneS.isEmpty())
339 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) );
340 phoneS = QString::fromUcs2( aItem->GetHome2TelephoneNumber().GetBuffer());
341 if ( ! phoneS.isEmpty())
342 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home ) );
343 phoneS = QString::fromUcs2( aItem->GetHomeFaxNumber().GetBuffer());
344 if ( ! phoneS.isEmpty())
345 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Home + KABC::PhoneNumber::Fax ) );
346 phoneS = QString::fromUcs2( aItem->GetISDNNumber().GetBuffer());
347 if ( ! phoneS.isEmpty())
348 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Isdn ) );
349 phoneS = QString::fromUcs2( aItem->GetMobileTelephoneNumber().GetBuffer());
350 if ( ! phoneS.isEmpty())
351 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Cell ) );
352 phoneS = QString::fromUcs2( aItem->GetOtherFaxNumber().GetBuffer());
353 if ( ! phoneS.isEmpty())
354 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax ) );
355 phoneS = QString::fromUcs2( aItem->GetOtherTelephoneNumber().GetBuffer());
356 if ( ! phoneS.isEmpty())
357 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice ) );
358 phoneS = QString::fromUcs2( aItem->GetPagerNumber().GetBuffer());
359 if ( ! phoneS.isEmpty())
360 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pager ) );
361 phoneS = QString::fromUcs2( aItem->GetPrimaryTelephoneNumber().GetBuffer());
362 if ( ! phoneS.isEmpty())
363 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Pref ) );
364 phoneS = QString::fromUcs2( aItem->GetTTYTDDTelephoneNumber().GetBuffer());
365 if ( ! phoneS.isEmpty())
366 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Modem ) );
367 phoneS = QString::fromUcs2( aItem->GetTelexNumber().GetBuffer());
368 if ( ! phoneS.isEmpty())
369 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Fax + KABC::PhoneNumber::Bbs ) );
370 phoneS = QString::fromUcs2( aItem->GetCompanyMainTelephoneNumber().GetBuffer());
371 if ( ! phoneS.isEmpty())
372 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Work + KABC::PhoneNumber::Pref ) );
373 phoneS = QString::fromUcs2( aItem->GetRadioTelephoneNumber().GetBuffer());
374 if ( ! phoneS.isEmpty())
375 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Video ) );
376 phoneS = QString::fromUcs2( aItem->GetCallbackTelephoneNumber().GetBuffer());
377 if ( ! phoneS.isEmpty())
378 addressee.insertPhoneNumber( KABC::PhoneNumber(phoneS ,KABC::PhoneNumber::Voice + KABC::PhoneNumber::Pref ) );
379
380 bool preferred = true;
381 phoneS = QString::fromUcs2( aItem->GetEmail1Address().GetBuffer());
382 if ( ! phoneS.isEmpty()) {
383 addressee.insertEmail(phoneS , preferred );
384 preferred = false;
385 }
386 phoneS = QString::fromUcs2( aItem->GetEmail2Address().GetBuffer());
387 if ( ! phoneS.isEmpty()) {
388 addressee.insertEmail(phoneS , preferred );
389 preferred = false;
390 }
391 phoneS = QString::fromUcs2( aItem->GetEmail3Address().GetBuffer());
392 if ( ! phoneS.isEmpty()) {
393 addressee.insertEmail(phoneS , preferred );
394 preferred = false;
395 }
396 // is this the number of the preferred email?
397 //long GetSelectedMailingAddress();???
398
399 KABC::Address addressHome;
400 KABC::Address* addressAdd = &addressHome;
401 bool insert = false;
402 phoneS = QString::fromUcs2( aItem->GetHomeAddressCountry().GetBuffer());
403 phoneS.replace( QRegExp("\\r"), "");
404 if ( ! phoneS.isEmpty()) {
405 addressAdd->setCountry(phoneS );
406 insert = true;
407 }
408 phoneS = QString::fromUcs2( aItem->GetHomeAddressState().GetBuffer());
409 phoneS.replace( QRegExp("\\r"), "");
410 if ( ! phoneS.isEmpty()) {
411 addressAdd->setRegion(phoneS );
412 insert = true;
413 }
414 phoneS = QString::fromUcs2( aItem->GetHomeAddressCity().GetBuffer());
415 phoneS.replace( QRegExp("\\r"), "");
416 if ( ! phoneS.isEmpty()) {
417 addressAdd->setLocality(phoneS );
418 insert = true;
419 }
420 phoneS = QString::fromUcs2( aItem->GetHomeAddressPostalCode().GetBuffer());
421 phoneS.replace( QRegExp("\\r"), "");
422 if ( ! phoneS.isEmpty()) {
423 addressAdd->setPostalCode(phoneS );
424 insert = true;
425 }
426 phoneS = QString::fromUcs2( aItem->GetHomeAddressPostOfficeBox().GetBuffer());
427 phoneS.replace( QRegExp("\\r"), "");
428 if ( ! phoneS.isEmpty()) {
429 addressAdd->setPostOfficeBox(phoneS );
430 insert = true;
431 }
432 phoneS = QString::fromUcs2( aItem->GetHomeAddressStreet().GetBuffer());
433 phoneS.replace( QRegExp("\\r"), "");
434 if ( ! phoneS.isEmpty()) {
435 addressAdd->setStreet(phoneS );
436 insert = true;
437 }
438 phoneS = QString::fromUcs2( aItem->GetHomeAddress().GetBuffer());
439 phoneS.replace( QRegExp("\\r"), "");
440 if ( ! phoneS.isEmpty()) {
441 // redundant !addressAdd->setExtended(phoneS );
442 // insert = true;
443 }
444 addressAdd->setType( KABC::Address::Home );
445 if ( insert )
446 addressee.insertAddress( *addressAdd );
447 // ++++++++++++++++++++++ end of address
448
449 KABC::Address addressWork;
450 addressAdd = &addressWork;
451 insert = false;
452 phoneS = QString::fromUcs2( aItem->GetBusinessAddressCountry().GetBuffer());
453 phoneS.replace( QRegExp("\\r"), "");
454 if ( ! phoneS.isEmpty()) {
455 addressAdd->setCountry(phoneS );
456 insert = true;
457 }
458 phoneS = QString::fromUcs2( aItem->GetBusinessAddressState().GetBuffer());
459 phoneS.replace( QRegExp("\\r"), "");
460 if ( ! phoneS.isEmpty()) {
461 addressAdd->setRegion(phoneS );
462 insert = true;
463 }
464 phoneS = QString::fromUcs2( aItem->GetBusinessAddressCity().GetBuffer());
465 phoneS.replace( QRegExp("\\r"), "");
466 if ( ! phoneS.isEmpty()) {
467 addressAdd->setLocality(phoneS );
468 insert = true;
469 }
470 phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostalCode().GetBuffer());
471 phoneS.replace( QRegExp("\\r"), "");
472 if ( ! phoneS.isEmpty()) {
473 addressAdd->setPostalCode(phoneS );
474 insert = true;
475 }
476 phoneS = QString::fromUcs2( aItem->GetBusinessAddressPostOfficeBox().GetBuffer());
477 phoneS.replace( QRegExp("\\r"), "");
478 if ( ! phoneS.isEmpty()) {
479 addressAdd->setPostOfficeBox(phoneS );
480 insert = true;
481 }
482 phoneS = QString::fromUcs2( aItem->GetBusinessAddressStreet().GetBuffer());
483 phoneS.replace( QRegExp("\\r"), "");
484 if ( ! phoneS.isEmpty()) {
485 addressAdd->setStreet(phoneS );
486 insert = true;
487 }
488 phoneS = QString::fromUcs2( aItem->GetBusinessAddress().GetBuffer());
489 phoneS.replace( QRegExp("\\r"), "");
490 if ( ! phoneS.isEmpty()) {
491 // redundant !addressAdd->setExtended(phoneS );
492 // insert = true;
493 }
494 addressAdd->setType( KABC::Address::Work );
495 if ( insert )
496 addressee.insertAddress( *addressAdd );
497 // ++++++++++++++++++++++ end of address
498
499 KABC::Address addressOther;
500 addressAdd = &addressOther;
501 insert = false;
502 phoneS = QString::fromUcs2( aItem->GetOtherAddressCountry().GetBuffer());
503 phoneS.replace( QRegExp("\\r"), "");
504 if ( ! phoneS.isEmpty()) {
505 addressAdd->setCountry(phoneS );
506 insert = true;
507 }
508 phoneS = QString::fromUcs2( aItem->GetOtherAddressState().GetBuffer());
509 phoneS.replace( QRegExp("\\r"), "");
510 if ( ! phoneS.isEmpty()) {
511 addressAdd->setRegion(phoneS );
512 insert = true;
513 }
514 phoneS = QString::fromUcs2( aItem->GetOtherAddressCity().GetBuffer());
515 phoneS.replace( QRegExp("\\r"), "");
516 if ( ! phoneS.isEmpty()) {
517 addressAdd->setLocality(phoneS );
518 insert = true;
519 }
520 phoneS = QString::fromUcs2( aItem->GetOtherAddressPostalCode().GetBuffer());
521 phoneS.replace( QRegExp("\\r"), "");
522 if ( ! phoneS.isEmpty()) {
523 addressAdd->setPostalCode(phoneS );
524 insert = true;
525 }
526 phoneS = QString::fromUcs2( aItem->GetOtherAddressPostOfficeBox().GetBuffer());
527 phoneS.replace( QRegExp("\\r"), "");
528 if ( ! phoneS.isEmpty()) {
529 addressAdd->setPostOfficeBox(phoneS );
530 insert = true;
531 }
532 phoneS = QString::fromUcs2( aItem->GetOtherAddressStreet().GetBuffer());
533 phoneS.replace( QRegExp("\\r"), "");
534 if ( ! phoneS.isEmpty()) {
535 addressAdd->setStreet(phoneS );
536 insert = true;
537 }
538 phoneS = QString::fromUcs2( aItem->GetOtherAddress().GetBuffer());
539 if ( ! phoneS.isEmpty()) {
540 // redundant !addressAdd->setExtended(phoneS );
541 //insert = true;
542 }
543 //addressAdd->setId( );
544 if ( insert )
545 addressee.insertAddress( *addressAdd );
546 // ++++++++++++++++++++++ end of address
547 KABC::Address addressMail;
548 addressAdd = &addressMail;
549 insert = false;
550 phoneS = QString::fromUcs2( aItem->GetMailingAddressCountry().GetBuffer());
551 phoneS.replace( QRegExp("\\r"), "");
552 if ( ! phoneS.isEmpty()) {
553 addressAdd->setCountry(phoneS );
554 insert = true;
555 }
556 phoneS = QString::fromUcs2( aItem->GetMailingAddressState().GetBuffer());
557 phoneS.replace( QRegExp("\\r"), "");
558 if ( ! phoneS.isEmpty()) {
559 addressAdd->setRegion(phoneS );
560 insert = true;
561 }
562 phoneS = QString::fromUcs2( aItem->GetMailingAddressCity().GetBuffer());
563 phoneS.replace( QRegExp("\\r"), "");
564 if ( ! phoneS.isEmpty()) {
565 addressAdd->setLocality(phoneS );
566 insert = true;
567 }
568 phoneS = QString::fromUcs2( aItem->GetMailingAddressPostalCode().GetBuffer());
569 phoneS.replace( QRegExp("\\r"), "");
570 if ( ! phoneS.isEmpty()) {
571 addressAdd->setPostalCode(phoneS );
572 insert = true;
573 }
574 phoneS = QString::fromUcs2( aItem->GetMailingAddressPostOfficeBox().GetBuffer());
575 phoneS.replace( QRegExp("\\r"), "");
576 if ( ! phoneS.isEmpty()) {
577 addressAdd->setPostOfficeBox(phoneS );
578 insert = true;
579 }
580 phoneS = QString::fromUcs2( aItem->GetMailingAddressStreet().GetBuffer());
581 phoneS.replace( QRegExp("\\r"), "");
582 if ( ! phoneS.isEmpty()) {
583 addressAdd->setStreet(phoneS );
584 insert = true;
585 }
586 phoneS = QString::fromUcs2( aItem->GetMailingAddress().GetBuffer());
587 phoneS.replace( QRegExp("\\r"), "");
588 if ( ! phoneS.isEmpty()) {
589 // redundant ! addressAdd->setExtended(phoneS );
590 // insert = true;
591 }
592 addressAdd->setType( KABC::Address::Postal );
593 if ( insert ) {
594 addressee.insertAddress( *addressAdd );
595 }
596 // the following code is disabled
597 // it does not seem to be useful
598#if 0
599 if ( insert ) {
600 addressAdd->setType( KABC::Address::Home );
601 if ( addressMail == addressHome ) {
602 addressHome.setType( KABC::Address::Postal+ KABC::Address::Home );
603 addressee.insertAddress( addressHome );
604 } else {
605 addressAdd->setType( KABC::Address::Work );
606 if ( addressMail == addressWork ){
607 addressWork.setType( KABC::Address::Postal+ KABC::Address::Work );
608 addressee.insertAddress( addressWork );
609
610 } else {
611 addressAdd->setType( 0 );
612 if ( addressOther == addressMail ){
613 addressOther.setType( KABC::Address::Postal );
614 addressee.insertAddress( addressOther );
615 } else {
616 addressee.insertAddress( *addressAdd );
617 }
618 }
619 }
620 }
621#endif
622 // ++++++++++++++++++++++ end of ALL addresses
623 //GetUserProperties();
624 tempS = QString::fromUcs2(aItem->GetInternetFreeBusyAddress().GetBuffer());
625 phoneS.replace( QRegExp("\\r"), "");
626 if ( !tempS.isEmpty() )
627 addressee.insertCustom( "KADDRESSBOOK", "X-FreeBusyUrl", tempS );
628 tempS = QString::fromUcs2(aItem->GetChildren().GetBuffer());
629 if ( !tempS.isEmpty() )
630 addressee.insertCustom( "KADDRESSBOOK", "X-Children", tempS );
631 int gen = aItem->GetGender();
632 if ( gen != 0 ) { // 0 undef - 1 female - 2 male
633 if ( gen == 1 )
634 addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female" );
635 else
636 addressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male" );
637 }
638 QString additionalInfo;
639 QString tempAdd;
640 tempAdd = QString::fromUcs2(aItem->GetLanguage().GetBuffer());
641 if ( ! tempAdd.isEmpty() ) {
642 additionalInfo += i18n("\nLanguage: ");
643 additionalInfo += tempAdd;
644 }
645 tempAdd = QString::fromUcs2(aItem->GetHobby().GetBuffer());
646 phoneS.replace( QRegExp("\\r"), "");
647 if ( ! tempAdd.isEmpty() ) {
648 additionalInfo += i18n("\nHobby: ");
649 additionalInfo += tempAdd;;
650 }
651 tempAdd =QString::fromUcs2(aItem->GetPersonalHomePage().GetBuffer());
652 phoneS.replace( QRegExp("\\r"), "");
653 if ( ! tempAdd.isEmpty() ) {
654 additionalInfo += i18n("\nHomepage: ");
655 additionalInfo += tempAdd;;
656 }
657 tempAdd = QString::fromUcs2(aItem->GetBillingInformation().GetBuffer());
658 phoneS.replace( QRegExp("\\r"), "");
659 if ( ! tempAdd.isEmpty() ) {
660 additionalInfo += i18n("\nBilling information: ");
661 additionalInfo += tempAdd;;
662 }
663 tempAdd = QString::fromUcs2(aItem->GetCustomerID().GetBuffer());
664 phoneS.replace( QRegExp("\\r"), "");
665 if ( ! tempAdd.isEmpty() ) {
666 additionalInfo += i18n("\nCustomer ID: ");
667 additionalInfo += tempAdd;;
668 }
669 tempAdd = QString::fromUcs2(aItem->GetUser1().GetBuffer());
670 phoneS.replace( QRegExp("\\r"), "");
671 if ( ! tempAdd.isEmpty() ) {
672 additionalInfo += i18n("\nUser1: ");
673 additionalInfo += tempAdd;;
674 }
675 tempAdd = QString::fromUcs2(aItem->GetUser2().GetBuffer());
676 phoneS.replace( QRegExp("\\r"), "");
677 if ( ! tempAdd.isEmpty() ) {
678 additionalInfo += i18n("\nUser2: ");
679 additionalInfo += tempAdd;;
680 }
681 tempAdd = QString::fromUcs2(aItem->GetUser3().GetBuffer());
682 phoneS.replace( QRegExp("\\r"), "");
683 if ( ! tempAdd.isEmpty() ) {
684 additionalInfo += i18n("\nUser3: ");
685 additionalInfo += tempAdd;;
686 }
687 tempAdd = QString::fromUcs2(aItem->GetUser4().GetBuffer());
688 phoneS.replace( QRegExp("\\r"), "");
689 if ( ! tempAdd.isEmpty() ) {
690 additionalInfo += i18n("\nUser4: ");
691 additionalInfo += tempAdd;;
692 }
693 if (!additionalInfo.isEmpty() ) {
694 tempAdd = notesStr;
695 notesStr = "+++++++++++++++++++++++++++\n";
696 notesStr += i18n("Additonal fields created\nby KA/Pi Outlook import:");
697 notesStr += additionalInfo;
698 notesStr += i18n("\nEnd additonal fields created\nby KA/Pi Outlook import!\n");
699 notesStr += "+++++++++++++++++++++++++++\n";
700 notesStr += tempAdd;
701 }
702 addressee.setNote( notesStr );
703#if 0
704 // pending
705 - IM address: no clue where to get info about the helper ID
706 -custom fields: difficult to implement - not implemented
707 -keys: makes no sense
708#endif
709
710 if ( addAddressee( addressee ))
711 ++importedItems;
712}
713void KAImportOLdialog::slotCancel()
714{
715 reject();
716}
717
718bool KAImportOLdialog::addAddressee( KABC::Addressee a )
719{
720 bool add = true;
721 KABC::Addressee::List::Iterator it;
722 for ( it = mAList.begin(); it != mAList.end(); ++it ) {
723 if ( (*it).uid() == a.uid() ) {
724 add = false;
725 break;
726 }
727 }
728 if ( add ) {
729 if ( mABook->findByUid(a.uid() ).isEmpty())
730 mAList.append ( a );
731 else
732 add = false;
733 }
734 return add;
735}
diff --git a/kaddressbook/kaimportoldialog.h b/kaddressbook/kaimportoldialog.h
index 41ea5f8..278935b 100644
--- a/kaddressbook/kaimportoldialog.h
+++ b/kaddressbook/kaimportoldialog.h
@@ -1,85 +1,22 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@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#ifndef KOINCIDENCEEDITOR_H
24#define KOINCIDENCEEDITOR_H
25
26#include <kdialogbase.h>
27
28#include <afxdisp.h>
29
30#include <kabc/addressee.h>
31#include <kabc/addressbook.h>
32
33class QDateTime;
34class QListView;
35class OLEListViewItem;
36class _ContactItem;
37
38
39//using namespace KABC;
40//class KABC::AddressBook;
41
42/**
43 This is the base class for the calendar component editors.
44*/
45class KAImportOLdialog : public KDialogBase
46{
47 Q_OBJECT
48 public:
49 /**
50 Construct new IncidenceEditor.
51 */
52 KAImportOLdialog( const QString &caption, KABC::AddressBook * aBook,
53 QWidget *parent );
54 ~KAImportOLdialog();
55
56 /** Initialize editor. This function creates the tab widgets. */
57 void init();
58 KABC::Addressee::List getAddressList();
59 public slots:
60
61
62 signals:
63
64 protected slots:
65 void slotApply();
66 void slotOk();
67 void slotCancel();
68
69 protected:
70 void setupFolderView();
71 void addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent);
72 void readContactData( DWORD folder );
73 void ol2kapiContact( _ContactItem * );
74
75 KABC::AddressBook * mABook;
76 QListView * mListView;
77 KABC::Addressee::List mAList;
78 bool addAddressee( KABC::Addressee a );
79 private:
80 int importedItems;
81};
82
83#endif
84
85
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp
index 5639aa2..df3b551 100644
--- a/kaddressbook/phoneeditwidget.cpp
+++ b/kaddressbook/phoneeditwidget.cpp
@@ -1,728 +1,731 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qtooltip.h> 26#include <qtooltip.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qcheckbox.h> 28#include <qcheckbox.h>
29#include <qstring.h> 29#include <qstring.h>
30#include <qlistbox.h> 30#include <qlistbox.h>
31#include <qlistview.h> 31#include <qlistview.h>
32#include <qbuttongroup.h> 32#include <qbuttongroup.h>
33#include <qhbox.h> 33#include <qhbox.h>
34#include <qcursor.h> 34#include <qcursor.h>
35#include <qtimer.h> 35#include <qtimer.h>
36#include <qapplication.h> 36#include <qapplication.h>
37 37
38#include <kbuttonbox.h> 38#include <kbuttonbox.h>
39#include <klistview.h> 39#include <klistview.h>
40#include <kapplication.h> 40#include <kapplication.h>
41#include <qapplication.h> 41#include <qapplication.h>
42#include <kconfig.h> 42#include <kconfig.h>
43#include <kmessagebox.h>
43#include <klineedit.h> 44#include <klineedit.h>
44#include <kcombobox.h> 45#include <kcombobox.h>
45#include <klocale.h> 46#include <klocale.h>
46#include <kdebug.h> 47#include <kdebug.h>
47#include <kglobal.h> 48#include <kglobal.h>
48#include <kiconloader.h> 49#include <kiconloader.h>
49 50
50#include <kabc/phonenumber.h> 51#include <kabc/phonenumber.h>
51 52
52#include "typecombo.h" 53#include "typecombo.h"
53 54
54#include "phoneeditwidget.h" 55#include "phoneeditwidget.h"
55 56
56PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) 57PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name )
57 : QWidget(parent,name) 58 : QWidget(parent,name)
58{ 59{
59 QGridLayout* gridLayout = new QGridLayout ( this, 2,2 ); 60 QGridLayout* gridLayout = new QGridLayout ( this, 2,2 );
60 61
61 QLabel *temp = new QLabel( "", this ); 62 QLabel *temp = new QLabel( "", this );
62 temp->setAlignment( Qt::AlignCenter ); 63 temp->setAlignment( Qt::AlignCenter );
63 temp->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); 64 temp->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) );
64 QPushButton *addBut = new QPushButton ( "add", this ); 65 QPushButton *addBut = new QPushButton ( "add", this );
65 addBut->setPixmap ( SmallIcon("plus")); 66 addBut->setPixmap ( SmallIcon("plus"));
66 addBut->setMaximumSize( addBut->sizeHint().height(),addBut->sizeHint().height() ); 67 addBut->setMaximumSize( addBut->sizeHint().height(),addBut->sizeHint().height() );
67 connect(addBut,SIGNAL(clicked ()),SLOT(addNumber())); 68 connect(addBut,SIGNAL(clicked ()),SLOT(addNumber()));
68 69
69 sv = new QScrollView( this ); 70 sv = new QScrollView( this );
70 sv->setFrameStyle ( QFrame::Plain ); 71 sv->setFrameStyle ( QFrame::Plain );
71 sv->setLineWidth ( 0 ); 72 sv->setLineWidth ( 0 );
72 sv->setMidLineWidth ( 0 ); 73 sv->setMidLineWidth ( 0 );
73 mw = new QWidget ( sv->viewport() ); 74 mw = new QWidget ( sv->viewport() );
74 sv->addChild(mw); 75 sv->addChild(mw);
75 sv->setResizePolicy( QScrollView::AutoOneFit ); 76 sv->setResizePolicy( QScrollView::AutoOneFit );
76 mainLayout = new QVBoxLayout ( mw ); 77 mainLayout = new QVBoxLayout ( mw );
77 mainLayout->setMargin( 0 ); 78 mainLayout->setMargin( 0 );
78 mainLayout->setSpacing( 0 ); 79 mainLayout->setSpacing( 0 );
79 gridLayout->setMargin( 2 ); 80 gridLayout->setMargin( 2 );
80 gridLayout->setSpacing( 4 ); 81 gridLayout->setSpacing( 4 );
81 if ( QApplication::desktop()->width() == 240 || QApplication::desktop()->width() == 480 ) { 82 if ( QApplication::desktop()->width() == 240 || QApplication::desktop()->width() == 480 ) {
82 gridLayout->addWidget( addBut, 0, 0 ); 83 gridLayout->addWidget( addBut, 0, 0 );
83 gridLayout->addWidget( temp, 0, 1 ); 84 gridLayout->addWidget( temp, 0, 1 );
84 gridLayout->addMultiCellWidget( sv, 1,1 , 0,1 ); 85 gridLayout->addMultiCellWidget( sv, 1,1 , 0,1 );
85 } else { 86 } else {
86 gridLayout->addWidget( temp, 1, 0 ); 87 gridLayout->addWidget( temp, 1, 0 );
87 gridLayout->addWidget( addBut, 0, 0 ); 88 gridLayout->addWidget( addBut, 0, 0 );
88 gridLayout->addMultiCellWidget( sv, 0, 1, 1,1 ); 89 gridLayout->addMultiCellWidget( sv, 0, 1, 1,1 );
89 } 90 }
90 setDefaults(); 91 setDefaults();
91 mTypeNumberEditList.setAutoDelete( true ); 92 mTypeNumberEditList.setAutoDelete( true );
92 mPopup = new QPopupMenu( this ); 93 mPopup = new QPopupMenu( this );
93 QStringList list = PhoneNumber::supportedTypeListNames(); 94 QStringList list = PhoneNumber::supportedTypeListNames();
94 mPopupCount = list.count(); 95 mPopupCount = list.count();
95 int i = 0; 96 int i = 0;
96 while ( i < mPopupCount ) { 97 while ( i < mPopupCount ) {
97 mPopup->insertItem( list[ i ], i ); 98 mPopup->insertItem( list[ i ], i );
98 ++i; 99 ++i;
99 } 100 }
100 connect(mPopup,SIGNAL(activated(int)),this,SLOT(addNumberInt( int))); 101 connect(mPopup,SIGNAL(activated(int)),this,SLOT(addNumberInt( int)));
101 102
102} 103}
103 104
104PhoneEditWidget::~PhoneEditWidget() 105PhoneEditWidget::~PhoneEditWidget()
105{ 106{
106} 107}
107void PhoneEditWidget::setDefaults() 108void PhoneEditWidget::setDefaults()
108{ 109{
109 mTypeNumberEditList.clear(); 110 mTypeNumberEditList.clear();
110 PhoneTypeNumberEdit* edit = appendEditCombo(); 111 PhoneTypeNumberEdit* edit = appendEditCombo();
111 KABC::PhoneNumber phoneNumber; 112 KABC::PhoneNumber phoneNumber;
112 phoneNumber.setType( KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref ); 113 phoneNumber.setType( KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref );
113 edit->setPhoneNumber( phoneNumber ); 114 edit->setPhoneNumber( phoneNumber );
114 edit = appendEditCombo(); 115 edit = appendEditCombo();
115 phoneNumber.setType( KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref ); 116 KABC::PhoneNumber phoneNumber2;
116 edit->setPhoneNumber( phoneNumber ); 117 phoneNumber2.setType( KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref );
118 edit->setPhoneNumber( phoneNumber2 );
117 edit = appendEditCombo(); 119 edit = appendEditCombo();
118 phoneNumber.setType( KABC::PhoneNumber::Cell ); 120 KABC::PhoneNumber phoneNumber3;
119 edit->setPhoneNumber( phoneNumber ); 121 phoneNumber3.setType( KABC::PhoneNumber::Cell );
122 edit->setPhoneNumber( phoneNumber3 );
120 123
121} 124}
122void PhoneEditWidget::addNumberInt( int index ) 125void PhoneEditWidget::addNumberInt( int index )
123{ 126{
124 PhoneTypeNumberEdit* edit = appendEditCombo(); 127 PhoneTypeNumberEdit* edit = appendEditCombo();
125 KABC::PhoneNumber phoneNumber; 128 KABC::PhoneNumber phoneNumber;
126 phoneNumber.setType( PhoneNumber::supportedTypeList()[index] ); 129 phoneNumber.setType( PhoneNumber::supportedTypeList()[index] );
127 edit->setPhoneNumber( phoneNumber ); 130 edit->setPhoneNumber( phoneNumber );
128 //verticalScrollBar()->setValue( 1024); 131 //verticalScrollBar()->setValue( 1024);
129 QTimer::singleShot( 0, this, SLOT ( bottomVisible() ) ); 132 QTimer::singleShot( 0, this, SLOT ( bottomVisible() ) );
130} 133}
131void PhoneEditWidget::bottomVisible() 134void PhoneEditWidget::bottomVisible()
132{ 135{
133 sv->setContentsPos ( 0, 1024 ); 136 sv->setContentsPos ( 0, 1024 );
134} 137}
135void PhoneEditWidget::addNumber() 138void PhoneEditWidget::addNumber()
136{ 139{
137 int i = 0; 140 int i = 0;
138 while ( i < mPopupCount ) { 141 while ( i < mPopupCount ) {
139 mPopup->setItemEnabled( i, true ); 142 mPopup->setItemEnabled( i, true );
140 ++i; 143 ++i;
141 } 144 }
142 PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); 145 PhoneTypeNumberEdit* edit = mTypeNumberEditList.first();
143 while ( edit ) { 146 while ( edit ) {
144 if ( edit->currentType() < mPopupCount -1 ) 147 if ( edit->currentType() < mPopupCount -1 )
145 mPopup->setItemEnabled( edit->currentType(), false ); 148 mPopup->setItemEnabled( edit->currentType(), false );
146 edit = mTypeNumberEditList.next(); 149 edit = mTypeNumberEditList.next();
147 } 150 }
148 mPopup->popup( QCursor::pos() ); 151 mPopup->popup( QCursor::pos() );
149} 152}
150PhoneTypeNumberEdit* PhoneEditWidget::appendEditCombo() 153PhoneTypeNumberEdit* PhoneEditWidget::appendEditCombo()
151{ 154{
152 PhoneTypeNumberEdit* edit = new PhoneTypeNumberEdit( mw ); 155 PhoneTypeNumberEdit* edit = new PhoneTypeNumberEdit( mw );
153 connect ( edit, SIGNAL ( typeChange( int , int) ), this, SIGNAL ( typeChange( int , int)) ); 156 connect ( edit, SIGNAL ( typeChange( int , int) ), this, SIGNAL ( typeChange( int , int)) );
154 connect ( edit, SIGNAL ( modified() ), this, SIGNAL ( modified() ) ); 157 connect ( edit, SIGNAL ( modified() ), this, SIGNAL ( modified() ) );
155 connect ( edit, SIGNAL ( deleteMe( PhoneTypeNumberEdit* ) ), this, SLOT ( deleteEdit( PhoneTypeNumberEdit*) ) ); 158 connect ( edit, SIGNAL ( deleteMe( PhoneTypeNumberEdit* ) ), this, SLOT ( deleteEdit( PhoneTypeNumberEdit*) ) );
156 connect ( this, SIGNAL ( typeChange( int , int)), edit, SLOT ( typeExternalChanged( int, int)) ); 159 connect ( this, SIGNAL ( typeChange( int , int)), edit, SLOT ( typeExternalChanged( int, int)) );
157 160
158 mainLayout->add( edit ); 161 mainLayout->add( edit );
159 mTypeNumberEditList.append( edit ); 162 mTypeNumberEditList.append( edit );
160 return edit; 163 return edit;
161} 164}
162 165
163void PhoneEditWidget::deleteEdit( PhoneTypeNumberEdit* ew ) 166void PhoneEditWidget::deleteEdit( PhoneTypeNumberEdit* ew )
164{ 167{
165 mPendingDelete = ew; 168 mPendingDelete = ew;
166 QTimer::singleShot( 0, this, SLOT ( pendingDelete() ) ); 169 QTimer::singleShot( 0, this, SLOT ( pendingDelete() ) );
167} 170}
168void PhoneEditWidget::pendingDelete() 171void PhoneEditWidget::pendingDelete()
169{ 172{
170 mTypeNumberEditList.removeRef( mPendingDelete ); 173 mTypeNumberEditList.removeRef( mPendingDelete );
171 emit modified(); 174 emit modified();
172} 175}
173 176
174void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &li ) 177void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &li )
175{ 178{
176 if ( li.isEmpty() ) { 179 if ( li.isEmpty() ) {
177 setDefaults(); 180 setDefaults();
178 return; 181 return;
179 } 182 }
180 mTypeNumberEditList.clear(); 183 mTypeNumberEditList.clear();
181 KABC::PhoneNumber::List::Iterator it; 184 KABC::PhoneNumber::List::Iterator it;
182 KABC::PhoneNumber::List list2 = li; 185 KABC::PhoneNumber::List list2 = li;
183 KABC::PhoneNumber::List list ; 186 KABC::PhoneNumber::List list ;
184 187
185 PhoneNumber::TypeList tList = PhoneNumber::supportedTypeList(); 188 PhoneNumber::TypeList tList = PhoneNumber::supportedTypeList();
186 int i = 0; 189 int i = 0;
187 int max = tList.count(); 190 int max = tList.count();
188 while ( i < max-1 ) { 191 while ( i < max-1 ) {
189 for ( it = list2.begin(); it != list2.end(); ++it ) { 192 for ( it = list2.begin(); it != list2.end(); ++it ) {
190 if ( (*it).type() == tList[i] ) { 193 if ( (*it).type() == tList[i] ) {
191 list.append( (*it ) ); 194 list.append( (*it ) );
192 break; 195 break;
193 } 196 }
194 } 197 }
195 ++i; 198 ++i;
196 } 199 }
197 for ( it = list2.begin(); it != list2.end(); ++it ) { 200 for ( it = list2.begin(); it != list2.end(); ++it ) {
198 if ( (*it).type() == tList[ max-1 ] ) 201 if ( (*it).type() == tList[ max-1 ] )
199 list.append( (*it ) ); 202 list.append( (*it ) );
200 } 203 }
201 for ( it = list.begin(); it != list.end(); ++it ) { 204 for ( it = list.begin(); it != list.end(); ++it ) {
202 PhoneTypeNumberEdit* editNew = appendEditCombo(); 205 PhoneTypeNumberEdit* editNew = appendEditCombo();
203 editNew->setPhoneNumber( (*it ) ); 206 editNew->setPhoneNumber( (*it ) );
204 } 207 }
205 208
206} 209}
207KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() 210KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers()
208{ 211{
209 KABC::PhoneNumber::List retList; 212 KABC::PhoneNumber::List retList;
210 213
211 PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); 214 PhoneTypeNumberEdit* edit = mTypeNumberEditList.first();
212 while ( edit ) { 215 while ( edit ) {
213 if ( edit->isValid() ) { 216 if ( edit->isValid() ) {
214 retList.append( edit->phoneNumber()); 217 retList.append( edit->phoneNumber());
215 } 218 }
216 edit = mTypeNumberEditList.next(); 219 edit = mTypeNumberEditList.next();
217 220
218 } 221 }
219 return retList; 222 return retList;
220} 223}
221 224
222#if 0 225#if 0
223PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) 226PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name )
224 : QWidget( parent, name ) 227 : QWidget( parent, name )
225{ 228{
226 QGridLayout *layout = new QGridLayout( this, 4, 1 ); 229 QGridLayout *layout = new QGridLayout( this, 4, 1 );
227//US layout->setSpacing( KDialog::spacingHint() ); 230//US layout->setSpacing( KDialog::spacingHint() );
228 layout->setSpacing( KDialogBase::spacingHintSmall() ); 231 layout->setSpacing( KDialogBase::spacingHintSmall() );
229 232
230 233
231 234
232 QLabel* label = new QLabel( this ); 235 QLabel* label = new QLabel( this );
233//US loadIcon call is ambiguous. Add one more parameter 236//US loadIcon call is ambiguous. Add one more parameter
234//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); 237//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) );
235 label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); 238 label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) );
236 label->setAlignment( AlignCenter ); 239 label->setAlignment( AlignCenter );
237//US layout->addMultiCellWidget( label, 0, 1, 3, 3 ); 240//US layout->addMultiCellWidget( label, 0, 1, 3, 3 );
238 layout->addWidget( label, 0, 0 ); 241 layout->addWidget( label, 0, 0 );
239 242
240 QPushButton *editButton = new QPushButton( i18n( "Edit Phone Numbers..." ), 243 QPushButton *editButton = new QPushButton( i18n( "Edit Phone Numbers..." ),
241 this ); 244 this );
242 if ( QApplication::desktop()->width() < 640 ) 245 if ( QApplication::desktop()->width() < 640 )
243 layout->addWidget( editButton, 0, 1 ); 246 layout->addWidget( editButton, 0, 1 );
244 else 247 else
245 layout->addMultiCellWidget( editButton, 0, 0, 1, 3); 248 layout->addMultiCellWidget( editButton, 0, 0, 1, 3);
246 249
247 mPrefCombo = new PhoneTypeCombo( mPhoneList, this ); 250 mPrefCombo = new PhoneTypeCombo( mPhoneList, this );
248 mPrefEdit = new KLineEdit( this ); 251 mPrefEdit = new KLineEdit( this );
249 //mPrefEdit->setMinimumWidth( int(mPrefEdit->sizeHint().width() * 1.5) ); 252 //mPrefEdit->setMinimumWidth( int(mPrefEdit->sizeHint().width() * 1.5) );
250 mPrefCombo->setLineEdit( mPrefEdit ); 253 mPrefCombo->setLineEdit( mPrefEdit );
251 layout->addWidget( mPrefCombo, 1, 0 ); 254 layout->addWidget( mPrefCombo, 1, 0 );
252 layout->addWidget( mPrefEdit, 1, 1 ); 255 layout->addWidget( mPrefEdit, 1, 1 );
253 int x = 1, y = 2; 256 int x = 1, y = 2;
254 if ( QApplication::desktop()->width() < 640 ) { 257 if ( QApplication::desktop()->width() < 640 ) {
255 ++x; 258 ++x;
256 y = 0; 259 y = 0;
257 } 260 }
258 mSecondCombo = new PhoneTypeCombo( mPhoneList, this ); 261 mSecondCombo = new PhoneTypeCombo( mPhoneList, this );
259 mSecondEdit = new KLineEdit( this ); 262 mSecondEdit = new KLineEdit( this );
260 mSecondCombo->setLineEdit( mSecondEdit ); 263 mSecondCombo->setLineEdit( mSecondEdit );
261 layout->addWidget( mSecondCombo, x, y++ ); 264 layout->addWidget( mSecondCombo, x, y++ );
262 layout->addWidget( mSecondEdit, x, y++ ); 265 layout->addWidget( mSecondEdit, x, y++ );
263 266
264 y = 0; 267 y = 0;
265 ++x; 268 ++x;
266 mThirdCombo = new PhoneTypeCombo( mPhoneList, this ); 269 mThirdCombo = new PhoneTypeCombo( mPhoneList, this );
267 mThirdEdit = new KLineEdit( this ); 270 mThirdEdit = new KLineEdit( this );
268 mThirdCombo->setLineEdit( mThirdEdit ); 271 mThirdCombo->setLineEdit( mThirdEdit );
269 layout->addWidget( mThirdCombo, x, y++ ); 272 layout->addWidget( mThirdCombo, x, y++ );
270 layout->addWidget( mThirdEdit, x, y++ ); 273 layout->addWidget( mThirdEdit, x, y++ );
271 if ( QApplication::desktop()->width() < 640 ) { 274 if ( QApplication::desktop()->width() < 640 ) {
272 ++x; 275 ++x;
273 y = 0; 276 y = 0;
274 } 277 }
275 mFourthCombo = new PhoneTypeCombo( mPhoneList, this ); 278 mFourthCombo = new PhoneTypeCombo( mPhoneList, this );
276 mFourthEdit = new KLineEdit( this ); 279 mFourthEdit = new KLineEdit( this );
277 mFourthCombo->setLineEdit( mFourthEdit ); 280 mFourthCombo->setLineEdit( mFourthEdit );
278 layout->addWidget( mFourthCombo, x, y++ ); 281 layout->addWidget( mFourthCombo, x, y++ );
279 layout->addWidget( mFourthEdit, x, y++ ); 282 layout->addWidget( mFourthEdit, x, y++ );
280 283
281 // Four numbers don't fit in the current dialog 284 // Four numbers don't fit in the current dialog
282 if ( QApplication::desktop()->width() < 640 ) { 285 if ( QApplication::desktop()->width() < 640 ) {
283 mFourthCombo->hide(); 286 mFourthCombo->hide();
284 mFourthEdit->hide(); 287 mFourthEdit->hide();
285 } else { 288 } else {
286 QFontMetrics fm ( font () ) ; 289 QFontMetrics fm ( font () ) ;
287 int wid = fm.width( "Messenger" ) +60; 290 int wid = fm.width( "Messenger" ) +60;
288 mPrefCombo->setMaximumWidth( wid ); 291 mPrefCombo->setMaximumWidth( wid );
289 mSecondCombo->setMaximumWidth( wid ); 292 mSecondCombo->setMaximumWidth( wid );
290 mThirdCombo->setMaximumWidth( wid ); 293 mThirdCombo->setMaximumWidth( wid );
291 mFourthCombo->setMaximumWidth( wid ); 294 mFourthCombo->setMaximumWidth( wid );
292 } 295 }
293 296
294 297
295 connect( mPrefEdit, SIGNAL( textChanged( const QString& ) ), 298 connect( mPrefEdit, SIGNAL( textChanged( const QString& ) ),
296 SLOT( slotPrefEditChanged() ) ); 299 SLOT( slotPrefEditChanged() ) );
297 connect( mSecondEdit, SIGNAL( textChanged( const QString& ) ), 300 connect( mSecondEdit, SIGNAL( textChanged( const QString& ) ),
298 SLOT( slotSecondEditChanged() ) ); 301 SLOT( slotSecondEditChanged() ) );
299 connect( mThirdEdit, SIGNAL( textChanged( const QString& ) ), 302 connect( mThirdEdit, SIGNAL( textChanged( const QString& ) ),
300 SLOT( slotThirdEditChanged() ) ); 303 SLOT( slotThirdEditChanged() ) );
301 connect( mFourthEdit, SIGNAL( textChanged( const QString& ) ), 304 connect( mFourthEdit, SIGNAL( textChanged( const QString& ) ),
302 SLOT( slotFourthEditChanged() ) ); 305 SLOT( slotFourthEditChanged() ) );
303 306
304 connect( editButton, SIGNAL( clicked() ), SLOT( edit() ) ); 307 connect( editButton, SIGNAL( clicked() ), SLOT( edit() ) );
305 308
306 connect( mPrefCombo, SIGNAL( activated( int ) ), 309 connect( mPrefCombo, SIGNAL( activated( int ) ),
307 SLOT( updatePrefEdit() ) ); 310 SLOT( updatePrefEdit() ) );
308 connect( mSecondCombo, SIGNAL( activated( int ) ), 311 connect( mSecondCombo, SIGNAL( activated( int ) ),
309 SLOT( updateSecondEdit() ) ); 312 SLOT( updateSecondEdit() ) );
310 connect( mThirdCombo, SIGNAL( activated( int ) ), 313 connect( mThirdCombo, SIGNAL( activated( int ) ),
311 SLOT( updateThirdEdit() ) ); 314 SLOT( updateThirdEdit() ) );
312 connect( mFourthCombo, SIGNAL( activated( int ) ), 315 connect( mFourthCombo, SIGNAL( activated( int ) ),
313 SLOT( updateFourthEdit() ) ); 316 SLOT( updateFourthEdit() ) );
314} 317}
315 318
316PhoneEditWidget::~PhoneEditWidget() 319PhoneEditWidget::~PhoneEditWidget()
317{ 320{
318} 321}
319 322
320void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &list ) 323void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &list )
321{ 324{
322 mPhoneList.clear(); 325 mPhoneList.clear();
323 326
324 // Insert types for existing numbers. 327 // Insert types for existing numbers.
325 mPrefCombo->insertTypeList( list ); 328 mPrefCombo->insertTypeList( list );
326 329
327 QValueList<int> defaultTypes; 330 QValueList<int> defaultTypes;
328 defaultTypes << KABC::PhoneNumber::Home; 331 defaultTypes << KABC::PhoneNumber::Home;
329 defaultTypes << KABC::PhoneNumber::Work; 332 defaultTypes << KABC::PhoneNumber::Work;
330 defaultTypes << KABC::PhoneNumber::Cell; 333 defaultTypes << KABC::PhoneNumber::Cell;
331 defaultTypes << ( KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax ); 334 defaultTypes << ( KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax );
332 defaultTypes << ( KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax ); 335 defaultTypes << ( KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax );
333 336
334 // Insert default types. 337 // Insert default types.
335 // Doing this for mPrefCombo is enough because the list is shared by all 338 // Doing this for mPrefCombo is enough because the list is shared by all
336 // combos. 339 // combos.
337 QValueList<int>::ConstIterator it; 340 QValueList<int>::ConstIterator it;
338 for( it = defaultTypes.begin(); it != defaultTypes.end(); ++it ) { 341 for( it = defaultTypes.begin(); it != defaultTypes.end(); ++it ) {
339 if ( !mPrefCombo->hasType( *it ) ) 342 if ( !mPrefCombo->hasType( *it ) )
340 mPrefCombo->insertType( list, *it, PhoneNumber( "", *it ) ); 343 mPrefCombo->insertType( list, *it, PhoneNumber( "", *it ) );
341 } 344 }
342 345
343 updateCombos(); 346 updateCombos();
344 347
345 mPrefCombo->selectType( defaultTypes[ 0 ] ); 348 mPrefCombo->selectType( defaultTypes[ 0 ] );
346 mSecondCombo->selectType( defaultTypes[ 1 ] ); 349 mSecondCombo->selectType( defaultTypes[ 1 ] );
347 mThirdCombo->selectType( defaultTypes[ 2 ] ); 350 mThirdCombo->selectType( defaultTypes[ 2 ] );
348 mFourthCombo->selectType( defaultTypes[ 3 ] ); 351 mFourthCombo->selectType( defaultTypes[ 3 ] );
349 352
350 updateLineEdits(); 353 updateLineEdits();
351} 354}
352 355
353void PhoneEditWidget::updateLineEdits() 356void PhoneEditWidget::updateLineEdits()
354{ 357{
355 updatePrefEdit(); 358 updatePrefEdit();
356 updateSecondEdit(); 359 updateSecondEdit();
357 updateThirdEdit(); 360 updateThirdEdit();
358 updateFourthEdit(); 361 updateFourthEdit();
359} 362}
360 363
361void PhoneEditWidget::updateCombos() 364void PhoneEditWidget::updateCombos()
362{ 365{
363 mPrefCombo->updateTypes(); 366 mPrefCombo->updateTypes();
364 mSecondCombo->updateTypes(); 367 mSecondCombo->updateTypes();
365 mThirdCombo->updateTypes(); 368 mThirdCombo->updateTypes();
366 mFourthCombo->updateTypes(); 369 mFourthCombo->updateTypes();
367} 370}
368 371
369KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() 372KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers()
370{ 373{
371 KABC::PhoneNumber::List retList; 374 KABC::PhoneNumber::List retList;
372 375
373 KABC::PhoneNumber::List::Iterator it; 376 KABC::PhoneNumber::List::Iterator it;
374 for ( it = mPhoneList.begin(); it != mPhoneList.end(); ++it ) 377 for ( it = mPhoneList.begin(); it != mPhoneList.end(); ++it )
375 if ( !(*it).number().isEmpty() ) 378 if ( !(*it).number().isEmpty() )
376 retList.append( *it ); 379 retList.append( *it );
377 380
378 return retList; 381 return retList;
379} 382}
380 383
381void PhoneEditWidget::edit() 384void PhoneEditWidget::edit()
382{ 385{
383 PhoneEditDialog dlg( mPhoneList, this ); 386 PhoneEditDialog dlg( mPhoneList, this );
384 387
385 if ( dlg.exec() ) { 388 if ( dlg.exec() ) {
386 if ( dlg.changed() ) { 389 if ( dlg.changed() ) {
387 KABC::PhoneNumber::List list = dlg.phoneNumbers(); 390 KABC::PhoneNumber::List list = dlg.phoneNumbers();
388 setPhoneNumbers( list ); 391 setPhoneNumbers( list );
389 updateCombos(); 392 updateCombos();
390 updateLineEdits(); 393 updateLineEdits();
391 emit modified(); 394 emit modified();
392 } 395 }
393 } 396 }
394} 397}
395 398
396void PhoneEditWidget::updatePrefEdit() 399void PhoneEditWidget::updatePrefEdit()
397{ 400{
398 updateEdit( mPrefCombo ); 401 updateEdit( mPrefCombo );
399} 402}
400 403
401void PhoneEditWidget::updateSecondEdit() 404void PhoneEditWidget::updateSecondEdit()
402{ 405{
403 updateEdit( mSecondCombo ); 406 updateEdit( mSecondCombo );
404} 407}
405 408
406void PhoneEditWidget::updateThirdEdit() 409void PhoneEditWidget::updateThirdEdit()
407{ 410{
408 updateEdit( mThirdCombo ); 411 updateEdit( mThirdCombo );
409} 412}
410 413
411void PhoneEditWidget::updateFourthEdit() 414void PhoneEditWidget::updateFourthEdit()
412{ 415{
413 updateEdit( mFourthCombo ); 416 updateEdit( mFourthCombo );
414} 417}
415 418
416void PhoneEditWidget::updateEdit( PhoneTypeCombo *combo ) 419void PhoneEditWidget::updateEdit( PhoneTypeCombo *combo )
417{ 420{
418 QLineEdit *edit = combo->lineEdit(); 421 QLineEdit *edit = combo->lineEdit();
419 if ( !edit ) 422 if ( !edit )
420 return; 423 return;
421 424
422#if 0 425#if 0
423 if ( edit == mPrefEdit ) kdDebug(5720) << " prefEdit" << endl; 426 if ( edit == mPrefEdit ) kdDebug(5720) << " prefEdit" << endl;
424 if ( edit == mSecondEdit ) kdDebug(5720) << " secondEdit" << endl; 427 if ( edit == mSecondEdit ) kdDebug(5720) << " secondEdit" << endl;
425 if ( edit == mThirdEdit ) kdDebug(5720) << " thirdEdit" << endl; 428 if ( edit == mThirdEdit ) kdDebug(5720) << " thirdEdit" << endl;
426 if ( edit == mFourthEdit ) kdDebug(5720) << " fourthEdit" << endl; 429 if ( edit == mFourthEdit ) kdDebug(5720) << " fourthEdit" << endl;
427#endif 430#endif
428 431
429 PhoneNumber::List::Iterator it = combo->selectedElement(); 432 PhoneNumber::List::Iterator it = combo->selectedElement();
430 if ( it != mPhoneList.end() ) { 433 if ( it != mPhoneList.end() ) {
431 edit->setText( (*it).number() ); 434 edit->setText( (*it).number() );
432 } else { 435 } else {
433 kdDebug(5720) << "PhoneEditWidget::updateEdit(): no selected element" << endl; 436 kdDebug(5720) << "PhoneEditWidget::updateEdit(): no selected element" << endl;
434 } 437 }
435} 438}
436 439
437void PhoneEditWidget::slotPrefEditChanged() 440void PhoneEditWidget::slotPrefEditChanged()
438{ 441{
439 updatePhoneNumber( mPrefCombo ); 442 updatePhoneNumber( mPrefCombo );
440} 443}
441 444
442void PhoneEditWidget::slotSecondEditChanged() 445void PhoneEditWidget::slotSecondEditChanged()
443{ 446{
444 updatePhoneNumber( mSecondCombo ); 447 updatePhoneNumber( mSecondCombo );
445} 448}
446 449
447void PhoneEditWidget::slotThirdEditChanged() 450void PhoneEditWidget::slotThirdEditChanged()
448{ 451{
449 updatePhoneNumber( mThirdCombo ); 452 updatePhoneNumber( mThirdCombo );
450} 453}
451 454
452void PhoneEditWidget::slotFourthEditChanged() 455void PhoneEditWidget::slotFourthEditChanged()
453{ 456{
454 updatePhoneNumber( mFourthCombo ); 457 updatePhoneNumber( mFourthCombo );
455} 458}
456 459
457void PhoneEditWidget::updatePhoneNumber( PhoneTypeCombo *combo ) 460void PhoneEditWidget::updatePhoneNumber( PhoneTypeCombo *combo )
458{ 461{
459 QLineEdit *edit = combo->lineEdit(); 462 QLineEdit *edit = combo->lineEdit();
460 if ( !edit ) return; 463 if ( !edit ) return;
461 464
462 PhoneNumber::List::Iterator it = combo->selectedElement(); 465 PhoneNumber::List::Iterator it = combo->selectedElement();
463 if ( it != mPhoneList.end() ) { 466 if ( it != mPhoneList.end() ) {
464 (*it).setNumber( edit->text() ); 467 (*it).setNumber( edit->text() );
465 } 468 }
466 469
467 updateOtherEdit( combo, mPrefCombo ); 470 updateOtherEdit( combo, mPrefCombo );
468 updateOtherEdit( combo, mSecondCombo ); 471 updateOtherEdit( combo, mSecondCombo );
469 updateOtherEdit( combo, mThirdCombo ); 472 updateOtherEdit( combo, mThirdCombo );
470 updateOtherEdit( combo, mFourthCombo ); 473 updateOtherEdit( combo, mFourthCombo );
471 474
472 emit modified(); 475 emit modified();
473} 476}
474 477
475void PhoneEditWidget::updateOtherEdit( PhoneTypeCombo *combo, PhoneTypeCombo *otherCombo ) 478void PhoneEditWidget::updateOtherEdit( PhoneTypeCombo *combo, PhoneTypeCombo *otherCombo )
476{ 479{
477 if ( combo == otherCombo ) return; 480 if ( combo == otherCombo ) return;
478 481
479 if ( combo->currentItem() == otherCombo->currentItem() ) { 482 if ( combo->currentItem() == otherCombo->currentItem() ) {
480 updateEdit( otherCombo ); 483 updateEdit( otherCombo );
481 } 484 }
482} 485}
483 486
484/////////////////////////////////////////// 487///////////////////////////////////////////
485// PhoneEditDialog 488// PhoneEditDialog
486 489
487class PhoneViewItem : public QListViewItem 490class PhoneViewItem : public QListViewItem
488{ 491{
489public: 492public:
490 PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ); 493 PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number );
491 494
492 void setPhoneNumber( const KABC::PhoneNumber &number ) 495 void setPhoneNumber( const KABC::PhoneNumber &number )
493 { 496 {
494 mPhoneNumber = number; 497 mPhoneNumber = number;
495 makeText(); 498 makeText();
496 } 499 }
497 500
498 QString key() { return mPhoneNumber.id(); } 501 QString key() { return mPhoneNumber.id(); }
499 QString country() { return ""; } 502 QString country() { return ""; }
500 QString region() { return ""; } 503 QString region() { return ""; }
501 QString number() { return ""; } 504 QString number() { return ""; }
502 505
503 KABC::PhoneNumber phoneNumber() { return mPhoneNumber; } 506 KABC::PhoneNumber phoneNumber() { return mPhoneNumber; }
504 507
505private: 508private:
506 void makeText(); 509 void makeText();
507 510
508 KABC::PhoneNumber mPhoneNumber; 511 KABC::PhoneNumber mPhoneNumber;
509}; 512};
510 513
511PhoneViewItem::PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ) 514PhoneViewItem::PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number )
512 : QListViewItem( parent ), mPhoneNumber( number ) 515 : QListViewItem( parent ), mPhoneNumber( number )
513{ 516{
514#ifdef DESKTOP_VERSION 517#ifdef DESKTOP_VERSION
515 setRenameEnabled ( 0, true ); 518 setRenameEnabled ( 0, true );
516#endif 519#endif
517 makeText(); 520 makeText();
518} 521}
519 522
520void PhoneViewItem::makeText() 523void PhoneViewItem::makeText()
521{ 524{
522 /** 525 /**
523 * Will be used in future versions of kaddressbook/libkabc 526 * Will be used in future versions of kaddressbook/libkabc
524 527
525 setText( 0, mPhoneNumber.country() ); 528 setText( 0, mPhoneNumber.country() );
526 setText( 1, mPhoneNumber.region() ); 529 setText( 1, mPhoneNumber.region() );
527 setText( 2, mPhoneNumber.number() ); 530 setText( 2, mPhoneNumber.number() );
528 setText( 3, mPhoneNumber.typeLabel() ); 531 setText( 3, mPhoneNumber.typeLabel() );
529 */ 532 */
530 533
531 setText( 0, mPhoneNumber.number() ); 534 setText( 0, mPhoneNumber.number() );
532 setText( 1, mPhoneNumber.typeLabel() ); 535 setText( 1, mPhoneNumber.typeLabel() );
533} 536}
534 537
535PhoneEditDialog::PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *parent, const char *name ) 538PhoneEditDialog::PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *parent, const char *name )
536 : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Numbers" ), 539 : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Numbers" ),
537 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, 540 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok,
538 parent, name, true) 541 parent, name, true)
539{ 542{
540 mPhoneNumberList = list; 543 mPhoneNumberList = list;
541 544
542 QWidget *page = plainPage(); 545 QWidget *page = plainPage();
543 546
544 QGridLayout *layout = new QGridLayout( page, 1, 2 ); 547 QGridLayout *layout = new QGridLayout( page, 1, 2 );
545 layout->setSpacing( spacingHint() ); 548 layout->setSpacing( spacingHint() );
546 549
547 mListView = new KListView( page ); 550 mListView = new KListView( page );
548 mListView->setAllColumnsShowFocus( true ); 551 mListView->setAllColumnsShowFocus( true );
549 mListView->addColumn( i18n( "Number" ) ); 552 mListView->addColumn( i18n( "Number" ) );
550 mListView->addColumn( i18n( "Type" ) ); 553 mListView->addColumn( i18n( "Type" ) );
551 554
552 KButtonBox *buttonBox = new KButtonBox( page, Vertical ); 555 KButtonBox *buttonBox = new KButtonBox( page, Vertical );
553 556
554 buttonBox->addButton( i18n( "&Add..." ), this, SLOT( slotAddPhoneNumber() ) ); 557 buttonBox->addButton( i18n( "&Add..." ), this, SLOT( slotAddPhoneNumber() ) );
555 mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT( slotEditPhoneNumber() ) ); 558 mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT( slotEditPhoneNumber() ) );
556 mEditButton->setEnabled( false ); 559 mEditButton->setEnabled( false );
557 mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT( slotRemovePhoneNumber() ) ); 560 mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT( slotRemovePhoneNumber() ) );
558 mRemoveButton->setEnabled( false ); 561 mRemoveButton->setEnabled( false );
559 buttonBox->layout(); 562 buttonBox->layout();
560 563
561 layout->addWidget( mListView, 0, 0 ); 564 layout->addWidget( mListView, 0, 0 );
562 layout->addWidget( buttonBox, 0, 1 ); 565 layout->addWidget( buttonBox, 0, 1 );
563 566
564 connect( mListView, SIGNAL(selectionChanged()), SLOT(slotSelectionChanged()) ); 567 connect( mListView, SIGNAL(selectionChanged()), SLOT(slotSelectionChanged()) );
565 connect( mListView, SIGNAL(doubleClicked( QListViewItem *, const QPoint &, int )), this, SLOT( slotEditPhoneNumber())); 568 connect( mListView, SIGNAL(doubleClicked( QListViewItem *, const QPoint &, int )), this, SLOT( slotEditPhoneNumber()));
566 569
567 KABC::PhoneNumber::List::Iterator it; 570 KABC::PhoneNumber::List::Iterator it;
568 for ( it = mPhoneNumberList.begin(); it != mPhoneNumberList.end(); ++it ) 571 for ( it = mPhoneNumberList.begin(); it != mPhoneNumberList.end(); ++it )
569 new PhoneViewItem( mListView, *it ); 572 new PhoneViewItem( mListView, *it );
570 if (QApplication::desktop()->width() < 480 ) 573 if (QApplication::desktop()->width() < 480 )
571 showMaximized(); 574 showMaximized();
572 else 575 else
573 resize( 400, 400 ); 576 resize( 400, 400 );
574 mChanged = false; 577 mChanged = false;
575} 578}
576 579
577PhoneEditDialog::~PhoneEditDialog() 580PhoneEditDialog::~PhoneEditDialog()
578{ 581{
579 qDebug("PhoneEditDialog::~PhoneEditDialog() "); 582 qDebug("PhoneEditDialog::~PhoneEditDialog() ");
580} 583}
581 584
582void PhoneEditDialog::slotAddPhoneNumber() 585void PhoneEditDialog::slotAddPhoneNumber()
583{ 586{
584 KABC::PhoneNumber tmp( "", 0 ); 587 KABC::PhoneNumber tmp( "", 0 );
585 PhoneTypeDialog dlg( tmp, this ); 588 PhoneTypeDialog dlg( tmp, this );
586 589
587 if ( dlg.exec() ) { 590 if ( dlg.exec() ) {
588 QListViewItem* i = mListView->firstChild(); 591 QListViewItem* i = mListView->firstChild();
589 KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); 592 KABC::PhoneNumber phoneNumber = dlg.phoneNumber();
590 bool insert = true; 593 bool insert = true;
591 while ( i ) { 594 while ( i ) {
592 PhoneViewItem* p = ( PhoneViewItem* ) i; 595 PhoneViewItem* p = ( PhoneViewItem* ) i;
593 KABC::PhoneNumber pn = p->phoneNumber(); 596 KABC::PhoneNumber pn = p->phoneNumber();
594 if ( (pn.type() | KABC::PhoneNumber::Pref) == (phoneNumber.type() | KABC::PhoneNumber::Pref) ) { 597 if ( (pn.type() | KABC::PhoneNumber::Pref) == (phoneNumber.type() | KABC::PhoneNumber::Pref) ) {
595 if ( p->text(0).isEmpty()) { 598 if ( p->text(0).isEmpty()) {
596 p->setPhoneNumber( phoneNumber ); 599 p->setPhoneNumber( phoneNumber );
597 mPhoneNumberList.remove( pn ); 600 mPhoneNumberList.remove( pn );
598 mPhoneNumberList.append( phoneNumber ); 601 mPhoneNumberList.append( phoneNumber );
599 insert = false; 602 insert = false;
600 break; 603 break;
601 } 604 }
602 } 605 }
603 i = i->nextSibling(); 606 i = i->nextSibling();
604 } 607 }
605 if ( insert ) { 608 if ( insert ) {
606 mPhoneNumberList.append( phoneNumber ); 609 mPhoneNumberList.append( phoneNumber );
607 new PhoneViewItem( mListView, phoneNumber ); 610 new PhoneViewItem( mListView, phoneNumber );
608 } 611 }
609 mChanged = true; 612 mChanged = true;
610 } 613 }
611} 614}
612 615
613void PhoneEditDialog::slotRemovePhoneNumber() 616void PhoneEditDialog::slotRemovePhoneNumber()
614{ 617{
615 PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() ); 618 PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() );
616 if ( !item ) 619 if ( !item )
617 return; 620 return;
618 621
619 mPhoneNumberList.remove( item->phoneNumber() ); 622 mPhoneNumberList.remove( item->phoneNumber() );
620 QListViewItem *currItem = mListView->currentItem(); 623 QListViewItem *currItem = mListView->currentItem();
621 mListView->takeItem( currItem ); 624 mListView->takeItem( currItem );
622 delete currItem; 625 delete currItem;
623 626
624 mChanged = true; 627 mChanged = true;
625} 628}
626 629
627void PhoneEditDialog::slotEditPhoneNumber() 630void PhoneEditDialog::slotEditPhoneNumber()
628{ 631{
629 PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() ); 632 PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() );
630 if ( !item ) 633 if ( !item )
631 return; 634 return;
632 635
633 PhoneTypeDialog dlg( item->phoneNumber(), this ); 636 PhoneTypeDialog dlg( item->phoneNumber(), this );
634 637
635 if ( dlg.exec() ) { 638 if ( dlg.exec() ) {
636 slotRemovePhoneNumber(); 639 slotRemovePhoneNumber();
637 KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); 640 KABC::PhoneNumber phoneNumber = dlg.phoneNumber();
638 mPhoneNumberList.append( phoneNumber ); 641 mPhoneNumberList.append( phoneNumber );
639 new PhoneViewItem( mListView, phoneNumber ); 642 new PhoneViewItem( mListView, phoneNumber );
640 643
641 mChanged = true; 644 mChanged = true;
642 } 645 }
643} 646}
644 647
645void PhoneEditDialog::slotSelectionChanged() 648void PhoneEditDialog::slotSelectionChanged()
646{ 649{
647 bool state = ( mListView->currentItem() != 0 ); 650 bool state = ( mListView->currentItem() != 0 );
648 651
649 mRemoveButton->setEnabled( state ); 652 mRemoveButton->setEnabled( state );
650 mEditButton->setEnabled( state ); 653 mEditButton->setEnabled( state );
651} 654}
652 655
653const KABC::PhoneNumber::List &PhoneEditDialog::phoneNumbers() 656const KABC::PhoneNumber::List &PhoneEditDialog::phoneNumbers()
654{ 657{
655 return mPhoneNumberList; 658 return mPhoneNumberList;
656} 659}
657 660
658bool PhoneEditDialog::changed() const 661bool PhoneEditDialog::changed() const
659{ 662{
660 return mChanged; 663 return mChanged;
661} 664}
662 665
663/////////////////////////////////////////// 666///////////////////////////////////////////
664// PhoneTypeDialog 667// PhoneTypeDialog
665PhoneTypeDialog::PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, 668PhoneTypeDialog::PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber,
666 QWidget *parent, const char *name) 669 QWidget *parent, const char *name)
667 : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Number" ), 670 : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Number" ),
668 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, 671 KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok,
669 parent, name, true), mPhoneNumber( phoneNumber ) 672 parent, name, true), mPhoneNumber( phoneNumber )
670{ 673{
671 QWidget *page = plainPage(); 674 QWidget *page = plainPage();
672 QLabel *label = 0; 675 QLabel *label = 0;
673 QGridLayout *layout = new QGridLayout( page, 3, 2, marginHint(), spacingHint() ); 676 QGridLayout *layout = new QGridLayout( page, 3, 2, marginHint(), spacingHint() );
674 677
675 label = new QLabel( i18n( "Number:" ), page ); 678 label = new QLabel( i18n( "Number:" ), page );
676 layout->addWidget( label, 0, 0 ); 679 layout->addWidget( label, 0, 0 );
677 mNumber = new KLineEdit( page ); 680 mNumber = new KLineEdit( page );
678 layout->addWidget( mNumber, 0, 1 ); 681 layout->addWidget( mNumber, 0, 1 );
679 682
680 mPreferredBox = new QCheckBox( i18n( "This is the preferred phone number" ), page ); 683 mPreferredBox = new QCheckBox( i18n( "This is the preferred phone number" ), page );
681 layout->addMultiCellWidget( mPreferredBox, 1, 1, 0, 1 ); 684 layout->addMultiCellWidget( mPreferredBox, 1, 1, 0, 1 );
682 685
683 mGroup = new QButtonGroup( 2, Horizontal, i18n( "Types" ), page ); 686 mGroup = new QButtonGroup( 2, Horizontal, i18n( "Types" ), page );
684 layout->addMultiCellWidget( mGroup, 2, 2, 0, 1 ); 687 layout->addMultiCellWidget( mGroup, 2, 2, 0, 1 );
685 688
686 // fill widgets 689 // fill widgets
687 mNumber->setText( mPhoneNumber.number() ); 690 mNumber->setText( mPhoneNumber.number() );
688 691
689 mTypeList = KABC::PhoneNumber::typeList(); 692 mTypeList = KABC::PhoneNumber::typeList();
690 mTypeList.remove( KABC::PhoneNumber::Pref ); 693 mTypeList.remove( KABC::PhoneNumber::Pref );
691 694
692 KABC::PhoneNumber::TypeList::Iterator it; 695 KABC::PhoneNumber::TypeList::Iterator it;
693 for ( it = mTypeList.begin(); it != mTypeList.end(); ++it ) 696 for ( it = mTypeList.begin(); it != mTypeList.end(); ++it )
694 new QCheckBox( KABC::PhoneNumber::typeLabel( *it ), mGroup ); 697 new QCheckBox( KABC::PhoneNumber::typeLabel( *it ), mGroup );
695 698
696 for ( int i = 0; i < mGroup->count(); ++i ) { 699 for ( int i = 0; i < mGroup->count(); ++i ) {
697 int type = mPhoneNumber.type(); 700 int type = mPhoneNumber.type();
698 QCheckBox *box = (QCheckBox*)mGroup->find( i ); 701 QCheckBox *box = (QCheckBox*)mGroup->find( i );
699 box->setChecked( type & mTypeList[ i ] ); 702 box->setChecked( type & mTypeList[ i ] );
700 } 703 }
701 704
702 mPreferredBox->setChecked( mPhoneNumber.type() & KABC::PhoneNumber::Pref ); 705 mPreferredBox->setChecked( mPhoneNumber.type() & KABC::PhoneNumber::Pref );
703 mNumber->setFocus(); 706 mNumber->setFocus();
704 mNumber->setSelection( 0, 1024); 707 mNumber->setSelection( 0, 1024);
705} 708}
706 709
707KABC::PhoneNumber PhoneTypeDialog::phoneNumber() 710KABC::PhoneNumber PhoneTypeDialog::phoneNumber()
708{ 711{
709 mPhoneNumber.setNumber( mNumber->text() ); 712 mPhoneNumber.setNumber( mNumber->text() );
710 713
711 int type = 0; 714 int type = 0;
712 for ( int i = 0; i < mGroup->count(); ++i ) { 715 for ( int i = 0; i < mGroup->count(); ++i ) {
713 QCheckBox *box = (QCheckBox*)mGroup->find( i ); 716 QCheckBox *box = (QCheckBox*)mGroup->find( i );
714 if ( box->isChecked() ) 717 if ( box->isChecked() )
715 type += mTypeList[ i ]; 718 type += mTypeList[ i ];
716 } 719 }
717 720
718 if ( mPreferredBox->isChecked() ) 721 if ( mPreferredBox->isChecked() )
719 mPhoneNumber.setType( type | KABC::PhoneNumber::Pref ); 722 mPhoneNumber.setType( type | KABC::PhoneNumber::Pref );
720 else 723 else
721 mPhoneNumber.setType( type & ~KABC::PhoneNumber::Pref ); 724 mPhoneNumber.setType( type & ~KABC::PhoneNumber::Pref );
722 725
723 return mPhoneNumber; 726 return mPhoneNumber;
724} 727}
725#endif 728#endif
726#ifndef KAB_EMBEDDED 729#ifndef KAB_EMBEDDED
727#include "phoneeditwidget.moc" 730#include "phoneeditwidget.moc"
728#endif //KAB_EMBEDDED 731#endif //KAB_EMBEDDED
diff --git a/korganizer/journalentry.h b/korganizer/journalentry.h
index a69846c..ee17da8 100644
--- a/korganizer/journalentry.h
+++ b/korganizer/journalentry.h
@@ -1,89 +1,90 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@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#ifndef JOURNALENTRY_H 23#ifndef JOURNALENTRY_H
24#define JOURNALENTRY_H 24#define JOURNALENTRY_H
25// 25//
26// Widget showing one Journal entry 26// Widget showing one Journal entry
27 27
28#include <qframe.h> 28#include <qframe.h>
29 29
30#include <libkcal/calendar.h> 30#include <libkcal/calendar.h>
31 31
32class QLabel; 32class QLabel;
33class KTextEdit; 33class KTextEdit;
34class QComboBox; 34class QComboBox;
35class KLineEdit; 35class KLineEdit;
36class KOLocationBox; 36class KOLocationBox;
37 37
38using namespace KCal; 38using namespace KCal;
39 39
40class JournalEntry : public QFrame { 40class JournalEntry : public QFrame {
41 Q_OBJECT 41 Q_OBJECT
42 public: 42 public:
43 JournalEntry(Calendar *,QWidget *parent); 43 JournalEntry(Calendar *,QWidget *parent);
44 virtual ~JournalEntry(); 44 virtual ~JournalEntry();
45 45
46 void setJournal(Journal *, bool saveJournal = true ); 46 void setJournal(Journal *, bool saveJournal = true );
47 Journal *journal() const; 47 Journal *journal() const;
48 48
49 void setDate(const QDate &); 49 void setDate(const QDate &);
50 50
51 void clear(); 51 void clear();
52 52
53 void flushEntry(); 53 void flushEntry();
54 void setShowOnly(); 54 void setShowOnly();
55 QSize sizeHint() const; 55 QSize sizeHint() const;
56 void setVisibleMode( bool b ) { visibleMode = b;} 56 void setVisibleMode( bool b ) { visibleMode = b;}
57 void fillCalendar( int id = 0 ); 57 void fillCalendar( int id = 0 );
58 void resizeEvent(QResizeEvent* e ) ; 58 void resizeEvent(QResizeEvent* e ) ;
59 KTextEdit * editor() {return mEditor;};
59 protected slots: 60 protected slots:
60 void slotSaveTemplate(); 61 void slotSaveTemplate();
61 void slotLoadTemplate(); 62 void slotLoadTemplate();
62 void toggleShowJournal(); 63 void toggleShowJournal();
63 void setVisibleOn(); 64 void setVisibleOn();
64 signals: 65 signals:
65 void deleteJournal(Journal *); 66 void deleteJournal(Journal *);
66 void newJournal(); 67 void newJournal();
67 void showJournalOnly( Journal * ); 68 void showJournalOnly( Journal * );
68 69
69 protected: 70 protected:
70 bool eventFilter( QObject *o, QEvent *e ); 71 bool eventFilter( QObject *o, QEvent *e );
71 72
72 void writeJournal(); 73 void writeJournal();
73 74
74 private: 75 private:
75 int mMaxWidDiff; 76 int mMaxWidDiff;
76 int mDeskWid; 77 int mDeskWid;
77 bool visibleMode; 78 bool visibleMode;
78 bool showOnlyMode; 79 bool showOnlyMode;
79 Calendar *mCalendar; 80 Calendar *mCalendar;
80 Journal *mJournal; 81 Journal *mJournal;
81 QDate mDate; 82 QDate mDate;
82 void keyPressEvent ( QKeyEvent * ) ; 83 void keyPressEvent ( QKeyEvent * ) ;
83 QComboBox *mCalendarBox; 84 QComboBox *mCalendarBox;
84 KOLocationBox * mTitle; 85 KOLocationBox * mTitle;
85 KTextEdit *mEditor; 86 KTextEdit *mEditor;
86 int heiHint; 87 int heiHint;
87}; 88};
88 89
89#endif 90#endif
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp
index a23a3b2..406df5a 100644
--- a/korganizer/kojournalview.cpp
+++ b/korganizer/kojournalview.cpp
@@ -1,241 +1,250 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@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//
25// View of Journal entries 25// View of Journal entries
26 26
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qscrollview.h> 28#include <qscrollview.h>
29#include <qpopupmenu.h> 29#include <qpopupmenu.h>
30#include <qhbox.h> 30#include <qhbox.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qlabel.h> 32#include <qlabel.h>
33#include <qpushbutton.h> 33#include <qpushbutton.h>
34#include <qapplication.h> 34#include <qapplication.h>
35 35
36#include <klocale.h> 36#include <klocale.h>
37#include <kdebug.h> 37#include <kdebug.h>
38#include "koprefs.h" 38#include "koprefs.h"
39#include <kglobal.h> 39#include <kglobal.h>
40#include <ktextedit.h>
40 41
41#include <libkcal/calendar.h> 42#include <libkcal/calendar.h>
42 43
43#include "journalentry.h" 44#include "journalentry.h"
44 45
45#include "kojournalview.h" 46#include "kojournalview.h"
46using namespace KOrg; 47using namespace KOrg;
47 48
48KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, 49KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent,
49 const char *name) 50 const char *name)
50 : KOrg::BaseView(calendar, parent, name) 51 : KOrg::BaseView(calendar, parent, name)
51{ 52{
52 mCalendar = calendar; 53 mCalendar = calendar;
53 QHBox * vb = new QHBox ( this ); 54 QHBox * vb = new QHBox ( this );
54 QPushButton * newJournal = new QPushButton( vb ); 55 QPushButton * newJournal = new QPushButton( vb );
55 QPixmap icon; 56 QPixmap icon;
56 if ( QApplication::desktop()->width() < 321 ) 57 if ( QApplication::desktop()->width() < 321 )
57 icon = SmallIcon("ko16old"); 58 icon = SmallIcon("ko16old");
58 else 59 else
59 icon = SmallIcon("ko24old"); 60 icon = SmallIcon("ko24old");
60 newJournal->setPixmap (icon ) ; 61 newJournal->setPixmap (icon ) ;
61 int size = newJournal->sizeHint().height(); 62 int size = newJournal->sizeHint().height();
62 newJournal->setFixedSize( size, size ); 63 newJournal->setFixedSize( size, size );
63 mDateLabel = new QLabel ( vb ); 64 mDateLabel = new QLabel ( vb );
64 mDateLabel->setMargin(1); 65 mDateLabel->setMargin(1);
65 mDateLabel->setAlignment(AlignCenter); 66 mDateLabel->setAlignment(AlignCenter);
66 QScrollView * sv = new QScrollView( this ); 67 QScrollView * sv = new QScrollView( this );
67 QVBoxLayout * hbl = new QVBoxLayout( this ); 68 QVBoxLayout * hbl = new QVBoxLayout( this );
68 hbl->addWidget( vb ); 69 hbl->addWidget( vb );
69 hbl->addWidget( sv ); 70 hbl->addWidget( sv );
70 parWid = new QWidget( sv->viewport() ); 71 parWid = new QWidget( sv->viewport() );
71 sv->addChild(parWid); 72 sv->addChild(parWid);
72 sv->setResizePolicy( QScrollView:: AutoOneFit ); 73 sv->setResizePolicy( QScrollView:: AutoOneFit );
73 mTopLayout = new QVBoxLayout(parWid); 74 mTopLayout = new QVBoxLayout(parWid);
74 connect( newJournal, SIGNAL( clicked() ), this , SLOT( newJournal() ) ); 75 connect( newJournal, SIGNAL( clicked() ), this , SLOT( newJournal() ) );
75 getNewEntry(); 76 getNewEntry();
76} 77}
77 78
78KOJournalView::~KOJournalView() 79KOJournalView::~KOJournalView()
79{ 80{
80} 81}
81 82
82int KOJournalView::currentDateCount() 83int KOJournalView::currentDateCount()
83{ 84{
84 return 0; 85 return 0;
85} 86}
86JournalEntry* KOJournalView::getNewEntry() 87JournalEntry* KOJournalView::getNewEntry()
87{ 88{
88 JournalEntry* Entry = new JournalEntry(mCalendar,parWid); 89 JournalEntry* Entry = new JournalEntry(mCalendar,parWid);
89 jEntries.append( Entry ); 90 jEntries.append( Entry );
90 mTopLayout->addWidget(Entry); 91 mTopLayout->addWidget(Entry);
91 Entry->setFont ( KOPrefs::instance()->mJornalViewFont ); 92 Entry->setFont ( KOPrefs::instance()->mJornalViewFont );
92 connect ( Entry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ; 93 connect ( Entry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ;
93 connect ( Entry,SIGNAL(newJournal() ),this ,SLOT(newJournal() ) ) ; 94 connect ( Entry,SIGNAL(newJournal() ),this ,SLOT(newJournal() ) ) ;
94 connect ( Entry,SIGNAL(showJournalOnly( Journal * ) ),this ,SLOT(showOnly ( Journal* ) ) ) ; 95 connect ( Entry,SIGNAL(showJournalOnly( Journal * ) ),this ,SLOT(showOnly ( Journal* ) ) ) ;
95 return Entry; 96 return Entry;
96} 97}
97 98
98QPtrList<Incidence> KOJournalView::selectedIncidences() 99QPtrList<Incidence> KOJournalView::selectedIncidences()
99{ 100{
100 QPtrList<Incidence> eventList; 101 QPtrList<Incidence> eventList;
101 102
102 return eventList; 103 return eventList;
103} 104}
104void KOJournalView::updateConfig() 105void KOJournalView::updateConfig()
105{ 106{
106 JournalEntry* mEntry = jEntries.first(); 107 JournalEntry* mEntry = jEntries.first();
107 while ( mEntry ) { 108 while ( mEntry ) {
108 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); 109 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
109 mEntry = jEntries.next(); 110 mEntry = jEntries.next();
110 } 111 }
111} 112}
112void KOJournalView::updateView() 113void KOJournalView::updateView()
113{ 114{
114 JournalEntry* mEntry = jEntries.first(); 115 JournalEntry* mEntry = jEntries.first();
115 while ( mEntry ) { 116 while ( mEntry ) {
116 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); 117 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
117 mEntry = jEntries.next(); 118 mEntry = jEntries.next();
118 } 119 }
119 showDates( mDate, QDate() ); 120 showDates( mDate, QDate() );
120} 121}
121void KOJournalView::checkModified() 122void KOJournalView::checkModified()
122{ 123{
123 flushView(); 124 flushView();
124} 125}
125void KOJournalView::flushView() 126void KOJournalView::flushView()
126{ 127{
127 static bool ff = false; 128 static bool ff = false;
128 if ( ff ) return; 129 if ( ff ) return;
129 ff = true; 130 ff = true;
130 JournalEntry* mEntry = jEntries.first(); 131 JournalEntry* mEntry = jEntries.first();
131 while ( mEntry ) { 132 while ( mEntry ) {
132 mEntry->flushEntry(); 133 mEntry->flushEntry();
133 mEntry = jEntries.next(); 134 mEntry = jEntries.next();
134 } 135 }
135 ff = false; 136 ff = false;
136} 137}
137 138
138void KOJournalView::clearList() 139void KOJournalView::clearList()
139{ 140{
140 JournalEntry* mEntry = jEntries.first(); 141 JournalEntry* mEntry = jEntries.first();
141 while ( mEntry ) { 142 while ( mEntry ) {
142 mEntry->clear(); 143 mEntry->clear();
143 mEntry = jEntries.next(); 144 mEntry = jEntries.next();
144 } 145 }
145} 146}
146void KOJournalView::newJournal() 147void KOJournalView::newJournal()
147{ 148{
148 //qDebug(" KOJournalView::newJournal()"); 149 //qDebug(" KOJournalView::newJournal()");
149 flushView(); 150 flushView();
150 Journal* mJournal = new Journal; 151 Journal* mJournal = new Journal;
151 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); 152 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0)));
152 mCalendar->addJournal(mJournal); 153 mCalendar->addJournal(mJournal);
153 showDates( mDate, QDate() ); 154 showDates( mDate, QDate() );
154} 155}
155 156
156void KOJournalView::showOnly ( Journal* j ) 157void KOJournalView::showOnly ( Journal* j )
157{ 158{
158 //qDebug("showOnly %x ", j); 159 //qDebug("showOnly %x ", j);
159 flushView(); 160 flushView();
160 if ( j == 0 ) { 161 if ( j == 0 ) {
161 showDates( mDate, QDate() ); 162 showDates( mDate, QDate() );
162 return; 163 return;
163 } 164 }
164 QPtrList<Journal> jl; 165 QPtrList<Journal> jl;
165 jl.append ( j ); 166 jl.append ( j );
166 showList( jl ); 167 showList( jl );
167 JournalEntry* mEntry = jEntries.first(); 168 JournalEntry* mEntry = jEntries.first();
168 mEntry->setShowOnly(); 169 mEntry->setShowOnly();
169} 170}
170void KOJournalView::showList(QPtrList<Journal> jl) 171void KOJournalView::showList(QPtrList<Journal> jl)
171{ 172{
172 static bool ff = false; 173 static bool ff = false;
173 if ( ff ) return; 174 if ( ff ) return;
174 ff = true; 175 ff = true;
175 //qDebug("KOJournalView::showList %d",jl.count() ); 176 //qDebug("KOJournalView::showList %d",jl.count() );
176 JournalEntry* mEntry = jEntries.first(); 177 JournalEntry* mEntry = jEntries.first();
177 JournalEntry* firstEntry = mEntry; 178 JournalEntry* firstEntry = mEntry;
178 int count = jl.count(); 179 int count = jl.count();
179 int iii = 0; 180 int iii = 0;
181 QWidget* fw = qApp->focusWidget ();
180 while ( iii < count ) { 182 while ( iii < count ) {
181 if ( !mEntry ) { 183 if ( !mEntry ) {
182 mEntry = getNewEntry(); 184 mEntry = getNewEntry();
183 mEntry->setVisibleMode( true ); 185 mEntry->setVisibleMode( true );
184 mEntry->setDate(mDate); 186 mEntry->setDate(mDate);
185 mEntry->setJournal(jl.at(iii), false); 187 mEntry->setJournal(jl.at(iii), false);
186 mEntry->setVisibleMode( true ); 188 mEntry->setVisibleMode( true );
187 mEntry->show(); 189 mEntry->show();
188 mEntry = 0; 190 mEntry = 0;
189 } else { 191 } else {
192 int xxx = -1, yyy = -1;
193 if ( ((QWidget*) mEntry->editor() ) == fw ) {
194 mEntry->editor()->getCursorPosition( &xxx,&yyy);
195 }
190 mEntry->setVisibleMode( true ); 196 mEntry->setVisibleMode( true );
191 mEntry->setDate(mDate); 197 mEntry->setDate(mDate);
192 mEntry->setJournal(jl.at(iii), false); 198 mEntry->setJournal(jl.at(iii), false);
193 mEntry->setVisibleMode( true ); 199 mEntry->setVisibleMode( true );
194 mEntry->show(); 200 mEntry->show();
201 if ( xxx > -1 && yyy > -1 ) {
202 mEntry->editor()->setCursorPosition( xxx, yyy );
203 }
195 mEntry = jEntries.next(); 204 mEntry = jEntries.next();
196 } 205 }
197 ++iii; 206 ++iii;
198 } 207 }
199 while ( mEntry ) { 208 while ( mEntry ) {
200 mEntry->setDate(mDate); 209 mEntry->setDate(mDate);
201 mEntry->clear(); 210 mEntry->clear();
202 if ( mEntry != firstEntry ) { 211 if ( mEntry != firstEntry ) {
203 mEntry->hide(); 212 mEntry->hide();
204 mEntry->setVisibleMode( false ); 213 mEntry->setVisibleMode( false );
205 } 214 }
206 else { 215 else {
207 mEntry->setVisibleMode( true ); 216 mEntry->setVisibleMode( true );
208 mEntry->show(); 217 mEntry->show();
209 } 218 }
210 mEntry = jEntries.next(); 219 mEntry = jEntries.next();
211 } 220 }
212 ff = false; 221 ff = false;
213} 222}
214 223
215void KOJournalView::showDates(const QDate &start, const QDate &) 224void KOJournalView::showDates(const QDate &start, const QDate &)
216{ 225{
217 mDate = start; 226 mDate = start;
218 mDateLabel->setText(KGlobal::locale()->formatDate(mDate)); 227 mDateLabel->setText(KGlobal::locale()->formatDate(mDate));
219 QPtrList<Journal> jl = calendar()->journals4Date( start ); 228 QPtrList<Journal> jl = calendar()->journals4Date( start );
220 showList( jl ); 229 showList( jl );
221} 230}
222 231
223void KOJournalView::showEvents(QPtrList<Event>) 232void KOJournalView::showEvents(QPtrList<Event>)
224{ 233{
225 // After new creation of list view no events are selected. 234 // After new creation of list view no events are selected.
226// emit incidenceSelected( 0 ); 235// emit incidenceSelected( 0 );
227} 236}
228 237
229void KOJournalView::changeEventDisplay(Event *, int /*action*/) 238void KOJournalView::changeEventDisplay(Event *, int /*action*/)
230{ 239{
231 updateView(); 240 updateView();
232} 241}
233 242
234void KOJournalView::keyPressEvent ( QKeyEvent * e ) 243void KOJournalView::keyPressEvent ( QKeyEvent * e )
235{ 244{
236 //qDebug("keyPressEven "); 245 //qDebug("keyPressEven ");
237 if ( e->state() == Qt::ControlButton ) { 246 if ( e->state() == Qt::ControlButton ) {
238 if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left ) 247 if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left )
239 e->ignore(); 248 e->ignore();
240 } 249 }
241} 250}
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index 59be506..f376e6c 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -1,1319 +1,1321 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 Cornelius Schumacher <schumacher@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#include <stdlib.h> 30#include <stdlib.h>
31 31
32#include <qfile.h> 32#include <qfile.h>
33#include <qtimer.h> 33#include <qtimer.h>
34#include <qmap.h> 34#include <qmap.h>
35#include <qregexp.h> 35#include <qregexp.h>
36 36
37#ifndef DESKTOP_VERSION 37#ifndef DESKTOP_VERSION
38#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
39#include <qtopia/qcopenvelope_qws.h> 39#include <qtopia/qcopenvelope_qws.h>
40#else 40#else
41#include <qapplication.h> 41#include <qapplication.h>
42#include <qprocess.h> 42#include <qprocess.h>
43#endif 43#endif
44 44
45#include <kstaticdeleter.h> 45#include <kstaticdeleter.h>
46#include <kmessagebox.h> 46#include <kmessagebox.h>
47 47
48 48
49#include "externalapphandler.h" 49#include "externalapphandler.h"
50 50
51#include "kpimglobalprefs.h" 51#include "kpimglobalprefs.h"
52 52
53//uncomment line to get debug output 53//uncomment line to get debug output
54//#define DEBUG_EXT_APP_HANDLER 54//#define DEBUG_EXT_APP_HANDLER
55 55
56/********************************************************************************* 56/*********************************************************************************
57 * 57 *
58 ********************************************************************************/ 58 ********************************************************************************/
59 59
60 60
61QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 61QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
62 : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) 62 : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage)
63{ 63{
64 //sourceMessage passes later three parameters: sourceChannel, uid, param1 64 //sourceMessage passes later three parameters: sourceChannel, uid, param1
65 if (_usedSourceParameters == 0) 65 if (_usedSourceParameters == 0)
66 _sourceMessageParameters = "QString,QString)"; 66 _sourceMessageParameters = "QString,QString)";
67 else if (_usedSourceParameters == 1) 67 else if (_usedSourceParameters == 1)
68 _sourceMessageParameters = "(QString,QString,QString)"; 68 _sourceMessageParameters = "(QString,QString,QString)";
69 else if (_usedSourceParameters == 2) 69 else if (_usedSourceParameters == 2)
70 _sourceMessageParameters = "(QString,QString,QString,QString)"; 70 _sourceMessageParameters = "(QString,QString,QString,QString)";
71 else if (_usedSourceParameters == 3) 71 else if (_usedSourceParameters == 3)
72 _sourceMessageParameters = "(QString,QString,QString,QString,QString)"; 72 _sourceMessageParameters = "(QString,QString,QString,QString,QString)";
73} 73}
74 74
75/*********************************************************************************/ 75/*********************************************************************************/
76 76
77QCopTransferItem::QCopTransferItem() 77QCopTransferItem::QCopTransferItem()
78{ 78{
79} 79}
80 80
81/*********************************************************************************/ 81/*********************************************************************************/
82bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3) 82bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3)
83{ 83{
84 84
85#ifndef DESKTOP_VERSION 85#ifndef DESKTOP_VERSION
86 //sourceMessage passes two parameters: sourceChannel, uid 86 //sourceMessage passes two parameters: sourceChannel, uid
87 QString sourceMessage = _sourceMessage + _sourceMessageParameters; 87 QString sourceMessage = _sourceMessage + _sourceMessageParameters;
88#ifdef DEBUG_EXT_APP_HANDLER 88#ifdef DEBUG_EXT_APP_HANDLER
89 qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1()); 89 qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1());
90 qDebug("passing sourcechannel(%s), uid(%s), param1(%s), param2(%s), param3(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1(), param2.latin1(), param3.latin1()); 90 qDebug("passing sourcechannel(%s), uid(%s), param1(%s), param2(%s), param3(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1(), param2.latin1(), param3.latin1());
91#endif 91#endif
92 92
93 QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1()); 93 QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1());
94 94
95 e << _sourceChannel << uid; 95 e << _sourceChannel << uid;
96 96
97 if (_usedSourceParameters == 1) 97 if (_usedSourceParameters == 1)
98 e << param1; 98 e << param1;
99 else if (_usedSourceParameters == 2) 99 else if (_usedSourceParameters == 2)
100 e << param1 << param2; 100 e << param1 << param2;
101 else if (_usedSourceParameters == 3) 101 else if (_usedSourceParameters == 3)
102 e << param1 << param2 << param3; 102 e << param1 << param2 << param3;
103 103
104 qApp->processEvents(); 104 qApp->processEvents();
105 105
106 return true; 106 return true;
107 107
108#else 108#else
109 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 109 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
110 return false; 110 return false;
111#endif 111#endif
112 112
113} 113}
114 114
115 115
116/*********************************************************************************/ 116/*********************************************************************************/
117void QCopTransferItem::setSourceChannel(const QString& sourceChannel) 117void QCopTransferItem::setSourceChannel(const QString& sourceChannel)
118{ 118{
119 119
120 if ( !sourceChannel.isEmpty()) 120 if ( !sourceChannel.isEmpty())
121 _sourceChannel = sourceChannel; 121 _sourceChannel = sourceChannel;
122} 122}
123 123
124 124
125/*********************************************************************************/ 125/*********************************************************************************/
126bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 126bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
127{ 127{
128 128
129 // copied from old mail2 129 // copied from old mail2
130/* 130/*
131 static int ii = 0; 131 static int ii = 0;
132 132
133 // block second call 133 // block second call
134 if ( ii < 2 ) { 134 if ( ii < 2 ) {
135 ++ii; 135 ++ii;
136 if ( ii > 1 ) { 136 if ( ii > 1 ) {
137 qDebug("qcop call blocked "); 137 qDebug("qcop call blocked ");
138 return true; 138 return true;
139 } 139 }
140 } 140 }
141*/ 141*/
142 142
143// qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() ); 143// qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() );
144 144
145 //we are in the target and get a request from the source 145 //we are in the target and get a request from the source
146 if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data()) 146 if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data())
147 { 147 {
148 148
149 QDataStream stream( data, IO_ReadOnly ); 149 QDataStream stream( data, IO_ReadOnly );
150 150
151 151
152 QString sourceChannel; 152 QString sourceChannel;
153 QString uid; 153 QString uid;
154 QString param1; 154 QString param1;
155 QString param2; 155 QString param2;
156 QString param3; 156 QString param3;
157 157
158 stream >> sourceChannel >> uid; 158 stream >> sourceChannel >> uid;
159 159
160 if (_usedSourceParameters == 0) 160 if (_usedSourceParameters == 0)
161 { 161 {
162 emit receivedMessageFromSource(sourceChannel, uid); 162 emit receivedMessageFromSource(sourceChannel, uid);
163 } 163 }
164 else if (_usedSourceParameters == 1) 164 else if (_usedSourceParameters == 1)
165 { 165 {
166 stream >> param1; 166 stream >> param1;
167 emit receivedMessageFromSource(sourceChannel, uid, param1); 167 emit receivedMessageFromSource(sourceChannel, uid, param1);
168 } 168 }
169 else if (_usedSourceParameters == 2) 169 else if (_usedSourceParameters == 2)
170 { 170 {
171 stream >> param1 >> param2; 171 stream >> param1 >> param2;
172 emit receivedMessageFromSource(sourceChannel, uid, param1, param2); 172 emit receivedMessageFromSource(sourceChannel, uid, param1, param2);
173 } 173 }
174 else if (_usedSourceParameters == 3) 174 else if (_usedSourceParameters == 3)
175 { 175 {
176 stream >> param1 >> param2 >> param3; 176 stream >> param1 >> param2 >> param3;
177 emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); 177 emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3);
178 } 178 }
179 179
180 return true; 180 return true;
181 } 181 }
182 182
183 return false; 183 return false;
184} 184}
185 185
186 186
187/********************************************************************************* 187/*********************************************************************************
188 * 188 *
189 ********************************************************************************/ 189 ********************************************************************************/
190 190
191 191
192QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 192QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
193 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) 193 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage)
194{ 194{
195 //targetMessage returns later two parameters: uid, and map<qstring,qstring> 195 //targetMessage returns later two parameters: uid, and map<qstring,qstring>
196 _targetMessageParameters = "(QString,QMAP<QString,QString>)"; 196 _targetMessageParameters = "(QString,QMAP<QString,QString>)";
197} 197}
198 198
199/*********************************************************************************/ 199/*********************************************************************************/
200bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) 200bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap)
201{ 201{
202#ifndef DESKTOP_VERSION 202#ifndef DESKTOP_VERSION
203 //targetMessage passes two parameters: uid, map 203 //targetMessage passes two parameters: uid, map
204 QString targetMessage = _targetMessage + _targetMessageParameters; 204 QString targetMessage = _targetMessage + _targetMessageParameters;
205 205
206#ifdef DEBUG_EXT_APP_HANDLER 206#ifdef DEBUG_EXT_APP_HANDLER
207 qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); 207 qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
208 qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); 208 qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1());
209#endif 209#endif
210 210
211 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); 211 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
212 //US we need no names in the To field. The emailadresses are enough 212 //US we need no names in the To field. The emailadresses are enough
213 213
214 e << uid << nameEmailMap; 214 e << uid << nameEmailMap;
215 215
216 qApp->processEvents(); 216 qApp->processEvents();
217 217
218 return true; 218 return true;
219 219
220#else 220#else
221 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 221 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
222 return false; 222 return false;
223#endif 223#endif
224 224
225} 225}
226 226
227 227
228/*********************************************************************************/ 228/*********************************************************************************/
229bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 229bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
230{ 230{
231 bool res = QCopTransferItem::appMessage( cmsg, data ); 231 bool res = QCopTransferItem::appMessage( cmsg, data );
232 232
233 if (res == false) 233 if (res == false)
234 { 234 {
235 QDataStream stream( data, IO_ReadOnly ); 235 QDataStream stream( data, IO_ReadOnly );
236 236
237// qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); 237// qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() );
238 238
239 //we are in the source and get an answer from the target 239 //we are in the source and get an answer from the target
240 if ((_targetMessage + _targetMessageParameters) == cmsg.data()) 240 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
241 { 241 {
242 QMap<QString,QString> adrMap; 242 QMap<QString,QString> adrMap;
243 QString uid; 243 QString uid;
244 244
245 stream >> uid >> adrMap; 245 stream >> uid >> adrMap;
246 246
247 emit receivedMessageFromTarget(uid, adrMap); 247 emit receivedMessageFromTarget(uid, adrMap);
248 248
249 249
250 return true; 250 return true;
251 } 251 }
252 } 252 }
253 253
254 return false; 254 return false;
255} 255}
256 256
257 257
258/********************************************************************************* 258/*********************************************************************************
259 * 259 *
260 ********************************************************************************/ 260 ********************************************************************************/
261 261
262QCopListTransferItem::~QCopListTransferItem() 262QCopListTransferItem::~QCopListTransferItem()
263{ 263{
264 264
265} 265}
266 266
267QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 267QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
268 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) 268 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage)
269{ 269{
270 //targetMessage returns later two parameters: uid, and three lists 270 //targetMessage returns later two parameters: uid, and three lists
271 _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)"; 271 _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)";
272} 272}
273 273
274/*********************************************************************************/ 274/*********************************************************************************/
275bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) 275bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6)
276{ 276{
277#ifndef DESKTOP_VERSION 277#ifndef DESKTOP_VERSION
278 //targetMessage passes two parameters: uid, map 278 //targetMessage passes two parameters: uid, map
279 QString targetMessage = _targetMessage + _targetMessageParameters; 279 QString targetMessage = _targetMessage + _targetMessageParameters;
280 280
281#ifdef DEBUG_EXT_APP_HANDLER 281#ifdef DEBUG_EXT_APP_HANDLER
282 qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); 282 qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
283 qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1()); 283 qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1());
284 284
285 285
286 for ( int i = 0; i < list3.count(); i++) 286 for ( int i = 0; i < list3.count(); i++)
287 qDebug("listentry list3: %s",list3[i].latin1()); 287 qDebug("listentry list3: %s",list3[i].latin1());
288#endif 288#endif
289 289
290 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); 290 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
291 //US we need no names in the To field. The emailadresses are enough 291 //US we need no names in the To field. The emailadresses are enough
292 292
293 e << uid << list1 << list2 << list3 << list4 << list5 << list6; 293 e << uid << list1 << list2 << list3 << list4 << list5 << list6;
294 294
295 qApp->processEvents(); 295 qApp->processEvents();
296 296
297 return true; 297 return true;
298 298
299#else 299#else
300 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 300 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
301 return false; 301 return false;
302#endif 302#endif
303 303
304} 304}
305 305
306 306
307/*********************************************************************************/ 307/*********************************************************************************/
308bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 308bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
309{ 309{
310 bool res = QCopTransferItem::appMessage( cmsg, data ); 310 bool res = QCopTransferItem::appMessage( cmsg, data );
311#ifdef DEBUG_EXT_APP_HANDLER 311#ifdef DEBUG_EXT_APP_HANDLER
312 qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 312 qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
313#endif 313#endif
314 314
315 if (res == false) 315 if (res == false)
316 { 316 {
317 QDataStream stream( data, IO_ReadOnly ); 317 QDataStream stream( data, IO_ReadOnly );
318 318
319#ifdef DEBUG_EXT_APP_HANDLER 319#ifdef DEBUG_EXT_APP_HANDLER
320 qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 320 qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
321#endif 321#endif
322 322
323 //we are in the source and get an answer from the target 323 //we are in the source and get an answer from the target
324 if ((_targetMessage + _targetMessageParameters) == cmsg.data()) 324 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
325 { 325 {
326 QStringList list1; 326 QStringList list1;
327 QStringList list2; 327 QStringList list2;
328 QStringList list3; 328 QStringList list3;
329 QStringList list4; 329 QStringList list4;
330 QStringList list5; 330 QStringList list5;
331 QStringList list6; 331 QStringList list6;
332 QString uid; 332 QString uid;
333 333
334#ifdef DEBUG_EXT_APP_HANDLER 334#ifdef DEBUG_EXT_APP_HANDLER
335 qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 335 qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
336#endif 336#endif
337 337
338 stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6; 338 stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6;
339 emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6); 339 emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6);
340 340
341 341
342 return true; 342 return true;
343 } 343 }
344 } 344 }
345 345
346 return false; 346 return false;
347} 347}
348 348
349 349
350 350
351/********************************************************************************* 351/*********************************************************************************
352 * 352 *
353 ********************************************************************************/ 353 ********************************************************************************/
354 354
355 355
356ExternalAppHandler *ExternalAppHandler::sInstance = 0; 356ExternalAppHandler *ExternalAppHandler::sInstance = 0;
357static KStaticDeleter<ExternalAppHandler> staticDeleter; 357static KStaticDeleter<ExternalAppHandler> staticDeleter;
358 358
359ExternalAppHandler::ExternalAppHandler() 359ExternalAppHandler::ExternalAppHandler()
360{ 360{
361 mDefaultItems.setAutoDelete(true); 361 mDefaultItems.setAutoDelete(true);
362 362
363 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); 363 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList");
364 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); 364 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&)));
365 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT (receivedNameEmailUidList_Slot(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 365 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT (receivedNameEmailUidList_Slot(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
366 366
367//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); 367//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList");
368//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); 368//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&)));
369//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); 369//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)));
370 370
371 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); 371 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", "");
372 connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 372 connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
373 373
374 374
375 375
376 mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList"); 376 mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList");
377 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&))); 377 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&)));
378 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 378 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
379 379
380 380
381} 381}
382 382
383ExternalAppHandler::~ExternalAppHandler() 383ExternalAppHandler::~ExternalAppHandler()
384{ 384{
385 delete mNameEmailUidListFromKAPITransfer; 385 delete mNameEmailUidListFromKAPITransfer;
386 //delete mFindByEmailFromKAPITransfer; 386 //delete mFindByEmailFromKAPITransfer;
387 delete mDisplayDetails; 387 delete mDisplayDetails;
388 delete mBirthdayListFromKAPITransfer; 388 delete mBirthdayListFromKAPITransfer;
389} 389}
390 390
391void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, 391void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid,
392 const QStringList& nameList, 392 const QStringList& nameList,
393 const QStringList& emailList, 393 const QStringList& emailList,
394 const QStringList& uidList, 394 const QStringList& uidList,
395 const QStringList&, 395 const QStringList&,
396 const QStringList&, 396 const QStringList&,
397 const QStringList& ) 397 const QStringList& )
398{ 398{
399 // this method is a conevnient way to reduce the number of parameters I have to pass 399 // this method is a conevnient way to reduce the number of parameters I have to pass
400 emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList); 400 emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList);
401} 401}
402 402
403 403
404void ExternalAppHandler::loadConfig() 404void ExternalAppHandler::loadConfig()
405{ 405{
406 406
407 mDefaultItems.clear(); 407 mDefaultItems.clear();
408 mEmailAppAvailable = UNDEFINED; 408 mEmailAppAvailable = UNDEFINED;
409 mPhoneAppAvailable = UNDEFINED; 409 mPhoneAppAvailable = UNDEFINED;
410 mFaxAppAvailable = UNDEFINED; 410 mFaxAppAvailable = UNDEFINED;
411 mSMSAppAvailable = UNDEFINED; 411 mSMSAppAvailable = UNDEFINED;
412 mPagerAppAvailable = UNDEFINED; 412 mPagerAppAvailable = UNDEFINED;
413 mSIPAppAvailable = UNDEFINED; 413 mSIPAppAvailable = UNDEFINED;
414 414
415 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); 415 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") );
416 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); 416 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") );
417 QString qtpath = QString::fromLatin1( getenv("QTDIR") ); 417 QString qtpath = QString::fromLatin1( getenv("QTDIR") );
418 418
419 //if qtopiapath is not set, fallback to qt 419 //if qtopiapath is not set, fallback to qt
420 if (qtopiapath.isEmpty()) 420 if (qtopiapath.isEmpty())
421 qtopiapath = qtpath; 421 qtopiapath = qtpath;
422 422
423 //if opiepath is not set, fallback to qtopia 423 //if opiepath is not set, fallback to qtopia
424 if (opiepath.isEmpty()) 424 if (opiepath.isEmpty())
425 opiepath = qtopiapath; 425 opiepath = qtopiapath;
426 426
427 427
428 428
429 //mailclients 429 //mailclients
430 QString mailmsg1 = "writeMail(QString,QString)"; 430 QString mailmsg1 = "writeMail(QString,QString)";
431 QString mailmsg2 = "writeMail(QMap(QString,QString))"; 431 QString mailmsg2 = "writeMail(QMap(QString,QString))";
432 432
433 QString undefined = ""; 433 QString undefined = "";
434 434
435 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); 435 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined);
436 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); 436 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined);
437 437
438#ifdef DESKTOP_VERSION 438#ifdef DESKTOP_VERSION
439 QString appPath; 439 QString appPath;
440#ifdef _WIN32_ 440#ifdef _WIN32_
441 appPath = "C:\\Programme\\Mozilla Thunderbird\\thunderbird.exe"; 441 appPath = "C:\\Programme\\Mozilla Thunderbird\\thunderbird.exe";
442#else 442#else
443 appPath = "/usr/bin/thunderbird"; 443 appPath = "/usr/bin/thunderbird";
444#endif 444#endif
445 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "Mozilla Thunderbird", appPath, "-compose", "to=%1 <%2>", ",", "subject=%1"); 445 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "Mozilla Thunderbird", appPath, "-compose", "to=%1 <%2>", ",", "subject=%1");
446 446
447#ifdef _WIN32_ 447#ifdef _WIN32_
448 appPath = "C:\\Programme\\Mozilla\\mozilla.exe"; 448 appPath = "C:\\Programme\\Mozilla\\mozilla.exe";
449#else 449#else
450 appPath = "/usr/bin/mozilla"; 450 appPath = "/usr/bin/mozilla";
451#endif 451#endif
452 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Mozilla Suite", appPath, "-mail -compose", "to=%1 <%2>", ",", "subject=%1"); 452 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Mozilla Suite", appPath, "-mail -compose", "to=%1 <%2>", ",", "subject=%1");
453 453
454 454
455 455
456#else 456#else
457 if (( QFile::exists( qtopiapath + "/bin/ompi" )) || 457 if (( QFile::exists( qtopiapath + "/bin/ompi" )) ||
458 ( QFile::exists( opiepath + "/bin/ompi" )) || 458 ( QFile::exists( opiepath + "/bin/ompi" )) ||
459 ( QFile::exists( qtpath + "/bin/ompi" ))) 459 ( QFile::exists( qtpath + "/bin/ompi" )))
460 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 460 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
461 461
462 if (( QFile::exists( qtopiapath + "/bin/qtmail" )) || 462 if (( QFile::exists( qtopiapath + "/bin/qtmail" )) ||
463 ( QFile::exists( qtpath + "/bin/qtmail" ))) 463 ( QFile::exists( qtpath + "/bin/qtmail" )))
464 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 464 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
465 465
466 if ( QFile::exists( opiepath + "/bin/opiemail" )) 466 if ( QFile::exists( opiepath + "/bin/opiemail" ))
467 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 467 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
468 468
469 if ( QFile::exists( opiepath + "/bin/mailit" )) 469 if ( QFile::exists( opiepath + "/bin/mailit" ))
470 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 470 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
471#endif 471#endif
472 472
473 473
474 //phoneclients 474 //phoneclients
475 475
476 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); 476 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined);
477 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); 477 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined);
478 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 478 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
479 ( QFile::exists( opiepath + "/bin/kppi" ))) 479 ( QFile::exists( opiepath + "/bin/kppi" )))
480 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); 480 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
481 481
482 //faxclients 482 //faxclients
483 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); 483 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined);
484 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); 484 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined);
485 485
486 //smsclients 486 //smsclients
487 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); 487 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined);
488 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); 488 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined);
489 489
490 //pagerclients 490 //pagerclients
491 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); 491 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined);
492 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); 492 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined);
493 493
494 //sipclients 494 //sipclients
495 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined); 495 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined);
496 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined); 496 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined);
497 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 497 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
498 ( QFile::exists( opiepath + "/bin/kppi" ))) 498 ( QFile::exists( opiepath + "/bin/kppi" )))
499 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); 499 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
500 500
501} 501}
502 502
503ExternalAppHandler *ExternalAppHandler::instance() 503ExternalAppHandler *ExternalAppHandler::instance()
504{ 504{
505 if ( !sInstance ) { 505 if ( !sInstance ) {
506 sInstance = staticDeleter.setObject( new ExternalAppHandler() ); 506 sInstance = staticDeleter.setObject( new ExternalAppHandler() );
507 sInstance->loadConfig(); 507 sInstance->loadConfig();
508 } 508 }
509 509
510 return sInstance; 510 return sInstance;
511} 511}
512 512
513void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) 513void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2)
514{ 514{
515 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); 515 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2);
516 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); 516 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() );
517 mDefaultItems.append(dai); 517 mDefaultItems.append(dai);
518} 518}
519 519
520 520
521QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) 521QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type)
522{ 522{
523 QList<DefaultAppItem> list; 523 QList<DefaultAppItem> list;
524 524
525 DefaultAppItem* dai; 525 DefaultAppItem* dai;
526 526
527 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 527 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
528 { 528 {
529 if (dai->_type == type) 529 if (dai->_type == type)
530 list.append(dai); 530 list.append(dai);
531 } 531 }
532 532
533 return list; 533 return list;
534} 534}
535 535
536DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) 536DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid)
537{ 537{
538 DefaultAppItem* dai; 538 DefaultAppItem* dai;
539 539
540 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 540 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
541 { 541 {
542 if (dai->_type == type && dai->_id == clientid) 542 if (dai->_type == type && dai->_id == clientid)
543 return dai; 543 return dai;
544 } 544 }
545 545
546 return 0; 546 return 0;
547} 547}
548 548
549bool ExternalAppHandler::isEmailAppAvailable() 549bool ExternalAppHandler::isEmailAppAvailable()
550{ 550{
551 551
552 if (mEmailAppAvailable == UNDEFINED) 552 if (mEmailAppAvailable == UNDEFINED)
553 { 553 {
554 int client = KPimGlobalPrefs::instance()->mEmailClient; 554 int client = KPimGlobalPrefs::instance()->mEmailClient;
555 if (client == KPimGlobalPrefs::NONE_EMC) 555 if (client == KPimGlobalPrefs::NONE_EMC)
556 mEmailAppAvailable = UNAVAILABLE; 556 mEmailAppAvailable = UNAVAILABLE;
557 else 557 else
558 mEmailAppAvailable = AVAILABLE; 558 mEmailAppAvailable = AVAILABLE;
559 } 559 }
560 return (mEmailAppAvailable == AVAILABLE); 560 return (mEmailAppAvailable == AVAILABLE);
561 561
562} 562}
563 563
564bool ExternalAppHandler::isSMSAppAvailable() 564bool ExternalAppHandler::isSMSAppAvailable()
565{ 565{
566#ifndef DESKTOP_VERSION 566#ifndef DESKTOP_VERSION
567 if (mSMSAppAvailable == UNDEFINED) 567 if (mSMSAppAvailable == UNDEFINED)
568 { 568 {
569 int client = KPimGlobalPrefs::instance()->mSMSClient; 569 int client = KPimGlobalPrefs::instance()->mSMSClient;
570 if (client == KPimGlobalPrefs::NONE_SMC) 570 if (client == KPimGlobalPrefs::NONE_SMC)
571 mSMSAppAvailable = UNAVAILABLE; 571 mSMSAppAvailable = UNAVAILABLE;
572 else 572 else
573 mSMSAppAvailable = AVAILABLE; 573 mSMSAppAvailable = AVAILABLE;
574 } 574 }
575 575
576 return (mSMSAppAvailable == AVAILABLE); 576 return (mSMSAppAvailable == AVAILABLE);
577#else //DESKTOP_VERSION 577#else //DESKTOP_VERSION
578 return false; 578 return false;
579#endif //DESKTOP_VERSION 579#endif //DESKTOP_VERSION
580} 580}
581 581
582bool ExternalAppHandler::isPhoneAppAvailable() 582bool ExternalAppHandler::isPhoneAppAvailable()
583{ 583{
584#ifndef DESKTOP_VERSION 584#ifndef DESKTOP_VERSION
585 if (mPhoneAppAvailable == UNDEFINED) 585 if (mPhoneAppAvailable == UNDEFINED)
586 { 586 {
587 int client = KPimGlobalPrefs::instance()->mPhoneClient; 587 int client = KPimGlobalPrefs::instance()->mPhoneClient;
588 if (client == KPimGlobalPrefs::NONE_PHC) 588 if (client == KPimGlobalPrefs::NONE_PHC)
589 mPhoneAppAvailable = UNAVAILABLE; 589 mPhoneAppAvailable = UNAVAILABLE;
590 else 590 else
591 mPhoneAppAvailable = AVAILABLE; 591 mPhoneAppAvailable = AVAILABLE;
592 } 592 }
593 593
594 return (mPhoneAppAvailable == AVAILABLE); 594 return (mPhoneAppAvailable == AVAILABLE);
595#else //DESKTOP_VERSION 595#else //DESKTOP_VERSION
596 return false; 596 return false;
597#endif //DESKTOP_VERSION 597#endif //DESKTOP_VERSION
598} 598}
599 599
600bool ExternalAppHandler::isFaxAppAvailable() 600bool ExternalAppHandler::isFaxAppAvailable()
601{ 601{
602#ifndef DESKTOP_VERSION 602#ifndef DESKTOP_VERSION
603 if (mFaxAppAvailable == UNDEFINED) 603 if (mFaxAppAvailable == UNDEFINED)
604 { 604 {
605 int client = KPimGlobalPrefs::instance()->mFaxClient; 605 int client = KPimGlobalPrefs::instance()->mFaxClient;
606 if (client == KPimGlobalPrefs::NONE_FAC) 606 if (client == KPimGlobalPrefs::NONE_FAC)
607 mFaxAppAvailable = UNAVAILABLE; 607 mFaxAppAvailable = UNAVAILABLE;
608 else 608 else
609 mFaxAppAvailable = AVAILABLE; 609 mFaxAppAvailable = AVAILABLE;
610 } 610 }
611 611
612 return (mFaxAppAvailable == AVAILABLE); 612 return (mFaxAppAvailable == AVAILABLE);
613#else //DESKTOP_VERSION 613#else //DESKTOP_VERSION
614 return false; 614 return false;
615#endif //DESKTOP_VERSION 615#endif //DESKTOP_VERSION
616} 616}
617 617
618bool ExternalAppHandler::isPagerAppAvailable() 618bool ExternalAppHandler::isPagerAppAvailable()
619{ 619{
620#ifndef DESKTOP_VERSION 620#ifndef DESKTOP_VERSION
621 if (mPagerAppAvailable == UNDEFINED) 621 if (mPagerAppAvailable == UNDEFINED)
622 { 622 {
623 int client = KPimGlobalPrefs::instance()->mPagerClient; 623 int client = KPimGlobalPrefs::instance()->mPagerClient;
624 if (client == KPimGlobalPrefs::NONE_PAC) 624 if (client == KPimGlobalPrefs::NONE_PAC)
625 mPagerAppAvailable = UNAVAILABLE; 625 mPagerAppAvailable = UNAVAILABLE;
626 else 626 else
627 mPagerAppAvailable = AVAILABLE; 627 mPagerAppAvailable = AVAILABLE;
628 } 628 }
629 629
630 return (mPagerAppAvailable == AVAILABLE); 630 return (mPagerAppAvailable == AVAILABLE);
631#else //DESKTOP_VERSION 631#else //DESKTOP_VERSION
632 return false; 632 return false;
633#endif //DESKTOP_VERSION 633#endif //DESKTOP_VERSION
634} 634}
635 635
636 636
637bool ExternalAppHandler::isSIPAppAvailable() 637bool ExternalAppHandler::isSIPAppAvailable()
638{ 638{
639#ifndef DESKTOP_VERSION 639#ifndef DESKTOP_VERSION
640 if (mSIPAppAvailable == UNDEFINED) 640 if (mSIPAppAvailable == UNDEFINED)
641 { 641 {
642 int client = KPimGlobalPrefs::instance()->mSipClient; 642 int client = KPimGlobalPrefs::instance()->mSipClient;
643 if (client == KPimGlobalPrefs::NONE_SIC) 643 if (client == KPimGlobalPrefs::NONE_SIC)
644 mSIPAppAvailable = UNAVAILABLE; 644 mSIPAppAvailable = UNAVAILABLE;
645 else 645 else
646 mSIPAppAvailable = AVAILABLE; 646 mSIPAppAvailable = AVAILABLE;
647 } 647 }
648 648
649 return (mSIPAppAvailable == AVAILABLE); 649 return (mSIPAppAvailable == AVAILABLE);
650#else //DESKTOP_VERSION 650#else //DESKTOP_VERSION
651 return false; 651 return false;
652#endif //DESKTOP_VERSION 652#endif //DESKTOP_VERSION
653} 653}
654 654
655/************************************************************************** 655/**************************************************************************
656 * 656 *
657 **************************************************************************/ 657 **************************************************************************/
658 658
659 659
660//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) 660//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma)
661bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) 661bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls )
662{ 662{
663 663
664#ifndef DESKTOP_VERSION 664#ifndef DESKTOP_VERSION
665 QString channel; 665 QString channel;
666 QString message2; 666 QString message2;
667 QString parameters2; 667 QString parameters2;
668 668
669 669
670 int client = KPimGlobalPrefs::instance()->mEmailClient; 670 int client = KPimGlobalPrefs::instance()->mEmailClient;
671 if (client == KPimGlobalPrefs::OTHER_EMC) 671 if (client == KPimGlobalPrefs::OTHER_EMC)
672 { 672 {
673 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 673 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
674 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; 674 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage;
675 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 675 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
676 } 676 }
677 else 677 else
678 { 678 {
679 DefaultAppItem* dai = getDefaultItem(EMAIL, client); 679 DefaultAppItem* dai = getDefaultItem(EMAIL, client);
680 if (!dai) 680 if (!dai)
681 { 681 {
682 qDebug("could not find configured email application."); 682 qDebug("could not find configured email application.");
683 return false; 683 return false;
684 } 684 }
685 channel = dai->_channel; 685 channel = dai->_channel;
686 message2 = dai->_message2; 686 message2 = dai->_message2;
687 parameters2 = dai->_parameters2; 687 parameters2 = dai->_parameters2;
688 } 688 }
689 689
690 //first check if one of the mailers need the emails right in the message. 690 //first check if one of the mailers need the emails right in the message.
691 message2 = translateMessage(message2, emails, urls); 691 message2 = translateMessage(message2, emails, urls);
692 692
693 693
694#ifdef DEBUG_EXT_APP_HANDLER 694#ifdef DEBUG_EXT_APP_HANDLER
695 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); 695 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
696 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); 696 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
697#endif 697#endif
698 698
699 699
700 QCopEnvelope e(channel.latin1(), message2.latin1()); 700 QCopEnvelope e(channel.latin1(), message2.latin1());
701 //US we need no names in the To field. The emailadresses are enough 701 //US we need no names in the To field. The emailadresses are enough
702 702
703 passParameters(&e, parameters2, emails, urls); 703 passParameters(&e, parameters2, emails, urls);
704 704
705 705
706 706
707#else 707#else
708 //qDebug("mtmc %s %s ", emails.latin1(), urls.latin1()); 708 //qDebug("mtmc %s %s ", emails.latin1(), urls.latin1());
709 709
710 QString channel; 710 QString channel;
711 QString message2; 711 QString message2;
712 QString parameters2; 712 QString parameters2;
713 QString message; 713 QString message;
714 QString parameters; 714 QString parameters;
715 715
716 716
717 int client = KPimGlobalPrefs::instance()->mEmailClient; 717 int client = KPimGlobalPrefs::instance()->mEmailClient;
718 if (client == KPimGlobalPrefs::OTHER_EMC) 718 if (client == KPimGlobalPrefs::OTHER_EMC)
719 { 719 {
720 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 720 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
721 message = KPimGlobalPrefs::instance()->mEmailOtherMessage; 721 message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
722 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage2; 722 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage2;
723 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 723 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
724 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters2; 724 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters2;
725 } 725 }
726 else 726 else
727 { 727 {
728 DefaultAppItem* dai = getDefaultItem(EMAIL, client); 728 DefaultAppItem* dai = getDefaultItem(EMAIL, client);
729 if (!dai) 729 if (!dai)
730 { 730 {
731 qDebug("could not find configured email application."); 731 qDebug("could not find configured email application.");
732 return false; 732 return false;
733 } 733 }
734 channel = dai->_channel; 734 channel = dai->_channel;
735 message2 = dai->_message2; 735 message2 = dai->_message2;
736 parameters2 = dai->_parameters2; 736 parameters2 = dai->_parameters2;
737 message = dai->_message; 737 message = dai->_message;
738 parameters = dai->_parameters; 738 parameters = dai->_parameters;
739 } 739 }
740 740
741 //first check if one of the mailers need the emails right in the message. 741 //first check if one of the mailers need the emails right in the message.
742 message2 = translateMessage(message2, emails, urls); 742 message2 = translateMessage(message2, emails, urls);
743#ifdef DEBUG_EXT_APP_HANDLER 743#ifdef DEBUG_EXT_APP_HANDLER
744 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); 744 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
745 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); 745 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
746#endif 746#endif
747 qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() ); 747 qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() );
748 //KMessageBox::sorry( 0, message2 ); 748 //KMessageBox::sorry( 0, message2 );
749 QProcess * proc = new QProcess( this ); 749 QProcess * proc = new QProcess( this );
750 int i = 0; 750 int i = 0;
751 proc->addArgument( channel ); 751 proc->addArgument( channel );
752 752
753 if ( message.find (" " ) > 0 ) { 753 if ( message.find (" " ) > 0 ) {
754 QStringList list = QStringList::split( " ", message ); 754 QStringList list = QStringList::split( " ", message );
755 int i = 0; 755 int i = 0;
756 while ( i < list.count ( ) ) { 756 while ( i < list.count ( ) ) {
757 //qDebug("add%sdd ",list[i].latin1() ); 757 //qDebug("add%sdd ",list[i].latin1() );
758 proc->addArgument( list[i] ); 758 proc->addArgument( list[i] );
759 //KMessageBox::sorry( 0,list[i]); 759 //KMessageBox::sorry( 0,list[i]);
760 ++i; 760 ++i;
761 } 761 }
762 } else { 762 } else {
763 proc->addArgument(message ); 763 proc->addArgument(message );
764 //KMessageBox::sorry( 0, message ); 764 //KMessageBox::sorry( 0, message );
765 765
766 } 766 }
767 767
768 parameters2 = translateMessage(parameters2, urls, "" ); 768 parameters2 = translateMessage(parameters2, urls, "" );
769 QString arg = "to='%1'"; 769 QString arg = "to='%1'";
770 arg = arg.arg( emails ) + ","+parameters2;; 770 arg = arg.arg( emails ) + ","+parameters2;;
771 771
772 //KMessageBox::sorry( 0,arg ); 772 //KMessageBox::sorry( 0,arg );
773 //qDebug("2add%sdd ",arg.latin1() ); 773 //qDebug("2add%sdd ",arg.latin1() );
774 proc->addArgument( arg); 774 proc->addArgument( arg);
775 proc->launch(""); 775 proc->launch("");
776#endif 776#endif
777 777
778 return true; 778 return true;
779} 779}
780 780
781/************************************************************************** 781/**************************************************************************
782 * 782 *
783 **************************************************************************/ 783 **************************************************************************/
784 784
785 785
786//calls the emailapplication and creates a mail with parameter emails as recipients 786//calls the emailapplication and creates a mail with parameter emails as recipients
787bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) 787bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress )
788{ 788{
789 789
790 QString channel; 790 QString channel;
791 QString message; 791 QString message;
792 QString parameters; 792 QString parameters;
793 793
794 794
795 int client = KPimGlobalPrefs::instance()->mEmailClient; 795 int client = KPimGlobalPrefs::instance()->mEmailClient;
796 if (client == KPimGlobalPrefs::OTHER_EMC) 796 if (client == KPimGlobalPrefs::OTHER_EMC)
797 { 797 {
798 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 798 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
799 message = KPimGlobalPrefs::instance()->mEmailOtherMessage; 799 message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
800 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 800 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
801 } 801 }
802 else 802 else
803 { 803 {
804 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); 804 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client);
805 if (!dai) 805 if (!dai)
806 { 806 {
807 qDebug("could not find configured email application."); 807 qDebug("could not find configured email application.");
808 return false; 808 return false;
809 } 809 }
810 channel = dai->_channel; 810 channel = dai->_channel;
811 message = dai->_message; 811 message = dai->_message;
812 parameters = dai->_parameters; 812 parameters = dai->_parameters;
813 } 813 }
814 814
815#ifdef DESKTOP_VERSION 815#ifdef DESKTOP_VERSION
816 //message = channel + " " +message + " \""+ parameters + "\""; 816 //message = channel + " " +message + " \""+ parameters + "\"";
817#endif 817#endif
818 //first check if one of the mailers need the emails right in the message. 818 //first check if one of the mailers need the emails right in the message.
819 message = translateMessage(message, name, emailadress); 819 message = translateMessage(message, name, emailadress);
820 820
821#ifdef DEBUG_EXT_APP_HANDLER 821#ifdef DEBUG_EXT_APP_HANDLER
822 qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 822 qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
823 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); 823 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1());
824#endif 824#endif
825 825
826#ifndef DESKTOP_VERSION 826#ifndef DESKTOP_VERSION
827 QCopEnvelope e(channel.latin1(), message.latin1()); 827 QCopEnvelope e(channel.latin1(), message.latin1());
828 //US we need no names in the To field. The emailadresses are enough 828 //US we need no names in the To field. The emailadresses are enough
829 829
830 passParameters(&e, parameters, name, emailadress); 830 passParameters(&e, parameters, name, emailadress);
831#else // DESKTOP_VERSION 831#else // DESKTOP_VERSION
832 832
833 //KMessageBox::sorry( 0,channel ); 833 //KMessageBox::sorry( 0,channel );
834 QProcess * proc = new QProcess( this ); 834 QProcess * proc = new QProcess( this );
835 proc->addArgument( channel ); 835 proc->addArgument( channel );
836 if ( message.find (" " ) > 0 ) { 836 if ( message.find (" " ) > 0 ) {
837 QStringList list = QStringList::split( " ", message ); 837 QStringList list = QStringList::split( " ", message );
838 int i = 0; 838 int i = 0;
839 while ( i < list.count ( ) ) { 839 while ( i < list.count ( ) ) {
840 //qDebug("add%sdd ",list[i].latin1() ); 840 //qDebug("add%sdd ",list[i].latin1() );
841 proc->addArgument( list[i] ); 841 proc->addArgument( list[i] );
842 //KMessageBox::sorry( 0,list[i]); 842 //KMessageBox::sorry( 0,list[i]);
843 ++i; 843 ++i;
844 } 844 }
845 } else { 845 } else {
846 proc->addArgument(message ); 846 proc->addArgument(message );
847 847
848 } 848 }
849 parameters = translateMessage(parameters, name, emailadress); 849 parameters = translateMessage(parameters, name, emailadress);
850
851 //KMessageBox::information(0,parameters);
850 proc->addArgument( parameters ); 852 proc->addArgument( parameters );
851 proc->launch(""); 853 proc->launch("");
852#endif 854#endif
853 855
854 return true; 856 return true;
855} 857}
856 858
857/************************************************************************** 859/**************************************************************************
858 * 860 *
859 **************************************************************************/ 861 **************************************************************************/
860 862
861//calls the emailapplication and creates a mail with parameter as recipients 863//calls the emailapplication and creates a mail with parameter as recipients
862// parameters format is 864// parameters format is
863// NAME <EMAIL>:SUBJECT 865// NAME <EMAIL>:SUBJECT
864bool ExternalAppHandler::mailToOneContact( const QString& adressline ) 866bool ExternalAppHandler::mailToOneContact( const QString& adressline )
865{ 867{
866 QString line = adressline; 868 QString line = adressline;
867 869
868 int first = line.find( "<"); 870 int first = line.find( "<");
869 int last = line.find( ">"); 871 int last = line.find( ">");
870 QString name = line.left(first); 872 QString name = line.left(first);
871 QString emailadress = line.mid(first+1, last-first-1); 873 QString emailadress = line.mid(first+1, last-first-1);
872 874
873 //Subject can not be handled right now. 875 //Subject can not be handled right now.
874 return mailToOneContact( name, emailadress ); 876 return mailToOneContact( name, emailadress );
875 877
876} 878}
877 879
878 880
879/************************************************************************** 881/**************************************************************************
880 * 882 *
881 **************************************************************************/ 883 **************************************************************************/
882 884
883//calls the phoneapplication with the number 885//calls the phoneapplication with the number
884bool ExternalAppHandler::callByPhone( const QString& phonenumber ) 886bool ExternalAppHandler::callByPhone( const QString& phonenumber )
885{ 887{
886#ifndef DESKTOP_VERSION 888#ifndef DESKTOP_VERSION
887 QString channel; 889 QString channel;
888 QString message; 890 QString message;
889 QString parameters; 891 QString parameters;
890 892
891 893
892 int client = KPimGlobalPrefs::instance()->mPhoneClient; 894 int client = KPimGlobalPrefs::instance()->mPhoneClient;
893 if (client == KPimGlobalPrefs::OTHER_PHC) 895 if (client == KPimGlobalPrefs::OTHER_PHC)
894 { 896 {
895 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; 897 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel;
896 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; 898 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage;
897 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; 899 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters;
898 } 900 }
899 else 901 else
900 { 902 {
901 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); 903 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client);
902 if (!dai) 904 if (!dai)
903 { 905 {
904 qDebug("could not find configured phone application."); 906 qDebug("could not find configured phone application.");
905 return false; 907 return false;
906 } 908 }
907 channel = dai->_channel; 909 channel = dai->_channel;
908 message = dai->_message; 910 message = dai->_message;
909 parameters = dai->_parameters; 911 parameters = dai->_parameters;
910 } 912 }
911 913
912 914
913 //first check if one of the mailers need the emails right in the message. 915 //first check if one of the mailers need the emails right in the message.
914 message = translateMessage(message, phonenumber, ""); 916 message = translateMessage(message, phonenumber, "");
915 917
916 918
917#ifdef DEBUG_EXT_APP_HANDLER 919#ifdef DEBUG_EXT_APP_HANDLER
918 qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 920 qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
919 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 921 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
920#endif 922#endif
921 923
922 QCopEnvelope e(channel.latin1(), message.latin1()); 924 QCopEnvelope e(channel.latin1(), message.latin1());
923 //US we need no names in the To field. The emailadresses are enough 925 //US we need no names in the To field. The emailadresses are enough
924 926
925 passParameters(&e, parameters, phonenumber, ""); 927 passParameters(&e, parameters, phonenumber, "");
926 928
927 929
928#else 930#else
929 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); 931 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) );
930#endif 932#endif
931 933
932 934
933 return true; 935 return true;
934} 936}
935 937
936/************************************************************************** 938/**************************************************************************
937 * 939 *
938 **************************************************************************/ 940 **************************************************************************/
939 941
940//calls the smsapplication with the number 942//calls the smsapplication with the number
941bool ExternalAppHandler::callBySMS( const QString& phonenumber ) 943bool ExternalAppHandler::callBySMS( const QString& phonenumber )
942{ 944{
943#ifndef DESKTOP_VERSION 945#ifndef DESKTOP_VERSION
944 QString channel; 946 QString channel;
945 QString message; 947 QString message;
946 QString parameters; 948 QString parameters;
947 949
948 950
949 int client = KPimGlobalPrefs::instance()->mSMSClient; 951 int client = KPimGlobalPrefs::instance()->mSMSClient;
950 if (client == KPimGlobalPrefs::OTHER_SMC) 952 if (client == KPimGlobalPrefs::OTHER_SMC)
951 { 953 {
952 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; 954 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel;
953 message = KPimGlobalPrefs::instance()->mSMSOtherMessage; 955 message = KPimGlobalPrefs::instance()->mSMSOtherMessage;
954 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; 956 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters;
955 } 957 }
956 else 958 else
957 { 959 {
958 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); 960 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client);
959 if (!dai) 961 if (!dai)
960 { 962 {
961 qDebug("could not find configured sms application."); 963 qDebug("could not find configured sms application.");
962 return false; 964 return false;
963 } 965 }
964 channel = dai->_channel; 966 channel = dai->_channel;
965 message = dai->_message; 967 message = dai->_message;
966 parameters = dai->_parameters; 968 parameters = dai->_parameters;
967 } 969 }
968 970
969 971
970 //first check if one of the mailers need the emails right in the message. 972 //first check if one of the mailers need the emails right in the message.
971 message = translateMessage(message, phonenumber, ""); 973 message = translateMessage(message, phonenumber, "");
972 974
973 975
974#ifdef DEBUG_EXT_APP_HANDLER 976#ifdef DEBUG_EXT_APP_HANDLER
975 qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 977 qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
976 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 978 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
977#endif 979#endif
978 980
979 QCopEnvelope e(channel.latin1(), message.latin1()); 981 QCopEnvelope e(channel.latin1(), message.latin1());
980 //US we need no names in the To field. The emailadresses are enough 982 //US we need no names in the To field. The emailadresses are enough
981 983
982 passParameters(&e, parameters, phonenumber, ""); 984 passParameters(&e, parameters, phonenumber, "");
983 985
984 986
985#else 987#else
986 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); 988 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) );
987#endif 989#endif
988 990
989 991
990 return true; 992 return true;
991} 993}
992 994
993/************************************************************************** 995/**************************************************************************
994 * 996 *
995 **************************************************************************/ 997 **************************************************************************/
996 998
997//calls the pagerapplication with the number 999//calls the pagerapplication with the number
998bool ExternalAppHandler::callByPager( const QString& pagernumber ) 1000bool ExternalAppHandler::callByPager( const QString& pagernumber )
999{ 1001{
1000#ifndef DESKTOP_VERSION 1002#ifndef DESKTOP_VERSION
1001 QString channel; 1003 QString channel;
1002 QString message; 1004 QString message;
1003 QString parameters; 1005 QString parameters;
1004 1006
1005 1007
1006 int client = KPimGlobalPrefs::instance()->mPagerClient; 1008 int client = KPimGlobalPrefs::instance()->mPagerClient;
1007 if (client == KPimGlobalPrefs::OTHER_PAC) 1009 if (client == KPimGlobalPrefs::OTHER_PAC)
1008 { 1010 {
1009 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; 1011 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel;
1010 message = KPimGlobalPrefs::instance()->mPagerOtherMessage; 1012 message = KPimGlobalPrefs::instance()->mPagerOtherMessage;
1011 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; 1013 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters;
1012 } 1014 }
1013 else 1015 else
1014 { 1016 {
1015 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); 1017 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client);
1016 if (!dai) 1018 if (!dai)
1017 { 1019 {
1018 qDebug("could not find configured pager application."); 1020 qDebug("could not find configured pager application.");
1019 return false; 1021 return false;
1020 } 1022 }
1021 channel = dai->_channel; 1023 channel = dai->_channel;
1022 message = dai->_message; 1024 message = dai->_message;
1023 parameters = dai->_parameters; 1025 parameters = dai->_parameters;
1024 } 1026 }
1025 1027
1026 1028
1027 //first check if one of the mailers need the emails right in the message. 1029 //first check if one of the mailers need the emails right in the message.
1028 message = translateMessage(message, pagernumber, ""); 1030 message = translateMessage(message, pagernumber, "");
1029 1031
1030 1032
1031#ifdef DEBUG_EXT_APP_HANDLER 1033#ifdef DEBUG_EXT_APP_HANDLER
1032 qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 1034 qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
1033 qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); 1035 qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1());
1034#endif 1036#endif
1035 1037
1036 QCopEnvelope e(channel.latin1(), message.latin1()); 1038 QCopEnvelope e(channel.latin1(), message.latin1());
1037 //US we need no names in the To field. The emailadresses are enough 1039 //US we need no names in the To field. The emailadresses are enough
1038 1040
1039 passParameters(&e, parameters, pagernumber, ""); 1041 passParameters(&e, parameters, pagernumber, "");
1040 1042
1041 1043
1042#else 1044#else
1043 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); 1045 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) );
1044#endif 1046#endif
1045 1047
1046 1048
1047 return true; 1049 return true;
1048} 1050}
1049 1051
1050/************************************************************************** 1052/**************************************************************************
1051 * 1053 *
1052 **************************************************************************/ 1054 **************************************************************************/
1053 1055
1054//calls the faxapplication with the number 1056//calls the faxapplication with the number
1055bool ExternalAppHandler::callByFax( const QString& faxnumber ) 1057bool ExternalAppHandler::callByFax( const QString& faxnumber )
1056{ 1058{
1057#ifndef DESKTOP_VERSION 1059#ifndef DESKTOP_VERSION
1058 QString channel; 1060 QString channel;
1059 QString message; 1061 QString message;
1060 QString parameters; 1062 QString parameters;
1061 1063
1062 1064
1063 int client = KPimGlobalPrefs::instance()->mFaxClient; 1065 int client = KPimGlobalPrefs::instance()->mFaxClient;
1064 if (client == KPimGlobalPrefs::OTHER_FAC) 1066 if (client == KPimGlobalPrefs::OTHER_FAC)
1065 { 1067 {
1066 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; 1068 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel;
1067 message = KPimGlobalPrefs::instance()->mFaxOtherMessage; 1069 message = KPimGlobalPrefs::instance()->mFaxOtherMessage;
1068 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; 1070 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters;
1069 } 1071 }
1070 else 1072 else
1071 { 1073 {
1072 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); 1074 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client);
1073 if (!dai) 1075 if (!dai)
1074 { 1076 {
1075 qDebug("could not find configured fax application."); 1077 qDebug("could not find configured fax application.");
1076 return false; 1078 return false;
1077 } 1079 }
1078 channel = dai->_channel; 1080 channel = dai->_channel;
1079 message = dai->_message; 1081 message = dai->_message;
1080 parameters = dai->_parameters; 1082 parameters = dai->_parameters;
1081 } 1083 }
1082 1084
1083 1085
1084 //first check if one of the mailers need the emails right in the message. 1086 //first check if one of the mailers need the emails right in the message.
1085 message = translateMessage(message, faxnumber, ""); 1087 message = translateMessage(message, faxnumber, "");
1086 1088
1087 1089
1088#ifdef DEBUG_EXT_APP_HANDLER 1090#ifdef DEBUG_EXT_APP_HANDLER
1089 qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 1091 qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
1090 qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); 1092 qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1());
1091#endif 1093#endif
1092 1094
1093 QCopEnvelope e(channel.latin1(), message.latin1()); 1095 QCopEnvelope e(channel.latin1(), message.latin1());
1094 //US we need no names in the To field. The emailadresses are enough 1096 //US we need no names in the To field. The emailadresses are enough
1095 1097
1096 passParameters(&e, parameters, faxnumber, ""); 1098 passParameters(&e, parameters, faxnumber, "");
1097 1099
1098 1100
1099#else 1101#else
1100 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); 1102 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) );
1101#endif 1103#endif
1102 1104
1103 1105
1104 return true; 1106 return true;
1105} 1107}
1106 1108
1107/************************************************************************** 1109/**************************************************************************
1108 * 1110 *
1109 **************************************************************************/ 1111 **************************************************************************/
1110 1112
1111//calls the sipapplication with the number 1113//calls the sipapplication with the number
1112bool ExternalAppHandler::callBySIP( const QString& sipnumber ) 1114bool ExternalAppHandler::callBySIP( const QString& sipnumber )
1113{ 1115{
1114#ifndef DESKTOP_VERSION 1116#ifndef DESKTOP_VERSION
1115 QString channel; 1117 QString channel;
1116 QString message; 1118 QString message;
1117 QString parameters; 1119 QString parameters;
1118 1120
1119 1121
1120 int client = KPimGlobalPrefs::instance()->mSipClient; 1122 int client = KPimGlobalPrefs::instance()->mSipClient;
1121 if (client == KPimGlobalPrefs::OTHER_SIC) 1123 if (client == KPimGlobalPrefs::OTHER_SIC)
1122 { 1124 {
1123 channel = KPimGlobalPrefs::instance()->mSipOtherChannel; 1125 channel = KPimGlobalPrefs::instance()->mSipOtherChannel;
1124 message = KPimGlobalPrefs::instance()->mSipOtherMessage; 1126 message = KPimGlobalPrefs::instance()->mSipOtherMessage;
1125 parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters; 1127 parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters;
1126 } 1128 }
1127 else 1129 else
1128 { 1130 {
1129 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client); 1131 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client);
1130 if (!dai) 1132 if (!dai)
1131 { 1133 {
1132 qDebug("could not find configured sip application."); 1134 qDebug("could not find configured sip application.");
1133 return false; 1135 return false;
1134 } 1136 }
1135 channel = dai->_channel; 1137 channel = dai->_channel;
1136 message = dai->_message; 1138 message = dai->_message;
1137 parameters = dai->_parameters; 1139 parameters = dai->_parameters;
1138 } 1140 }
1139 1141
1140 1142
1141 //first check if one of the sip apps need the emails right in the message. 1143 //first check if one of the sip apps need the emails right in the message.
1142 message = translateMessage(message, sipnumber, ""); 1144 message = translateMessage(message, sipnumber, "");
1143 1145
1144 1146
1145#ifdef DEBUG_EXT_APP_HANDLER 1147#ifdef DEBUG_EXT_APP_HANDLER
1146 qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 1148 qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
1147 qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1()); 1149 qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1());
1148#endif 1150#endif
1149 1151
1150 QCopEnvelope e(channel.latin1(), message.latin1()); 1152 QCopEnvelope e(channel.latin1(), message.latin1());
1151 //US we need no names in the To field. The emailadresses are enough 1153 //US we need no names in the To field. The emailadresses are enough
1152 1154
1153 passParameters(&e, parameters, sipnumber, ""); 1155 passParameters(&e, parameters, sipnumber, "");
1154 1156
1155 1157
1156#else 1158#else
1157 KMessageBox::sorry( 0, i18n( "This version does not support sip." ) ); 1159 KMessageBox::sorry( 0, i18n( "This version does not support sip." ) );
1158#endif 1160#endif
1159 1161
1160 1162
1161 return true; 1163 return true;
1162} 1164}
1163 1165
1164 1166
1165/************************************************************************** 1167/**************************************************************************
1166 * 1168 *
1167 **************************************************************************/ 1169 **************************************************************************/
1168 1170
1169 1171
1170QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const 1172QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const
1171{ 1173{
1172 message = message.replace( QRegExp("%1"), param1 ); 1174 message = message.replace( QRegExp("%1"), param1 );
1173 return message.replace( QRegExp("%2"), param2 ); 1175 return message.replace( QRegExp("%2"), param2 );
1174} 1176}
1175 1177
1176/************************************************************************** 1178/**************************************************************************
1177 * 1179 *
1178 **************************************************************************/ 1180 **************************************************************************/
1179 1181
1180void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const 1182void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const
1181{ 1183{
1182#ifndef DESKTOP_VERSION 1184#ifndef DESKTOP_VERSION
1183 QMap<QString, QString> valmap; 1185 QMap<QString, QString> valmap;
1184 bool useValMap = false; 1186 bool useValMap = false;
1185 1187
1186 // first extract all parts of the parameters. 1188 // first extract all parts of the parameters.
1187 QStringList paramlist = QStringList::split(";", parameters); 1189 QStringList paramlist = QStringList::split(";", parameters);
1188 1190
1189 //Now check how many parts we have. 1191 //Now check how many parts we have.
1190 //=0 :no params to pass 1192 //=0 :no params to pass
1191 //>0 :parameters to pass 1193 //>0 :parameters to pass
1192 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) 1194 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it )
1193 { 1195 {
1194 QString param = (*it); 1196 QString param = (*it);
1195 QStringList keyvallist = QStringList::split("=", param); 1197 QStringList keyvallist = QStringList::split("=", param);
1196 1198
1197 //if we have keyvalue pairs, we assume that we pass a map to the envelope 1199 //if we have keyvalue pairs, we assume that we pass a map to the envelope
1198 QStringList::Iterator it2 = keyvallist.begin(); 1200 QStringList::Iterator it2 = keyvallist.begin();
1199 QString key = (*it2); 1201 QString key = (*it2);
1200 key = key.replace( QRegExp("%1"), param1 ); 1202 key = key.replace( QRegExp("%1"), param1 );
1201 key = key.replace( QRegExp("%2"), param2 ); 1203 key = key.replace( QRegExp("%2"), param2 );
1202 ++it2; 1204 ++it2;
1203 1205
1204 if(it2 != keyvallist.end()) 1206 if(it2 != keyvallist.end())
1205 { 1207 {
1206 QString value = (*it2); 1208 QString value = (*it2);
1207 value = value.replace( QRegExp("%1"), param1 ); 1209 value = value.replace( QRegExp("%1"), param1 );
1208 value = value.replace( QRegExp("%2"), param2 ); 1210 value = value.replace( QRegExp("%2"), param2 );
1209 1211
1210 valmap.insert(key, value); 1212 valmap.insert(key, value);
1211 useValMap = true; 1213 useValMap = true;
1212 } 1214 }
1213 else 1215 else
1214 { 1216 {
1215 // qDebug("pass parameter << %s", key.latin1()); 1217 // qDebug("pass parameter << %s", key.latin1());
1216 (*e) << key; 1218 (*e) << key;
1217 } 1219 }
1218 } 1220 }
1219 1221
1220 if (useValMap == true) 1222 if (useValMap == true)
1221 (*e) << valmap; 1223 (*e) << valmap;
1222 1224
1223#endif 1225#endif
1224 1226
1225} 1227}
1226 1228
1227 1229
1228 1230
1229/************************************************************************** 1231/**************************************************************************
1230 * 1232 *
1231 **************************************************************************/ 1233 **************************************************************************/
1232 1234
1233void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) 1235void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data )
1234{ 1236{
1235 qDebug("ExternalAppHandler::appMessage %s %x", cmsg.data(), this); 1237 qDebug("ExternalAppHandler::appMessage %s %x", cmsg.data(), this);
1236 if ( cmsg == "nextView()" ) { 1238 if ( cmsg == "nextView()" ) {
1237 qDebug("nextView()"); 1239 qDebug("nextView()");
1238 QTimer::singleShot( 0, this, SIGNAL ( nextView() )); 1240 QTimer::singleShot( 0, this, SIGNAL ( nextView() ));
1239 return; 1241 return;
1240 } 1242 }
1241 if ( cmsg == "callContactdialog()" ) { 1243 if ( cmsg == "callContactdialog()" ) {
1242 qDebug("callContactdialog()"); 1244 qDebug("callContactdialog()");
1243 QTimer::singleShot( 0, this, SIGNAL ( callContactdialog() )); 1245 QTimer::singleShot( 0, this, SIGNAL ( callContactdialog() ));
1244 return; 1246 return;
1245 } 1247 }
1246 if ( cmsg == "doRingSync" ) { 1248 if ( cmsg == "doRingSync" ) {
1247 qDebug("doRingSync"); 1249 qDebug("doRingSync");
1248 QTimer::singleShot( 0, this, SIGNAL ( doRingSync() )); 1250 QTimer::singleShot( 0, this, SIGNAL ( doRingSync() ));
1249 return; 1251 return;
1250 } 1252 }
1251 1253
1252 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); 1254 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
1253 if (!res) 1255 if (!res)
1254 res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data ); 1256 res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data );
1255 1257
1256 if (!res) 1258 if (!res)
1257 res = mDisplayDetails->appMessage( cmsg, data ); 1259 res = mDisplayDetails->appMessage( cmsg, data );
1258 1260
1259// if (!res) 1261// if (!res)
1260// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); 1262// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
1261} 1263}
1262 1264
1263 1265
1264 1266
1265bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) 1267bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid)
1266{ 1268{
1267 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); 1269 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
1268 // maybe we are sending to KA/Pi fom a different worldd... 1270 // maybe we are sending to KA/Pi fom a different worldd...
1269 // it may be that the QAplication::desktop()->width() values in KA/Pi are not the same as in our application 1271 // it may be that the QAplication::desktop()->width() values in KA/Pi are not the same as in our application
1270 // for that reason we send the current QApplication::desktop()->width() to KA/Pi 1272 // for that reason we send the current QApplication::desktop()->width() to KA/Pi
1271 //qDebug("UID %s ", sessionuid.latin1()); 1273 //qDebug("UID %s ", sessionuid.latin1());
1272 //return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(QString::number ( QApplication::desktop()->width() )); 1274 //return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(QString::number ( QApplication::desktop()->width() ));
1273 return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); 1275 return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid);
1274} 1276}
1275 1277
1276bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 1278bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
1277{ 1279{
1278 QStringList list4, list5, list6; 1280 QStringList list4, list5, list6;
1279 1281
1280 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); 1282 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
1281 return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1283 return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1282} 1284}
1283 1285
1284bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) 1286bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email)
1285{ 1287{
1286 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); 1288 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
1287 return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); 1289 return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email);
1288} 1290}
1289 1291
1290bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 1292bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
1291{ 1293{
1292 QStringList list4, list5, list6; 1294 QStringList list4, list5, list6;
1293 1295
1294 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); 1296 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
1295 return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1297 return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1296} 1298}
1297 1299
1298bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) 1300bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid)
1299{ 1301{
1300 mDisplayDetails->setSourceChannel(""); 1302 mDisplayDetails->setSourceChannel("");
1301 return mDisplayDetails->sendMessageToTarget("", name, email, uid); 1303 return mDisplayDetails->sendMessageToTarget("", name, email, uid);
1302} 1304}
1303 1305
1304bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid) 1306bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid)
1305{ 1307{
1306 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); 1308 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel);
1307 return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid); 1309 return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid);
1308} 1310}
1309 1311
1310bool ExternalAppHandler::returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) 1312bool ExternalAppHandler::returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6)
1311{ 1313{
1312 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); 1314 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel);
1313 return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1315 return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1314} 1316}
1315 1317
1316 1318
1317 1319
1318 1320
1319 1321
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index b7929ec..5708dfc 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,1816 +1,1883 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21// $Id$ 21// $Id$
22 22
23#include "ksyncmanager.h" 23#include "ksyncmanager.h"
24 24
25#include <stdlib.h> 25#include <stdlib.h>
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#include <unistd.h> 28#include <unistd.h>
29#endif 29#endif
30 30
31 31
32#include "ksyncprofile.h" 32#include "ksyncprofile.h"
33#include "ksyncprefsdialog.h" 33#include "ksyncprefsdialog.h"
34#include "kpimprefs.h" 34#include "kpimprefs.h"
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <qdir.h> 37#include <qdir.h>
38#include <qprogressbar.h> 38#include <qprogressbar.h>
39#include <qpopupmenu.h> 39#include <qpopupmenu.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qradiobutton.h> 41#include <qradiobutton.h>
42#include <qbuttongroup.h> 42#include <qbuttongroup.h>
43#include <qtimer.h> 43#include <qtimer.h>
44#include <qmessagebox.h> 44#include <qmessagebox.h>
45#include <qapplication.h> 45#include <qapplication.h>
46#include <qlineedit.h> 46#include <qlineedit.h>
47#include <qdialog.h> 47#include <qdialog.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qtextcodec.h> 49#include <qtextcodec.h>
50#include <qlabel.h> 50#include <qlabel.h>
51#include <qcheckbox.h> 51#include <qcheckbox.h>
52#include <qapplication.h> 52#include <qapplication.h>
53 53
54#include <klocale.h> 54#include <klocale.h>
55#include <kglobal.h> 55#include <kglobal.h>
56#include <kconfig.h> 56#include <kconfig.h>
57#include <kfiledialog.h> 57#include <kfiledialog.h>
58 58
59QDateTime KSyncManager::mRequestedSyncEvent; 59QDateTime KSyncManager::mRequestedSyncEvent;
60 60
61 61
62KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 62KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
63 : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) 63 : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu)
64{ 64{
65 mServerSocket = 0; 65 mServerSocket = 0;
66 bar = new QProgressBar ( 1, 0 ); 66 bar = new QProgressBar ( 1, 0 );
67 bar->setCaption (""); 67 bar->setCaption ("");
68 mWriteBackInPast = 2; 68 mWriteBackInPast = 2;
69 69
70 70
71} 71}
72 72
73KSyncManager::~KSyncManager() 73KSyncManager::~KSyncManager()
74{ 74{
75 delete bar; 75 delete bar;
76} 76}
77 77
78void KSyncManager::setDefaultFileName( QString s) 78void KSyncManager::setDefaultFileName( QString s)
79{ 79{
80 mDefFileName = s ; 80 mDefFileName = s ;
81 if ( mPrefs->mPassiveSyncAutoStart ) 81 if ( mPrefs->mPassiveSyncAutoStart )
82 enableQuick( false ); 82 enableQuick( false );
83} 83}
84 84
85void KSyncManager::fillSyncMenu() 85void KSyncManager::fillSyncMenu()
86{ 86{
87 if ( mSyncMenu->count() ) 87 if ( mSyncMenu->count() )
88 mSyncMenu->clear(); 88 mSyncMenu->clear();
89 89
90 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 90 mSyncMenu->insertItem( i18n("Configure..."), 0 );
91 mSyncMenu->insertSeparator(); 91 mSyncMenu->insertSeparator();
92 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); 92 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu );
93 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); 93 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 );
94 clearMenu->insertItem( i18n("For all profiles"), 1 ); 94 clearMenu->insertItem( i18n("For all profiles"), 1 );
95 clearMenu->insertSeparator(); 95 clearMenu->insertSeparator();
96 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); 96 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) );
97 mSyncMenu->insertSeparator(); 97 mSyncMenu->insertSeparator();
98 if ( mServerSocket == 0 ) { 98 if ( mServerSocket == 0 ) {
99 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 99 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
100 } else { 100 } else {
101 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 101 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
102 } 102 }
103 mSyncMenu->insertSeparator(); 103 mSyncMenu->insertSeparator();
104 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 104 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
105 mSyncMenu->insertSeparator(); 105 mSyncMenu->insertSeparator();
106 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 106 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
107 config.setGroup("General"); 107 config.setGroup("General");
108 QStringList prof = config.readListEntry("SyncProfileNames"); 108 QStringList prof = config.readListEntry("SyncProfileNames");
109 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 109 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
110 if ( prof.count() < 2 ) { 110 if ( prof.count() < 2 ) {
111 prof.clear(); 111 prof.clear();
112 QString externalName; 112 QString externalName;
113#ifdef DESKTOP_VERSION 113#ifdef DESKTOP_VERSION
114#ifdef _WIN32_ 114#ifdef _WIN32_
115 externalName = "OutLook(not_implemented)"; 115 externalName = "OutLook";
116#else 116#else
117 externalName = "KDE_Desktop"; 117 externalName = "KDE_Desktop";
118#endif 118#endif
119#else 119#else
120 externalName = "Sharp_DTM"; 120 externalName = "Sharp_DTM";
121#endif 121#endif
122 prof << externalName; 122 prof << externalName;
123 prof << i18n("Local_file"); 123 prof << i18n("Local_file");
124 prof << i18n("Last_file"); 124 prof << i18n("Last_file");
125 KSyncProfile* temp = new KSyncProfile (); 125 KSyncProfile* temp = new KSyncProfile ();
126 temp->setName( prof[0] ); 126 temp->setName( prof[0] );
127 temp->writeConfig(&config); 127 temp->writeConfig(&config);
128 temp->setName( prof[1] ); 128 temp->setName( prof[1] );
129 temp->writeConfig(&config); 129 temp->writeConfig(&config);
130 temp->setName( prof[2] ); 130 temp->setName( prof[2] );
131 temp->writeConfig(&config); 131 temp->writeConfig(&config);
132 config.setGroup("General"); 132 config.setGroup("General");
133 config.writeEntry("SyncProfileNames",prof); 133 config.writeEntry("SyncProfileNames",prof);
134 config.writeEntry("ExternSyncProfiles",externalName); 134 config.writeEntry("ExternSyncProfiles",externalName);
135 config.sync(); 135 config.sync();
136 delete temp; 136 delete temp;
137 } 137 }
138 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 138 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
139 mSyncProfileNames = prof; 139 mSyncProfileNames = prof;
140 unsigned int i; 140 unsigned int i;
141 for ( i = 0; i < prof.count(); ++i ) { 141 for ( i = 0; i < prof.count(); ++i ) {
142 QString insertText = prof[i]; 142 QString insertText = prof[i];
143 if ( i == 0 ) { 143 if ( i == 0 ) {
144#ifdef DESKTOP_VERSION 144#ifdef DESKTOP_VERSION
145#ifdef _WIN32_ 145#ifdef _WIN32_
146 insertText = "OutLook(not_implemented)"; 146 insertText = "OutLook";
147#else 147#else
148 insertText = "KDE_Desktop"; 148 insertText = "KDE_Desktop";
149#endif 149#endif
150#else 150#else
151 insertText = "Sharp_DTM"; 151 insertText = "Sharp_DTM";
152#endif 152#endif
153 } 153 }
154 mSyncMenu->insertItem( insertText, 1000+i ); 154 mSyncMenu->insertItem( insertText, 1000+i );
155 clearMenu->insertItem( insertText, 1000+i ); 155 clearMenu->insertItem( insertText, 1000+i );
156 if ( i == 2 ) 156 if ( i == 2 )
157 mSyncMenu->insertSeparator(); 157 mSyncMenu->insertSeparator();
158 } 158 }
159 QDir app_dir; 159 QDir app_dir;
160 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 160 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
161 if ( mTargetApp == PWMPI) { 161 if ( mTargetApp == PWMPI) {
162 mSyncMenu->removeItem( 1000 ); 162 mSyncMenu->removeItem( 1000 );
163 clearMenu->removeItem( 1000 ); 163 clearMenu->removeItem( 1000 );
164 } 164 }
165#ifndef DESKTOP_VERSION 165#ifndef DESKTOP_VERSION
166 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 166 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
167 mSyncMenu->removeItem( 1000 ); 167 mSyncMenu->removeItem( 1000 );
168 clearMenu->removeItem( 1000 ); 168 clearMenu->removeItem( 1000 );
169 } 169 }
170#endif 170#endif
171 mSyncMenu->removeItem( 1002 ); 171 mSyncMenu->removeItem( 1002 );
172 clearMenu->removeItem( 1002 ); 172 clearMenu->removeItem( 1002 );
173} 173}
174void KSyncManager::slotClearMenu( int action ) 174void KSyncManager::slotClearMenu( int action )
175{ 175{
176 QString syncDevice; 176 QString syncDevice;
177 if ( action > 999 ) { 177 if ( action > 999 ) {
178 syncDevice = mSyncProfileNames[action - 1000] ; 178 syncDevice = mSyncProfileNames[action - 1000] ;
179 } 179 }
180 180
181 181
182 182
183 int result = 0; 183 int result = 0;
184 QString sd; 184 QString sd;
185 if ( syncDevice.isEmpty() ) 185 if ( syncDevice.isEmpty() )
186 sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); 186 sd = i18n("Do you want to\nclear all sync info\nof all profiles?");
187 else 187 else
188 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); 188 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice );
189 189
190 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, 190 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0,
191 0, 1 ); 191 0, 1 );
192 if ( result ) 192 if ( result )
193 return; 193 return;
194 mImplementation->removeSyncInfo( syncDevice ); 194 mImplementation->removeSyncInfo( syncDevice );
195} 195}
196void KSyncManager::slotSyncMenu( int action ) 196void KSyncManager::slotSyncMenu( int action )
197{ 197{
198 qDebug("KSM::syncaction %d ", action); 198 qDebug("KSM::syncaction %d ", action);
199 mCurrentResourceLocal = ""; 199 mCurrentResourceLocal = "";
200 emit multiResourceSyncStart( false ); 200 emit multiResourceSyncStart( false );
201 if ( action == 5000 ) 201 if ( action == 5000 )
202 return; 202 return;
203 mSyncWithDesktop = false; 203 mSyncWithDesktop = false;
204 if ( action == 0 ) { 204 if ( action == 0 ) {
205 205
206 // seems to be a Qt2 event handling bug 206 // seems to be a Qt2 event handling bug
207 // syncmenu.clear causes a segfault at first time 207 // syncmenu.clear causes a segfault at first time
208 // when we call it after the main event loop, it is ok 208 // when we call it after the main event loop, it is ok
209 // same behaviour when calling OM/Pi via QCOP for the first time 209 // same behaviour when calling OM/Pi via QCOP for the first time
210 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 210 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
211 //confSync(); 211 //confSync();
212 212
213 return; 213 return;
214 } 214 }
215 if ( action == 1 ) { 215 if ( action == 1 ) {
216 multiSync( true ); 216 multiSync( true );
217 return; 217 return;
218 } 218 }
219 if ( action == 2 ) { 219 if ( action == 2 ) {
220 enableQuick(); 220 enableQuick();
221 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 221 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
222 return; 222 return;
223 } 223 }
224 if ( action == 3 ) { 224 if ( action == 3 ) {
225 delete mServerSocket; 225 delete mServerSocket;
226 mServerSocket = 0; 226 mServerSocket = 0;
227 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 227 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
228 return; 228 return;
229 } 229 }
230 230
231 if (blockSave()) 231 if (blockSave())
232 return; 232 return;
233 233
234 setBlockSave(true); 234 setBlockSave(true);
235 bool silent = false; 235 bool silent = false;
236 if ( action == 999 ) { 236 if ( action == 999 ) {
237 //special mode for silent syncing 237 //special mode for silent syncing
238 action = 1000; 238 action = 1000;
239 silent = true; 239 silent = true;
240 } 240 }
241 241
242 mCurrentSyncProfile = action - 1000 ; 242 mCurrentSyncProfile = action - 1000 ;
243 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 243 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
244 mCurrentSyncName = mLocalMachineName ; 244 mCurrentSyncName = mLocalMachineName ;
245 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 245 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
246 KSyncProfile* temp = new KSyncProfile (); 246 KSyncProfile* temp = new KSyncProfile ();
247 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 247 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
248 temp->readConfig(&config); 248 temp->readConfig(&config);
249 if (silent) { 249 if (silent) {
250 mAskForPreferences = false; 250 mAskForPreferences = false;
251 mShowSyncSummary = false; 251 mShowSyncSummary = false;
252 mWriteBackFile = true; 252 mWriteBackFile = true;
253 mSyncAlgoPrefs = 2;// take newest 253 mSyncAlgoPrefs = 2;// take newest
254 } 254 }
255 else { 255 else {
256 mAskForPreferences = temp->getAskForPreferences(); 256 mAskForPreferences = temp->getAskForPreferences();
257 mShowSyncSummary = temp->getShowSummaryAfterSync(); 257 mShowSyncSummary = temp->getShowSummaryAfterSync();
258 mWriteBackFile = temp->getWriteBackFile(); 258 mWriteBackFile = temp->getWriteBackFile();
259 mSyncAlgoPrefs = temp->getSyncPrefs(); 259 mSyncAlgoPrefs = temp->getSyncPrefs();
260 } 260 }
261 mWriteBackExistingOnly = temp->getWriteBackExisting(); 261 mWriteBackExistingOnly = temp->getWriteBackExisting();
262 mIsKapiFile = temp->getIsKapiFile(); 262 mIsKapiFile = temp->getIsKapiFile();
263 mWriteBackInFuture = 0; 263 mWriteBackInFuture = 0;
264 if ( temp->getWriteBackFuture() ) { 264 if ( temp->getWriteBackFuture() ) {
265 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 265 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
266 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 266 mWriteBackInPast = temp->getWriteBackPastWeeks( );
267 } 267 }
268 mFilterInCal = temp->getFilterInCal(); 268 mFilterInCal = temp->getFilterInCal();
269 mFilterOutCal = temp->getFilterOutCal(); 269 mFilterOutCal = temp->getFilterOutCal();
270 mFilterInAB = temp->getFilterInAB(); 270 mFilterInAB = temp->getFilterInAB();
271 mFilterOutAB = temp->getFilterOutAB(); 271 mFilterOutAB = temp->getFilterOutAB();
272 272
273 if ( action == 1000 ) { 273 if ( action == 1000 ) {
274 mIsKapiFile = false; 274 mIsKapiFile = false;
275#ifdef DESKTOP_VERSION 275#ifdef DESKTOP_VERSION
276 syncKDE(); 276 syncKDE();
277#else 277#else
278 syncSharp(); 278 syncSharp();
279#endif 279#endif
280 280
281 } else if ( action == 1001 ) { 281 } else if ( action == 1001 ) {
282 syncLocalFile(); 282 syncLocalFile();
283 283
284 } else if ( action == 1002 ) { 284 } else if ( action == 1002 ) {
285 mWriteBackFile = false; 285 mWriteBackFile = false;
286 mAskForPreferences = false; 286 mAskForPreferences = false;
287 mShowSyncSummary = false; 287 mShowSyncSummary = false;
288 mSyncAlgoPrefs = 3; 288 mSyncAlgoPrefs = 3;
289 quickSyncLocalFile(); 289 quickSyncLocalFile();
290 290
291 } else if ( action >= 1003 ) { 291 } else if ( action >= 1003 ) {
292 if ( temp->getIsLocalFileSync() ) { 292 if ( temp->getIsLocalFileSync() ) {
293 switch(mTargetApp) 293 switch(mTargetApp)
294 { 294 {
295 case (KAPI): 295 case (KAPI):
296 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 296 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
297 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 297 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
298 break; 298 break;
299 case (KOPI): 299 case (KOPI):
300 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 300 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
301 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 301 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
302 break; 302 break;
303 case (PWMPI): 303 case (PWMPI):
304 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 304 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
305 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 305 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
306 break; 306 break;
307 default: 307 default:
308 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 308 qDebug("KSM::slotSyncMenu: invalid apptype selected");
309 break; 309 break;
310 310
311 } 311 }
312 } else { 312 } else {
313 if ( temp->getIsPhoneSync() ) { 313 if ( temp->getIsPhoneSync() ) {
314 mPhoneDevice = temp->getPhoneDevice( ) ; 314 mPhoneDevice = temp->getPhoneDevice( ) ;
315 mPhoneConnection = temp->getPhoneConnection( ); 315 mPhoneConnection = temp->getPhoneConnection( );
316 mPhoneModel = temp->getPhoneModel( ); 316 mPhoneModel = temp->getPhoneModel( );
317 syncPhone(); 317 syncPhone();
318 } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) { 318 } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) {
319 mSpecificResources.clear(); 319 mSpecificResources.clear();
320 if ( mTargetApp == KAPI ) { 320 if ( mTargetApp == KAPI ) {
321 if ( temp->getIsPiSyncSpec() ) 321 if ( temp->getIsPiSyncSpec() )
322 mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true ); 322 mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true );
323 mPassWordPiSync = temp->getRemotePwAB(); 323 mPassWordPiSync = temp->getRemotePwAB();
324 mActiveSyncPort = temp->getRemotePortAB(); 324 mActiveSyncPort = temp->getRemotePortAB();
325 mActiveSyncIP = temp->getRemoteIPAB(); 325 mActiveSyncIP = temp->getRemoteIPAB();
326 } else if ( mTargetApp == KOPI ) { 326 } else if ( mTargetApp == KOPI ) {
327 if ( temp->getIsPiSyncSpec() ) 327 if ( temp->getIsPiSyncSpec() )
328 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); 328 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true );
329 mPassWordPiSync = temp->getRemotePw(); 329 mPassWordPiSync = temp->getRemotePw();
330 mActiveSyncPort = temp->getRemotePort(); 330 mActiveSyncPort = temp->getRemotePort();
331 mActiveSyncIP = temp->getRemoteIP(); 331 mActiveSyncIP = temp->getRemoteIP();
332 } else { 332 } else {
333 mPassWordPiSync = temp->getRemotePwPWM(); 333 mPassWordPiSync = temp->getRemotePwPWM();
334 mActiveSyncPort = temp->getRemotePortPWM(); 334 mActiveSyncPort = temp->getRemotePortPWM();
335 mActiveSyncIP = temp->getRemoteIPPWM(); 335 mActiveSyncIP = temp->getRemoteIPPWM();
336 } 336 }
337 syncPi(); 337 syncPi();
338 while ( !mPisyncFinished ) { 338 while ( !mPisyncFinished ) {
339 //qDebug("waiting "); 339 //qDebug("waiting ");
340 qApp->processEvents(); 340 qApp->processEvents();
341 } 341 }
342 } else 342 } else
343 syncRemote( temp ); 343 syncRemote( temp );
344 344
345 } 345 }
346 } 346 }
347 delete temp; 347 delete temp;
348 setBlockSave(false); 348 setBlockSave(false);
349} 349}
350 350
351void KSyncManager::enableQuick( bool ask ) 351void KSyncManager::enableQuick( bool ask )
352{ 352{
353 bool autoStart; 353 bool autoStart;
354 bool changed = false; 354 bool changed = false;
355 if ( ask ) { 355 if ( ask ) {
356 QDialog dia ( 0, "input-dialog", true ); 356 QDialog dia ( 0, "input-dialog", true );
357 QLineEdit lab ( &dia ); 357 QLineEdit lab ( &dia );
358 QVBoxLayout lay( &dia ); 358 QVBoxLayout lay( &dia );
359 lab.setText( mPrefs->mPassiveSyncPort ); 359 lab.setText( mPrefs->mPassiveSyncPort );
360 lay.setMargin(7); 360 lay.setMargin(7);
361 lay.setSpacing(7); 361 lay.setSpacing(7);
362 int po = 9197+mTargetApp; 362 int po = 9197+mTargetApp;
363 QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); 363 QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia );
364 lay.addWidget( &label); 364 lay.addWidget( &label);
365 lay.addWidget( &lab); 365 lay.addWidget( &lab);
366 366
367 QLineEdit lepw ( &dia ); 367 QLineEdit lepw ( &dia );
368 lepw.setText( mPrefs->mPassiveSyncPw ); 368 lepw.setText( mPrefs->mPassiveSyncPw );
369 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 369 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
370 lay.addWidget( &label2); 370 lay.addWidget( &label2);
371 lay.addWidget( &lepw); 371 lay.addWidget( &lepw);
372 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); 372 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia );
373 lay.addWidget( &autostart); 373 lay.addWidget( &autostart);
374 autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); 374 autostart.setChecked( mPrefs->mPassiveSyncAutoStart );
375#ifdef DESKTOP_VERSION 375#ifdef DESKTOP_VERSION
376#ifdef _WIN32_ 376#ifdef _WIN32_
377 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); 377 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia );
378 syncdesktop.hide();// not implemented! 378 syncdesktop.hide();// not implemented!
379#else 379#else
380 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); 380 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia );
381#endif 381#endif
382 lay.addWidget( &syncdesktop); 382 lay.addWidget( &syncdesktop);
383#else 383#else
384 mPrefs->mPassiveSyncWithDesktop = false; 384 mPrefs->mPassiveSyncWithDesktop = false;
385 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); 385 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
386 syncdesktop.hide(); 386 syncdesktop.hide();
387#endif 387#endif
388 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); 388 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
389 389
390 QPushButton pb ( "OK", &dia); 390 QPushButton pb ( "OK", &dia);
391 lay.addWidget( &pb ); 391 lay.addWidget( &pb );
392 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 392 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
393 dia.resize( 230,120 ); 393 dia.resize( 230,120 );
394 dia.setCaption( i18n("Enter port for Pi-Sync") ); 394 dia.setCaption( i18n("Enter port for Pi-Sync") );
395 dia.show(); 395 dia.show();
396#ifndef DESKTOP_VERSION 396#ifndef DESKTOP_VERSION
397 int dw = QApplication::desktop()->width(); 397 int dw = QApplication::desktop()->width();
398 int dh = QApplication::desktop()->height(); 398 int dh = QApplication::desktop()->height();
399 dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); 399 dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 );
400#endif 400#endif
401 if ( ! dia.exec() ) 401 if ( ! dia.exec() )
402 return; 402 return;
403 dia.hide(); 403 dia.hide();
404 qApp->processEvents(); 404 qApp->processEvents();
405 if ( mPrefs->mPassiveSyncPw != lepw.text() ) { 405 if ( mPrefs->mPassiveSyncPw != lepw.text() ) {
406 changed = true; 406 changed = true;
407 mPrefs->mPassiveSyncPw = lepw.text(); 407 mPrefs->mPassiveSyncPw = lepw.text();
408 } 408 }
409 if ( mPrefs->mPassiveSyncPort != lab.text() ) { 409 if ( mPrefs->mPassiveSyncPort != lab.text() ) {
410 mPrefs->mPassiveSyncPort = lab.text(); 410 mPrefs->mPassiveSyncPort = lab.text();
411 changed = true; 411 changed = true;
412 } 412 }
413 autoStart = autostart.isChecked(); 413 autoStart = autostart.isChecked();
414 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { 414 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) {
415 changed = true; 415 changed = true;
416 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); 416 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked();
417 } 417 }
418 } 418 }
419 else 419 else
420 autoStart = mPrefs->mPassiveSyncAutoStart; 420 autoStart = mPrefs->mPassiveSyncAutoStart;
421 if ( autoStart != mPrefs->mPassiveSyncAutoStart ) 421 if ( autoStart != mPrefs->mPassiveSyncAutoStart )
422 changed = true; 422 changed = true;
423 bool ok; 423 bool ok;
424 mPrefs->mPassiveSyncAutoStart = false; 424 mPrefs->mPassiveSyncAutoStart = false;
425 Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); 425 Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok);
426 if ( ! ok || port_t > 65535 ) { 426 if ( ! ok || port_t > 65535 ) {
427 KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); 427 KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error"));
428 return; 428 return;
429 } 429 }
430 Q_UINT16 port = port_t; 430 Q_UINT16 port = port_t;
431 //qDebug("port %d ", port); 431 //qDebug("port %d ", port);
432 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 432 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
433 mServerSocket->setFileName( defaultFileName() );//bbb 433 mServerSocket->setFileName( defaultFileName() );//bbb
434 if ( !mServerSocket->ok() ) { 434 if ( !mServerSocket->ok() ) {
435 QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); 435 QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) );
436 delete mServerSocket; 436 delete mServerSocket;
437 mServerSocket = 0; 437 mServerSocket = 0;
438 return; 438 return;
439 } 439 }
440 mPrefs->mPassiveSyncAutoStart = autoStart; 440 mPrefs->mPassiveSyncAutoStart = autoStart;
441 if ( changed ) { 441 if ( changed ) {
442 mPrefs->writeConfig(); 442 mPrefs->writeConfig();
443 } 443 }
444 //connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 444 //connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
445 //connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 445 //connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
446 connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) ); 446 connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) );
447 connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) ); 447 connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) );
448} 448}
449void KSyncManager::displayErrorPort() 449void KSyncManager::displayErrorPort()
450{ 450{
451 KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); 451 KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error"));
452} 452}
453void KSyncManager::syncLocalFile() 453void KSyncManager::syncLocalFile()
454{ 454{
455 455
456 QString fn =mPrefs->mLastSyncedLocalFile; 456 QString fn =mPrefs->mLastSyncedLocalFile;
457 QString ext; 457 QString ext;
458 458
459 switch(mTargetApp) 459 switch(mTargetApp)
460 { 460 {
461 case (KAPI): 461 case (KAPI):
462 ext = "(*.vcf)"; 462 ext = "(*.vcf)";
463 break; 463 break;
464 case (KOPI): 464 case (KOPI):
465 ext = "(*.ics/*.vcs)"; 465 ext = "(*.ics/*.vcs)";
466 break; 466 break;
467 case (PWMPI): 467 case (PWMPI):
468 ext = "(*.pwm)"; 468 ext = "(*.pwm)";
469 break; 469 break;
470 default: 470 default:
471 qDebug("KSM::syncLocalFile: invalid apptype selected"); 471 qDebug("KSM::syncLocalFile: invalid apptype selected");
472 break; 472 break;
473 473
474 } 474 }
475 475
476 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 476 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
477 if ( fn == "" ) 477 if ( fn == "" )
478 return; 478 return;
479 if ( syncWithFile( fn, false ) ) { 479 if ( syncWithFile( fn, false ) ) {
480 qDebug("KSM::syncLocalFile() successful "); 480 qDebug("KSM::syncLocalFile() successful ");
481 } 481 }
482 482
483} 483}
484 484
485bool KSyncManager::syncWithFile( QString fn , bool quick ) 485bool KSyncManager::syncWithFile( QString fn , bool quick )
486{ 486{
487 bool ret = false; 487 bool ret = false;
488 QFileInfo info; 488 QFileInfo info;
489 info.setFile( fn ); 489 info.setFile( fn );
490 QString mess; 490 QString mess;
491 if ( !info. exists() ) { 491 if ( !info. exists() ) {
492 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 492 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
493 QMessageBox::warning( mParent, i18n("Warning!"), 493 QMessageBox::warning( mParent, i18n("Warning!"),
494 mess ); 494 mess );
495 return ret; 495 return ret;
496 } 496 }
497 int result = 0; 497 int result = 0;
498 if ( !quick ) { 498 if ( !quick ) {
499 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 499 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
500 result = QMessageBox::warning( mParent, i18n("Warning!"), 500 result = QMessageBox::warning( mParent, i18n("Warning!"),
501 mess, 501 mess,
502 i18n("Sync"), i18n("Cancel"), 0, 502 i18n("Sync"), i18n("Cancel"), 0,
503 0, 1 ); 503 0, 1 );
504 if ( result ) 504 if ( result )
505 return false; 505 return false;
506 } 506 }
507 if ( mAskForPreferences ) 507 if ( mAskForPreferences )
508 if ( !edit_sync_options()) { 508 if ( !edit_sync_options()) {
509 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 509 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
510 return false; 510 return false;
511 } 511 }
512 if ( result == 0 ) { 512 if ( result == 0 ) {
513 //qDebug("Now sycing ... "); 513 //qDebug("Now sycing ... ");
514 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) ) 514 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) )
515 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 515 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
516 else 516 else
517 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 517 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
518 if ( ! quick ) 518 if ( ! quick )
519 mPrefs->mLastSyncedLocalFile = fn; 519 mPrefs->mLastSyncedLocalFile = fn;
520 } 520 }
521 return ret; 521 return ret;
522} 522}
523 523
524void KSyncManager::quickSyncLocalFile() 524void KSyncManager::quickSyncLocalFile()
525{ 525{
526 526
527 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { 527 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
528 qDebug("KSM::quick syncLocalFile() successful "); 528 qDebug("KSM::quick syncLocalFile() successful ");
529 529
530 } 530 }
531} 531}
532 532
533void KSyncManager::multiSync( bool askforPrefs ) 533void KSyncManager::multiSync( bool askforPrefs )
534{ 534{
535 if (blockSave()) 535 if (blockSave())
536 return; 536 return;
537 setBlockSave(true); 537 setBlockSave(true);
538 mCurrentResourceLocal = ""; 538 mCurrentResourceLocal = "";
539 if ( askforPrefs ) { 539 if ( askforPrefs ) {
540 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 540 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
541 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 541 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
542 question, 542 question,
543 i18n("Yes"), i18n("No"), 543 i18n("Yes"), i18n("No"),
544 0, 0 ) != 0 ) { 544 0, 0 ) != 0 ) {
545 setBlockSave(false); 545 setBlockSave(false);
546 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 546 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
547 return; 547 return;
548 } 548 }
549 } 549 }
550 mCurrentSyncDevice = i18n("Multiple profiles") ; 550 mCurrentSyncDevice = i18n("Multiple profiles") ;
551 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 551 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
552 if ( askforPrefs ) { 552 if ( askforPrefs ) {
553 if ( !edit_sync_options()) { 553 if ( !edit_sync_options()) {
554 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); 554 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") );
555 return; 555 return;
556 } 556 }
557 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; 557 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
558 } 558 }
559 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 559 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
560 qApp->processEvents(); 560 qApp->processEvents();
561 int num = ringSync() ; 561 int num = ringSync() ;
562 if ( num > 1 ) 562 if ( num > 1 )
563 ringSync(); 563 ringSync();
564 setBlockSave(false); 564 setBlockSave(false);
565 if ( num ) 565 if ( num )
566 emit save(); 566 emit save();
567 if ( num ) 567 if ( num )
568 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); 568 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
569 else 569 else
570 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 570 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
571 return; 571 return;
572} 572}
573 573
574int KSyncManager::ringSync() 574int KSyncManager::ringSync()
575{ 575{
576 emit multiResourceSyncStart( false ); 576 emit multiResourceSyncStart( false );
577 int syncedProfiles = 0; 577 int syncedProfiles = 0;
578 unsigned int i; 578 unsigned int i;
579 QTime timer; 579 QTime timer;
580 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 580 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
581 QStringList syncProfileNames = mSyncProfileNames; 581 QStringList syncProfileNames = mSyncProfileNames;
582 KSyncProfile* temp = new KSyncProfile (); 582 KSyncProfile* temp = new KSyncProfile ();
583 mAskForPreferences = false; 583 mAskForPreferences = false;
584 mCurrentResourceLocal = ""; 584 mCurrentResourceLocal = "";
585 for ( i = 0; i < syncProfileNames.count(); ++i ) { 585 for ( i = 0; i < syncProfileNames.count(); ++i ) {
586 mCurrentSyncProfile = i; 586 mCurrentSyncProfile = i;
587 temp->setName(syncProfileNames[mCurrentSyncProfile]); 587 temp->setName(syncProfileNames[mCurrentSyncProfile]);
588 temp->readConfig(&config); 588 temp->readConfig(&config);
589 589
590 bool includeInRingSync = false; 590 bool includeInRingSync = false;
591 switch(mTargetApp) 591 switch(mTargetApp)
592 { 592 {
593 case (KAPI): 593 case (KAPI):
594 includeInRingSync = temp->getIncludeInRingSyncAB(); 594 includeInRingSync = temp->getIncludeInRingSyncAB();
595 break; 595 break;
596 case (KOPI): 596 case (KOPI):
597 includeInRingSync = temp->getIncludeInRingSync(); 597 includeInRingSync = temp->getIncludeInRingSync();
598 break; 598 break;
599 case (PWMPI): 599 case (PWMPI):
600 includeInRingSync = temp->getIncludeInRingSyncPWM(); 600 includeInRingSync = temp->getIncludeInRingSyncPWM();
601 break; 601 break;
602 default: 602 default:
603 qDebug("KSM::ringSync: invalid apptype selected"); 603 qDebug("KSM::ringSync: invalid apptype selected");
604 break; 604 break;
605 605
606 } 606 }
607 607
608 608
609 if ( includeInRingSync && ( i < 1 || i > 2 )) { 609 if ( includeInRingSync && ( i < 1 || i > 2 )) {
610 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 610 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
611 ++syncedProfiles; 611 ++syncedProfiles;
612 mSyncWithDesktop = false; 612 mSyncWithDesktop = false;
613 // mAskForPreferences = temp->getAskForPreferences(); 613 // mAskForPreferences = temp->getAskForPreferences();
614 mWriteBackFile = temp->getWriteBackFile(); 614 mWriteBackFile = temp->getWriteBackFile();
615 mWriteBackExistingOnly = temp->getWriteBackExisting(); 615 mWriteBackExistingOnly = temp->getWriteBackExisting();
616 mIsKapiFile = temp->getIsKapiFile(); 616 mIsKapiFile = temp->getIsKapiFile();
617 mWriteBackInFuture = 0; 617 mWriteBackInFuture = 0;
618 if ( temp->getWriteBackFuture() ) { 618 if ( temp->getWriteBackFuture() ) {
619 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 619 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
620 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 620 mWriteBackInPast = temp->getWriteBackPastWeeks( );
621 } 621 }
622 mFilterInCal = temp->getFilterInCal(); 622 mFilterInCal = temp->getFilterInCal();
623 mFilterOutCal = temp->getFilterOutCal(); 623 mFilterOutCal = temp->getFilterOutCal();
624 mFilterInAB = temp->getFilterInAB(); 624 mFilterInAB = temp->getFilterInAB();
625 mFilterOutAB = temp->getFilterOutAB(); 625 mFilterOutAB = temp->getFilterOutAB();
626 mShowSyncSummary = false; 626 mShowSyncSummary = false;
627 mCurrentSyncDevice = syncProfileNames[i] ; 627 mCurrentSyncDevice = syncProfileNames[i] ;
628 mCurrentSyncName = mLocalMachineName; 628 mCurrentSyncName = mLocalMachineName;
629 if ( i == 0 ) { 629 if ( i == 0 ) {
630 mIsKapiFile = false; 630 mIsKapiFile = false;
631#ifdef DESKTOP_VERSION 631#ifdef DESKTOP_VERSION
632 syncKDE(); 632 syncKDE();
633#else 633#else
634 syncSharp(); 634 syncSharp();
635#endif 635#endif
636 } else { 636 } else {
637 if ( temp->getIsLocalFileSync() ) { 637 if ( temp->getIsLocalFileSync() ) {
638 switch(mTargetApp) 638 switch(mTargetApp)
639 { 639 {
640 case (KAPI): 640 case (KAPI):
641 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 641 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
642 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 642 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
643 break; 643 break;
644 case (KOPI): 644 case (KOPI):
645 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 645 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
646 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 646 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
647 break; 647 break;
648 case (PWMPI): 648 case (PWMPI):
649 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 649 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
650 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 650 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
651 break; 651 break;
652 default: 652 default:
653 qDebug("KSM: invalid apptype selected"); 653 qDebug("KSM: invalid apptype selected");
654 break; 654 break;
655 } 655 }
656 } else { 656 } else {
657 if ( temp->getIsPhoneSync() ) { 657 if ( temp->getIsPhoneSync() ) {
658 mPhoneDevice = temp->getPhoneDevice( ) ; 658 mPhoneDevice = temp->getPhoneDevice( ) ;
659 mPhoneConnection = temp->getPhoneConnection( ); 659 mPhoneConnection = temp->getPhoneConnection( );
660 mPhoneModel = temp->getPhoneModel( ); 660 mPhoneModel = temp->getPhoneModel( );
661 syncPhone(); 661 syncPhone();
662 } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) { 662 } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) {
663 mSpecificResources.clear(); 663 mSpecificResources.clear();
664 if ( mTargetApp == KAPI ) { 664 if ( mTargetApp == KAPI ) {
665 if ( temp->getIsPiSyncSpec() ) 665 if ( temp->getIsPiSyncSpec() )
666 mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true ); 666 mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true );
667 mPassWordPiSync = temp->getRemotePwAB(); 667 mPassWordPiSync = temp->getRemotePwAB();
668 mActiveSyncPort = temp->getRemotePortAB(); 668 mActiveSyncPort = temp->getRemotePortAB();
669 mActiveSyncIP = temp->getRemoteIPAB(); 669 mActiveSyncIP = temp->getRemoteIPAB();
670 } else if ( mTargetApp == KOPI ) { 670 } else if ( mTargetApp == KOPI ) {
671 if ( temp->getIsPiSyncSpec() ) 671 if ( temp->getIsPiSyncSpec() )
672 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); 672 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true );
673 mPassWordPiSync = temp->getRemotePw(); 673 mPassWordPiSync = temp->getRemotePw();
674 mActiveSyncPort = temp->getRemotePort(); 674 mActiveSyncPort = temp->getRemotePort();
675 mActiveSyncIP = temp->getRemoteIP(); 675 mActiveSyncIP = temp->getRemoteIP();
676 } else { 676 } else {
677 mPassWordPiSync = temp->getRemotePwPWM(); 677 mPassWordPiSync = temp->getRemotePwPWM();
678 mActiveSyncPort = temp->getRemotePortPWM(); 678 mActiveSyncPort = temp->getRemotePortPWM();
679 mActiveSyncIP = temp->getRemoteIPPWM(); 679 mActiveSyncIP = temp->getRemoteIPPWM();
680 } 680 }
681 syncPi(); 681 syncPi();
682 while ( !mPisyncFinished ) { 682 while ( !mPisyncFinished ) {
683 //qDebug("waiting "); 683 //qDebug("waiting ");
684 qApp->processEvents(); 684 qApp->processEvents();
685 } 685 }
686 timer.start(); 686 timer.start();
687 while ( timer.elapsed () < 2000 ) { 687 while ( timer.elapsed () < 2000 ) {
688 qApp->processEvents(); 688 qApp->processEvents();
689 } 689 }
690 } else 690 } else
691 syncRemote( temp, false ); 691 syncRemote( temp, false );
692 692
693 } 693 }
694 } 694 }
695 timer.start(); 695 timer.start();
696 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 696 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
697 while ( timer.elapsed () < 2000 ) { 697 while ( timer.elapsed () < 2000 ) {
698 qApp->processEvents(); 698 qApp->processEvents();
699#ifndef _WIN32_ 699#ifndef _WIN32_
700 sleep (1); 700 sleep (1);
701#endif 701#endif
702 } 702 }
703 703
704 } 704 }
705 705
706 } 706 }
707 delete temp; 707 delete temp;
708 return syncedProfiles; 708 return syncedProfiles;
709} 709}
710 710
711void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 711void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
712{ 712{
713 QString question; 713 QString question;
714 if ( ask ) { 714 if ( ask ) {
715 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 715 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
716 if ( QMessageBox::information( mParent, i18n("Sync"), 716 if ( QMessageBox::information( mParent, i18n("Sync"),
717 question, 717 question,
718 i18n("Yes"), i18n("No"), 718 i18n("Yes"), i18n("No"),
719 0, 0 ) != 0 ) 719 0, 0 ) != 0 )
720 return; 720 return;
721 } 721 }
722 722
723 QString preCommand; 723 QString preCommand;
724 QString localTempFile; 724 QString localTempFile;
725 QString postCommand; 725 QString postCommand;
726 726
727 switch(mTargetApp) 727 switch(mTargetApp)
728 { 728 {
729 case (KAPI): 729 case (KAPI):
730 preCommand = prof->getPreSyncCommandAB(); 730 preCommand = prof->getPreSyncCommandAB();
731 postCommand = prof->getPostSyncCommandAB(); 731 postCommand = prof->getPostSyncCommandAB();
732 localTempFile = prof->getLocalTempFileAB(); 732 localTempFile = prof->getLocalTempFileAB();
733 break; 733 break;
734 case (KOPI): 734 case (KOPI):
735 preCommand = prof->getPreSyncCommand(); 735 preCommand = prof->getPreSyncCommand();
736 postCommand = prof->getPostSyncCommand(); 736 postCommand = prof->getPostSyncCommand();
737 localTempFile = prof->getLocalTempFile(); 737 localTempFile = prof->getLocalTempFile();
738 break; 738 break;
739 case (PWMPI): 739 case (PWMPI):
740 preCommand = prof->getPreSyncCommandPWM(); 740 preCommand = prof->getPreSyncCommandPWM();
741 postCommand = prof->getPostSyncCommandPWM(); 741 postCommand = prof->getPostSyncCommandPWM();
742 localTempFile = prof->getLocalTempFilePWM(); 742 localTempFile = prof->getLocalTempFilePWM();
743 break; 743 break;
744 default: 744 default:
745 qDebug("KSM::syncRemote: invalid apptype selected"); 745 qDebug("KSM::syncRemote: invalid apptype selected");
746 break; 746 break;
747 } 747 }
748 748
749 749
750 int fi; 750 int fi;
751 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 751 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
752 QString pwd = getPassword(); 752 QString pwd = getPassword();
753 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 753 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
754 754
755 } 755 }
756 int maxlen = 30; 756 int maxlen = 30;
757 if ( QApplication::desktop()->width() > 320 ) 757 if ( QApplication::desktop()->width() > 320 )
758 maxlen += 25; 758 maxlen += 25;
759 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 759 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
760 int result = system ( preCommand ); 760 int result = system ( preCommand );
761 // 0 : okay 761 // 0 : okay
762 // 256: no such file or dir 762 // 256: no such file or dir
763 // 763 //
764 qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); 764 qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result );
765 if ( result != 0 ) { 765 if ( result != 0 ) {
766 unsigned int len = maxlen; 766 unsigned int len = maxlen;
767 while ( len < preCommand.length() ) { 767 while ( len < preCommand.length() ) {
768 preCommand.insert( len , "\n" ); 768 preCommand.insert( len , "\n" );
769 len += maxlen +2; 769 len += maxlen +2;
770 } 770 }
771 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; 771 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ;
772 QMessageBox::information( mParent, i18n("Sync - ERROR"), 772 QMessageBox::information( mParent, i18n("Sync - ERROR"),
773 question, 773 question,
774 i18n("Okay!")) ; 774 i18n("Okay!")) ;
775 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 775 mParent->topLevelWidget()->setCaption ("KDE-Pim");
776 return; 776 return;
777 } 777 }
778 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 778 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
779 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 779 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
780 780
781 if ( syncWithFile( localTempFile, true ) ) { 781 if ( syncWithFile( localTempFile, true ) ) {
782 782
783 if ( mWriteBackFile ) { 783 if ( mWriteBackFile ) {
784 int fi; 784 int fi;
785 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 785 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
786 QString pwd = getPassword(); 786 QString pwd = getPassword();
787 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 787 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
788 788
789 } 789 }
790 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 790 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
791 result = system ( postCommand ); 791 result = system ( postCommand );
792 qDebug("KSM::Sync:Writing back file result: %d ", result); 792 qDebug("KSM::Sync:Writing back file result: %d ", result);
793 if ( result != 0 ) { 793 if ( result != 0 ) {
794 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 794 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
795 return; 795 return;
796 } else { 796 } else {
797 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 797 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
798 } 798 }
799 } 799 }
800 } 800 }
801 return; 801 return;
802} 802}
803bool KSyncManager::edit_pisync_options() 803bool KSyncManager::edit_pisync_options()
804{ 804{
805 QDialog dia( mParent, "dia", true ); 805 QDialog dia( mParent, "dia", true );
806 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 806 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
807 QVBoxLayout lay ( &dia ); 807 QVBoxLayout lay ( &dia );
808 lay.setSpacing( 5 ); 808 lay.setSpacing( 5 );
809 lay.setMargin( 3 ); 809 lay.setMargin( 3 );
810 QLabel lab1 ( i18n("Password for remote access:"), &dia); 810 QLabel lab1 ( i18n("Password for remote access:"), &dia);
811 lay.addWidget( &lab1 ); 811 lay.addWidget( &lab1 );
812 QLineEdit le1 (&dia ); 812 QLineEdit le1 (&dia );
813 lay.addWidget( &le1 ); 813 lay.addWidget( &le1 );
814 QLabel lab2 ( i18n("Remote IP address:"), &dia); 814 QLabel lab2 ( i18n("Remote IP address:"), &dia);
815 lay.addWidget( &lab2 ); 815 lay.addWidget( &lab2 );
816 QLineEdit le2 (&dia ); 816 QLineEdit le2 (&dia );
817 lay.addWidget( &le2 ); 817 lay.addWidget( &le2 );
818 QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia); 818 QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia);
819 lay.addWidget( &lab3 ); 819 lay.addWidget( &lab3 );
820 QLineEdit le3 (&dia ); 820 QLineEdit le3 (&dia );
821 lay.addWidget( &le3 ); 821 lay.addWidget( &le3 );
822 QPushButton pb ( "OK", &dia); 822 QPushButton pb ( "OK", &dia);
823 lay.addWidget( &pb ); 823 lay.addWidget( &pb );
824 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 824 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
825 le1.setText( mPassWordPiSync ); 825 le1.setText( mPassWordPiSync );
826 le2.setText( mActiveSyncIP ); 826 le2.setText( mActiveSyncIP );
827 le3.setText( mActiveSyncPort ); 827 le3.setText( mActiveSyncPort );
828 if ( dia.exec() ) { 828 if ( dia.exec() ) {
829 mPassWordPiSync = le1.text(); 829 mPassWordPiSync = le1.text();
830 mActiveSyncPort = le3.text(); 830 mActiveSyncPort = le3.text();
831 mActiveSyncIP = le2.text(); 831 mActiveSyncIP = le2.text();
832 return true; 832 return true;
833 } 833 }
834 return false; 834 return false;
835} 835}
836bool KSyncManager::edit_sync_options() 836bool KSyncManager::edit_sync_options()
837{ 837{
838 838
839 QDialog dia( mParent, "dia", true ); 839 QDialog dia( mParent, "dia", true );
840 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 840 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
841 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 841 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
842 QVBoxLayout lay ( &dia ); 842 QVBoxLayout lay ( &dia );
843 lay.setSpacing( 2 ); 843 lay.setSpacing( 2 );
844 lay.setMargin( 3 ); 844 lay.setMargin( 3 );
845 lay.addWidget(&gr); 845 lay.addWidget(&gr);
846 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 846 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
847 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 847 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
848 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 848 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
849 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 849 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
850 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 850 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
851 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 851 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
852 //QRadioButton both( i18n("Take both on conflict"), &gr ); 852 //QRadioButton both( i18n("Take both on conflict"), &gr );
853 QPushButton pb ( "OK", &dia); 853 QPushButton pb ( "OK", &dia);
854 lay.addWidget( &pb ); 854 lay.addWidget( &pb );
855 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 855 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
856 switch ( mSyncAlgoPrefs ) { 856 switch ( mSyncAlgoPrefs ) {
857 case 0: 857 case 0:
858 loc.setChecked( true); 858 loc.setChecked( true);
859 break; 859 break;
860 case 1: 860 case 1:
861 rem.setChecked( true ); 861 rem.setChecked( true );
862 break; 862 break;
863 case 2: 863 case 2:
864 newest.setChecked( true); 864 newest.setChecked( true);
865 break; 865 break;
866 case 3: 866 case 3:
867 ask.setChecked( true); 867 ask.setChecked( true);
868 break; 868 break;
869 case 4: 869 case 4:
870 f_loc.setChecked( true); 870 f_loc.setChecked( true);
871 break; 871 break;
872 case 5: 872 case 5:
873 f_rem.setChecked( true); 873 f_rem.setChecked( true);
874 break; 874 break;
875 case 6: 875 case 6:
876 // both.setChecked( true); 876 // both.setChecked( true);
877 break; 877 break;
878 default: 878 default:
879 break; 879 break;
880 } 880 }
881 if ( dia.exec() ) { 881 if ( dia.exec() ) {
882 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 882 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
883 return true; 883 return true;
884 } 884 }
885 return false; 885 return false;
886} 886}
887 887
888QString KSyncManager::getPassword( ) 888QString KSyncManager::getPassword( )
889{ 889{
890 QString retfile = ""; 890 QString retfile = "";
891 QDialog dia ( mParent, "input-dialog", true ); 891 QDialog dia ( mParent, "input-dialog", true );
892 QLineEdit lab ( &dia ); 892 QLineEdit lab ( &dia );
893 lab.setEchoMode( QLineEdit::Password ); 893 lab.setEchoMode( QLineEdit::Password );
894 QVBoxLayout lay( &dia ); 894 QVBoxLayout lay( &dia );
895 lay.setMargin(7); 895 lay.setMargin(7);
896 lay.setSpacing(7); 896 lay.setSpacing(7);
897 lay.addWidget( &lab); 897 lay.addWidget( &lab);
898 dia.setFixedSize( 230,50 ); 898 dia.setFixedSize( 230,50 );
899 dia.setCaption( i18n("Enter password") ); 899 dia.setCaption( i18n("Enter password") );
900 QPushButton pb ( "OK", &dia); 900 QPushButton pb ( "OK", &dia);
901 lay.addWidget( &pb ); 901 lay.addWidget( &pb );
902 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 902 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
903 dia.show(); 903 dia.show();
904 int res = dia.exec(); 904 int res = dia.exec();
905 if ( res ) 905 if ( res )
906 retfile = lab.text(); 906 retfile = lab.text();
907 dia.hide(); 907 dia.hide();
908 qApp->processEvents(); 908 qApp->processEvents();
909 return retfile; 909 return retfile;
910 910
911} 911}
912 912
913 913
914void KSyncManager::confSync() 914void KSyncManager::confSync()
915{ 915{
916 static KSyncPrefsDialog* sp = 0; 916 static KSyncPrefsDialog* sp = 0;
917 if ( ! sp ) { 917 if ( ! sp ) {
918 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 918 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
919 } 919 }
920 sp->usrReadConfig(); 920 sp->usrReadConfig();
921#ifndef DESKTOP_VERSION 921#ifndef DESKTOP_VERSION
922 sp->showMaximized(); 922 sp->showMaximized();
923#else 923#else
924 sp->show(); 924 sp->show();
925#endif 925#endif
926 sp->exec(); 926 sp->exec();
927 QStringList oldSyncProfileNames = mSyncProfileNames; 927 QStringList oldSyncProfileNames = mSyncProfileNames;
928 mSyncProfileNames = sp->getSyncProfileNames(); 928 mSyncProfileNames = sp->getSyncProfileNames();
929 mLocalMachineName = sp->getLocalMachineName (); 929 mLocalMachineName = sp->getLocalMachineName ();
930 uint ii; 930 uint ii;
931 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { 931 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) {
932 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) 932 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) )
933 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); 933 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] );
934 } 934 }
935 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 935 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
936} 936}
937void KSyncManager::syncOL()
938{
939 mSyncWithDesktop = true;
940 emit save();
941 switch(mTargetApp)
942 {
943 case (KAPI):
944 {
945 syncExternalApplication("ol");
946 }
947 break;
948 case (KOPI):
949 {
950#ifdef DESKTOP_VERSION
951 QString command = "kdecaldump33";
952 QString commandfile = "kdecaldump33";
953 QString commandpath = qApp->applicationDirPath () + "/";
954#else
955 QString command = "kdecaldump33";
956 QString commandfile = "kdecaldump33";
957 QString commandpath = QDir::homeDirPath ()+"/";
958#endif
959 if ( ! QFile::exists ( commandpath+commandfile ) )
960 command = commandfile;
961 else
962 command = commandpath+commandfile;
963
964 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
965 int result = system ( command.latin1());
966 qDebug("Cal dump 33 command call result result: %d ", result);
967 if ( result != 0 ) {
968 qDebug("Calling CAL dump version 33 failed. Trying 34... ");
969 commandfile = "kdecaldump34";
970 if ( ! QFile::exists ( commandpath+commandfile ) )
971 command = commandfile;
972 else
973 command = commandpath+commandfile;
974 result = system ( command.latin1());
975 qDebug("Cal dump 34 command call result result: %d ", result);
976 if ( result != 0 ) {
977 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath ));
978 return;
979 }
980 }
981 if ( syncWithFile( fileName,true ) ) {
982 if ( mWriteBackFile ) {
983 command += " --read";
984 system ( command.latin1());
985 }
986 }
987
988 }
989 break;
990 case (PWMPI):
991
992 break;
993 default:
994 qDebug("KSM::slotSyncMenu: invalid apptype selected");
995 break;
996
997 }
998}
937void KSyncManager::syncKDE() 999void KSyncManager::syncKDE()
938{ 1000{
1001#ifdef _WIN32_
1002 syncOL();
1003#else
1004
939 mSyncWithDesktop = true; 1005 mSyncWithDesktop = true;
940 emit save(); 1006 emit save();
941 switch(mTargetApp) 1007 switch(mTargetApp)
942 { 1008 {
943 case (KAPI): 1009 case (KAPI):
944 { 1010 {
945#ifdef DESKTOP_VERSION 1011#ifdef DESKTOP_VERSION
946 QString command = "kdeabdump33"; 1012 QString command = "kdeabdump33";
947 QString commandfile = "kdeabdump33"; 1013 QString commandfile = "kdeabdump33";
948 QString commandpath = qApp->applicationDirPath () + "/"; 1014 QString commandpath = qApp->applicationDirPath () + "/";
949#else 1015#else
950 QString command = "kdeabdump33"; 1016 QString command = "kdeabdump33";
951 QString commandfile = "kdeabdump33"; 1017 QString commandfile = "kdeabdump33";
952 QString commandpath = QDir::homeDirPath ()+"/"; 1018 QString commandpath = QDir::homeDirPath ()+"/";
953#endif 1019#endif
954 if ( ! QFile::exists ( commandpath+commandfile ) ) 1020 if ( ! QFile::exists ( commandpath+commandfile ) )
955 command = commandfile; 1021 command = commandfile;
956 else 1022 else
957 command = commandpath+commandfile; 1023 command = commandpath+commandfile;
958 1024
959 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; 1025 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf";
960 int result = system ( command.latin1()); 1026 int result = system ( command.latin1());
961 qDebug("AB dump 33 command call result: %d ", result); 1027 qDebug("AB dump 33 command call result: %d ", result);
962 if ( result != 0 ) { 1028 if ( result != 0 ) {
963 qDebug("Calling AB dump version 33 failed. Trying 34... "); 1029 qDebug("Calling AB dump version 33 failed. Trying 34... ");
964 commandfile = "kdeabdump34"; 1030 commandfile = "kdeabdump34";
965 if ( ! QFile::exists ( commandpath+commandfile ) ) 1031 if ( ! QFile::exists ( commandpath+commandfile ) )
966 command = commandfile; 1032 command = commandfile;
967 else 1033 else
968 command = commandpath+commandfile; 1034 command = commandpath+commandfile;
969 result = system ( command.latin1()); 1035 result = system ( command.latin1());
970 qDebug("AB dump 34 command call result: %d ", result); 1036 qDebug("AB dump 34 command call result: %d ", result);
971 if ( result != 0 ) { 1037 if ( result != 0 ) {
972 KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); 1038 KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath ));
973 return; 1039 return;
974 } 1040 }
975 } 1041 }
976 if ( syncWithFile( fileName,true ) ) { 1042 if ( syncWithFile( fileName,true ) ) {
977 if ( mWriteBackFile ) { 1043 if ( mWriteBackFile ) {
978 command += " --read"; 1044 command += " --read";
979 system ( command.latin1()); 1045 system ( command.latin1());
980 } 1046 }
981 } 1047 }
982 1048
983 } 1049 }
984 break; 1050 break;
985 case (KOPI): 1051 case (KOPI):
986 { 1052 {
987#ifdef DESKTOP_VERSION 1053#ifdef DESKTOP_VERSION
988 QString command = "kdecaldump33"; 1054 QString command = "kdecaldump33";
989 QString commandfile = "kdecaldump33"; 1055 QString commandfile = "kdecaldump33";
990 QString commandpath = qApp->applicationDirPath () + "/"; 1056 QString commandpath = qApp->applicationDirPath () + "/";
991#else 1057#else
992 QString command = "kdecaldump33"; 1058 QString command = "kdecaldump33";
993 QString commandfile = "kdecaldump33"; 1059 QString commandfile = "kdecaldump33";
994 QString commandpath = QDir::homeDirPath ()+"/"; 1060 QString commandpath = QDir::homeDirPath ()+"/";
995#endif 1061#endif
996 if ( ! QFile::exists ( commandpath+commandfile ) ) 1062 if ( ! QFile::exists ( commandpath+commandfile ) )
997 command = commandfile; 1063 command = commandfile;
998 else 1064 else
999 command = commandpath+commandfile; 1065 command = commandpath+commandfile;
1000 1066
1001 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; 1067 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
1002 int result = system ( command.latin1()); 1068 int result = system ( command.latin1());
1003 qDebug("Cal dump 33 command call result result: %d ", result); 1069 qDebug("Cal dump 33 command call result result: %d ", result);
1004 if ( result != 0 ) { 1070 if ( result != 0 ) {
1005 qDebug("Calling CAL dump version 33 failed. Trying 34... "); 1071 qDebug("Calling CAL dump version 33 failed. Trying 34... ");
1006 commandfile = "kdecaldump34"; 1072 commandfile = "kdecaldump34";
1007 if ( ! QFile::exists ( commandpath+commandfile ) ) 1073 if ( ! QFile::exists ( commandpath+commandfile ) )
1008 command = commandfile; 1074 command = commandfile;
1009 else 1075 else
1010 command = commandpath+commandfile; 1076 command = commandpath+commandfile;
1011 result = system ( command.latin1()); 1077 result = system ( command.latin1());
1012 qDebug("Cal dump 34 command call result result: %d ", result); 1078 qDebug("Cal dump 34 command call result result: %d ", result);
1013 if ( result != 0 ) { 1079 if ( result != 0 ) {
1014 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); 1080 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath ));
1015 return; 1081 return;
1016 } 1082 }
1017 } 1083 }
1018 if ( syncWithFile( fileName,true ) ) { 1084 if ( syncWithFile( fileName,true ) ) {
1019 if ( mWriteBackFile ) { 1085 if ( mWriteBackFile ) {
1020 command += " --read"; 1086 command += " --read";
1021 system ( command.latin1()); 1087 system ( command.latin1());
1022 } 1088 }
1023 } 1089 }
1024 1090
1025 } 1091 }
1026 break; 1092 break;
1027 case (PWMPI): 1093 case (PWMPI):
1028 1094
1029 break; 1095 break;
1030 default: 1096 default:
1031 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 1097 qDebug("KSM::slotSyncMenu: invalid apptype selected");
1032 break; 1098 break;
1033 1099
1034 } 1100 }
1101#endif
1035} 1102}
1036 1103
1037void KSyncManager::syncSharp() 1104void KSyncManager::syncSharp()
1038{ 1105{
1039 1106
1040 if ( ! syncExternalApplication("sharp") ) 1107 if ( ! syncExternalApplication("sharp") )
1041 qDebug("KSM::ERROR sync sharp "); 1108 qDebug("KSM::ERROR sync sharp ");
1042} 1109}
1043 1110
1044bool KSyncManager::syncExternalApplication(QString resource) 1111bool KSyncManager::syncExternalApplication(QString resource)
1045{ 1112{
1046 1113
1047 emit save(); 1114 emit save();
1048 1115
1049 if ( mAskForPreferences ) 1116 if ( mAskForPreferences )
1050 if ( !edit_sync_options()) { 1117 if ( !edit_sync_options()) {
1051 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1118 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1052 return false; 1119 return false;
1053 } 1120 }
1054 1121
1055 qDebug("KSM::Sync extern %s", resource.latin1()); 1122 qDebug("KSM::Sync extern %s", resource.latin1());
1056 1123
1057 bool syncOK = mImplementation->syncExternal(this, resource); 1124 bool syncOK = mImplementation->syncExternal(this, resource);
1058 1125
1059 return syncOK; 1126 return syncOK;
1060 1127
1061} 1128}
1062 1129
1063void KSyncManager::syncPhone() 1130void KSyncManager::syncPhone()
1064{ 1131{
1065 1132
1066 syncExternalApplication("phone"); 1133 syncExternalApplication("phone");
1067 1134
1068} 1135}
1069 1136
1070void KSyncManager::showProgressBar(int percentage, QString caption, int total) 1137void KSyncManager::showProgressBar(int percentage, QString caption, int total)
1071{ 1138{
1072 if (!bar->isVisible()) 1139 if (!bar->isVisible())
1073 { 1140 {
1074 int w = 300; 1141 int w = 300;
1075 if ( QApplication::desktop()->width() < 320 ) 1142 if ( QApplication::desktop()->width() < 320 )
1076 w = 220; 1143 w = 220;
1077 int h = bar->sizeHint().height() ; 1144 int h = bar->sizeHint().height() ;
1078 int dw = QApplication::desktop()->width(); 1145 int dw = QApplication::desktop()->width();
1079 int dh = QApplication::desktop()->height(); 1146 int dh = QApplication::desktop()->height();
1080 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1147 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1081 bar->setCaption (caption); 1148 bar->setCaption (caption);
1082 bar->setTotalSteps ( total ) ; 1149 bar->setTotalSteps ( total ) ;
1083 bar->show(); 1150 bar->show();
1084 } 1151 }
1085 bar->raise(); 1152 bar->raise();
1086 bar->setProgress( percentage ); 1153 bar->setProgress( percentage );
1087 qApp->processEvents(); 1154 qApp->processEvents();
1088} 1155}
1089 1156
1090void KSyncManager::hideProgressBar() 1157void KSyncManager::hideProgressBar()
1091{ 1158{
1092 bar->hide(); 1159 bar->hide();
1093 qApp->processEvents(); 1160 qApp->processEvents();
1094} 1161}
1095 1162
1096bool KSyncManager::isProgressBarCanceled() 1163bool KSyncManager::isProgressBarCanceled()
1097{ 1164{
1098 return !bar->isVisible(); 1165 return !bar->isVisible();
1099} 1166}
1100 1167
1101QString KSyncManager::syncFileName() 1168QString KSyncManager::syncFileName()
1102{ 1169{
1103 1170
1104 QString fn = "tempfile"; 1171 QString fn = "tempfile";
1105 switch(mTargetApp) 1172 switch(mTargetApp)
1106 { 1173 {
1107 case (KAPI): 1174 case (KAPI):
1108 fn = "tempsyncab.vcf"; 1175 fn = "tempsyncab.vcf";
1109 break; 1176 break;
1110 case (KOPI): 1177 case (KOPI):
1111 fn = "tempsynccal.ics"; 1178 fn = "tempsynccal.ics";
1112 break; 1179 break;
1113 case (PWMPI): 1180 case (PWMPI):
1114 fn = "tempsyncpw.pwm"; 1181 fn = "tempsyncpw.pwm";
1115 break; 1182 break;
1116 default: 1183 default:
1117 break; 1184 break;
1118 } 1185 }
1119#ifdef DESKTOP_VERSION 1186#ifdef DESKTOP_VERSION
1120 return locateLocal( "tmp", fn ); 1187 return locateLocal( "tmp", fn );
1121#else 1188#else
1122 return (QString( "/tmp/" )+ fn ); 1189 return (QString( "/tmp/" )+ fn );
1123#endif 1190#endif
1124} 1191}
1125 1192
1126void KSyncManager::syncPi() 1193void KSyncManager::syncPi()
1127{ 1194{
1128 mIsKapiFile = true; 1195 mIsKapiFile = true;
1129 mPisyncFinished = false; 1196 mPisyncFinished = false;
1130 qApp->processEvents(); 1197 qApp->processEvents();
1131 if ( mAskForPreferences ) 1198 if ( mAskForPreferences )
1132 if ( !edit_pisync_options()) { 1199 if ( !edit_pisync_options()) {
1133 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1200 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1134 mPisyncFinished = true; 1201 mPisyncFinished = true;
1135 return; 1202 return;
1136 } 1203 }
1137 bool ok; 1204 bool ok;
1138 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 1205 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
1139 if ( ! ok ) { 1206 if ( ! ok ) {
1140 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1207 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
1141 mPisyncFinished = true; 1208 mPisyncFinished = true;
1142 return; 1209 return;
1143 } 1210 }
1144 mCurrentResourceLocal = ""; 1211 mCurrentResourceLocal = "";
1145 mCurrentResourceRemote = ""; 1212 mCurrentResourceRemote = "";
1146 if ( mSpecificResources.count() ) { 1213 if ( mSpecificResources.count() ) {
1147 uint lastSyncRes = mSpecificResources.count()/2; 1214 uint lastSyncRes = mSpecificResources.count()/2;
1148 int ccc = mSpecificResources.count()-1; 1215 int ccc = mSpecificResources.count()-1;
1149 while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) { 1216 while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) {
1150 --ccc; 1217 --ccc;
1151 --lastSyncRes; 1218 --lastSyncRes;
1152 //qDebug ( "KSM: sync pi %d",ccc ); 1219 //qDebug ( "KSM: sync pi %d",ccc );
1153 } 1220 }
1154 uint startLocal = 0; 1221 uint startLocal = 0;
1155 uint startRemote = mSpecificResources.count()/2; 1222 uint startRemote = mSpecificResources.count()/2;
1156 emit multiResourceSyncStart( true ); 1223 emit multiResourceSyncStart( true );
1157 while ( startLocal < mSpecificResources.count()/2 ) { 1224 while ( startLocal < mSpecificResources.count()/2 ) {
1158 if ( startLocal+1 >= lastSyncRes ) 1225 if ( startLocal+1 >= lastSyncRes )
1159 emit multiResourceSyncStart( false ); 1226 emit multiResourceSyncStart( false );
1160 mPisyncFinished = false; 1227 mPisyncFinished = false;
1161 mCurrentResourceLocal = mSpecificResources[ startLocal ]; 1228 mCurrentResourceLocal = mSpecificResources[ startLocal ];
1162 mCurrentResourceRemote = mSpecificResources[ startRemote ]; 1229 mCurrentResourceRemote = mSpecificResources[ startRemote ];
1163 //qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); 1230 //qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() );
1164 if ( !mCurrentResourceRemote.isEmpty() ) { 1231 if ( !mCurrentResourceRemote.isEmpty() ) {
1165 qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); 1232 qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() );
1166 1233
1167 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); 1234 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1168 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1235 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1169 commandSocket->readFile( syncFileName() ); 1236 commandSocket->readFile( syncFileName() );
1170 mParent->topLevelWidget()->setCaption( i18n("Syncing %1 <-> %2").arg( mCurrentResourceLocal ).arg( mCurrentResourceRemote ) ); 1237 mParent->topLevelWidget()->setCaption( i18n("Syncing %1 <-> %2").arg( mCurrentResourceLocal ).arg( mCurrentResourceRemote ) );
1171 while ( !mPisyncFinished ) { 1238 while ( !mPisyncFinished ) {
1172 //qDebug("waiting "); 1239 //qDebug("waiting ");
1173 qApp->processEvents(); 1240 qApp->processEvents();
1174 } 1241 }
1175 if ( startLocal+1 < mSpecificResources.count()/2 ) { 1242 if ( startLocal+1 < mSpecificResources.count()/2 ) {
1176 mParent->topLevelWidget()->setCaption( i18n("Waiting a second before syncing next resource...") ); 1243 mParent->topLevelWidget()->setCaption( i18n("Waiting a second before syncing next resource...") );
1177 QTime timer; 1244 QTime timer;
1178 timer.start(); 1245 timer.start();
1179 while ( timer.elapsed () < 1000 ) { 1246 while ( timer.elapsed () < 1000 ) {
1180 qApp->processEvents(); 1247 qApp->processEvents();
1181 } 1248 }
1182 } 1249 }
1183 } 1250 }
1184 ++startRemote; 1251 ++startRemote;
1185 ++startLocal; 1252 ++startLocal;
1186 mAskForPreferences = false; 1253 mAskForPreferences = false;
1187 } 1254 }
1188 mPisyncFinished = true; 1255 mPisyncFinished = true;
1189 mParent->topLevelWidget()->setCaption( i18n("Multi-resource Pi-sync finished") ); 1256 mParent->topLevelWidget()->setCaption( i18n("Multi-resource Pi-sync finished") );
1190 } else { 1257 } else {
1191 KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); 1258 KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1192 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1259 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1193 commandSocket->readFile( syncFileName() ); 1260 commandSocket->readFile( syncFileName() );
1194 } 1261 }
1195} 1262}
1196 1263
1197void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 1264void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1198{ 1265{
1199 //enum { success, errorW, errorR, quiet }; 1266 //enum { success, errorW, errorR, quiet };
1200 1267
1201 1268
1202 1269
1203 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || 1270 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW ||
1204 state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { 1271 state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) {
1205 if ( state == KCommandSocket::errorPW ) 1272 if ( state == KCommandSocket::errorPW )
1206 mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); 1273 mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") );
1207 else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) 1274 else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO )
1208 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 1275 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
1209 else if ( state == KCommandSocket::errorCA ) 1276 else if ( state == KCommandSocket::errorCA )
1210 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); 1277 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") );
1211 else if ( state == KCommandSocket::errorFI ) 1278 else if ( state == KCommandSocket::errorFI )
1212 mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); 1279 mParent->topLevelWidget()->setCaption( i18n("File error on remote.") );
1213 else if ( state == KCommandSocket::errorED ) 1280 else if ( state == KCommandSocket::errorED )
1214 mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); 1281 mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") );
1215 else if ( state == KCommandSocket::errorUN ) 1282 else if ( state == KCommandSocket::errorUN )
1216 mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); 1283 mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") );
1217 delete s; 1284 delete s;
1218 if ( state == KCommandSocket::errorR ) { 1285 if ( state == KCommandSocket::errorR ) {
1219 KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); 1286 KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget());
1220 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1287 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1221 commandSocket->sendStop(); 1288 commandSocket->sendStop();
1222 } 1289 }
1223 mPisyncFinished = true; 1290 mPisyncFinished = true;
1224 return; 1291 return;
1225 1292
1226 } else if ( state == KCommandSocket::errorW ) { 1293 } else if ( state == KCommandSocket::errorW ) {
1227 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 1294 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
1228 mPisyncFinished = true; 1295 mPisyncFinished = true;
1229 1296
1230 } else if ( state == KCommandSocket::successR ) { 1297 } else if ( state == KCommandSocket::successR ) {
1231 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1298 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
1232 1299
1233 } else if ( state == KCommandSocket::successW ) { 1300 } else if ( state == KCommandSocket::successW ) {
1234 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); 1301 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
1235 mPisyncFinished = true; 1302 mPisyncFinished = true;
1236 } else if ( state == KCommandSocket::quiet ){ 1303 } else if ( state == KCommandSocket::quiet ){
1237 qDebug("KSS: quiet "); 1304 qDebug("KSS: quiet ");
1238 mPisyncFinished = true; 1305 mPisyncFinished = true;
1239 } else { 1306 } else {
1240 qDebug("KSS: Error: unknown state: %d ", state); 1307 qDebug("KSS: Error: unknown state: %d ", state);
1241 mPisyncFinished = true; 1308 mPisyncFinished = true;
1242 } 1309 }
1243 1310
1244 delete s; 1311 delete s;
1245} 1312}
1246 1313
1247void KSyncManager::readFileFromSocket() 1314void KSyncManager::readFileFromSocket()
1248{ 1315{
1249 QString fileName = syncFileName(); 1316 QString fileName = syncFileName();
1250 bool syncOK = true; 1317 bool syncOK = true;
1251 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 1318 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
1252 if ( ! syncWithFile( fileName , true ) ) { 1319 if ( ! syncWithFile( fileName , true ) ) {
1253 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 1320 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
1254 syncOK = false; 1321 syncOK = false;
1255 } 1322 }
1256 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote,mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); 1323 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote,mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() );
1257 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1324 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1258 if ( mWriteBackFile && syncOK ) { 1325 if ( mWriteBackFile && syncOK ) {
1259 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); 1326 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") );
1260 commandSocket->writeFile( fileName ); 1327 commandSocket->writeFile( fileName );
1261 } 1328 }
1262 else { 1329 else {
1263 commandSocket->sendStop(); 1330 commandSocket->sendStop();
1264 if ( syncOK ) 1331 if ( syncOK )
1265 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1332 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1266 mPisyncFinished = true; 1333 mPisyncFinished = true;
1267 } 1334 }
1268} 1335}
1269 1336
1270KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 1337KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
1271{ 1338{
1272 mPendingConnect = 0; 1339 mPendingConnect = 0;
1273 mPassWord = pw; 1340 mPassWord = pw;
1274 mSocket = 0; 1341 mSocket = 0;
1275 mSyncActionDialog = 0; 1342 mSyncActionDialog = 0;
1276 blockRC = false; 1343 blockRC = false;
1277 mErrorMessage = 0; 1344 mErrorMessage = 0;
1278} 1345}
1279void KServerSocket::waitForSocketFinish() 1346void KServerSocket::waitForSocketFinish()
1280{ 1347{
1281 if ( mSocket ) { 1348 if ( mSocket ) {
1282 //qDebug("KSS:: waiting for finish operation"); 1349 //qDebug("KSS:: waiting for finish operation");
1283 QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); 1350 QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish()));
1284 return; 1351 return;
1285 } 1352 }
1286 mSocket = new QSocket( this ); 1353 mSocket = new QSocket( this );
1287 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1354 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1288 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1355 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1289 mSocket->setSocket( mPendingConnect ); 1356 mSocket->setSocket( mPendingConnect );
1290 mPendingConnect = 0; 1357 mPendingConnect = 0;
1291} 1358}
1292void KServerSocket::newConnection ( int socket ) 1359void KServerSocket::newConnection ( int socket )
1293{ 1360{
1294 // qDebug("KServerSocket:New connection %d ", socket); 1361 // qDebug("KServerSocket:New connection %d ", socket);
1295 if ( mPendingConnect ) { 1362 if ( mPendingConnect ) {
1296 qDebug("KSS::Error : new Connection"); 1363 qDebug("KSS::Error : new Connection");
1297 return; 1364 return;
1298 } 1365 }
1299 if ( mSocket ) { 1366 if ( mSocket ) {
1300 mPendingConnect = socket; 1367 mPendingConnect = socket;
1301 QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); 1368 QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish()));
1302 return; 1369 return;
1303 qDebug("KSS::newConnection Socket deleted! "); 1370 qDebug("KSS::newConnection Socket deleted! ");
1304 delete mSocket; 1371 delete mSocket;
1305 mSocket = 0; 1372 mSocket = 0;
1306 } 1373 }
1307 mPendingConnect = 0; 1374 mPendingConnect = 0;
1308 mSocket = new QSocket( this ); 1375 mSocket = new QSocket( this );
1309 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1376 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1310 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1377 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1311 mSocket->setSocket( socket ); 1378 mSocket->setSocket( socket );
1312} 1379}
1313 1380
1314void KServerSocket::discardClient() 1381void KServerSocket::discardClient()
1315{ 1382{
1316 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1383 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1317} 1384}
1318void KServerSocket::deleteSocket() 1385void KServerSocket::deleteSocket()
1319{ 1386{
1320 //qDebug("KSS::deleteSocket"); 1387 //qDebug("KSS::deleteSocket");
1321 if ( mSocket ) { 1388 if ( mSocket ) {
1322 delete mSocket; 1389 delete mSocket;
1323 mSocket = 0; 1390 mSocket = 0;
1324 } 1391 }
1325 if ( mErrorMessage ) 1392 if ( mErrorMessage )
1326 QTimer::singleShot( 10, this , SLOT ( displayErrorMessage())); 1393 QTimer::singleShot( 10, this , SLOT ( displayErrorMessage()));
1327} 1394}
1328void KServerSocket::readClient() 1395void KServerSocket::readClient()
1329{ 1396{
1330 if ( blockRC ) 1397 if ( blockRC )
1331 return; 1398 return;
1332 if ( mSocket == 0 ) { 1399 if ( mSocket == 0 ) {
1333 qDebug("ERROR::KSS::readClient(): mSocket == 0 "); 1400 qDebug("ERROR::KSS::readClient(): mSocket == 0 ");
1334 return; 1401 return;
1335 } 1402 }
1336 if ( mErrorMessage ) { 1403 if ( mErrorMessage ) {
1337 mErrorMessage = 999; 1404 mErrorMessage = 999;
1338 error_connect("ERROR_ED\r\n\r\n"); 1405 error_connect("ERROR_ED\r\n\r\n");
1339 return; 1406 return;
1340 } 1407 }
1341 mResource = ""; 1408 mResource = "";
1342 mErrorMessage = 0; 1409 mErrorMessage = 0;
1343 //qDebug("KServerSocket::readClient()"); 1410 //qDebug("KServerSocket::readClient()");
1344 if ( mSocket->canReadLine() ) { 1411 if ( mSocket->canReadLine() ) {
1345 QString line = mSocket->readLine(); 1412 QString line = mSocket->readLine();
1346 //qDebug("KServerSocket readline: %s ", line.latin1()); 1413 //qDebug("KServerSocket readline: %s ", line.latin1());
1347 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 1414 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
1348 if ( tokens[0] == "GET" ) { 1415 if ( tokens[0] == "GET" ) {
1349 if ( tokens[1] == mPassWord ) { 1416 if ( tokens[1] == mPassWord ) {
1350 //emit sendFile( mSocket ); 1417 //emit sendFile( mSocket );
1351 bool ok = false; 1418 bool ok = false;
1352 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); 1419 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok);
1353 if ( ok ) { 1420 if ( ok ) {
1354 KSyncManager::mRequestedSyncEvent = dt; 1421 KSyncManager::mRequestedSyncEvent = dt;
1355 } 1422 }
1356 else 1423 else
1357 KSyncManager::mRequestedSyncEvent = QDateTime(); 1424 KSyncManager::mRequestedSyncEvent = QDateTime();
1358 mResource =tokens[3]; 1425 mResource =tokens[3];
1359 send_file(); 1426 send_file();
1360 } 1427 }
1361 else { 1428 else {
1362 mErrorMessage = 1; 1429 mErrorMessage = 1;
1363 error_connect("ERROR_PW\r\n\r\n"); 1430 error_connect("ERROR_PW\r\n\r\n");
1364 } 1431 }
1365 } 1432 }
1366 if ( tokens[0] == "PUT" ) { 1433 if ( tokens[0] == "PUT" ) {
1367 if ( tokens[1] == mPassWord ) { 1434 if ( tokens[1] == mPassWord ) {
1368 //emit getFile( mSocket ); 1435 //emit getFile( mSocket );
1369 blockRC = true; 1436 blockRC = true;
1370 mResource =tokens[2]; 1437 mResource =tokens[2];
1371 get_file(); 1438 get_file();
1372 } 1439 }
1373 else { 1440 else {
1374 mErrorMessage = 2; 1441 mErrorMessage = 2;
1375 error_connect("ERROR_PW\r\n\r\n"); 1442 error_connect("ERROR_PW\r\n\r\n");
1376 end_connect(); 1443 end_connect();
1377 } 1444 }
1378 } 1445 }
1379 if ( tokens[0] == "STOP" ) { 1446 if ( tokens[0] == "STOP" ) {
1380 //emit endConnect(); 1447 //emit endConnect();
1381 end_connect(); 1448 end_connect();
1382 } 1449 }
1383 } 1450 }
1384} 1451}
1385void KServerSocket::displayErrorMessage() 1452void KServerSocket::displayErrorMessage()
1386{ 1453{
1387 if ( mErrorMessage == 1 ) { 1454 if ( mErrorMessage == 1 ) {
1388 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error")); 1455 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error"));
1389 mErrorMessage = 0; 1456 mErrorMessage = 0;
1390 } 1457 }
1391 else if ( mErrorMessage == 2 ) { 1458 else if ( mErrorMessage == 2 ) {
1392 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); 1459 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error"));
1393 mErrorMessage = 0; 1460 mErrorMessage = 0;
1394 } 1461 }
1395} 1462}
1396void KServerSocket::error_connect( QString errmess ) 1463void KServerSocket::error_connect( QString errmess )
1397{ 1464{
1398 QTextStream os( mSocket ); 1465 QTextStream os( mSocket );
1399 os.setEncoding( QTextStream::Latin1 ); 1466 os.setEncoding( QTextStream::Latin1 );
1400 os << errmess ; 1467 os << errmess ;
1401 mSocket->close(); 1468 mSocket->close();
1402 if ( mSocket->state() == QSocket::Idle ) { 1469 if ( mSocket->state() == QSocket::Idle ) {
1403 QTimer::singleShot( 0, this , SLOT ( discardClient())); 1470 QTimer::singleShot( 0, this , SLOT ( discardClient()));
1404 } 1471 }
1405} 1472}
1406void KServerSocket::end_connect() 1473void KServerSocket::end_connect()
1407{ 1474{
1408 delete mSyncActionDialog; 1475 delete mSyncActionDialog;
1409 mSyncActionDialog = 0; 1476 mSyncActionDialog = 0;
1410} 1477}
1411void KServerSocket::send_file() 1478void KServerSocket::send_file()
1412{ 1479{
1413 //qDebug("MainWindow::sendFile(QSocket* s) "); 1480 //qDebug("MainWindow::sendFile(QSocket* s) ");
1414 if ( mSyncActionDialog ) 1481 if ( mSyncActionDialog )
1415 delete mSyncActionDialog; 1482 delete mSyncActionDialog;
1416 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 1483 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
1417 mSyncActionDialog->setCaption(i18n("Received sync request")); 1484 mSyncActionDialog->setCaption(i18n("Received sync request"));
1418 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 1485 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
1419 label->setAlignment ( Qt::AlignHCenter ); 1486 label->setAlignment ( Qt::AlignHCenter );
1420 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1487 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
1421 lay->addWidget( label); 1488 lay->addWidget( label);
1422 lay->setMargin(7); 1489 lay->setMargin(7);
1423 lay->setSpacing(7); 1490 lay->setSpacing(7);
1424 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1491 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1425 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); 1492 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent );
1426 //secs = 333; 1493 //secs = 333;
1427 if ( secs < 0 ) 1494 if ( secs < 0 )
1428 secs = secs * (-1); 1495 secs = secs * (-1);
1429 if ( secs > 30 ) 1496 if ( secs > 30 )
1430 //if ( true ) 1497 //if ( true )
1431 { 1498 {
1432 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); 1499 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs );
1433 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1500 QLabel* label = new QLabel( warning, mSyncActionDialog );
1434 label->setAlignment ( Qt::AlignHCenter ); 1501 label->setAlignment ( Qt::AlignHCenter );
1435 lay->addWidget( label); 1502 lay->addWidget( label);
1436 if ( secs > 180 ) 1503 if ( secs > 180 )
1437 { 1504 {
1438 if ( secs > 300 ) { 1505 if ( secs > 300 ) {
1439 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { 1506 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) {
1440 qDebug("KSS::Sync cancelled ,cs"); 1507 qDebug("KSS::Sync cancelled ,cs");
1441 mErrorMessage = 0; 1508 mErrorMessage = 0;
1442 end_connect(); 1509 end_connect();
1443 error_connect("ERROR_CA\r\n\r\n"); 1510 error_connect("ERROR_CA\r\n\r\n");
1444 return ; 1511 return ;
1445 } 1512 }
1446 } 1513 }
1447 QFont f = label->font(); 1514 QFont f = label->font();
1448 f.setPointSize ( f.pointSize() *2 ); 1515 f.setPointSize ( f.pointSize() *2 );
1449 f. setBold (true ); 1516 f. setBold (true );
1450 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1517 QLabel* label = new QLabel( warning, mSyncActionDialog );
1451 label->setFont( f ); 1518 label->setFont( f );
1452 warning = i18n("ADJUST\nYOUR\nCLOCKS!"); 1519 warning = i18n("ADJUST\nYOUR\nCLOCKS!");
1453 label->setText( warning ); 1520 label->setText( warning );
1454 label->setAlignment ( Qt::AlignHCenter ); 1521 label->setAlignment ( Qt::AlignHCenter );
1455 lay->addWidget( label); 1522 lay->addWidget( label);
1456 mSyncActionDialog->setFixedSize( 230, 300); 1523 mSyncActionDialog->setFixedSize( 230, 300);
1457 } else { 1524 } else {
1458 mSyncActionDialog->setFixedSize( 230, 200); 1525 mSyncActionDialog->setFixedSize( 230, 200);
1459 } 1526 }
1460 } else { 1527 } else {
1461 mSyncActionDialog->setFixedSize( 230, 120); 1528 mSyncActionDialog->setFixedSize( 230, 120);
1462 } 1529 }
1463 } else 1530 } else
1464 mSyncActionDialog->setFixedSize( 230, 120); 1531 mSyncActionDialog->setFixedSize( 230, 120);
1465 mSyncActionDialog->show(); 1532 mSyncActionDialog->show();
1466 mSyncActionDialog->raise(); 1533 mSyncActionDialog->raise();
1467 emit request_file(mResource); 1534 emit request_file(mResource);
1468 //emit request_file(); 1535 //emit request_file();
1469 qApp->processEvents(); 1536 qApp->processEvents();
1470 QString fileName = mFileName; 1537 QString fileName = mFileName;
1471 QFile file( fileName ); 1538 QFile file( fileName );
1472 if (!file.open( IO_ReadOnly ) ) { 1539 if (!file.open( IO_ReadOnly ) ) {
1473 mErrorMessage = 0; 1540 mErrorMessage = 0;
1474 end_connect(); 1541 end_connect();
1475 error_connect("ERROR_FI\r\n\r\n"); 1542 error_connect("ERROR_FI\r\n\r\n");
1476 return ; 1543 return ;
1477 } 1544 }
1478 mSyncActionDialog->setCaption( i18n("Sending file...") ); 1545 mSyncActionDialog->setCaption( i18n("Sending file...") );
1479 QTextStream ts( &file ); 1546 QTextStream ts( &file );
1480 ts.setEncoding( QTextStream::Latin1 ); 1547 ts.setEncoding( QTextStream::Latin1 );
1481 1548
1482 QTextStream os( mSocket ); 1549 QTextStream os( mSocket );
1483 os.setEncoding( QTextStream::Latin1 ); 1550 os.setEncoding( QTextStream::Latin1 );
1484 while ( ! ts.atEnd() ) { 1551 while ( ! ts.atEnd() ) {
1485 os << ts.readLine() << "\r\n"; 1552 os << ts.readLine() << "\r\n";
1486 } 1553 }
1487 os << "\r\n"; 1554 os << "\r\n";
1488 //os << ts.read(); 1555 //os << ts.read();
1489 file.close(); 1556 file.close();
1490 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 1557 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
1491 mSocket->close(); 1558 mSocket->close();
1492 if ( mSocket->state() == QSocket::Idle ) 1559 if ( mSocket->state() == QSocket::Idle )
1493 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1560 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1494} 1561}
1495void KServerSocket::get_file() 1562void KServerSocket::get_file()
1496{ 1563{
1497 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 1564 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
1498 1565
1499 piTime.start(); 1566 piTime.start();
1500 piFileString = ""; 1567 piFileString = "";
1501 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 1568 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
1502} 1569}
1503 1570
1504 1571
1505void KServerSocket::readBackFileFromSocket() 1572void KServerSocket::readBackFileFromSocket()
1506{ 1573{
1507 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 1574 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
1508 while ( mSocket->canReadLine () ) { 1575 while ( mSocket->canReadLine () ) {
1509 piTime.restart(); 1576 piTime.restart();
1510 QString line = mSocket->readLine (); 1577 QString line = mSocket->readLine ();
1511 piFileString += line; 1578 piFileString += line;
1512 //qDebug("readline: %s ", line.latin1()); 1579 //qDebug("readline: %s ", line.latin1());
1513 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 1580 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
1514 1581
1515 } 1582 }
1516 if ( piTime.elapsed () < 3000 ) { 1583 if ( piTime.elapsed () < 3000 ) {
1517 // wait for more 1584 // wait for more
1518 //qDebug("waitformore "); 1585 //qDebug("waitformore ");
1519 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 1586 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
1520 return; 1587 return;
1521 } 1588 }
1522 QString fileName = mFileName; 1589 QString fileName = mFileName;
1523 QFile file ( fileName ); 1590 QFile file ( fileName );
1524 if (!file.open( IO_WriteOnly ) ) { 1591 if (!file.open( IO_WriteOnly ) ) {
1525 delete mSyncActionDialog; 1592 delete mSyncActionDialog;
1526 mSyncActionDialog = 0; 1593 mSyncActionDialog = 0;
1527 qDebug("KSS:Error open read back file "); 1594 qDebug("KSS:Error open read back file ");
1528 piFileString = ""; 1595 piFileString = "";
1529 emit file_received( false, mResource); 1596 emit file_received( false, mResource);
1530 emit file_received( false); 1597 emit file_received( false);
1531 blockRC = false; 1598 blockRC = false;
1532 return ; 1599 return ;
1533 1600
1534 } 1601 }
1535 1602
1536 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1603 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1537 QTextStream ts ( &file ); 1604 QTextStream ts ( &file );
1538 ts.setEncoding( QTextStream::Latin1 ); 1605 ts.setEncoding( QTextStream::Latin1 );
1539 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 1606 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1540 ts << piFileString; 1607 ts << piFileString;
1541 mSocket->close(); 1608 mSocket->close();
1542 if ( mSocket->state() == QSocket::Idle ) 1609 if ( mSocket->state() == QSocket::Idle )
1543 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1610 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1544 file.close(); 1611 file.close();
1545 piFileString = ""; 1612 piFileString = "";
1546 emit file_received( true, mResource ); 1613 emit file_received( true, mResource );
1547 emit file_received( true); 1614 emit file_received( true);
1548 delete mSyncActionDialog; 1615 delete mSyncActionDialog;
1549 mSyncActionDialog = 0; 1616 mSyncActionDialog = 0;
1550 blockRC = false; 1617 blockRC = false;
1551 1618
1552} 1619}
1553 1620
1554KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) 1621KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name )
1555{ 1622{
1556 mRemoteResource = remres; 1623 mRemoteResource = remres;
1557 if ( mRemoteResource.isEmpty() ) 1624 if ( mRemoteResource.isEmpty() )
1558 mRemoteResource = "ALL"; 1625 mRemoteResource = "ALL";
1559 else 1626 else
1560 mRemoteResource.replace (QRegExp (" "),"_" ); 1627 mRemoteResource.replace (QRegExp (" "),"_" );
1561 mPassWord = password; 1628 mPassWord = password;
1562 mSocket = 0; 1629 mSocket = 0;
1563 mFirst = false; 1630 mFirst = false;
1564 mFirstLine = true; 1631 mFirstLine = true;
1565 mPort = port; 1632 mPort = port;
1566 mHost = host; 1633 mHost = host;
1567 tlw = cap; 1634 tlw = cap;
1568 mRetVal = quiet; 1635 mRetVal = quiet;
1569 mTimerSocket = new QTimer ( this ); 1636 mTimerSocket = new QTimer ( this );
1570 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) ); 1637 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) );
1571 mConnectProgress.setCaption( i18n("Pi-Sync") ); 1638 mConnectProgress.setCaption( i18n("Pi-Sync") );
1572 connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) ); 1639 connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) );
1573 mConnectCount = -1; 1640 mConnectCount = -1;
1574} 1641}
1575void KCommandSocket::sendFileRequest() 1642void KCommandSocket::sendFileRequest()
1576{ 1643{
1577 if ( tlw ) 1644 if ( tlw )
1578 tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); 1645 tlw->setCaption( i18n("Connected! Sending request for remote file ...") );
1579 mConnectProgress.hide(); 1646 mConnectProgress.hide();
1580 mConnectCount = 300;mConnectMax = 300; 1647 mConnectCount = 300;mConnectMax = 300;
1581 mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); 1648 mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") );
1582 mConnectProgress.setLabelText( i18n("Waiting for remote file...") ); 1649 mConnectProgress.setLabelText( i18n("Waiting for remote file...") );
1583 mTimerSocket->start( 100, true ); 1650 mTimerSocket->start( 100, true );
1584 QTextStream os( mSocket ); 1651 QTextStream os( mSocket );
1585 os.setEncoding( QTextStream::Latin1 ); 1652 os.setEncoding( QTextStream::Latin1 );
1586 1653
1587 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); 1654 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate );
1588 os << "GET " << mPassWord << curDt << " " << mRemoteResource << "\r\n\r\n"; 1655 os << "GET " << mPassWord << curDt << " " << mRemoteResource << "\r\n\r\n";
1589} 1656}
1590 1657
1591void KCommandSocket::readFile( QString fn ) 1658void KCommandSocket::readFile( QString fn )
1592{ 1659{
1593 if ( !mSocket ) { 1660 if ( !mSocket ) {
1594 mSocket = new QSocket( this ); 1661 mSocket = new QSocket( this );
1595 //qDebug("KCS: read file - new socket"); 1662 //qDebug("KCS: read file - new socket");
1596 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1663 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1597 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1664 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1598 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); 1665 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() ));
1599 } 1666 }
1600 mFileString = ""; 1667 mFileString = "";
1601 mFileName = fn; 1668 mFileName = fn;
1602 mFirst = true; 1669 mFirst = true;
1603 if ( tlw ) 1670 if ( tlw )
1604 tlw->setCaption( i18n("Trying to connect to remote...") ); 1671 tlw->setCaption( i18n("Trying to connect to remote...") );
1605 mConnectCount = 30;mConnectMax = 30; 1672 mConnectCount = 30;mConnectMax = 30;
1606 mTimerSocket->start( 1000, true ); 1673 mTimerSocket->start( 1000, true );
1607 mSocket->connectToHost( mHost, mPort ); 1674 mSocket->connectToHost( mHost, mPort );
1608 //qDebug("KCS: Waiting for connection"); 1675 //qDebug("KCS: Waiting for connection");
1609} 1676}
1610void KCommandSocket::updateConnectDialog() 1677void KCommandSocket::updateConnectDialog()
1611{ 1678{
1612 1679
1613 if ( mConnectCount == mConnectMax ) { 1680 if ( mConnectCount == mConnectMax ) {
1614 //qDebug("MAXX %d", mConnectMax); 1681 //qDebug("MAXX %d", mConnectMax);
1615 mConnectProgress.setTotalSteps ( 30 ); 1682 mConnectProgress.setTotalSteps ( 30 );
1616 mConnectProgress.show(); 1683 mConnectProgress.show();
1617 mConnectProgress.setLabelText( i18n("Trying to connect to remote...") ); 1684 mConnectProgress.setLabelText( i18n("Trying to connect to remote...") );
1618 } 1685 }
1619 //qDebug("updateConnectDialog() %d", mConnectCount); 1686 //qDebug("updateConnectDialog() %d", mConnectCount);
1620 mConnectProgress.raise(); 1687 mConnectProgress.raise();
1621 mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 ); 1688 mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 );
1622 --mConnectCount; 1689 --mConnectCount;
1623 if ( mConnectCount > 0 ) 1690 if ( mConnectCount > 0 )
1624 mTimerSocket->start( 1000, true ); 1691 mTimerSocket->start( 1000, true );
1625 else 1692 else
1626 deleteSocket(); 1693 deleteSocket();
1627 1694
1628} 1695}
1629void KCommandSocket::writeFile( QString fileName ) 1696void KCommandSocket::writeFile( QString fileName )
1630{ 1697{
1631 if ( !mSocket ) { 1698 if ( !mSocket ) {
1632 mSocket = new QSocket( this ); 1699 mSocket = new QSocket( this );
1633 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1700 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1634 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 1701 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1635 } 1702 }
1636 mFileName = fileName ; 1703 mFileName = fileName ;
1637 mConnectCount = 30;mConnectMax = 30; 1704 mConnectCount = 30;mConnectMax = 30;
1638 mTimerSocket->start( 1000, true ); 1705 mTimerSocket->start( 1000, true );
1639 mSocket->connectToHost( mHost, mPort ); 1706 mSocket->connectToHost( mHost, mPort );
1640} 1707}
1641void KCommandSocket::writeFileToSocket() 1708void KCommandSocket::writeFileToSocket()
1642{ 1709{
1643 mTimerSocket->stop(); 1710 mTimerSocket->stop();
1644 QFile file2( mFileName ); 1711 QFile file2( mFileName );
1645 if (!file2.open( IO_ReadOnly ) ) { 1712 if (!file2.open( IO_ReadOnly ) ) {
1646 mConnectProgress.hide(); 1713 mConnectProgress.hide();
1647 mConnectCount = -1; 1714 mConnectCount = -1;
1648 mRetVal= errorW; 1715 mRetVal= errorW;
1649 mSocket->close(); 1716 mSocket->close();
1650 if ( mSocket->state() == QSocket::Idle ) 1717 if ( mSocket->state() == QSocket::Idle )
1651 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1718 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1652 return ; 1719 return ;
1653 } 1720 }
1654 mConnectProgress.setTotalSteps ( file2.size() ); 1721 mConnectProgress.setTotalSteps ( file2.size() );
1655 mConnectProgress.show(); 1722 mConnectProgress.show();
1656 int count = 0; 1723 int count = 0;
1657 mConnectProgress.setLabelText( i18n("Sending back synced file...") ); 1724 mConnectProgress.setLabelText( i18n("Sending back synced file...") );
1658 mConnectProgress.setProgress( count ); 1725 mConnectProgress.setProgress( count );
1659 mConnectProgress.blockSignals( true ); 1726 mConnectProgress.blockSignals( true );
1660 QTextStream ts2( &file2 ); 1727 QTextStream ts2( &file2 );
1661 ts2.setEncoding( QTextStream::Latin1 ); 1728 ts2.setEncoding( QTextStream::Latin1 );
1662 QTextStream os2( mSocket ); 1729 QTextStream os2( mSocket );
1663 os2.setEncoding( QTextStream::Latin1 ); 1730 os2.setEncoding( QTextStream::Latin1 );
1664 os2 << "PUT " << mPassWord << " " << mRemoteResource << "\r\n\r\n";; 1731 os2 << "PUT " << mPassWord << " " << mRemoteResource << "\r\n\r\n";;
1665 int byteCount = 0; 1732 int byteCount = 0;
1666 int byteMax = file2.size()/53; 1733 int byteMax = file2.size()/53;
1667 while ( ! ts2.atEnd() ) { 1734 while ( ! ts2.atEnd() ) {
1668 qApp->processEvents(); 1735 qApp->processEvents();
1669 if ( byteCount > byteMax ) { 1736 if ( byteCount > byteMax ) {
1670 byteCount = 0; 1737 byteCount = 0;
1671 mConnectProgress.setProgress( count ); 1738 mConnectProgress.setProgress( count );
1672 } 1739 }
1673 QString temp = ts2.readLine(); 1740 QString temp = ts2.readLine();
1674 count += temp.length(); 1741 count += temp.length();
1675 byteCount += temp.length(); 1742 byteCount += temp.length();
1676 os2 << temp << "\r\n"; 1743 os2 << temp << "\r\n";
1677 } 1744 }
1678 file2.close(); 1745 file2.close();
1679 mConnectProgress.hide(); 1746 mConnectProgress.hide();
1680 mConnectCount = -1; 1747 mConnectCount = -1;
1681 os2 << "\r\n"; 1748 os2 << "\r\n";
1682 mRetVal= successW; 1749 mRetVal= successW;
1683 mSocket->close(); 1750 mSocket->close();
1684 if ( mSocket->state() == QSocket::Idle ) 1751 if ( mSocket->state() == QSocket::Idle )
1685 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1752 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1686 mConnectProgress.blockSignals( false ); 1753 mConnectProgress.blockSignals( false );
1687} 1754}
1688void KCommandSocket::sendStop() 1755void KCommandSocket::sendStop()
1689{ 1756{
1690 if ( !mSocket ) { 1757 if ( !mSocket ) {
1691 mSocket = new QSocket( this ); 1758 mSocket = new QSocket( this );
1692 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1759 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1693 } 1760 }
1694 mSocket->connectToHost( mHost, mPort ); 1761 mSocket->connectToHost( mHost, mPort );
1695 QTextStream os2( mSocket ); 1762 QTextStream os2( mSocket );
1696 os2.setEncoding( QTextStream::Latin1 ); 1763 os2.setEncoding( QTextStream::Latin1 );
1697 os2 << "STOP\r\n\r\n"; 1764 os2 << "STOP\r\n\r\n";
1698 mSocket->close(); 1765 mSocket->close();
1699 if ( mSocket->state() == QSocket::Idle ) 1766 if ( mSocket->state() == QSocket::Idle )
1700 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1767 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1701} 1768}
1702 1769
1703void KCommandSocket::startReadFileFromSocket() 1770void KCommandSocket::startReadFileFromSocket()
1704{ 1771{
1705 if ( ! mFirst ) 1772 if ( ! mFirst )
1706 return; 1773 return;
1707 mConnectProgress.setLabelText( i18n("Receiving file from remote...") ); 1774 mConnectProgress.setLabelText( i18n("Receiving file from remote...") );
1708 mFirst = false; 1775 mFirst = false;
1709 mFileString = ""; 1776 mFileString = "";
1710 mTime.start(); 1777 mTime.start();
1711 mFirstLine = true; 1778 mFirstLine = true;
1712 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 1779 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
1713 1780
1714} 1781}
1715void KCommandSocket::readFileFromSocket() 1782void KCommandSocket::readFileFromSocket()
1716{ 1783{
1717 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 1784 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
1718 while ( mSocket->canReadLine () ) { 1785 while ( mSocket->canReadLine () ) {
1719 mTime.restart(); 1786 mTime.restart();
1720 QString line = mSocket->readLine (); 1787 QString line = mSocket->readLine ();
1721 if ( mFirstLine ) { 1788 if ( mFirstLine ) {
1722 mFirstLine = false; 1789 mFirstLine = false;
1723 if ( line.left( 6 ) == "ERROR_" ) { 1790 if ( line.left( 6 ) == "ERROR_" ) {
1724 mTimerSocket->stop(); 1791 mTimerSocket->stop();
1725 mConnectCount = -1; 1792 mConnectCount = -1;
1726 if ( line.left( 8 ) == "ERROR_PW" ) { 1793 if ( line.left( 8 ) == "ERROR_PW" ) {
1727 mRetVal = errorPW; 1794 mRetVal = errorPW;
1728 deleteSocket(); 1795 deleteSocket();
1729 return ; 1796 return ;
1730 } 1797 }
1731 if ( line.left( 8 ) == "ERROR_CA" ) { 1798 if ( line.left( 8 ) == "ERROR_CA" ) {
1732 mRetVal = errorCA; 1799 mRetVal = errorCA;
1733 deleteSocket(); 1800 deleteSocket();
1734 return ; 1801 return ;
1735 } 1802 }
1736 if ( line.left( 8 ) == "ERROR_FI" ) { 1803 if ( line.left( 8 ) == "ERROR_FI" ) {
1737 mRetVal = errorFI; 1804 mRetVal = errorFI;
1738 deleteSocket(); 1805 deleteSocket();
1739 return ; 1806 return ;
1740 } 1807 }
1741 if ( line.left( 8 ) == "ERROR_ED" ) { 1808 if ( line.left( 8 ) == "ERROR_ED" ) {
1742 mRetVal = errorED; 1809 mRetVal = errorED;
1743 deleteSocket(); 1810 deleteSocket();
1744 return ; 1811 return ;
1745 } 1812 }
1746 mRetVal = errorUN; 1813 mRetVal = errorUN;
1747 deleteSocket(); 1814 deleteSocket();
1748 return ; 1815 return ;
1749 } 1816 }
1750 } 1817 }
1751 mFileString += line; 1818 mFileString += line;
1752 //qDebug("readline: %s ", line.latin1()); 1819 //qDebug("readline: %s ", line.latin1());
1753 } 1820 }
1754 if ( mTime.elapsed () < 3000 ) { 1821 if ( mTime.elapsed () < 3000 ) {
1755 // wait for more 1822 // wait for more
1756 //qDebug("waitformore "); 1823 //qDebug("waitformore ");
1757 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 1824 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
1758 return; 1825 return;
1759 } 1826 }
1760 mTimerSocket->stop(); 1827 mTimerSocket->stop();
1761 mConnectCount = -1; 1828 mConnectCount = -1;
1762 mConnectProgress.hide(); 1829 mConnectProgress.hide();
1763 QString fileName = mFileName; 1830 QString fileName = mFileName;
1764 QFile file ( fileName ); 1831 QFile file ( fileName );
1765 if (!file.open( IO_WriteOnly ) ) { 1832 if (!file.open( IO_WriteOnly ) ) {
1766 mFileString = ""; 1833 mFileString = "";
1767 mRetVal = errorR; 1834 mRetVal = errorR;
1768 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); 1835 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() );
1769 deleteSocket(); 1836 deleteSocket();
1770 return ; 1837 return ;
1771 1838
1772 } 1839 }
1773 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1840 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1774 QTextStream ts ( &file ); 1841 QTextStream ts ( &file );
1775 ts.setEncoding( QTextStream::Latin1 ); 1842 ts.setEncoding( QTextStream::Latin1 );
1776 ts << mFileString; 1843 ts << mFileString;
1777 file.close(); 1844 file.close();
1778 mFileString = ""; 1845 mFileString = "";
1779 mRetVal = successR; 1846 mRetVal = successR;
1780 mSocket->close(); 1847 mSocket->close();
1781 // if state is not idle, deleteSocket(); is called via 1848 // if state is not idle, deleteSocket(); is called via
1782 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1849 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1783 if ( mSocket->state() == QSocket::Idle ) 1850 if ( mSocket->state() == QSocket::Idle )
1784 deleteSocket(); 1851 deleteSocket();
1785} 1852}
1786 1853
1787void KCommandSocket::deleteSocket() 1854void KCommandSocket::deleteSocket()
1788{ 1855{
1789 //qDebug("KCommandSocket::deleteSocket() "); 1856 //qDebug("KCommandSocket::deleteSocket() ");
1790 mConnectProgress.hide(); 1857 mConnectProgress.hide();
1791 1858
1792 if ( mConnectCount >= 0 ) { 1859 if ( mConnectCount >= 0 ) {
1793 mTimerSocket->stop(); 1860 mTimerSocket->stop();
1794 mRetVal = errorTO; 1861 mRetVal = errorTO;
1795 qDebug("KCS::Connection to remote host timed out"); 1862 qDebug("KCS::Connection to remote host timed out");
1796 if ( mSocket ) { 1863 if ( mSocket ) {
1797 mSocket->close(); 1864 mSocket->close();
1798 //if ( mSocket->state() == QSocket::Idle ) 1865 //if ( mSocket->state() == QSocket::Idle )
1799 // deleteSocket(); 1866 // deleteSocket();
1800 delete mSocket; 1867 delete mSocket;
1801 mSocket = 0; 1868 mSocket = 0;
1802 } 1869 }
1803 if ( mConnectCount == 0 ) 1870 if ( mConnectCount == 0 )
1804 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?")); 1871 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?"));
1805 else if ( tlw ) 1872 else if ( tlw )
1806 tlw->setCaption( i18n("Connection to remote host cancelled!") ); 1873 tlw->setCaption( i18n("Connection to remote host cancelled!") );
1807 emit commandFinished( this, mRetVal ); 1874 emit commandFinished( this, mRetVal );
1808 return; 1875 return;
1809 } 1876 }
1810 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 1877 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
1811 if ( mSocket) 1878 if ( mSocket)
1812 delete mSocket; 1879 delete mSocket;
1813 mSocket = 0; 1880 mSocket = 0;
1814 //qDebug("commandFinished "); 1881 //qDebug("commandFinished ");
1815 emit commandFinished( this, mRetVal ); 1882 emit commandFinished( this, mRetVal );
1816} 1883}
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 04cdade..71d17e9 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,249 +1,248 @@
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#include <qprogressdialog.h> 32#include <qprogressdialog.h>
33#include <kdialog.h> 33#include <kdialog.h>
34 34
35class QPopupMenu; 35class QPopupMenu;
36class KSyncProfile; 36class KSyncProfile;
37class KPimPrefs; 37class KPimPrefs;
38class QWidget; 38class QWidget;
39class KSyncManager; 39class KSyncManager;
40class KSyncInterface; 40class KSyncInterface;
41class QProgressBar; 41class QProgressBar;
42 42
43 43
44class KServerSocket : public QServerSocket 44class KServerSocket : public QServerSocket
45{ 45{
46 Q_OBJECT 46 Q_OBJECT
47 47
48 public: 48 public:
49 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); 49 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
50 50
51 void newConnection ( int socket ) ; 51 void newConnection ( int socket ) ;
52 void setFileName( QString fn ) {mFileName = fn;}; 52 void setFileName( QString fn ) {mFileName = fn;};
53 signals: 53 signals:
54 void file_received( bool ); 54 void file_received( bool );
55 void request_file(); 55 void request_file();
56 void file_received( bool, const QString &); 56 void file_received( bool, const QString &);
57 void request_file(const QString &); 57 void request_file(const QString &);
58 void saveFile(); 58 void saveFile();
59 void endConnect(); 59 void endConnect();
60 private slots: 60 private slots:
61 void waitForSocketFinish(); 61 void waitForSocketFinish();
62 void discardClient(); 62 void discardClient();
63 void deleteSocket(); 63 void deleteSocket();
64 void readClient(); 64 void readClient();
65 void displayErrorMessage(); 65 void displayErrorMessage();
66 void readBackFileFromSocket(); 66 void readBackFileFromSocket();
67 private : 67 private :
68 int mPendingConnect; 68 int mPendingConnect;
69 QString mResource; 69 QString mResource;
70 int mErrorMessage; 70 int mErrorMessage;
71 bool blockRC; 71 bool blockRC;
72 void send_file(); 72 void send_file();
73 void get_file(); 73 void get_file();
74 void end_connect(); 74 void end_connect();
75 void error_connect( QString ); 75 void error_connect( QString );
76 QDialog* mSyncActionDialog; 76 QDialog* mSyncActionDialog;
77 QSocket* mSocket; 77 QSocket* mSocket;
78 QString mPassWord; 78 QString mPassWord;
79 QString mFileName; 79 QString mFileName;
80 QTime piTime; 80 QTime piTime;
81 QString piFileString; 81 QString piFileString;
82}; 82};
83 83
84class KCommandSocket : public QObject 84class KCommandSocket : public QObject
85{ 85{
86 Q_OBJECT 86 Q_OBJECT
87 public: 87 public:
88 enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet }; 88 enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet };
89 KCommandSocket (QString remoteResource, QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 ); 89 KCommandSocket (QString remoteResource, QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 );
90 void readFile( QString ); 90 void readFile( QString );
91 void writeFile( QString ); 91 void writeFile( QString );
92 void sendStop(); 92 void sendStop();
93 93
94 private slots : 94 private slots :
95 void sendFileRequest(); 95 void sendFileRequest();
96 void updateConnectDialog(); 96 void updateConnectDialog();
97 97
98 signals: 98 signals:
99 void commandFinished( KCommandSocket*, int ); 99 void commandFinished( KCommandSocket*, int );
100 private slots: 100 private slots:
101 void startReadFileFromSocket(); 101 void startReadFileFromSocket();
102 void readFileFromSocket(); 102 void readFileFromSocket();
103 void deleteSocket(); 103 void deleteSocket();
104 void writeFileToSocket(); 104 void writeFileToSocket();
105 private : 105 private :
106 QString mRemoteResource; 106 QString mRemoteResource;
107 int mConnectCount; 107 int mConnectCount;
108 int mConnectMax; 108 int mConnectMax;
109 KProgressDialog mConnectProgress; 109 KProgressDialog mConnectProgress;
110 QWidget* tlw; 110 QWidget* tlw;
111 QSocket* mSocket; 111 QSocket* mSocket;
112 QString mPassWord; 112 QString mPassWord;
113 Q_UINT16 mPort; 113 Q_UINT16 mPort;
114 QString mHost; 114 QString mHost;
115 QString mFileName; 115 QString mFileName;
116 QTimer* mTimerSocket; 116 QTimer* mTimerSocket;
117 int mRetVal; 117 int mRetVal;
118 QTime mTime; 118 QTime mTime;
119 QString mFileString; 119 QString mFileString;
120 bool mFirst; 120 bool mFirst;
121 bool mFirstLine; 121 bool mFirstLine;
122}; 122};
123 123
124 124
125class KSyncManager : public QObject 125class KSyncManager : public QObject
126{ 126{
127 Q_OBJECT 127 Q_OBJECT
128 128
129 public: 129 public:
130 enum TargetApp { 130 enum TargetApp {
131 KOPI = 0, 131 KOPI = 0,
132 KAPI = 1, 132 KAPI = 1,
133 PWMPI = 2 }; 133 PWMPI = 2 };
134 134
135 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 135 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
136 ~KSyncManager() ; 136 ~KSyncManager() ;
137 137
138 void multiSync( bool askforPrefs ); 138 void multiSync( bool askforPrefs );
139 bool blockSave() { return mBlockSaveFlag; } 139 bool blockSave() { return mBlockSaveFlag; }
140 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 140 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
141 void setDefaultFileName( QString s) ; 141 void setDefaultFileName( QString s) ;
142 QString defaultFileName() { return mDefFileName ;} 142 QString defaultFileName() { return mDefFileName ;}
143 QString syncFileName(); 143 QString syncFileName();
144 void enableQuick( bool ask = true); 144 void enableQuick( bool ask = true);
145 145
146 bool syncWithDesktop () { return mSyncWithDesktop;} 146 bool syncWithDesktop () { return mSyncWithDesktop;}
147 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 147 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
148 QString getCurrentSyncName() { return mCurrentSyncName; } 148 QString getCurrentSyncName() { return mCurrentSyncName; }
149 149
150 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 150 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
151 void hideProgressBar(); 151 void hideProgressBar();
152 bool isProgressBarCanceled(); 152 bool isProgressBarCanceled();
153 153
154 // sync stuff 154 // sync stuff
155 QString mLocalMachineName; 155 QString mLocalMachineName;
156 QStringList mExternSyncProfiles; 156 QStringList mExternSyncProfiles;
157 QStringList mSyncProfileNames; 157 QStringList mSyncProfileNames;
158 bool mAskForPreferences; 158 bool mAskForPreferences;
159 bool mShowSyncSummary; 159 bool mShowSyncSummary;
160 bool mIsKapiFile; 160 bool mIsKapiFile;
161 bool mWriteBackExistingOnly; 161 bool mWriteBackExistingOnly;
162 int mSyncAlgoPrefs; 162 int mSyncAlgoPrefs;
163 bool mWriteBackFile; 163 bool mWriteBackFile;
164 int mWriteBackInFuture; 164 int mWriteBackInFuture;
165 int mWriteBackInPast; 165 int mWriteBackInPast;
166 QString mPhoneDevice; 166 QString mPhoneDevice;
167 QString mPhoneConnection; 167 QString mPhoneConnection;
168 QString mPhoneModel; 168 QString mPhoneModel;
169 QString mPassWordPiSync; 169 QString mPassWordPiSync;
170 QString mActiveSyncPort; 170 QString mActiveSyncPort;
171 QString mActiveSyncIP ; 171 QString mActiveSyncIP ;
172 QString mFilterInCal; 172 QString mFilterInCal;
173 QString mFilterOutCal; 173 QString mFilterOutCal;
174 QString mFilterInAB; 174 QString mFilterInAB;
175 QString mFilterOutAB; 175 QString mFilterOutAB;
176 static QDateTime mRequestedSyncEvent; 176 static QDateTime mRequestedSyncEvent;
177 177
178 signals: 178 signals:
179 void save(); 179 void save();
180 void request_file(); 180 void request_file();
181 void getFile( bool ); 181 void getFile( bool );
182 void getFile( bool, const QString &); 182 void getFile( bool, const QString &);
183 void request_file(const QString &); 183 void request_file(const QString &);
184 void multiResourceSyncStart( bool ); 184 void multiResourceSyncStart( bool );
185 185
186 public slots: 186 public slots:
187 void slotSyncMenu( int ); 187 void slotSyncMenu( int );
188 void slotClearMenu( int action ); 188 void slotClearMenu( int action );
189 void deleteCommandSocket(KCommandSocket*s, int state); 189 void deleteCommandSocket(KCommandSocket*s, int state);
190 void readFileFromSocket(); 190 void readFileFromSocket();
191 void fillSyncMenu(); 191 void fillSyncMenu();
192 192
193 private: 193 private:
194 void syncPi(); 194 void syncPi();
195 KServerSocket * mServerSocket; 195 KServerSocket * mServerSocket;
196 KPimPrefs* mPrefs; 196 KPimPrefs* mPrefs;
197 QString mDefFileName; 197 QString mDefFileName;
198 QString mCurrentSyncDevice; 198 QString mCurrentSyncDevice;
199 QString mCurrentSyncName; 199 QString mCurrentSyncName;
200 void quickSyncLocalFile(); 200 void quickSyncLocalFile();
201 bool syncWithFile( QString fn , bool quick ); 201 bool syncWithFile( QString fn , bool quick );
202 void syncLocalFile(); 202 void syncLocalFile();
203 void syncPhone(); 203 void syncPhone();
204 void syncSharp(); 204 void syncSharp();
205 void syncKDE(); 205 void syncKDE();
206 void syncOL();
206 bool syncExternalApplication(QString); 207 bool syncExternalApplication(QString);
207 int mCurrentSyncProfile ; 208 int mCurrentSyncProfile ;
208 void syncRemote( KSyncProfile* prof, bool ask = true); 209 void syncRemote( KSyncProfile* prof, bool ask = true);
209 bool edit_sync_options(); 210 bool edit_sync_options();
210 bool edit_pisync_options(); 211 bool edit_pisync_options();
211 int ringSync(); 212 int ringSync();
212 QString getPassword( ); 213 QString getPassword( );
213 bool mPisyncFinished; 214 bool mPisyncFinished;
214 QStringList mSpecificResources; 215 QStringList mSpecificResources;
215 QString mCurrentResourceLocal; 216 QString mCurrentResourceLocal;
216 QString mCurrentResourceRemote; 217 QString mCurrentResourceRemote;
217 bool mBlockSaveFlag; 218 bool mBlockSaveFlag;
218 QWidget* mParent; 219 QWidget* mParent;
219 KSyncInterface* mImplementation; 220 KSyncInterface* mImplementation;
220 TargetApp mTargetApp; 221 TargetApp mTargetApp;
221 QPopupMenu* mSyncMenu; 222 QPopupMenu* mSyncMenu;
222 QProgressBar* bar; 223 QProgressBar* bar;
223 bool mSyncWithDesktop; 224 bool mSyncWithDesktop;
224 225
225private slots: 226private slots:
226 void displayErrorPort(); 227 void displayErrorPort();
227 void confSync(); 228 void confSync();
228 229
229 230
230}; 231};
231 232
232 233
233class KSyncInterface 234class KSyncInterface
234{ 235{
235 public : 236 public :
236 virtual void removeSyncInfo( QString syncProfile) = 0; 237 virtual void removeSyncInfo( QString syncProfile) = 0;
237 virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0; 238 virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0;
238 virtual bool syncExternal(KSyncManager* /*manager*/, QString /*resource*/) 239 virtual bool syncExternal(KSyncManager* /*manager*/, QString /*resource*/)
239 { 240 {
240 // empty implementation, because some syncable applications do not 241 // empty implementation, because some syncable applications do not
241 // have an external(sharpdtm) syncmode, like pwmanager. 242 // have an external(sharpdtm) syncmode, like pwmanager.
242 return false; 243 return false;
243 } 244 }
244
245
246}; 245};
247 246
248 247
249#endif 248#endif
diff --git a/libkdepim/libkdepim.pro b/libkdepim/libkdepim.pro
index 84af7ad..7160d0e 100644
--- a/libkdepim/libkdepim.pro
+++ b/libkdepim/libkdepim.pro
@@ -1,61 +1,76 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG = qt warn_on 2 CONFIG = qt warn_on
3DEFINES +=KORG_NOKABC 3DEFINES +=KORG_NOKABC
4TARGET = microkdepim 4TARGET = microkdepim
5INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kdeui . .. 5INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kdeui . ..
6DESTDIR=../bin 6DESTDIR=../bin
7 7
8DEFINES += DESKTOP_VERSION 8DEFINES += DESKTOP_VERSION
9include( ../variables.pri ) 9include( ../variables.pri )
10unix : { 10unix : {
11OBJECTS_DIR = obj/unix 11OBJECTS_DIR = obj/unix
12MOC_DIR = moc/unix 12MOC_DIR = moc/unix
13} 13}
14win32: { 14win32: {
15DEFINES += _WIN32_ 15DEFINES += _WIN32_
16OBJECTS_DIR = obj/win 16OBJECTS_DIR = obj/win
17MOC_DIR = moc/win 17MOC_DIR = moc/win
18} 18}
19INTERFACES = \ 19INTERFACES = \
20 20
21HEADERS = \ 21HEADERS = \
22 categoryeditdialog.h \ 22 categoryeditdialog.h \
23 categoryeditdialog_base.h \ 23 categoryeditdialog_base.h \
24 categoryselectdialog.h \ 24 categoryselectdialog.h \
25 categoryselectdialog_base.h \ 25 categoryselectdialog_base.h \
26 externalapphandler.h \ 26 externalapphandler.h \
27 kdateedit.h \ 27 kdateedit.h \
28 kdatepicker.h \ 28 kdatepicker.h \
29 kinputdialog.h \ 29 kinputdialog.h \
30 kpimprefs.h \ 30 kpimprefs.h \
31 kpimglobalprefs.h \ 31 kpimglobalprefs.h \
32 kprefsdialog.h \ 32 kprefsdialog.h \
33 kprefswidget.h \ 33 kprefswidget.h \
34 ksyncmanager.h \ 34 ksyncmanager.h \
35 ksyncprofile.h \ 35 ksyncprofile.h \
36 ksyncprefsdialog.h \ 36 ksyncprefsdialog.h \
37 kcmconfigs/kcmkdepimconfig.h \ 37 kcmconfigs/kcmkdepimconfig.h \
38 kcmconfigs/kdepimconfigwidget.h \ 38 kcmconfigs/kdepimconfigwidget.h \
39 phoneaccess.h 39 phoneaccess.h
40 40
41SOURCES = \ 41SOURCES = \
42 categoryeditdialog.cpp \ 42 categoryeditdialog.cpp \
43 categoryeditdialog_base.cpp \ 43 categoryeditdialog_base.cpp \
44 categoryselectdialog.cpp \ 44 categoryselectdialog.cpp \
45 categoryselectdialog_base.cpp \ 45 categoryselectdialog_base.cpp \
46 externalapphandler.cpp \ 46 externalapphandler.cpp \
47 kdateedit.cpp \ 47 kdateedit.cpp \
48 kdatepicker.cpp \ 48 kdatepicker.cpp \
49 kinputdialog.cpp \ 49 kinputdialog.cpp \
50 kpimprefs.cpp \ 50 kpimprefs.cpp \
51 kpimglobalprefs.cpp \ 51 kpimglobalprefs.cpp \
52 kprefsdialog.cpp \ 52 kprefsdialog.cpp \
53 kprefswidget.cpp \ 53 kprefswidget.cpp \
54 ksyncmanager.cpp \ 54 ksyncmanager.cpp \
55 ksyncprofile.cpp \ 55 ksyncprofile.cpp \
56 ksyncprefsdialog.cpp \ 56 ksyncprefsdialog.cpp \
57 kcmconfigs/kcmkdepimconfig.cpp \ 57 kcmconfigs/kcmkdepimconfig.cpp \
58 kcmconfigs/kdepimconfigwidget.cpp \ 58 kcmconfigs/kdepimconfigwidget.cpp \
59 phoneaccess.cpp 59 phoneaccess.cpp
60 60
61win32: {
61 62
63#olimport section
64importol {
65debug: {
66LIBS += mfc71ud.lib
67}
68release: {
69LIBS += mfc71u.lib
70}
71DEFINES += _OL_IMPORT_
72HEADERS += ol_access.h
73SOURCES += ol_access.cpp
74#olimport section end
75}
76}