summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabcore.cpp
Unidiff
Diffstat (limited to 'kaddressbook/kabcore.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp130
1 files changed, 108 insertions, 22 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 7d8586a..ab2824c 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -65,192 +65,193 @@ $Id$
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);
@@ -1276,218 +1277,266 @@ void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
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 )
@@ -3281,198 +3330,235 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
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 );