summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-10-01 05:22:45 (UTC)
committer ulf69 <ulf69>2004-10-01 05:22:45 (UTC)
commitae6aaaf2ec81317d275ebaabba2de188279b58cd (patch) (unidiff)
treef773df13a4e4f9fa5c6c54d01786e2de561ae661
parent11c2acda0533e579512cf416de870328a79e66e8 (diff)
downloadkdepimpi-ae6aaaf2ec81317d275ebaabba2de188279b58cd.zip
kdepimpi-ae6aaaf2ec81317d275ebaabba2de188279b58cd.tar.gz
kdepimpi-ae6aaaf2ec81317d275ebaabba2de188279b58cd.tar.bz2
moved the global sync stuff from kabcore into a new class ksyncmanaager which
can be used from all types of applications, like kapi, kopi and pwmpi
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp509
-rw-r--r--kaddressbook/kabcore.h38
-rw-r--r--kaddressbook/kabprefs.h18
-rw-r--r--libkdepim/kpimprefs.h21
-rw-r--r--libkdepim/ksyncmanager.cpp274
-rw-r--r--libkdepim/ksyncmanager.h79
-rw-r--r--libkdepim/libkdepimE.pro2
7 files changed, 335 insertions, 606 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index df634d0..f222234 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,3068 +1,2669 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "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 <qprogressbar.h> 37#include <qprogressbar.h>
38 38
39#ifndef KAB_EMBEDDED 39#ifndef KAB_EMBEDDED
40#include <qclipboard.h> 40#include <qclipboard.h>
41#include <qdir.h> 41#include <qdir.h>
42#include <qfile.h> 42#include <qfile.h>
43#include <qapplicaton.h> 43#include <qapplicaton.h>
44#include <qprogressbar.h> 44#include <qprogressbar.h>
45#include <qlayout.h> 45#include <qlayout.h>
46#include <qregexp.h> 46#include <qregexp.h>
47#include <qvbox.h> 47#include <qvbox.h>
48#include <kabc/addresseelist.h> 48#include <kabc/addresseelist.h>
49#include <kabc/errorhandler.h> 49#include <kabc/errorhandler.h>
50#include <kabc/resource.h> 50#include <kabc/resource.h>
51#include <kabc/vcardconverter.h> 51#include <kabc/vcardconverter.h>
52#include <kapplication.h> 52#include <kapplication.h>
53#include <kactionclasses.h> 53#include <kactionclasses.h>
54#include <kcmultidialog.h> 54#include <kcmultidialog.h>
55#include <kdebug.h> 55#include <kdebug.h>
56#include <kdeversion.h> 56#include <kdeversion.h>
57#include <kkeydialog.h> 57#include <kkeydialog.h>
58#include <kmessagebox.h> 58#include <kmessagebox.h>
59#include <kprinter.h> 59#include <kprinter.h>
60#include <kprotocolinfo.h> 60#include <kprotocolinfo.h>
61#include <kresources/selectdialog.h> 61#include <kresources/selectdialog.h>
62#include <kstandarddirs.h> 62#include <kstandarddirs.h>
63#include <ktempfile.h> 63#include <ktempfile.h>
64#include <kxmlguiclient.h> 64#include <kxmlguiclient.h>
65#include <kaboutdata.h> 65#include <kaboutdata.h>
66#include <libkdepim/categoryselectdialog.h> 66#include <libkdepim/categoryselectdialog.h>
67 67
68#include "addresseeutil.h" 68#include "addresseeutil.h"
69#include "addresseeeditordialog.h" 69#include "addresseeeditordialog.h"
70#include "extensionmanager.h" 70#include "extensionmanager.h"
71#include "kstdaction.h" 71#include "kstdaction.h"
72#include "kaddressbookservice.h" 72#include "kaddressbookservice.h"
73#include "ldapsearchdialog.h" 73#include "ldapsearchdialog.h"
74#include "printing/printingwizard.h" 74#include "printing/printingwizard.h"
75#else // KAB_EMBEDDED 75#else // KAB_EMBEDDED
76 76
77#include <kapplication.h> 77#include <kapplication.h>
78#include "KDGanttMinimizeSplitter.h" 78#include "KDGanttMinimizeSplitter.h"
79#include "kaddressbookmain.h" 79#include "kaddressbookmain.h"
80#include "kactioncollection.h" 80#include "kactioncollection.h"
81#include "addresseedialog.h" 81#include "addresseedialog.h"
82//US 82//US
83#include <addresseeview.h> 83#include <addresseeview.h>
84 84
85#include <qapp.h> 85#include <qapp.h>
86#include <qmenubar.h> 86#include <qmenubar.h>
87//#include <qtoolbar.h> 87//#include <qtoolbar.h>
88#include <qmessagebox.h> 88#include <qmessagebox.h>
89#include <kdebug.h> 89#include <kdebug.h>
90#include <kiconloader.h> // needed for SmallIcon 90#include <kiconloader.h> // needed for SmallIcon
91#include <kresources/kcmkresources.h> 91#include <kresources/kcmkresources.h>
92#include <ktoolbar.h> 92#include <ktoolbar.h>
93 93
94 94
95//#include <qlabel.h> 95//#include <qlabel.h>
96 96
97 97
98#ifndef DESKTOP_VERSION 98#ifndef DESKTOP_VERSION
99#include <qpe/ir.h> 99#include <qpe/ir.h>
100#include <qpe/qpemenubar.h> 100#include <qpe/qpemenubar.h>
101#include <qtopia/qcopenvelope_qws.h> 101#include <qtopia/qcopenvelope_qws.h>
102#else 102#else
103 103
104#include <qmenubar.h> 104#include <qmenubar.h>
105#endif 105#endif
106 106
107#endif // KAB_EMBEDDED 107#endif // KAB_EMBEDDED
108#include "kcmconfigs/kcmkabconfig.h" 108#include "kcmconfigs/kcmkabconfig.h"
109#include "kcmconfigs/kcmkdepimconfig.h" 109#include "kcmconfigs/kcmkdepimconfig.h"
110#include "kpimglobalprefs.h" 110#include "kpimglobalprefs.h"
111#include "externalapphandler.h" 111#include "externalapphandler.h"
112 112
113 113
114#include <kresources/selectdialog.h> 114#include <kresources/selectdialog.h>
115#include <kmessagebox.h> 115#include <kmessagebox.h>
116 116
117#include <picture.h> 117#include <picture.h>
118#include <resource.h> 118#include <resource.h>
119 119
120//US#include <qsplitter.h> 120//US#include <qsplitter.h>
121#include <qmap.h> 121#include <qmap.h>
122#include <qdir.h> 122#include <qdir.h>
123#include <qfile.h> 123#include <qfile.h>
124#include <qvbox.h> 124#include <qvbox.h>
125#include <qlayout.h> 125#include <qlayout.h>
126#include <qclipboard.h> 126#include <qclipboard.h>
127#include <qtextstream.h> 127#include <qtextstream.h>
128 128
129#include <libkdepim/categoryselectdialog.h> 129#include <libkdepim/categoryselectdialog.h>
130#include <kabc/vcardconverter.h> 130#include <kabc/vcardconverter.h>
131 131
132 132
133#include "addresseeutil.h" 133#include "addresseeutil.h"
134#include "undocmds.h" 134#include "undocmds.h"
135#include "addresseeeditordialog.h" 135#include "addresseeeditordialog.h"
136#include "viewmanager.h" 136#include "viewmanager.h"
137#include "details/detailsviewcontainer.h" 137#include "details/detailsviewcontainer.h"
138#include "kabprefs.h" 138#include "kabprefs.h"
139#include "xxportmanager.h" 139#include "xxportmanager.h"
140#include "incsearchwidget.h" 140#include "incsearchwidget.h"
141#include "jumpbuttonbar.h" 141#include "jumpbuttonbar.h"
142#include "extensionmanager.h" 142#include "extensionmanager.h"
143#include "addresseeconfig.h" 143#include "addresseeconfig.h"
144#include <kcmultidialog.h> 144#include <kcmultidialog.h>
145 145
146#ifdef _WIN32_ 146#ifdef _WIN32_
147 147
148#include "kaimportoldialog.h" 148#include "kaimportoldialog.h"
149#else 149#else
150#include <unistd.h> 150#include <unistd.h>
151#endif 151#endif
152// sync includes 152// sync includes
153#include <libkdepim/ksyncprofile.h> 153#include <libkdepim/ksyncprofile.h>
154#include <libkdepim/ksyncprefsdialog.h> 154#include <libkdepim/ksyncprefsdialog.h>
155 155
156 156
157bool pasteWithNewUid = true; 157bool pasteWithNewUid = true;
158 158
159#ifdef KAB_EMBEDDED 159#ifdef KAB_EMBEDDED
160KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 160KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
161 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 161 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
162 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 162 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
163 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 163 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
164#else //KAB_EMBEDDED 164#else //KAB_EMBEDDED
165KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 165KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
166 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 166 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
167 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 167 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
168 mReadWrite( readWrite ), mModified( false ) 168 mReadWrite( readWrite ), mModified( false )
169#endif //KAB_EMBEDDED 169#endif //KAB_EMBEDDED
170{ 170{
171 171 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
172 mBlockSaveFlag = false; 172 // syncManager->setBlockSave(false);
173 mExtensionBarSplitter = 0; 173 mExtensionBarSplitter = 0;
174 mIsPart = !parent->inherits( "KAddressBookMain" ); 174 mIsPart = !parent->inherits( "KAddressBookMain" );
175 175
176 mAddressBook = KABC::StdAddressBook::self(); 176 mAddressBook = KABC::StdAddressBook::self();
177 KABC::StdAddressBook::setAutomaticSave( false ); 177 KABC::StdAddressBook::setAutomaticSave( false );
178 178
179#ifndef KAB_EMBEDDED 179#ifndef KAB_EMBEDDED
180 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 180 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
181#endif //KAB_EMBEDDED 181#endif //KAB_EMBEDDED
182 182
183 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 183 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
184 SLOT( addressBookChanged() ) ); 184 SLOT( addressBookChanged() ) );
185 185
186#if 0 186#if 0
187 // LP moved to addressbook init method 187 // LP moved to addressbook init method
188 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 188 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
189 "X-Department", "KADDRESSBOOK" ); 189 "X-Department", "KADDRESSBOOK" );
190 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 190 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
191 "X-Profession", "KADDRESSBOOK" ); 191 "X-Profession", "KADDRESSBOOK" );
192 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 192 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
193 "X-AssistantsName", "KADDRESSBOOK" ); 193 "X-AssistantsName", "KADDRESSBOOK" );
194 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 194 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
195 "X-ManagersName", "KADDRESSBOOK" ); 195 "X-ManagersName", "KADDRESSBOOK" );
196 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 196 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
197 "X-SpousesName", "KADDRESSBOOK" ); 197 "X-SpousesName", "KADDRESSBOOK" );
198 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 198 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
199 "X-Office", "KADDRESSBOOK" ); 199 "X-Office", "KADDRESSBOOK" );
200 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 200 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
201 "X-IMAddress", "KADDRESSBOOK" ); 201 "X-IMAddress", "KADDRESSBOOK" );
202 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 202 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
203 "X-Anniversary", "KADDRESSBOOK" ); 203 "X-Anniversary", "KADDRESSBOOK" );
204 204
205 //US added this field to become compatible with Opie/qtopia addressbook 205 //US added this field to become compatible with Opie/qtopia addressbook
206 // values can be "female" or "male" or "". An empty field represents undefined. 206 // values can be "female" or "male" or "". An empty field represents undefined.
207 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 207 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
208 "X-Gender", "KADDRESSBOOK" ); 208 "X-Gender", "KADDRESSBOOK" );
209 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 209 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
210 "X-Children", "KADDRESSBOOK" ); 210 "X-Children", "KADDRESSBOOK" );
211 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 211 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
212 "X-FreeBusyUrl", "KADDRESSBOOK" ); 212 "X-FreeBusyUrl", "KADDRESSBOOK" );
213#endif 213#endif
214 initGUI(); 214 initGUI();
215 215
216 mIncSearchWidget->setFocus(); 216 mIncSearchWidget->setFocus();
217 217
218 218
219 connect( mViewManager, SIGNAL( selected( const QString& ) ), 219 connect( mViewManager, SIGNAL( selected( const QString& ) ),
220 SLOT( setContactSelected( const QString& ) ) ); 220 SLOT( setContactSelected( const QString& ) ) );
221 connect( mViewManager, SIGNAL( executed( const QString& ) ), 221 connect( mViewManager, SIGNAL( executed( const QString& ) ),
222 SLOT( executeContact( const QString& ) ) ); 222 SLOT( executeContact( const QString& ) ) );
223 223
224 connect( mViewManager, SIGNAL( deleteRequest( ) ), 224 connect( mViewManager, SIGNAL( deleteRequest( ) ),
225 SLOT( deleteContacts( ) ) ); 225 SLOT( deleteContacts( ) ) );
226 connect( mViewManager, SIGNAL( modified() ), 226 connect( mViewManager, SIGNAL( modified() ),
227 SLOT( setModified() ) ); 227 SLOT( setModified() ) );
228 228
229 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 229 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
230 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 230 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
231 231
232 connect( mXXPortManager, SIGNAL( modified() ), 232 connect( mXXPortManager, SIGNAL( modified() ),
233 SLOT( setModified() ) ); 233 SLOT( setModified() ) );
234 234
235 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 235 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
236 SLOT( incrementalSearch( const QString& ) ) ); 236 SLOT( incrementalSearch( const QString& ) ) );
237 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 237 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
238 mJumpButtonBar, SLOT( recreateButtons() ) ); 238 mJumpButtonBar, SLOT( recreateButtons() ) );
239 239
240 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 240 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
241 SLOT( sendMail( const QString& ) ) ); 241 SLOT( sendMail( const QString& ) ) );
242 242
243 243
244 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 244 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
245 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&))); 245 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&)));
246 246
247 247
248#ifndef KAB_EMBEDDED 248#ifndef KAB_EMBEDDED
249 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 249 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
250 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 250 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
251 251
252 connect( mDetails, SIGNAL( browse( const QString& ) ), 252 connect( mDetails, SIGNAL( browse( const QString& ) ),
253 SLOT( browse( const QString& ) ) ); 253 SLOT( browse( const QString& ) ) );
254 254
255 255
256 mAddressBookService = new KAddressBookService( this ); 256 mAddressBookService = new KAddressBookService( this );
257 257
258#endif //KAB_EMBEDDED 258#endif //KAB_EMBEDDED
259 mEditorDialog = 0; 259 mEditorDialog = 0;
260 createAddresseeEditorDialog( this ); 260 createAddresseeEditorDialog( this );
261 setModified( false ); 261 setModified( false );
262} 262}
263 263
264KABCore::~KABCore() 264KABCore::~KABCore()
265{ 265{
266 // save(); 266 // save();
267 //saveSettings(); 267 //saveSettings();
268 //KABPrefs::instance()->writeConfig(); 268 //KABPrefs::instance()->writeConfig();
269 delete AddresseeConfig::instance(); 269 delete AddresseeConfig::instance();
270 mAddressBook = 0; 270 mAddressBook = 0;
271 KABC::StdAddressBook::close(); 271 KABC::StdAddressBook::close();
272
273 delete syncManager;
272} 274}
273 275
274void KABCore::restoreSettings() 276void KABCore::restoreSettings()
275{ 277{
276 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 278 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
277 279
278 bool state; 280 bool state;
279 281
280 if (mMultipleViewsAtOnce) 282 if (mMultipleViewsAtOnce)
281 state = KABPrefs::instance()->mDetailsPageVisible; 283 state = KABPrefs::instance()->mDetailsPageVisible;
282 else 284 else
283 state = false; 285 state = false;
284 286
285 mActionDetails->setChecked( state ); 287 mActionDetails->setChecked( state );
286 setDetailsVisible( state ); 288 setDetailsVisible( state );
287 289
288 state = KABPrefs::instance()->mJumpButtonBarVisible; 290 state = KABPrefs::instance()->mJumpButtonBarVisible;
289 291
290 mActionJumpBar->setChecked( state ); 292 mActionJumpBar->setChecked( state );
291 setJumpButtonBarVisible( state ); 293 setJumpButtonBarVisible( state );
292/*US 294/*US
293 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 295 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
294 if ( splitterSize.count() == 0 ) { 296 if ( splitterSize.count() == 0 ) {
295 splitterSize.append( width() / 2 ); 297 splitterSize.append( width() / 2 );
296 splitterSize.append( width() / 2 ); 298 splitterSize.append( width() / 2 );
297 } 299 }
298 mMiniSplitter->setSizes( splitterSize ); 300 mMiniSplitter->setSizes( splitterSize );
299 if ( mExtensionBarSplitter ) { 301 if ( mExtensionBarSplitter ) {
300 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 302 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
301 if ( splitterSize.count() == 0 ) { 303 if ( splitterSize.count() == 0 ) {
302 splitterSize.append( width() / 2 ); 304 splitterSize.append( width() / 2 );
303 splitterSize.append( width() / 2 ); 305 splitterSize.append( width() / 2 );
304 } 306 }
305 mExtensionBarSplitter->setSizes( splitterSize ); 307 mExtensionBarSplitter->setSizes( splitterSize );
306 308
307 } 309 }
308*/ 310*/
309 mViewManager->restoreSettings(); 311 mViewManager->restoreSettings();
310 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 312 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
311 mExtensionManager->restoreSettings(); 313 mExtensionManager->restoreSettings();
312#ifdef DESKTOP_VERSION 314#ifdef DESKTOP_VERSION
313 int wid = width(); 315 int wid = width();
314 if ( wid < 10 ) 316 if ( wid < 10 )
315 wid = 400; 317 wid = 400;
316#else 318#else
317 int wid = QApplication::desktop()->width(); 319 int wid = QApplication::desktop()->width();
318 if ( wid < 640 ) 320 if ( wid < 640 )
319 wid = QApplication::desktop()->height(); 321 wid = QApplication::desktop()->height();
320#endif 322#endif
321 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 323 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
322 if ( true /*splitterSize.count() == 0*/ ) { 324 if ( true /*splitterSize.count() == 0*/ ) {
323 splitterSize.append( wid / 2 ); 325 splitterSize.append( wid / 2 );
324 splitterSize.append( wid / 2 ); 326 splitterSize.append( wid / 2 );
325 } 327 }
326 mMiniSplitter->setSizes( splitterSize ); 328 mMiniSplitter->setSizes( splitterSize );
327 if ( mExtensionBarSplitter ) { 329 if ( mExtensionBarSplitter ) {
328 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 330 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
329 if ( true /*splitterSize.count() == 0*/ ) { 331 if ( true /*splitterSize.count() == 0*/ ) {
330 splitterSize.append( wid / 2 ); 332 splitterSize.append( wid / 2 );
331 splitterSize.append( wid / 2 ); 333 splitterSize.append( wid / 2 );
332 } 334 }
333 mExtensionBarSplitter->setSizes( splitterSize ); 335 mExtensionBarSplitter->setSizes( splitterSize );
334 336
335 } 337 }
336 338
337 339
338} 340}
339 341
340void KABCore::saveSettings() 342void KABCore::saveSettings()
341{ 343{
342 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 344 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
343 if ( mExtensionBarSplitter ) 345 if ( mExtensionBarSplitter )
344 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 346 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
345 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 347 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
346 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 348 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
347#ifndef KAB_EMBEDDED 349#ifndef KAB_EMBEDDED
348 350
349 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 351 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
350 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 352 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
351#endif //KAB_EMBEDDED 353#endif //KAB_EMBEDDED
352 mExtensionManager->saveSettings(); 354 mExtensionManager->saveSettings();
353 mViewManager->saveSettings(); 355 mViewManager->saveSettings();
354 356
355 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 357 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
356} 358}
357 359
358KABC::AddressBook *KABCore::addressBook() const 360KABC::AddressBook *KABCore::addressBook() const
359{ 361{
360 return mAddressBook; 362 return mAddressBook;
361} 363}
362 364
363KConfig *KABCore::config() 365KConfig *KABCore::config()
364{ 366{
365#ifndef KAB_EMBEDDED 367#ifndef KAB_EMBEDDED
366 return KABPrefs::instance()->config(); 368 return KABPrefs::instance()->config();
367#else //KAB_EMBEDDED 369#else //KAB_EMBEDDED
368 return KABPrefs::instance()->getConfig(); 370 return KABPrefs::instance()->getConfig();
369#endif //KAB_EMBEDDED 371#endif //KAB_EMBEDDED
370} 372}
371 373
372KActionCollection *KABCore::actionCollection() const 374KActionCollection *KABCore::actionCollection() const
373{ 375{
374 return mGUIClient->actionCollection(); 376 return mGUIClient->actionCollection();
375} 377}
376 378
377KABC::Field *KABCore::currentSearchField() const 379KABC::Field *KABCore::currentSearchField() const
378{ 380{
379 if (mIncSearchWidget) 381 if (mIncSearchWidget)
380 return mIncSearchWidget->currentField(); 382 return mIncSearchWidget->currentField();
381 else 383 else
382 return 0; 384 return 0;
383} 385}
384 386
385QStringList KABCore::selectedUIDs() const 387QStringList KABCore::selectedUIDs() const
386{ 388{
387 return mViewManager->selectedUids(); 389 return mViewManager->selectedUids();
388} 390}
389 391
390KABC::Resource *KABCore::requestResource( QWidget *parent ) 392KABC::Resource *KABCore::requestResource( QWidget *parent )
391{ 393{
392 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 394 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
393 395
394 QPtrList<KRES::Resource> kresResources; 396 QPtrList<KRES::Resource> kresResources;
395 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 397 QPtrListIterator<KABC::Resource> resIt( kabcResources );
396 KABC::Resource *resource; 398 KABC::Resource *resource;
397 while ( ( resource = resIt.current() ) != 0 ) { 399 while ( ( resource = resIt.current() ) != 0 ) {
398 ++resIt; 400 ++resIt;
399 if ( !resource->readOnly() ) { 401 if ( !resource->readOnly() ) {
400 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 402 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
401 if ( res ) 403 if ( res )
402 kresResources.append( res ); 404 kresResources.append( res );
403 } 405 }
404 } 406 }
405 407
406 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 408 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
407 return static_cast<KABC::Resource*>( res ); 409 return static_cast<KABC::Resource*>( res );
408} 410}
409 411
410#ifndef KAB_EMBEDDED 412#ifndef KAB_EMBEDDED
411KAboutData *KABCore::createAboutData() 413KAboutData *KABCore::createAboutData()
412#else //KAB_EMBEDDED 414#else //KAB_EMBEDDED
413void KABCore::createAboutData() 415void KABCore::createAboutData()
414#endif //KAB_EMBEDDED 416#endif //KAB_EMBEDDED
415{ 417{
416#ifndef KAB_EMBEDDED 418#ifndef KAB_EMBEDDED
417 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 419 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
418 "3.1", I18N_NOOP( "The KDE Address Book" ), 420 "3.1", I18N_NOOP( "The KDE Address Book" ),
419 KAboutData::License_GPL_V2, 421 KAboutData::License_GPL_V2,
420 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 422 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
421 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 423 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
422 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 424 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
423 about->addAuthor( "Cornelius Schumacher", 425 about->addAuthor( "Cornelius Schumacher",
424 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 426 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
425 "schumacher@kde.org" ); 427 "schumacher@kde.org" );
426 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 428 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
427 "mpilone@slac.com" ); 429 "mpilone@slac.com" );
428 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 430 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
429 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 431 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
430 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 432 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
431 "michel@klaralvdalens-datakonsult.se" ); 433 "michel@klaralvdalens-datakonsult.se" );
432 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 434 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
433 "hansen@kde.org" ); 435 "hansen@kde.org" );
434 436
435 return about; 437 return about;
436#endif //KAB_EMBEDDED 438#endif //KAB_EMBEDDED
437 439
438 QString version; 440 QString version;
439#include <../version> 441#include <../version>
440 QMessageBox::about( this, "About KAddressbook/Pi", 442 QMessageBox::about( this, "About KAddressbook/Pi",
441 "KAddressbook/Platform-independent\n" 443 "KAddressbook/Platform-independent\n"
442 "(KA/Pi) " +version + " - " + 444 "(KA/Pi) " +version + " - " +
443#ifdef DESKTOP_VERSION 445#ifdef DESKTOP_VERSION
444 "Desktop Edition\n" 446 "Desktop Edition\n"
445#else 447#else
446 "PDA-Edition\n" 448 "PDA-Edition\n"
447 "for: Zaurus 5500 / 7x0 / 8x0\n" 449 "for: Zaurus 5500 / 7x0 / 8x0\n"
448#endif 450#endif
449 451
450 "(c) 2004 Ulf Schenk\n" 452 "(c) 2004 Ulf Schenk\n"
451 "(c) 2004 Lutz Rogowski\n" 453 "(c) 2004 Lutz Rogowski\n"
452 "(c) 1997-2003, The KDE PIM Team\n" 454 "(c) 1997-2003, The KDE PIM Team\n"
453 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 455 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
454 "Don Sanders Original author\n" 456 "Don Sanders Original author\n"
455 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 457 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
456 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 458 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
457 "Greg Stern DCOP interface\n" 459 "Greg Stern DCOP interface\n"
458 "Mark Westcot Contact pinning\n" 460 "Mark Westcot Contact pinning\n"
459 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 461 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
460 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 462 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
461#ifdef _WIN32_ 463#ifdef _WIN32_
462 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 464 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
463#endif 465#endif
464 ); 466 );
465} 467}
466 468
467void KABCore::setContactSelected( const QString &uid ) 469void KABCore::setContactSelected( const QString &uid )
468{ 470{
469 KABC::Addressee addr = mAddressBook->findByUid( uid ); 471 KABC::Addressee addr = mAddressBook->findByUid( uid );
470 if ( !mDetails->isHidden() ) 472 if ( !mDetails->isHidden() )
471 mDetails->setAddressee( addr ); 473 mDetails->setAddressee( addr );
472 474
473 if ( !addr.isEmpty() ) { 475 if ( !addr.isEmpty() ) {
474 emit contactSelected( addr.formattedName() ); 476 emit contactSelected( addr.formattedName() );
475 KABC::Picture pic = addr.photo(); 477 KABC::Picture pic = addr.photo();
476 if ( pic.isIntern() ) { 478 if ( pic.isIntern() ) {
477//US emit contactSelected( pic.data() ); 479//US emit contactSelected( pic.data() );
478//US instead use: 480//US instead use:
479 QPixmap px; 481 QPixmap px;
480 if (pic.data().isNull() != true) 482 if (pic.data().isNull() != true)
481 { 483 {
482 px.convertFromImage(pic.data()); 484 px.convertFromImage(pic.data());
483 } 485 }
484 486
485 emit contactSelected( px ); 487 emit contactSelected( px );
486 } 488 }
487 } 489 }
488 490
489 491
490 mExtensionManager->setSelectionChanged(); 492 mExtensionManager->setSelectionChanged();
491 493
492 // update the actions 494 // update the actions
493 bool selected = !uid.isEmpty(); 495 bool selected = !uid.isEmpty();
494 496
495 if ( mReadWrite ) { 497 if ( mReadWrite ) {
496 mActionCut->setEnabled( selected ); 498 mActionCut->setEnabled( selected );
497 mActionPaste->setEnabled( selected ); 499 mActionPaste->setEnabled( selected );
498 } 500 }
499 501
500 mActionCopy->setEnabled( selected ); 502 mActionCopy->setEnabled( selected );
501 mActionDelete->setEnabled( selected ); 503 mActionDelete->setEnabled( selected );
502 mActionEditAddressee->setEnabled( selected ); 504 mActionEditAddressee->setEnabled( selected );
503 mActionMail->setEnabled( selected ); 505 mActionMail->setEnabled( selected );
504 mActionMailVCard->setEnabled( selected ); 506 mActionMailVCard->setEnabled( selected );
505 //if (mActionBeam) 507 //if (mActionBeam)
506 //mActionBeam->setEnabled( selected ); 508 //mActionBeam->setEnabled( selected );
507 509
508 if (mActionBeamVCard) 510 if (mActionBeamVCard)
509 mActionBeamVCard->setEnabled( selected ); 511 mActionBeamVCard->setEnabled( selected );
510 512
511 mActionWhoAmI->setEnabled( selected ); 513 mActionWhoAmI->setEnabled( selected );
512 mActionCategories->setEnabled( selected ); 514 mActionCategories->setEnabled( selected );
513} 515}
514 516
515void KABCore::sendMail() 517void KABCore::sendMail()
516{ 518{
517 sendMail( mViewManager->selectedEmails().join( ", " ) ); 519 sendMail( mViewManager->selectedEmails().join( ", " ) );
518} 520}
519 521
520void KABCore::sendMail( const QString& emaillist ) 522void KABCore::sendMail( const QString& emaillist )
521{ 523{
522 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 524 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
523 if (emaillist.contains(",") > 0) 525 if (emaillist.contains(",") > 0)
524 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 526 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
525 else 527 else
526 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 528 ExternalAppHandler::instance()->mailToOneContact( emaillist );
527} 529}
528 530
529 531
530 532
531void KABCore::mailVCard() 533void KABCore::mailVCard()
532{ 534{
533 QStringList uids = mViewManager->selectedUids(); 535 QStringList uids = mViewManager->selectedUids();
534 if ( !uids.isEmpty() ) 536 if ( !uids.isEmpty() )
535 mailVCard( uids ); 537 mailVCard( uids );
536} 538}
537 539
538void KABCore::mailVCard( const QStringList& uids ) 540void KABCore::mailVCard( const QStringList& uids )
539{ 541{
540 QStringList urls; 542 QStringList urls;
541 543
542// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 544// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
543 545
544 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 546 QString dirName = "/tmp/" + KApplication::randomString( 8 );
545 547
546 548
547 549
548 QDir().mkdir( dirName, true ); 550 QDir().mkdir( dirName, true );
549 551
550 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 552 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
551 KABC::Addressee a = mAddressBook->findByUid( *it ); 553 KABC::Addressee a = mAddressBook->findByUid( *it );
552 554
553 if ( a.isEmpty() ) 555 if ( a.isEmpty() )
554 continue; 556 continue;
555 557
556 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 558 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
557 559
558 QString fileName = dirName + "/" + name; 560 QString fileName = dirName + "/" + name;
559 561
560 QFile outFile(fileName); 562 QFile outFile(fileName);
561 563
562 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 564 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
563 KABC::VCardConverter converter; 565 KABC::VCardConverter converter;
564 QString vcard; 566 QString vcard;
565 567
566 converter.addresseeToVCard( a, vcard ); 568 converter.addresseeToVCard( a, vcard );
567 569
568 QTextStream t( &outFile ); // use a text stream 570 QTextStream t( &outFile ); // use a text stream
569 t.setEncoding( QTextStream::UnicodeUTF8 ); 571 t.setEncoding( QTextStream::UnicodeUTF8 );
570 t << vcard; 572 t << vcard;
571 573
572 outFile.close(); 574 outFile.close();
573 575
574 urls.append( fileName ); 576 urls.append( fileName );
575 } 577 }
576 } 578 }
577 579
578 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 580 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
579 581
580 582
581/*US 583/*US
582 kapp->invokeMailer( QString::null, QString::null, QString::null, 584 kapp->invokeMailer( QString::null, QString::null, QString::null,
583 QString::null, // subject 585 QString::null, // subject
584 QString::null, // body 586 QString::null, // body
585 QString::null, 587 QString::null,
586 urls ); // attachments 588 urls ); // attachments
587*/ 589*/
588 590
589} 591}
590 592
591/** 593/**
592 Beams the "WhoAmI contact. 594 Beams the "WhoAmI contact.
593*/ 595*/
594void KABCore::beamMySelf() 596void KABCore::beamMySelf()
595{ 597{
596 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 598 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
597 if (!a.isEmpty()) 599 if (!a.isEmpty())
598 { 600 {
599 QStringList uids; 601 QStringList uids;
600 uids << a.uid(); 602 uids << a.uid();
601 603
602 beamVCard(uids); 604 beamVCard(uids);
603 } else { 605 } else {
604 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 606 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
605 607
606 608
607 } 609 }
608} 610}
609 611
610void KABCore::beamVCard() 612void KABCore::beamVCard()
611{ 613{
612 QStringList uids = mViewManager->selectedUids(); 614 QStringList uids = mViewManager->selectedUids();
613 if ( !uids.isEmpty() ) 615 if ( !uids.isEmpty() )
614 beamVCard( uids ); 616 beamVCard( uids );
615} 617}
616 618
617 619
618void KABCore::beamVCard(const QStringList& uids) 620void KABCore::beamVCard(const QStringList& uids)
619{ 621{
620/*US 622/*US
621 QString beamFilename; 623 QString beamFilename;
622 Opie::OPimContact c; 624 Opie::OPimContact c;
623 if ( actionPersonal->isOn() ) { 625 if ( actionPersonal->isOn() ) {
624 beamFilename = addressbookPersonalVCardName(); 626 beamFilename = addressbookPersonalVCardName();
625 if ( !QFile::exists( beamFilename ) ) 627 if ( !QFile::exists( beamFilename ) )
626 return; // can't beam a non-existent file 628 return; // can't beam a non-existent file
627 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 629 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
628 beamFilename ); 630 beamFilename );
629 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 631 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
630 Opie::OPimContactAccess::List allList = access->allRecords(); 632 Opie::OPimContactAccess::List allList = access->allRecords();
631 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 633 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
632 c = *it; 634 c = *it;
633 635
634 delete access; 636 delete access;
635 } else { 637 } else {
636 unlink( beamfile ); // delete if exists 638 unlink( beamfile ); // delete if exists
637 mkdir("/tmp/obex/", 0755); 639 mkdir("/tmp/obex/", 0755);
638 c = m_abView -> currentEntry(); 640 c = m_abView -> currentEntry();
639 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 641 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
640 beamfile ); 642 beamfile );
641 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 643 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
642 access->add( c ); 644 access->add( c );
643 access->save(); 645 access->save();
644 delete access; 646 delete access;
645 647
646 beamFilename = beamfile; 648 beamFilename = beamfile;
647 } 649 }
648 650
649 owarn << "Beaming: " << beamFilename << oendl; 651 owarn << "Beaming: " << beamFilename << oendl;
650*/ 652*/
651 653
652#if 0 654#if 0
653 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 655 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
654 656
655 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 657 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
656 658
657 QString name = "contact.vcf"; 659 QString name = "contact.vcf";
658 660
659 QString fileName = dirName + "/" + name; 661 QString fileName = dirName + "/" + name;
660#endif 662#endif
661 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory 663 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
662 // 664 //
663 QString fileName = "/tmp/kapibeamfile.vcf"; 665 QString fileName = "/tmp/kapibeamfile.vcf";
664 666
665 667
666 //QDir().mkdir( dirName, true ); 668 //QDir().mkdir( dirName, true );
667 669
668 670
669 KABC::VCardConverter converter; 671 KABC::VCardConverter converter;
670 QString description; 672 QString description;
671 QString datastream; 673 QString datastream;
672 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 674 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
673 KABC::Addressee a = mAddressBook->findByUid( *it ); 675 KABC::Addressee a = mAddressBook->findByUid( *it );
674 676
675 if ( a.isEmpty() ) 677 if ( a.isEmpty() )
676 continue; 678 continue;
677 679
678 if (description.isEmpty()) 680 if (description.isEmpty())
679 description = a.formattedName(); 681 description = a.formattedName();
680 682
681 QString vcard; 683 QString vcard;
682 converter.addresseeToVCard( a, vcard ); 684 converter.addresseeToVCard( a, vcard );
683 int start = 0; 685 int start = 0;
684 int next; 686 int next;
685 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 687 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
686 int semi = vcard.find(";", next); 688 int semi = vcard.find(";", next);
687 int dopp = vcard.find(":", next); 689 int dopp = vcard.find(":", next);
688 int sep; 690 int sep;
689 if ( semi < dopp && semi >= 0 ) 691 if ( semi < dopp && semi >= 0 )
690 sep = semi ; 692 sep = semi ;
691 else 693 else
692 sep = dopp; 694 sep = dopp;
693 datastream +=vcard.mid( start, next - start); 695 datastream +=vcard.mid( start, next - start);
694 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 696 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
695 start = sep; 697 start = sep;
696 } 698 }
697 datastream += vcard.mid( start,vcard.length() ); 699 datastream += vcard.mid( start,vcard.length() );
698 } 700 }
699#ifndef DESKTOP_VERSION 701#ifndef DESKTOP_VERSION
700 QFile outFile(fileName); 702 QFile outFile(fileName);
701 if ( outFile.open(IO_WriteOnly) ) { 703 if ( outFile.open(IO_WriteOnly) ) {
702 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 704 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
703 QTextStream t( &outFile ); // use a text stream 705 QTextStream t( &outFile ); // use a text stream
704 t.setEncoding( QTextStream::UnicodeUTF8 ); 706 t.setEncoding( QTextStream::UnicodeUTF8 );
705 t <<datastream; 707 t <<datastream;
706 outFile.close(); 708 outFile.close();
707 Ir *ir = new Ir( this ); 709 Ir *ir = new Ir( this );
708 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 710 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
709 ir->send( fileName, description, "text/x-vCard" ); 711 ir->send( fileName, description, "text/x-vCard" );
710 } else { 712 } else {
711 qDebug("Error open temp beam file "); 713 qDebug("Error open temp beam file ");
712 return; 714 return;
713 } 715 }
714#endif 716#endif
715 717
716} 718}
717 719
718void KABCore::beamDone( Ir *ir ) 720void KABCore::beamDone( Ir *ir )
719{ 721{
720#ifndef DESKTOP_VERSION 722#ifndef DESKTOP_VERSION
721 delete ir; 723 delete ir;
722#endif 724#endif
723} 725}
724 726
725 727
726void KABCore::browse( const QString& url ) 728void KABCore::browse( const QString& url )
727{ 729{
728#ifndef KAB_EMBEDDED 730#ifndef KAB_EMBEDDED
729 kapp->invokeBrowser( url ); 731 kapp->invokeBrowser( url );
730#else //KAB_EMBEDDED 732#else //KAB_EMBEDDED
731 qDebug("KABCore::browse must be fixed"); 733 qDebug("KABCore::browse must be fixed");
732#endif //KAB_EMBEDDED 734#endif //KAB_EMBEDDED
733} 735}
734 736
735void KABCore::selectAllContacts() 737void KABCore::selectAllContacts()
736{ 738{
737 mViewManager->setSelected( QString::null, true ); 739 mViewManager->setSelected( QString::null, true );
738} 740}
739 741
740void KABCore::deleteContacts() 742void KABCore::deleteContacts()
741{ 743{
742 QStringList uidList = mViewManager->selectedUids(); 744 QStringList uidList = mViewManager->selectedUids();
743 deleteContacts( uidList ); 745 deleteContacts( uidList );
744} 746}
745 747
746void KABCore::deleteContacts( const QStringList &uids ) 748void KABCore::deleteContacts( const QStringList &uids )
747{ 749{
748 if ( uids.count() > 0 ) { 750 if ( uids.count() > 0 ) {
749 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 751 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
750 UndoStack::instance()->push( command ); 752 UndoStack::instance()->push( command );
751 RedoStack::instance()->clear(); 753 RedoStack::instance()->clear();
752 754
753 // now if we deleted anything, refresh 755 // now if we deleted anything, refresh
754 setContactSelected( QString::null ); 756 setContactSelected( QString::null );
755 setModified( true ); 757 setModified( true );
756 } 758 }
757} 759}
758 760
759void KABCore::copyContacts() 761void KABCore::copyContacts()
760{ 762{
761 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 763 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
762 764
763 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 765 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
764 766
765 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 767 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
766 768
767 QClipboard *cb = QApplication::clipboard(); 769 QClipboard *cb = QApplication::clipboard();
768 cb->setText( clipText ); 770 cb->setText( clipText );
769} 771}
770 772
771void KABCore::cutContacts() 773void KABCore::cutContacts()
772{ 774{
773 QStringList uidList = mViewManager->selectedUids(); 775 QStringList uidList = mViewManager->selectedUids();
774 776
775//US if ( uidList.size() > 0 ) { 777//US if ( uidList.size() > 0 ) {
776 if ( uidList.count() > 0 ) { 778 if ( uidList.count() > 0 ) {
777 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 779 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
778 UndoStack::instance()->push( command ); 780 UndoStack::instance()->push( command );
779 RedoStack::instance()->clear(); 781 RedoStack::instance()->clear();
780 782
781 setModified( true ); 783 setModified( true );
782 } 784 }
783} 785}
784 786
785void KABCore::pasteContacts() 787void KABCore::pasteContacts()
786{ 788{
787 QClipboard *cb = QApplication::clipboard(); 789 QClipboard *cb = QApplication::clipboard();
788 790
789 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 791 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
790 792
791 pasteContacts( list ); 793 pasteContacts( list );
792} 794}
793 795
794void KABCore::pasteContacts( KABC::Addressee::List &list ) 796void KABCore::pasteContacts( KABC::Addressee::List &list )
795{ 797{
796 KABC::Resource *resource = requestResource( this ); 798 KABC::Resource *resource = requestResource( this );
797 KABC::Addressee::List::Iterator it; 799 KABC::Addressee::List::Iterator it;
798 for ( it = list.begin(); it != list.end(); ++it ) 800 for ( it = list.begin(); it != list.end(); ++it )
799 (*it).setResource( resource ); 801 (*it).setResource( resource );
800 802
801 PwPasteCommand *command = new PwPasteCommand( this, list ); 803 PwPasteCommand *command = new PwPasteCommand( this, list );
802 UndoStack::instance()->push( command ); 804 UndoStack::instance()->push( command );
803 RedoStack::instance()->clear(); 805 RedoStack::instance()->clear();
804 806
805 setModified( true ); 807 setModified( true );
806} 808}
807 809
808void KABCore::setWhoAmI() 810void KABCore::setWhoAmI()
809{ 811{
810 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 812 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
811 813
812 if ( addrList.count() > 1 ) { 814 if ( addrList.count() > 1 ) {
813 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 815 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
814 return; 816 return;
815 } 817 }
816 818
817 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 819 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
818 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 820 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
819 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 821 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
820} 822}
821 823
822void KABCore::setCategories() 824void KABCore::setCategories()
823{ 825{
824 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 826 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
825 if ( !dlg.exec() ) 827 if ( !dlg.exec() )
826 return; 828 return;
827 829
828 bool merge = false; 830 bool merge = false;
829 QString msg = i18n( "Merge with existing categories?" ); 831 QString msg = i18n( "Merge with existing categories?" );
830 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 832 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
831 merge = true; 833 merge = true;
832 834
833 QStringList categories = dlg.selectedCategories(); 835 QStringList categories = dlg.selectedCategories();
834 836
835 QStringList uids = mViewManager->selectedUids(); 837 QStringList uids = mViewManager->selectedUids();
836 QStringList::Iterator it; 838 QStringList::Iterator it;
837 for ( it = uids.begin(); it != uids.end(); ++it ) { 839 for ( it = uids.begin(); it != uids.end(); ++it ) {
838 KABC::Addressee addr = mAddressBook->findByUid( *it ); 840 KABC::Addressee addr = mAddressBook->findByUid( *it );
839 if ( !addr.isEmpty() ) { 841 if ( !addr.isEmpty() ) {
840 if ( !merge ) 842 if ( !merge )
841 addr.setCategories( categories ); 843 addr.setCategories( categories );
842 else { 844 else {
843 QStringList addrCategories = addr.categories(); 845 QStringList addrCategories = addr.categories();
844 QStringList::Iterator catIt; 846 QStringList::Iterator catIt;
845 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 847 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
846 if ( !addrCategories.contains( *catIt ) ) 848 if ( !addrCategories.contains( *catIt ) )
847 addrCategories.append( *catIt ); 849 addrCategories.append( *catIt );
848 } 850 }
849 addr.setCategories( addrCategories ); 851 addr.setCategories( addrCategories );
850 } 852 }
851 853
852 mAddressBook->insertAddressee( addr ); 854 mAddressBook->insertAddressee( addr );
853 } 855 }
854 } 856 }
855 857
856 if ( uids.count() > 0 ) 858 if ( uids.count() > 0 )
857 setModified( true ); 859 setModified( true );
858} 860}
859 861
860void KABCore::setSearchFields( const KABC::Field::List &fields ) 862void KABCore::setSearchFields( const KABC::Field::List &fields )
861{ 863{
862 mIncSearchWidget->setFields( fields ); 864 mIncSearchWidget->setFields( fields );
863} 865}
864 866
865void KABCore::incrementalSearch( const QString& text ) 867void KABCore::incrementalSearch( const QString& text )
866{ 868{
867 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 869 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
868} 870}
869 871
870void KABCore::setModified() 872void KABCore::setModified()
871{ 873{
872 setModified( true ); 874 setModified( true );
873} 875}
874 876
875void KABCore::setModifiedWOrefresh() 877void KABCore::setModifiedWOrefresh()
876{ 878{
877 // qDebug("KABCore::setModifiedWOrefresh() "); 879 // qDebug("KABCore::setModifiedWOrefresh() ");
878 mModified = true; 880 mModified = true;
879 mActionSave->setEnabled( mModified ); 881 mActionSave->setEnabled( mModified );
880#ifdef DESKTOP_VERSION 882#ifdef DESKTOP_VERSION
881 mDetails->refreshView(); 883 mDetails->refreshView();
882#endif 884#endif
883 885
884} 886}
885void KABCore::setModified( bool modified ) 887void KABCore::setModified( bool modified )
886{ 888{
887 mModified = modified; 889 mModified = modified;
888 mActionSave->setEnabled( mModified ); 890 mActionSave->setEnabled( mModified );
889 891
890 if ( modified ) 892 if ( modified )
891 mJumpButtonBar->recreateButtons(); 893 mJumpButtonBar->recreateButtons();
892 894
893 mViewManager->refreshView(); 895 mViewManager->refreshView();
894 mDetails->refreshView(); 896 mDetails->refreshView();
895 897
896} 898}
897 899
898bool KABCore::modified() const 900bool KABCore::modified() const
899{ 901{
900 return mModified; 902 return mModified;
901} 903}
902 904
903void KABCore::contactModified( const KABC::Addressee &addr ) 905void KABCore::contactModified( const KABC::Addressee &addr )
904{ 906{
905 907
906 Command *command = 0; 908 Command *command = 0;
907 QString uid; 909 QString uid;
908 910
909 // check if it exists already 911 // check if it exists already
910 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 912 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
911 if ( origAddr.isEmpty() ) 913 if ( origAddr.isEmpty() )
912 command = new PwNewCommand( mAddressBook, addr ); 914 command = new PwNewCommand( mAddressBook, addr );
913 else { 915 else {
914 command = new PwEditCommand( mAddressBook, origAddr, addr ); 916 command = new PwEditCommand( mAddressBook, origAddr, addr );
915 uid = addr.uid(); 917 uid = addr.uid();
916 } 918 }
917 919
918 UndoStack::instance()->push( command ); 920 UndoStack::instance()->push( command );
919 RedoStack::instance()->clear(); 921 RedoStack::instance()->clear();
920 922
921 setModified( true ); 923 setModified( true );
922} 924}
923 925
924void KABCore::newContact() 926void KABCore::newContact()
925{ 927{
926 928
927 929
928 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 930 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
929 931
930 QPtrList<KRES::Resource> kresResources; 932 QPtrList<KRES::Resource> kresResources;
931 QPtrListIterator<KABC::Resource> it( kabcResources ); 933 QPtrListIterator<KABC::Resource> it( kabcResources );
932 KABC::Resource *resource; 934 KABC::Resource *resource;
933 while ( ( resource = it.current() ) != 0 ) { 935 while ( ( resource = it.current() ) != 0 ) {
934 ++it; 936 ++it;
935 if ( !resource->readOnly() ) { 937 if ( !resource->readOnly() ) {
936 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 938 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
937 if ( res ) 939 if ( res )
938 kresResources.append( res ); 940 kresResources.append( res );
939 } 941 }
940 } 942 }
941 943
942 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 944 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
943 resource = static_cast<KABC::Resource*>( res ); 945 resource = static_cast<KABC::Resource*>( res );
944 946
945 if ( resource ) { 947 if ( resource ) {
946 KABC::Addressee addr; 948 KABC::Addressee addr;
947 addr.setResource( resource ); 949 addr.setResource( resource );
948 mEditorDialog->setAddressee( addr ); 950 mEditorDialog->setAddressee( addr );
949 KApplication::execDialog ( mEditorDialog ); 951 KApplication::execDialog ( mEditorDialog );
950 952
951 } else 953 } else
952 return; 954 return;
953 955
954 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 956 // mEditorDict.insert( dialog->addressee().uid(), dialog );
955 957
956 958
957} 959}
958 960
959void KABCore::addEmail( QString aStr ) 961void KABCore::addEmail( QString aStr )
960{ 962{
961#ifndef KAB_EMBEDDED 963#ifndef KAB_EMBEDDED
962 QString fullName, email; 964 QString fullName, email;
963 965
964 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 966 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
965 967
966 // Try to lookup the addressee matching the email address 968 // Try to lookup the addressee matching the email address
967 bool found = false; 969 bool found = false;
968 QStringList emailList; 970 QStringList emailList;
969 KABC::AddressBook::Iterator it; 971 KABC::AddressBook::Iterator it;
970 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 972 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
971 emailList = (*it).emails(); 973 emailList = (*it).emails();
972 if ( emailList.contains( email ) > 0 ) { 974 if ( emailList.contains( email ) > 0 ) {
973 found = true; 975 found = true;
974 (*it).setNameFromString( fullName ); 976 (*it).setNameFromString( fullName );
975 editContact( (*it).uid() ); 977 editContact( (*it).uid() );
976 } 978 }
977 } 979 }
978 980
979 if ( !found ) { 981 if ( !found ) {
980 KABC::Addressee addr; 982 KABC::Addressee addr;
981 addr.setNameFromString( fullName ); 983 addr.setNameFromString( fullName );
982 addr.insertEmail( email, true ); 984 addr.insertEmail( email, true );
983 985
984 mAddressBook->insertAddressee( addr ); 986 mAddressBook->insertAddressee( addr );
985 mViewManager->refreshView( addr.uid() ); 987 mViewManager->refreshView( addr.uid() );
986 editContact( addr.uid() ); 988 editContact( addr.uid() );
987 } 989 }
988#else //KAB_EMBEDDED 990#else //KAB_EMBEDDED
989 qDebug("KABCore::addEmail finsih method"); 991 qDebug("KABCore::addEmail finsih method");
990#endif //KAB_EMBEDDED 992#endif //KAB_EMBEDDED
991} 993}
992 994
993void KABCore::importVCard( const KURL &url, bool showPreview ) 995void KABCore::importVCard( const KURL &url, bool showPreview )
994{ 996{
995 mXXPortManager->importVCard( url, showPreview ); 997 mXXPortManager->importVCard( url, showPreview );
996} 998}
997void KABCore::importFromOL() 999void KABCore::importFromOL()
998{ 1000{
999#ifdef _WIN32_ 1001#ifdef _WIN32_
1000 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1002 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1001 idgl->exec(); 1003 idgl->exec();
1002 KABC::Addressee::List list = idgl->getAddressList(); 1004 KABC::Addressee::List list = idgl->getAddressList();
1003 if ( list.count() > 0 ) { 1005 if ( list.count() > 0 ) {
1004 KABC::Addressee::List listNew; 1006 KABC::Addressee::List listNew;
1005 KABC::Addressee::List listExisting; 1007 KABC::Addressee::List listExisting;
1006 KABC::Addressee::List::Iterator it; 1008 KABC::Addressee::List::Iterator it;
1007 KABC::AddressBook::Iterator iter; 1009 KABC::AddressBook::Iterator iter;
1008 for ( it = list.begin(); it != list.end(); ++it ) { 1010 for ( it = list.begin(); it != list.end(); ++it ) {
1009 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1011 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1010 listNew.append( (*it) ); 1012 listNew.append( (*it) );
1011 else 1013 else
1012 listExisting.append( (*it) ); 1014 listExisting.append( (*it) );
1013 } 1015 }
1014 if ( listExisting.count() > 0 ) 1016 if ( listExisting.count() > 0 )
1015 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1017 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1016 if ( listNew.count() > 0 ) { 1018 if ( listNew.count() > 0 ) {
1017 pasteWithNewUid = false; 1019 pasteWithNewUid = false;
1018 pasteContacts( listNew ); 1020 pasteContacts( listNew );
1019 pasteWithNewUid = true; 1021 pasteWithNewUid = true;
1020 } 1022 }
1021 } 1023 }
1022 delete idgl; 1024 delete idgl;
1023#endif 1025#endif
1024} 1026}
1025 1027
1026void KABCore::importVCard( const QString &vCard, bool showPreview ) 1028void KABCore::importVCard( const QString &vCard, bool showPreview )
1027{ 1029{
1028 mXXPortManager->importVCard( vCard, showPreview ); 1030 mXXPortManager->importVCard( vCard, showPreview );
1029} 1031}
1030 1032
1031//US added a second method without defaultparameter 1033//US added a second method without defaultparameter
1032void KABCore::editContact2() { 1034void KABCore::editContact2() {
1033 editContact( QString::null ); 1035 editContact( QString::null );
1034} 1036}
1035 1037
1036void KABCore::editContact( const QString &uid ) 1038void KABCore::editContact( const QString &uid )
1037{ 1039{
1038 1040
1039 if ( mExtensionManager->isQuickEditVisible() ) 1041 if ( mExtensionManager->isQuickEditVisible() )
1040 return; 1042 return;
1041 1043
1042 // First, locate the contact entry 1044 // First, locate the contact entry
1043 QString localUID = uid; 1045 QString localUID = uid;
1044 if ( localUID.isNull() ) { 1046 if ( localUID.isNull() ) {
1045 QStringList uidList = mViewManager->selectedUids(); 1047 QStringList uidList = mViewManager->selectedUids();
1046 if ( uidList.count() > 0 ) 1048 if ( uidList.count() > 0 )
1047 localUID = *( uidList.at( 0 ) ); 1049 localUID = *( uidList.at( 0 ) );
1048 } 1050 }
1049 1051
1050 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1052 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1051 if ( !addr.isEmpty() ) { 1053 if ( !addr.isEmpty() ) {
1052 mEditorDialog->setAddressee( addr ); 1054 mEditorDialog->setAddressee( addr );
1053 KApplication::execDialog ( mEditorDialog ); 1055 KApplication::execDialog ( mEditorDialog );
1054 } 1056 }
1055} 1057}
1056 1058
1057/** 1059/**
1058 Shows or edits the detail view for the given uid. If the uid is QString::null, 1060 Shows or edits the detail view for the given uid. If the uid is QString::null,
1059 the method will try to find a selected addressee in the view. 1061 the method will try to find a selected addressee in the view.
1060 */ 1062 */
1061void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1063void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1062{ 1064{
1063 if ( mMultipleViewsAtOnce ) 1065 if ( mMultipleViewsAtOnce )
1064 { 1066 {
1065 editContact( uid ); 1067 editContact( uid );
1066 } 1068 }
1067 else 1069 else
1068 { 1070 {
1069 setDetailsVisible( true ); 1071 setDetailsVisible( true );
1070 mActionDetails->setChecked(true); 1072 mActionDetails->setChecked(true);
1071 } 1073 }
1072 1074
1073} 1075}
1074 1076
1075void KABCore::save() 1077void KABCore::save()
1076{ 1078{
1077 if (mBlockSaveFlag) 1079 if (syncManager->blockSave())
1078 return; 1080 return;
1079 mBlockSaveFlag = true; 1081 syncManager->setBlockSave(true);
1080 if ( !mModified ) 1082 if ( !mModified )
1081 return; 1083 return;
1082 QString text = i18n( "There was an error while attempting to save\n the " 1084 QString text = i18n( "There was an error while attempting to save\n the "
1083 "address book. Please check that some \nother application is " 1085 "address book. Please check that some \nother application is "
1084 "not using it. " ); 1086 "not using it. " );
1085 statusMessage(i18n("Saving addressbook ... ")); 1087 statusMessage(i18n("Saving addressbook ... "));
1086#ifndef KAB_EMBEDDED 1088#ifndef KAB_EMBEDDED
1087 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1089 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1088 if ( !b || !b->save() ) { 1090 if ( !b || !b->save() ) {
1089 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1091 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1090 } 1092 }
1091#else //KAB_EMBEDDED 1093#else //KAB_EMBEDDED
1092 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1094 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1093 if ( !b || !b->save() ) { 1095 if ( !b || !b->save() ) {
1094 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1096 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1095 } 1097 }
1096#endif //KAB_EMBEDDED 1098#endif //KAB_EMBEDDED
1097 1099
1098 statusMessage(i18n("Addressbook saved!")); 1100 statusMessage(i18n("Addressbook saved!"));
1099 setModified( false ); 1101 setModified( false );
1100 mBlockSaveFlag = false; 1102 syncManager->setBlockSave(false);
1101} 1103}
1102 1104
1103void KABCore::statusMessage(QString mess , int time ) 1105void KABCore::statusMessage(QString mess , int time )
1104{ 1106{
1105 //topLevelWidget()->setCaption( mess ); 1107 //topLevelWidget()->setCaption( mess );
1106 // pending setting timer to revome message 1108 // pending setting timer to revome message
1107} 1109}
1108void KABCore::undo() 1110void KABCore::undo()
1109{ 1111{
1110 UndoStack::instance()->undo(); 1112 UndoStack::instance()->undo();
1111 1113
1112 // Refresh the view 1114 // Refresh the view
1113 mViewManager->refreshView(); 1115 mViewManager->refreshView();
1114} 1116}
1115 1117
1116void KABCore::redo() 1118void KABCore::redo()
1117{ 1119{
1118 RedoStack::instance()->redo(); 1120 RedoStack::instance()->redo();
1119 1121
1120 // Refresh the view 1122 // Refresh the view
1121 mViewManager->refreshView(); 1123 mViewManager->refreshView();
1122} 1124}
1123 1125
1124void KABCore::setJumpButtonBarVisible( bool visible ) 1126void KABCore::setJumpButtonBarVisible( bool visible )
1125{ 1127{
1126 if (mMultipleViewsAtOnce) 1128 if (mMultipleViewsAtOnce)
1127 { 1129 {
1128 if ( visible ) 1130 if ( visible )
1129 mJumpButtonBar->show(); 1131 mJumpButtonBar->show();
1130 else 1132 else
1131 mJumpButtonBar->hide(); 1133 mJumpButtonBar->hide();
1132 } 1134 }
1133 else 1135 else
1134 { 1136 {
1135 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1137 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1136 if (mViewManager->isVisible()) 1138 if (mViewManager->isVisible())
1137 { 1139 {
1138 if ( visible ) 1140 if ( visible )
1139 mJumpButtonBar->show(); 1141 mJumpButtonBar->show();
1140 else 1142 else
1141 mJumpButtonBar->hide(); 1143 mJumpButtonBar->hide();
1142 } 1144 }
1143 else 1145 else
1144 { 1146 {
1145 mJumpButtonBar->hide(); 1147 mJumpButtonBar->hide();
1146 } 1148 }
1147 } 1149 }
1148} 1150}
1149 1151
1150 1152
1151void KABCore::setDetailsToState() 1153void KABCore::setDetailsToState()
1152{ 1154{
1153 setDetailsVisible( mActionDetails->isChecked() ); 1155 setDetailsVisible( mActionDetails->isChecked() );
1154} 1156}
1155 1157
1156 1158
1157 1159
1158void KABCore::setDetailsVisible( bool visible ) 1160void KABCore::setDetailsVisible( bool visible )
1159{ 1161{
1160 if (visible && mDetails->isHidden()) 1162 if (visible && mDetails->isHidden())
1161 { 1163 {
1162 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1164 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1163 if ( addrList.count() > 0 ) 1165 if ( addrList.count() > 0 )
1164 mDetails->setAddressee( addrList[ 0 ] ); 1166 mDetails->setAddressee( addrList[ 0 ] );
1165 } 1167 }
1166 1168
1167 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1169 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1168 // the listview and the detailview. We do that by changing the splitbar size. 1170 // the listview and the detailview. We do that by changing the splitbar size.
1169 if (mMultipleViewsAtOnce) 1171 if (mMultipleViewsAtOnce)
1170 { 1172 {
1171 if ( visible ) 1173 if ( visible )
1172 mDetails->show(); 1174 mDetails->show();
1173 else 1175 else
1174 mDetails->hide(); 1176 mDetails->hide();
1175 } 1177 }
1176 else 1178 else
1177 { 1179 {
1178 if ( visible ) { 1180 if ( visible ) {
1179 mViewManager->hide(); 1181 mViewManager->hide();
1180 mDetails->show(); 1182 mDetails->show();
1181 } 1183 }
1182 else { 1184 else {
1183 mViewManager->show(); 1185 mViewManager->show();
1184 mDetails->hide(); 1186 mDetails->hide();
1185 } 1187 }
1186 setJumpButtonBarVisible( !visible ); 1188 setJumpButtonBarVisible( !visible );
1187 } 1189 }
1188 1190
1189} 1191}
1190 1192
1191void KABCore::extensionChanged( int id ) 1193void KABCore::extensionChanged( int id )
1192{ 1194{
1193 //change the details view only for non desktop systems 1195 //change the details view only for non desktop systems
1194#ifndef DESKTOP_VERSION 1196#ifndef DESKTOP_VERSION
1195 1197
1196 if (id == 0) 1198 if (id == 0)
1197 { 1199 {
1198 //the user disabled the extension. 1200 //the user disabled the extension.
1199 1201
1200 if (mMultipleViewsAtOnce) 1202 if (mMultipleViewsAtOnce)
1201 { // enable detailsview again 1203 { // enable detailsview again
1202 setDetailsVisible( true ); 1204 setDetailsVisible( true );
1203 mActionDetails->setChecked( true ); 1205 mActionDetails->setChecked( true );
1204 } 1206 }
1205 else 1207 else
1206 { //go back to the listview 1208 { //go back to the listview
1207 setDetailsVisible( false ); 1209 setDetailsVisible( false );
1208 mActionDetails->setChecked( false ); 1210 mActionDetails->setChecked( false );
1209 mActionDetails->setEnabled(true); 1211 mActionDetails->setEnabled(true);
1210 } 1212 }
1211 1213
1212 } 1214 }
1213 else 1215 else
1214 { 1216 {
1215 //the user enabled the extension. 1217 //the user enabled the extension.
1216 setDetailsVisible( false ); 1218 setDetailsVisible( false );
1217 mActionDetails->setChecked( false ); 1219 mActionDetails->setChecked( false );
1218 1220
1219 if (!mMultipleViewsAtOnce) 1221 if (!mMultipleViewsAtOnce)
1220 { 1222 {
1221 mActionDetails->setEnabled(false); 1223 mActionDetails->setEnabled(false);
1222 } 1224 }
1223 1225
1224 mExtensionManager->setSelectionChanged(); 1226 mExtensionManager->setSelectionChanged();
1225 1227
1226 } 1228 }
1227 1229
1228#endif// DESKTOP_VERSION 1230#endif// DESKTOP_VERSION
1229 1231
1230} 1232}
1231 1233
1232 1234
1233void KABCore::extensionModified( const KABC::Addressee::List &list ) 1235void KABCore::extensionModified( const KABC::Addressee::List &list )
1234{ 1236{
1235 1237
1236 if ( list.count() != 0 ) { 1238 if ( list.count() != 0 ) {
1237 KABC::Addressee::List::ConstIterator it; 1239 KABC::Addressee::List::ConstIterator it;
1238 for ( it = list.begin(); it != list.end(); ++it ) 1240 for ( it = list.begin(); it != list.end(); ++it )
1239 mAddressBook->insertAddressee( *it ); 1241 mAddressBook->insertAddressee( *it );
1240 if ( list.count() > 1 ) 1242 if ( list.count() > 1 )
1241 setModified(); 1243 setModified();
1242 else 1244 else
1243 setModifiedWOrefresh(); 1245 setModifiedWOrefresh();
1244 } 1246 }
1245 if ( list.count() == 0 ) 1247 if ( list.count() == 0 )
1246 mViewManager->refreshView(); 1248 mViewManager->refreshView();
1247 else 1249 else
1248 mViewManager->refreshView( list[ 0 ].uid() ); 1250 mViewManager->refreshView( list[ 0 ].uid() );
1249 1251
1250 1252
1251 1253
1252} 1254}
1253 1255
1254QString KABCore::getNameByPhone( const QString &phone ) 1256QString KABCore::getNameByPhone( const QString &phone )
1255{ 1257{
1256#ifndef KAB_EMBEDDED 1258#ifndef KAB_EMBEDDED
1257 QRegExp r( "[/*/-/ ]" ); 1259 QRegExp r( "[/*/-/ ]" );
1258 QString localPhone( phone ); 1260 QString localPhone( phone );
1259 1261
1260 bool found = false; 1262 bool found = false;
1261 QString ownerName = ""; 1263 QString ownerName = "";
1262 KABC::AddressBook::Iterator iter; 1264 KABC::AddressBook::Iterator iter;
1263 KABC::PhoneNumber::List::Iterator phoneIter; 1265 KABC::PhoneNumber::List::Iterator phoneIter;
1264 KABC::PhoneNumber::List phoneList; 1266 KABC::PhoneNumber::List phoneList;
1265 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1267 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1266 phoneList = (*iter).phoneNumbers(); 1268 phoneList = (*iter).phoneNumbers();
1267 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1269 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1268 ++phoneIter) { 1270 ++phoneIter) {
1269 // Get rid of separator chars so just the numbers are compared. 1271 // Get rid of separator chars so just the numbers are compared.
1270 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1272 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1271 ownerName = (*iter).formattedName(); 1273 ownerName = (*iter).formattedName();
1272 found = true; 1274 found = true;
1273 } 1275 }
1274 } 1276 }
1275 } 1277 }
1276 1278
1277 return ownerName; 1279 return ownerName;
1278#else //KAB_EMBEDDED 1280#else //KAB_EMBEDDED
1279 qDebug("KABCore::getNameByPhone finsih method"); 1281 qDebug("KABCore::getNameByPhone finsih method");
1280 return ""; 1282 return "";
1281#endif //KAB_EMBEDDED 1283#endif //KAB_EMBEDDED
1282 1284
1283} 1285}
1284 1286
1285void KABCore::openConfigDialog() 1287void KABCore::openConfigDialog()
1286{ 1288{
1287 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1289 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1288 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1290 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1289 ConfigureDialog->addModule(kabcfg ); 1291 ConfigureDialog->addModule(kabcfg );
1290 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1292 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1291 ConfigureDialog->addModule(kdelibcfg ); 1293 ConfigureDialog->addModule(kdelibcfg );
1292 1294
1293 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1295 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1294 this, SLOT( configurationChanged() ) ); 1296 this, SLOT( configurationChanged() ) );
1295 connect( ConfigureDialog, SIGNAL( okClicked() ), 1297 connect( ConfigureDialog, SIGNAL( okClicked() ),
1296 this, SLOT( configurationChanged() ) ); 1298 this, SLOT( configurationChanged() ) );
1297 saveSettings(); 1299 saveSettings();
1298#ifndef DESKTOP_VERSION 1300#ifndef DESKTOP_VERSION
1299 ConfigureDialog->showMaximized(); 1301 ConfigureDialog->showMaximized();
1300#endif 1302#endif
1301 if ( ConfigureDialog->exec() ) 1303 if ( ConfigureDialog->exec() )
1302 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1304 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1303 delete ConfigureDialog; 1305 delete ConfigureDialog;
1304} 1306}
1305 1307
1306void KABCore::openLDAPDialog() 1308void KABCore::openLDAPDialog()
1307{ 1309{
1308#ifndef KAB_EMBEDDED 1310#ifndef KAB_EMBEDDED
1309 if ( !mLdapSearchDialog ) { 1311 if ( !mLdapSearchDialog ) {
1310 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1312 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1311 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1313 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1312 SLOT( refreshView() ) ); 1314 SLOT( refreshView() ) );
1313 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1315 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1314 SLOT( setModified() ) ); 1316 SLOT( setModified() ) );
1315 } else 1317 } else
1316 mLdapSearchDialog->restoreSettings(); 1318 mLdapSearchDialog->restoreSettings();
1317 1319
1318 if ( mLdapSearchDialog->isOK() ) 1320 if ( mLdapSearchDialog->isOK() )
1319 mLdapSearchDialog->exec(); 1321 mLdapSearchDialog->exec();
1320#else //KAB_EMBEDDED 1322#else //KAB_EMBEDDED
1321 qDebug("KABCore::openLDAPDialog() finsih method"); 1323 qDebug("KABCore::openLDAPDialog() finsih method");
1322#endif //KAB_EMBEDDED 1324#endif //KAB_EMBEDDED
1323} 1325}
1324 1326
1325void KABCore::print() 1327void KABCore::print()
1326{ 1328{
1327#ifndef KAB_EMBEDDED 1329#ifndef KAB_EMBEDDED
1328 KPrinter printer; 1330 KPrinter printer;
1329 if ( !printer.setup( this ) ) 1331 if ( !printer.setup( this ) )
1330 return; 1332 return;
1331 1333
1332 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1334 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1333 mViewManager->selectedUids(), this ); 1335 mViewManager->selectedUids(), this );
1334 1336
1335 wizard.exec(); 1337 wizard.exec();
1336#else //KAB_EMBEDDED 1338#else //KAB_EMBEDDED
1337 qDebug("KABCore::print() finsih method"); 1339 qDebug("KABCore::print() finsih method");
1338#endif //KAB_EMBEDDED 1340#endif //KAB_EMBEDDED
1339 1341
1340} 1342}
1341 1343
1342 1344
1343void KABCore::addGUIClient( KXMLGUIClient *client ) 1345void KABCore::addGUIClient( KXMLGUIClient *client )
1344{ 1346{
1345 if ( mGUIClient ) 1347 if ( mGUIClient )
1346 mGUIClient->insertChildClient( client ); 1348 mGUIClient->insertChildClient( client );
1347 else 1349 else
1348 KMessageBox::error( this, "no KXMLGUICLient"); 1350 KMessageBox::error( this, "no KXMLGUICLient");
1349} 1351}
1350 1352
1351 1353
1352void KABCore::configurationChanged() 1354void KABCore::configurationChanged()
1353{ 1355{
1354 mExtensionManager->reconfigure(); 1356 mExtensionManager->reconfigure();
1355} 1357}
1356 1358
1357void KABCore::addressBookChanged() 1359void KABCore::addressBookChanged()
1358{ 1360{
1359/*US 1361/*US
1360 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1362 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1361 while ( it.current() ) { 1363 while ( it.current() ) {
1362 if ( it.current()->dirty() ) { 1364 if ( it.current()->dirty() ) {
1363 QString text = i18n( "Data has been changed externally. Unsaved " 1365 QString text = i18n( "Data has been changed externally. Unsaved "
1364 "changes will be lost." ); 1366 "changes will be lost." );
1365 KMessageBox::information( this, text ); 1367 KMessageBox::information( this, text );
1366 } 1368 }
1367 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1369 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1368 ++it; 1370 ++it;
1369 } 1371 }
1370*/ 1372*/
1371 if (mEditorDialog) 1373 if (mEditorDialog)
1372 { 1374 {
1373 if (mEditorDialog->dirty()) 1375 if (mEditorDialog->dirty())
1374 { 1376 {
1375 QString text = i18n( "Data has been changed externally. Unsaved " 1377 QString text = i18n( "Data has been changed externally. Unsaved "
1376 "changes will be lost." ); 1378 "changes will be lost." );
1377 KMessageBox::information( this, text ); 1379 KMessageBox::information( this, text );
1378 } 1380 }
1379 QString currentuid = mEditorDialog->addressee().uid(); 1381 QString currentuid = mEditorDialog->addressee().uid();
1380 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1382 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1381 } 1383 }
1382 mViewManager->refreshView(); 1384 mViewManager->refreshView();
1383// mDetails->refreshView(); 1385// mDetails->refreshView();
1384 1386
1385 1387
1386} 1388}
1387 1389
1388AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1390AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1389 const char *name ) 1391 const char *name )
1390{ 1392{
1391 1393
1392 if ( mEditorDialog == 0 ) { 1394 if ( mEditorDialog == 0 ) {
1393 mEditorDialog = new AddresseeEditorDialog( this, parent, 1395 mEditorDialog = new AddresseeEditorDialog( this, parent,
1394 name ? name : "editorDialog" ); 1396 name ? name : "editorDialog" );
1395 1397
1396 1398
1397 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1399 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1398 SLOT( contactModified( const KABC::Addressee& ) ) ); 1400 SLOT( contactModified( const KABC::Addressee& ) ) );
1399 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1401 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1400 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1402 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1401 } 1403 }
1402 1404
1403 return mEditorDialog; 1405 return mEditorDialog;
1404} 1406}
1405 1407
1406void KABCore::slotEditorDestroyed( const QString &uid ) 1408void KABCore::slotEditorDestroyed( const QString &uid )
1407{ 1409{
1408 //mEditorDict.remove( uid ); 1410 //mEditorDict.remove( uid );
1409} 1411}
1410 1412
1411void KABCore::initGUI() 1413void KABCore::initGUI()
1412{ 1414{
1413#ifndef KAB_EMBEDDED 1415#ifndef KAB_EMBEDDED
1414 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1416 QHBoxLayout *topLayout = new QHBoxLayout( this );
1415 topLayout->setSpacing( KDialogBase::spacingHint() ); 1417 topLayout->setSpacing( KDialogBase::spacingHint() );
1416 1418
1417 mExtensionBarSplitter = new QSplitter( this ); 1419 mExtensionBarSplitter = new QSplitter( this );
1418 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1420 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1419 1421
1420 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1422 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1421 1423
1422 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1424 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1423 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1425 mIncSearchWidget = new IncSearchWidget( viewSpace );
1424 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1426 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1425 SLOT( incrementalSearch( const QString& ) ) ); 1427 SLOT( incrementalSearch( const QString& ) ) );
1426 1428
1427 mViewManager = new ViewManager( this, viewSpace ); 1429 mViewManager = new ViewManager( this, viewSpace );
1428 viewSpace->setStretchFactor( mViewManager, 1 ); 1430 viewSpace->setStretchFactor( mViewManager, 1 );
1429 1431
1430 mDetails = new ViewContainer( mDetailsSplitter ); 1432 mDetails = new ViewContainer( mDetailsSplitter );
1431 1433
1432 mJumpButtonBar = new JumpButtonBar( this, this ); 1434 mJumpButtonBar = new JumpButtonBar( this, this );
1433 1435
1434 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1436 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1435 1437
1436 topLayout->addWidget( mExtensionBarSplitter ); 1438 topLayout->addWidget( mExtensionBarSplitter );
1437 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1439 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1438 topLayout->addWidget( mJumpButtonBar ); 1440 topLayout->addWidget( mJumpButtonBar );
1439 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1441 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1440 1442
1441 mXXPortManager = new XXPortManager( this, this ); 1443 mXXPortManager = new XXPortManager( this, this );
1442 1444
1443#else //KAB_EMBEDDED 1445#else //KAB_EMBEDDED
1444 //US initialize viewMenu before settingup viewmanager. 1446 //US initialize viewMenu before settingup viewmanager.
1445 // Viewmanager needs this menu to plugin submenues. 1447 // Viewmanager needs this menu to plugin submenues.
1446 viewMenu = new QPopupMenu( this ); 1448 viewMenu = new QPopupMenu( this );
1447 settingsMenu = new QPopupMenu( this ); 1449 settingsMenu = new QPopupMenu( this );
1448 //filterMenu = new QPopupMenu( this ); 1450 //filterMenu = new QPopupMenu( this );
1449 ImportMenu = new QPopupMenu( this ); 1451 ImportMenu = new QPopupMenu( this );
1450 ExportMenu = new QPopupMenu( this ); 1452 ExportMenu = new QPopupMenu( this );
1451 syncMenu = new QPopupMenu( this ); 1453 syncMenu = new QPopupMenu( this );
1452 changeMenu= new QPopupMenu( this ); 1454 changeMenu= new QPopupMenu( this );
1453 1455
1454//US since we have no splitter for the embedded system, setup 1456//US since we have no splitter for the embedded system, setup
1455// a layout with two frames. One left and one right. 1457// a layout with two frames. One left and one right.
1456 1458
1457 QBoxLayout *topLayout; 1459 QBoxLayout *topLayout;
1458 1460
1459 // = new QHBoxLayout( this ); 1461 // = new QHBoxLayout( this );
1460// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1462// QBoxLayout *topLayout = (QBoxLayout*)layout();
1461 1463
1462// QWidget *mainBox = new QWidget( this ); 1464// QWidget *mainBox = new QWidget( this );
1463// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1465// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1464 1466
1465#ifdef DESKTOP_VERSION 1467#ifdef DESKTOP_VERSION
1466 topLayout = new QHBoxLayout( this ); 1468 topLayout = new QHBoxLayout( this );
1467 1469
1468 1470
1469 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1471 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1470 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1472 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1471 1473
1472 topLayout->addWidget(mMiniSplitter ); 1474 topLayout->addWidget(mMiniSplitter );
1473 1475
1474 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1476 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1475 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1477 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1476 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1478 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1477 mDetails = new ViewContainer( mMiniSplitter ); 1479 mDetails = new ViewContainer( mMiniSplitter );
1478 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1480 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1479#else 1481#else
1480 if ( QApplication::desktop()->width() > 480 ) { 1482 if ( QApplication::desktop()->width() > 480 ) {
1481 topLayout = new QHBoxLayout( this ); 1483 topLayout = new QHBoxLayout( this );
1482 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1484 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1483 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1485 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1484 } else { 1486 } else {
1485 1487
1486 topLayout = new QHBoxLayout( this ); 1488 topLayout = new QHBoxLayout( this );
1487 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1489 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1488 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1490 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1489 } 1491 }
1490 1492
1491 topLayout->addWidget(mMiniSplitter ); 1493 topLayout->addWidget(mMiniSplitter );
1492 mViewManager = new ViewManager( this, mMiniSplitter ); 1494 mViewManager = new ViewManager( this, mMiniSplitter );
1493 mDetails = new ViewContainer( mMiniSplitter ); 1495 mDetails = new ViewContainer( mMiniSplitter );
1494 1496
1495 1497
1496 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1498 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1497#endif 1499#endif
1498 //eh->hide(); 1500 //eh->hide();
1499 // topLayout->addWidget(mExtensionManager ); 1501 // topLayout->addWidget(mExtensionManager );
1500 1502
1501 1503
1502/*US 1504/*US
1503#ifndef KAB_NOSPLITTER 1505#ifndef KAB_NOSPLITTER
1504 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1506 QHBoxLayout *topLayout = new QHBoxLayout( this );
1505//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1507//US topLayout->setSpacing( KDialogBase::spacingHint() );
1506 topLayout->setSpacing( 10 ); 1508 topLayout->setSpacing( 10 );
1507 1509
1508 mDetailsSplitter = new QSplitter( this ); 1510 mDetailsSplitter = new QSplitter( this );
1509 1511
1510 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1512 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1511 1513
1512 mViewManager = new ViewManager( this, viewSpace ); 1514 mViewManager = new ViewManager( this, viewSpace );
1513 viewSpace->setStretchFactor( mViewManager, 1 ); 1515 viewSpace->setStretchFactor( mViewManager, 1 );
1514 1516
1515 mDetails = new ViewContainer( mDetailsSplitter ); 1517 mDetails = new ViewContainer( mDetailsSplitter );
1516 1518
1517 topLayout->addWidget( mDetailsSplitter ); 1519 topLayout->addWidget( mDetailsSplitter );
1518 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1520 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1519#else //KAB_NOSPLITTER 1521#else //KAB_NOSPLITTER
1520 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1522 QHBoxLayout *topLayout = new QHBoxLayout( this );
1521//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1523//US topLayout->setSpacing( KDialogBase::spacingHint() );
1522 topLayout->setSpacing( 10 ); 1524 topLayout->setSpacing( 10 );
1523 1525
1524// mDetailsSplitter = new QSplitter( this ); 1526// mDetailsSplitter = new QSplitter( this );
1525 1527
1526 QVBox *viewSpace = new QVBox( this ); 1528 QVBox *viewSpace = new QVBox( this );
1527 1529
1528 mViewManager = new ViewManager( this, viewSpace ); 1530 mViewManager = new ViewManager( this, viewSpace );
1529 viewSpace->setStretchFactor( mViewManager, 1 ); 1531 viewSpace->setStretchFactor( mViewManager, 1 );
1530 1532
1531 mDetails = new ViewContainer( this ); 1533 mDetails = new ViewContainer( this );
1532 1534
1533 topLayout->addWidget( viewSpace ); 1535 topLayout->addWidget( viewSpace );
1534// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1536// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1535 topLayout->addWidget( mDetails ); 1537 topLayout->addWidget( mDetails );
1536#endif //KAB_NOSPLITTER 1538#endif //KAB_NOSPLITTER
1537*/ 1539*/
1538 1540
1541 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1542 syncManager->setBlockSave(false);
1543
1539 1544
1540#endif //KAB_EMBEDDED 1545#endif //KAB_EMBEDDED
1541 initActions(); 1546 initActions();
1542 1547
1543#ifdef KAB_EMBEDDED 1548#ifdef KAB_EMBEDDED
1544 addActionsManually(); 1549 addActionsManually();
1545 //US make sure the export and import menues are initialized before creating the xxPortManager. 1550 //US make sure the export and import menues are initialized before creating the xxPortManager.
1546 mXXPortManager = new XXPortManager( this, this ); 1551 mXXPortManager = new XXPortManager( this, this );
1547 1552
1548 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1553 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1549 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1554 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1550 // mActionQuit->plug ( mMainWindow->toolBar()); 1555 // mActionQuit->plug ( mMainWindow->toolBar());
1551 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1556 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1552 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1557 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1553 // mIncSearchWidget->hide(); 1558 // mIncSearchWidget->hide();
1554 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1559 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1555 SLOT( incrementalSearch( const QString& ) ) ); 1560 SLOT( incrementalSearch( const QString& ) ) );
1556 1561
1557 1562
1558 mJumpButtonBar = new JumpButtonBar( this, this ); 1563 mJumpButtonBar = new JumpButtonBar( this, this );
1559 1564
1560 topLayout->addWidget( mJumpButtonBar ); 1565 topLayout->addWidget( mJumpButtonBar );
1561//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1566//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1562 1567
1563// mMainWindow->getIconToolBar()->raise(); 1568// mMainWindow->getIconToolBar()->raise();
1564 1569
1565#endif //KAB_EMBEDDED 1570#endif //KAB_EMBEDDED
1566 1571
1567} 1572}
1568void KABCore::initActions() 1573void KABCore::initActions()
1569{ 1574{
1570//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1575//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1571 1576
1572#ifndef KAB_EMBEDDED 1577#ifndef KAB_EMBEDDED
1573 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1578 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1574 SLOT( clipboardDataChanged() ) ); 1579 SLOT( clipboardDataChanged() ) );
1575#endif //KAB_EMBEDDED 1580#endif //KAB_EMBEDDED
1576 1581
1577 // file menu 1582 // file menu
1578 if ( mIsPart ) { 1583 if ( mIsPart ) {
1579 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1584 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1580 SLOT( sendMail() ), actionCollection(), 1585 SLOT( sendMail() ), actionCollection(),
1581 "kaddressbook_mail" ); 1586 "kaddressbook_mail" );
1582 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1587 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1583 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1588 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1584 1589
1585 } else { 1590 } else {
1586 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1591 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1587 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1592 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1588 } 1593 }
1589 1594
1590 1595
1591 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1596 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1592 SLOT( save() ), actionCollection(), "file_sync" ); 1597 SLOT( save() ), actionCollection(), "file_sync" );
1593 1598
1594 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1599 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1595 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1600 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1596 1601
1597 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1602 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1598 this, SLOT( mailVCard() ), 1603 this, SLOT( mailVCard() ),
1599 actionCollection(), "file_mail_vcard"); 1604 actionCollection(), "file_mail_vcard");
1600 1605
1601 mActionBeamVCard = 0; 1606 mActionBeamVCard = 0;
1602 mActionBeam = 0; 1607 mActionBeam = 0;
1603 1608
1604#ifndef DESKTOP_VERSION 1609#ifndef DESKTOP_VERSION
1605 if ( Ir::supported() ) { 1610 if ( Ir::supported() ) {
1606 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1611 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1607 SLOT( beamVCard() ), actionCollection(), 1612 SLOT( beamVCard() ), actionCollection(),
1608 "kaddressbook_beam_vcard" ); 1613 "kaddressbook_beam_vcard" );
1609 1614
1610 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1615 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1611 SLOT( beamMySelf() ), actionCollection(), 1616 SLOT( beamMySelf() ), actionCollection(),
1612 "kaddressbook_beam_myself" ); 1617 "kaddressbook_beam_myself" );
1613 } 1618 }
1614#endif 1619#endif
1615 1620
1616 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1621 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1617 this, SLOT( editContact2() ), 1622 this, SLOT( editContact2() ),
1618 actionCollection(), "file_properties" ); 1623 actionCollection(), "file_properties" );
1619 1624
1620#ifdef KAB_EMBEDDED 1625#ifdef KAB_EMBEDDED
1621 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1626 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1622 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1627 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1623 mMainWindow, SLOT( exit() ), 1628 mMainWindow, SLOT( exit() ),
1624 actionCollection(), "quit" ); 1629 actionCollection(), "quit" );
1625#endif //KAB_EMBEDDED 1630#endif //KAB_EMBEDDED
1626 1631
1627 // edit menu 1632 // edit menu
1628 if ( mIsPart ) { 1633 if ( mIsPart ) {
1629 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1634 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1630 SLOT( copyContacts() ), actionCollection(), 1635 SLOT( copyContacts() ), actionCollection(),
1631 "kaddressbook_copy" ); 1636 "kaddressbook_copy" );
1632 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1637 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1633 SLOT( cutContacts() ), actionCollection(), 1638 SLOT( cutContacts() ), actionCollection(),
1634 "kaddressbook_cut" ); 1639 "kaddressbook_cut" );
1635 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1640 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1636 SLOT( pasteContacts() ), actionCollection(), 1641 SLOT( pasteContacts() ), actionCollection(),
1637 "kaddressbook_paste" ); 1642 "kaddressbook_paste" );
1638 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1643 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1639 SLOT( selectAllContacts() ), actionCollection(), 1644 SLOT( selectAllContacts() ), actionCollection(),
1640 "kaddressbook_select_all" ); 1645 "kaddressbook_select_all" );
1641 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1646 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1642 SLOT( undo() ), actionCollection(), 1647 SLOT( undo() ), actionCollection(),
1643 "kaddressbook_undo" ); 1648 "kaddressbook_undo" );
1644 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1649 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1645 this, SLOT( redo() ), actionCollection(), 1650 this, SLOT( redo() ), actionCollection(),
1646 "kaddressbook_redo" ); 1651 "kaddressbook_redo" );
1647 } else { 1652 } else {
1648 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1653 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1649 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1654 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1650 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1655 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1651 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1656 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1652 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1657 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1653 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1658 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1654 } 1659 }
1655 1660
1656 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1661 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1657 Key_Delete, this, SLOT( deleteContacts() ), 1662 Key_Delete, this, SLOT( deleteContacts() ),
1658 actionCollection(), "edit_delete" ); 1663 actionCollection(), "edit_delete" );
1659 1664
1660 mActionUndo->setEnabled( false ); 1665 mActionUndo->setEnabled( false );
1661 mActionRedo->setEnabled( false ); 1666 mActionRedo->setEnabled( false );
1662 1667
1663 // settings menu 1668 // settings menu
1664#ifdef KAB_EMBEDDED 1669#ifdef KAB_EMBEDDED
1665//US special menuentry to configure the addressbook resources. On KDE 1670//US special menuentry to configure the addressbook resources. On KDE
1666// you do that through the control center !!! 1671// you do that through the control center !!!
1667 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1672 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1668 SLOT( configureResources() ), actionCollection(), 1673 SLOT( configureResources() ), actionCollection(),
1669 "kaddressbook_configure_resources" ); 1674 "kaddressbook_configure_resources" );
1670#endif //KAB_EMBEDDED 1675#endif //KAB_EMBEDDED
1671 1676
1672 if ( mIsPart ) { 1677 if ( mIsPart ) {
1673 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1678 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1674 SLOT( openConfigDialog() ), actionCollection(), 1679 SLOT( openConfigDialog() ), actionCollection(),
1675 "kaddressbook_configure" ); 1680 "kaddressbook_configure" );
1676 1681
1677 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1682 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1678 this, SLOT( configureKeyBindings() ), actionCollection(), 1683 this, SLOT( configureKeyBindings() ), actionCollection(),
1679 "kaddressbook_configure_shortcuts" ); 1684 "kaddressbook_configure_shortcuts" );
1680#ifdef KAB_EMBEDDED 1685#ifdef KAB_EMBEDDED
1681 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1686 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1682 mActionConfigureToolbars->setEnabled( false ); 1687 mActionConfigureToolbars->setEnabled( false );
1683#endif //KAB_EMBEDDED 1688#endif //KAB_EMBEDDED
1684 1689
1685 } else { 1690 } else {
1686 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1691 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1687 1692
1688 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1693 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1689 } 1694 }
1690 1695
1691 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1696 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1692 actionCollection(), "options_show_jump_bar" ); 1697 actionCollection(), "options_show_jump_bar" );
1693 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1698 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1694 1699
1695 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1700 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1696 actionCollection(), "options_show_details" ); 1701 actionCollection(), "options_show_details" );
1697 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1702 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1698 1703
1699 // misc 1704 // misc
1700 // only enable LDAP lookup if we can handle the protocol 1705 // only enable LDAP lookup if we can handle the protocol
1701#ifndef KAB_EMBEDDED 1706#ifndef KAB_EMBEDDED
1702 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1707 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1703 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1708 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1704 this, SLOT( openLDAPDialog() ), actionCollection(), 1709 this, SLOT( openLDAPDialog() ), actionCollection(),
1705 "ldap_lookup" ); 1710 "ldap_lookup" );
1706 } 1711 }
1707#else //KAB_EMBEDDED 1712#else //KAB_EMBEDDED
1708 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1713 //qDebug("KABCore::initActions() LDAP has to be implemented");
1709#endif //KAB_EMBEDDED 1714#endif //KAB_EMBEDDED
1710 1715
1711 1716
1712 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1717 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1713 SLOT( setWhoAmI() ), actionCollection(), 1718 SLOT( setWhoAmI() ), actionCollection(),
1714 "set_personal" ); 1719 "set_personal" );
1715 1720
1716 1721
1717 1722
1718 1723
1719 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1724 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1720 SLOT( setCategories() ), actionCollection(), 1725 SLOT( setCategories() ), actionCollection(),
1721 "edit_set_categories" ); 1726 "edit_set_categories" );
1722 1727
1723 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1728 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1724 SLOT( removeVoice() ), actionCollection(), 1729 SLOT( removeVoice() ), actionCollection(),
1725 "remove_voice" ); 1730 "remove_voice" );
1726 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 1731 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
1727 SLOT( importFromOL() ), actionCollection(), 1732 SLOT( importFromOL() ), actionCollection(),
1728 "import_OL" ); 1733 "import_OL" );
1729#ifdef KAB_EMBEDDED 1734#ifdef KAB_EMBEDDED
1730 mActionLicence = new KAction( i18n( "Licence" ), 0, 1735 mActionLicence = new KAction( i18n( "Licence" ), 0,
1731 this, SLOT( showLicence() ), actionCollection(), 1736 this, SLOT( showLicence() ), actionCollection(),
1732 "licence_about_data" ); 1737 "licence_about_data" );
1733 mActionFaq = new KAction( i18n( "Faq" ), 0, 1738 mActionFaq = new KAction( i18n( "Faq" ), 0,
1734 this, SLOT( faq() ), actionCollection(), 1739 this, SLOT( faq() ), actionCollection(),
1735 "faq_about_data" ); 1740 "faq_about_data" );
1736 1741
1737 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1742 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1738 this, SLOT( createAboutData() ), actionCollection(), 1743 this, SLOT( createAboutData() ), actionCollection(),
1739 "kaddressbook_about_data" ); 1744 "kaddressbook_about_data" );
1740#endif //KAB_EMBEDDED 1745#endif //KAB_EMBEDDED
1741 1746
1742 clipboardDataChanged(); 1747 clipboardDataChanged();
1743 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1748 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1744 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1749 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1745} 1750}
1746 1751
1747//US we need this function, to plug all actions into the correct menues. 1752//US we need this function, to plug all actions into the correct menues.
1748// KDE uses a XML format to plug the actions, but we work her without this overhead. 1753// KDE uses a XML format to plug the actions, but we work her without this overhead.
1749void KABCore::addActionsManually() 1754void KABCore::addActionsManually()
1750{ 1755{
1751//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1756//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1752 1757
1753#ifdef KAB_EMBEDDED 1758#ifdef KAB_EMBEDDED
1754 QPopupMenu *fileMenu = new QPopupMenu( this ); 1759 QPopupMenu *fileMenu = new QPopupMenu( this );
1755 QPopupMenu *editMenu = new QPopupMenu( this ); 1760 QPopupMenu *editMenu = new QPopupMenu( this );
1756 QPopupMenu *helpMenu = new QPopupMenu( this ); 1761 QPopupMenu *helpMenu = new QPopupMenu( this );
1757 1762
1758 KToolBar* tb = mMainWindow->toolBar(); 1763 KToolBar* tb = mMainWindow->toolBar();
1759 1764
1760#ifdef DESKTOP_VERSION 1765#ifdef DESKTOP_VERSION
1761 QMenuBar* mb = mMainWindow->menuBar(); 1766 QMenuBar* mb = mMainWindow->menuBar();
1762 1767
1763 //US setup menubar. 1768 //US setup menubar.
1764 //Disable the following block if you do not want to have a menubar. 1769 //Disable the following block if you do not want to have a menubar.
1765 mb->insertItem( "&File", fileMenu ); 1770 mb->insertItem( "&File", fileMenu );
1766 mb->insertItem( "&Edit", editMenu ); 1771 mb->insertItem( "&Edit", editMenu );
1767 mb->insertItem( "&View", viewMenu ); 1772 mb->insertItem( "&View", viewMenu );
1768 mb->insertItem( "&Settings", settingsMenu ); 1773 mb->insertItem( "&Settings", settingsMenu );
1769 mb->insertItem( i18n("Synchronize"), syncMenu ); 1774 mb->insertItem( i18n("Synchronize"), syncMenu );
1770 mb->insertItem( "&Change selected", changeMenu ); 1775 mb->insertItem( "&Change selected", changeMenu );
1771 mb->insertItem( "&Help", helpMenu ); 1776 mb->insertItem( "&Help", helpMenu );
1772 mIncSearchWidget = new IncSearchWidget( tb ); 1777 mIncSearchWidget = new IncSearchWidget( tb );
1773 // tb->insertWidget(-1, 0, mIncSearchWidget); 1778 // tb->insertWidget(-1, 0, mIncSearchWidget);
1774 1779
1775#else 1780#else
1776 //US setup toolbar 1781 //US setup toolbar
1777 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 1782 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
1778 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1783 QPopupMenu *popupBarTB = new QPopupMenu( this );
1779 menuBarTB->insertItem( "ME", popupBarTB); 1784 menuBarTB->insertItem( "ME", popupBarTB);
1780 tb->insertWidget(-1, 0, menuBarTB); 1785 tb->insertWidget(-1, 0, menuBarTB);
1781 mIncSearchWidget = new IncSearchWidget( tb ); 1786 mIncSearchWidget = new IncSearchWidget( tb );
1782 1787
1783 tb->enableMoving(false); 1788 tb->enableMoving(false);
1784 popupBarTB->insertItem( "&File", fileMenu ); 1789 popupBarTB->insertItem( "&File", fileMenu );
1785 popupBarTB->insertItem( "&Edit", editMenu ); 1790 popupBarTB->insertItem( "&Edit", editMenu );
1786 popupBarTB->insertItem( "&View", viewMenu ); 1791 popupBarTB->insertItem( "&View", viewMenu );
1787 popupBarTB->insertItem( "&Settings", settingsMenu ); 1792 popupBarTB->insertItem( "&Settings", settingsMenu );
1788 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 1793 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
1789 mViewManager->getFilterAction()->plug ( popupBarTB); 1794 mViewManager->getFilterAction()->plug ( popupBarTB);
1790 popupBarTB->insertItem( "&Change selected", changeMenu ); 1795 popupBarTB->insertItem( "&Change selected", changeMenu );
1791 popupBarTB->insertItem( "&Help", helpMenu ); 1796 popupBarTB->insertItem( "&Help", helpMenu );
1792 if (QApplication::desktop()->width() > 320 ) { 1797 if (QApplication::desktop()->width() > 320 ) {
1793 // mViewManager->getFilterAction()->plug ( tb); 1798 // mViewManager->getFilterAction()->plug ( tb);
1794 } 1799 }
1795#endif 1800#endif
1796 // mActionQuit->plug ( mMainWindow->toolBar()); 1801 // mActionQuit->plug ( mMainWindow->toolBar());
1797 1802
1798 1803
1799 1804
1800 //US Now connect the actions with the menue entries. 1805 //US Now connect the actions with the menue entries.
1801 mActionPrint->plug( fileMenu ); 1806 mActionPrint->plug( fileMenu );
1802 mActionMail->plug( fileMenu ); 1807 mActionMail->plug( fileMenu );
1803 fileMenu->insertSeparator(); 1808 fileMenu->insertSeparator();
1804 1809
1805 mActionNewContact->plug( fileMenu ); 1810 mActionNewContact->plug( fileMenu );
1806 mActionNewContact->plug( tb ); 1811 mActionNewContact->plug( tb );
1807 1812
1808 mActionEditAddressee->plug( fileMenu ); 1813 mActionEditAddressee->plug( fileMenu );
1809 if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 1814 if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
1810 (!KABPrefs::instance()->mMultipleViewsAtOnce )) 1815 (!KABPrefs::instance()->mMultipleViewsAtOnce ))
1811 mActionEditAddressee->plug( tb ); 1816 mActionEditAddressee->plug( tb );
1812 1817
1813 fileMenu->insertSeparator(); 1818 fileMenu->insertSeparator();
1814 mActionSave->plug( fileMenu ); 1819 mActionSave->plug( fileMenu );
1815 fileMenu->insertItem( "&Import", ImportMenu ); 1820 fileMenu->insertItem( "&Import", ImportMenu );
1816 fileMenu->insertItem( "&Export", ExportMenu ); 1821 fileMenu->insertItem( "&Export", ExportMenu );
1817 fileMenu->insertSeparator(); 1822 fileMenu->insertSeparator();
1818 mActionMailVCard->plug( fileMenu ); 1823 mActionMailVCard->plug( fileMenu );
1819#ifndef DESKTOP_VERSION 1824#ifndef DESKTOP_VERSION
1820 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 1825 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1821 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 1826 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
1822#endif 1827#endif
1823 fileMenu->insertSeparator(); 1828 fileMenu->insertSeparator();
1824 mActionQuit->plug( fileMenu ); 1829 mActionQuit->plug( fileMenu );
1825#ifdef _WIN32_ 1830#ifdef _WIN32_
1826 mActionImportOL->plug( ImportMenu ); 1831 mActionImportOL->plug( ImportMenu );
1827#endif 1832#endif
1828 // edit menu 1833 // edit menu
1829 mActionUndo->plug( editMenu ); 1834 mActionUndo->plug( editMenu );
1830 mActionRedo->plug( editMenu ); 1835 mActionRedo->plug( editMenu );
1831 editMenu->insertSeparator(); 1836 editMenu->insertSeparator();
1832 mActionCut->plug( editMenu ); 1837 mActionCut->plug( editMenu );
1833 mActionCopy->plug( editMenu ); 1838 mActionCopy->plug( editMenu );
1834 mActionPaste->plug( editMenu ); 1839 mActionPaste->plug( editMenu );
1835 mActionDelete->plug( editMenu ); 1840 mActionDelete->plug( editMenu );
1836 editMenu->insertSeparator(); 1841 editMenu->insertSeparator();
1837 mActionSelectAll->plug( editMenu ); 1842 mActionSelectAll->plug( editMenu );
1838 1843
1839 mActionRemoveVoice->plug( changeMenu ); 1844 mActionRemoveVoice->plug( changeMenu );
1840 // settings menu 1845 // settings menu
1841//US special menuentry to configure the addressbook resources. On KDE 1846//US special menuentry to configure the addressbook resources. On KDE
1842// you do that through the control center !!! 1847// you do that through the control center !!!
1843 mActionConfigResources->plug( settingsMenu ); 1848 mActionConfigResources->plug( settingsMenu );
1844 settingsMenu->insertSeparator(); 1849 settingsMenu->insertSeparator();
1845 1850
1846 mActionConfigKAddressbook->plug( settingsMenu ); 1851 mActionConfigKAddressbook->plug( settingsMenu );
1847 1852
1848 if ( mIsPart ) { 1853 if ( mIsPart ) {
1849 mActionConfigShortcuts->plug( settingsMenu ); 1854 mActionConfigShortcuts->plug( settingsMenu );
1850 mActionConfigureToolbars->plug( settingsMenu ); 1855 mActionConfigureToolbars->plug( settingsMenu );
1851 1856
1852 } else { 1857 } else {
1853 mActionKeyBindings->plug( settingsMenu ); 1858 mActionKeyBindings->plug( settingsMenu );
1854 } 1859 }
1855 1860
1856 settingsMenu->insertSeparator(); 1861 settingsMenu->insertSeparator();
1857 1862
1858 mActionJumpBar->plug( settingsMenu ); 1863 mActionJumpBar->plug( settingsMenu );
1859 mActionDetails->plug( settingsMenu ); 1864 mActionDetails->plug( settingsMenu );
1860 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 1865 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
1861 mActionDetails->plug( tb ); 1866 mActionDetails->plug( tb );
1862 settingsMenu->insertSeparator(); 1867 settingsMenu->insertSeparator();
1863 1868
1864 mActionWhoAmI->plug( settingsMenu ); 1869 mActionWhoAmI->plug( settingsMenu );
1865 mActionCategories->plug( settingsMenu ); 1870 mActionCategories->plug( settingsMenu );
1866 1871
1867 mActionLicence->plug( helpMenu ); 1872 mActionLicence->plug( helpMenu );
1868 mActionFaq->plug( helpMenu ); 1873 mActionFaq->plug( helpMenu );
1869 mActionAboutKAddressbook->plug( helpMenu ); 1874 mActionAboutKAddressbook->plug( helpMenu );
1870 1875
1871 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 1876 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
1872 1877
1873 mActionSave->plug( tb ); 1878 mActionSave->plug( tb );
1874 mViewManager->getFilterAction()->plug ( tb); 1879 mViewManager->getFilterAction()->plug ( tb);
1875 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 1880 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
1876 mActionUndo->plug( tb ); 1881 mActionUndo->plug( tb );
1877 mActionDelete->plug( tb ); 1882 mActionDelete->plug( tb );
1878 mActionRedo->plug( tb ); 1883 mActionRedo->plug( tb );
1879 } 1884 }
1880 } 1885 }
1881 //mActionQuit->plug ( tb ); 1886 //mActionQuit->plug ( tb );
1882 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 1887 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
1883 1888
1884 //US link the searchwidget first to this. 1889 //US link the searchwidget first to this.
1885 // The real linkage to the toolbar happens later. 1890 // The real linkage to the toolbar happens later.
1886//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 1891//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
1887//US tb->insertItem( mIncSearchWidget ); 1892//US tb->insertItem( mIncSearchWidget );
1888/*US 1893/*US
1889 mIncSearchWidget = new IncSearchWidget( tb ); 1894 mIncSearchWidget = new IncSearchWidget( tb );
1890 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1895 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1891 SLOT( incrementalSearch( const QString& ) ) ); 1896 SLOT( incrementalSearch( const QString& ) ) );
1892 1897
1893 mJumpButtonBar = new JumpButtonBar( this, this ); 1898 mJumpButtonBar = new JumpButtonBar( this, this );
1894 1899
1895//US topLayout->addWidget( mJumpButtonBar ); 1900//US topLayout->addWidget( mJumpButtonBar );
1896 this->layout()->add( mJumpButtonBar ); 1901 this->layout()->add( mJumpButtonBar );
1897*/ 1902*/
1898 1903
1899#endif //KAB_EMBEDDED 1904#endif //KAB_EMBEDDED
1900 1905
1901 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); 1906 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
1902 fillSyncMenu(); 1907 syncManager->fillSyncMenu();
1903 1908
1904} 1909}
1905void KABCore::showLicence() 1910void KABCore::showLicence()
1906{ 1911{
1907 KApplication::showLicence(); 1912 KApplication::showLicence();
1908} 1913}
1909void KABCore::removeVoice() 1914void KABCore::removeVoice()
1910{ 1915{
1911 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 ) 1916 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 )
1912 return; 1917 return;
1913 KABC::Addressee::List list = mViewManager->selectedAddressees(); 1918 KABC::Addressee::List list = mViewManager->selectedAddressees();
1914 KABC::Addressee::List::Iterator it; 1919 KABC::Addressee::List::Iterator it;
1915 for ( it = list.begin(); it != list.end(); ++it ) { 1920 for ( it = list.begin(); it != list.end(); ++it ) {
1916 PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); 1921 PhoneNumber::List phoneNumbers = (*it).phoneNumbers();
1917 PhoneNumber::List::Iterator phoneIt; 1922 PhoneNumber::List::Iterator phoneIt;
1918 bool found = false; 1923 bool found = false;
1919 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { 1924 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) {
1920 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 1925 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
1921 if ((*phoneIt).type() - PhoneNumber::Voice ) { 1926 if ((*phoneIt).type() - PhoneNumber::Voice ) {
1922 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 1927 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
1923 (*it).insertPhoneNumber( (*phoneIt) ); 1928 (*it).insertPhoneNumber( (*phoneIt) );
1924 found = true; 1929 found = true;
1925 } 1930 }
1926 } 1931 }
1927 1932
1928 } 1933 }
1929 if ( found ) 1934 if ( found )
1930 contactModified((*it) ); 1935 contactModified((*it) );
1931 } 1936 }
1932} 1937}
1933 1938
1934 1939
1935 1940
1936void KABCore::clipboardDataChanged() 1941void KABCore::clipboardDataChanged()
1937{ 1942{
1938 1943
1939 if ( mReadWrite ) 1944 if ( mReadWrite )
1940 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 1945 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
1941 1946
1942} 1947}
1943 1948
1944void KABCore::updateActionMenu() 1949void KABCore::updateActionMenu()
1945{ 1950{
1946 UndoStack *undo = UndoStack::instance(); 1951 UndoStack *undo = UndoStack::instance();
1947 RedoStack *redo = RedoStack::instance(); 1952 RedoStack *redo = RedoStack::instance();
1948 1953
1949 if ( undo->isEmpty() ) 1954 if ( undo->isEmpty() )
1950 mActionUndo->setText( i18n( "Undo" ) ); 1955 mActionUndo->setText( i18n( "Undo" ) );
1951 else 1956 else
1952 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 1957 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
1953 1958
1954 mActionUndo->setEnabled( !undo->isEmpty() ); 1959 mActionUndo->setEnabled( !undo->isEmpty() );
1955 1960
1956 if ( !redo->top() ) 1961 if ( !redo->top() )
1957 mActionRedo->setText( i18n( "Redo" ) ); 1962 mActionRedo->setText( i18n( "Redo" ) );
1958 else 1963 else
1959 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 1964 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
1960 1965
1961 mActionRedo->setEnabled( !redo->isEmpty() ); 1966 mActionRedo->setEnabled( !redo->isEmpty() );
1962} 1967}
1963 1968
1964void KABCore::configureKeyBindings() 1969void KABCore::configureKeyBindings()
1965{ 1970{
1966#ifndef KAB_EMBEDDED 1971#ifndef KAB_EMBEDDED
1967 KKeyDialog::configure( actionCollection(), true ); 1972 KKeyDialog::configure( actionCollection(), true );
1968#else //KAB_EMBEDDED 1973#else //KAB_EMBEDDED
1969 qDebug("KABCore::configureKeyBindings() not implemented"); 1974 qDebug("KABCore::configureKeyBindings() not implemented");
1970#endif //KAB_EMBEDDED 1975#endif //KAB_EMBEDDED
1971} 1976}
1972 1977
1973#ifdef KAB_EMBEDDED 1978#ifdef KAB_EMBEDDED
1974void KABCore::configureResources() 1979void KABCore::configureResources()
1975{ 1980{
1976 KRES::KCMKResources dlg( this, "" , 0 ); 1981 KRES::KCMKResources dlg( this, "" , 0 );
1977 1982
1978 if ( !dlg.exec() ) 1983 if ( !dlg.exec() )
1979 return; 1984 return;
1980 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 1985 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
1981} 1986}
1982#endif //KAB_EMBEDDED 1987#endif //KAB_EMBEDDED
1983 1988
1984 1989
1985/* this method will be called through the QCop interface from Ko/Pi to select addresses 1990/* this method will be called through the QCop interface from Ko/Pi to select addresses
1986 * for the attendees list of an event. 1991 * for the attendees list of an event.
1987 */ 1992 */
1988void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 1993void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
1989{ 1994{
1990 QStringList nameList; 1995 QStringList nameList;
1991 QStringList emailList; 1996 QStringList emailList;
1992 QStringList uidList; 1997 QStringList uidList;
1993 1998
1994 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 1999 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
1995 uint i=0; 2000 uint i=0;
1996 for (i=0; i < list.count(); i++) 2001 for (i=0; i < list.count(); i++)
1997 { 2002 {
1998 nameList.append(list[i].realName()); 2003 nameList.append(list[i].realName());
1999 emailList.append(list[i].preferredEmail()); 2004 emailList.append(list[i].preferredEmail());
2000 uidList.append(list[i].uid()); 2005 uidList.append(list[i].uid());
2001 } 2006 }
2002 2007
2003 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2008 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2004 2009
2005} 2010}
2006 2011
2007/* this method will be called through the QCop interface from other apps to show details of a contact. 2012/* this method will be called through the QCop interface from other apps to show details of a contact.
2008 */ 2013 */
2009void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2014void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2010{ 2015{
2011 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2016 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2012 2017
2013 QString foundUid = QString::null; 2018 QString foundUid = QString::null;
2014 if ( ! uid.isEmpty() ) { 2019 if ( ! uid.isEmpty() ) {
2015 Addressee adrr = mAddressBook->findByUid( uid ); 2020 Addressee adrr = mAddressBook->findByUid( uid );
2016 if ( !adrr.isEmpty() ) { 2021 if ( !adrr.isEmpty() ) {
2017 foundUid = uid; 2022 foundUid = uid;
2018 } 2023 }
2019 if ( email == "sendbacklist" ) { 2024 if ( email == "sendbacklist" ) {
2020 //qDebug("ssssssssssssssssssssssend "); 2025 //qDebug("ssssssssssssssssssssssend ");
2021 QStringList nameList; 2026 QStringList nameList;
2022 QStringList emailList; 2027 QStringList emailList;
2023 QStringList uidList; 2028 QStringList uidList;
2024 nameList.append(adrr.realName()); 2029 nameList.append(adrr.realName());
2025 emailList = adrr.emails(); 2030 emailList = adrr.emails();
2026 uidList.append( adrr.preferredEmail()); 2031 uidList.append( adrr.preferredEmail());
2027 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2032 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2028 return; 2033 return;
2029 } 2034 }
2030 2035
2031 } 2036 }
2032 2037
2033 if ( email == "sendbacklist" ) 2038 if ( email == "sendbacklist" )
2034 return; 2039 return;
2035 if (foundUid.isEmpty()) 2040 if (foundUid.isEmpty())
2036 { 2041 {
2037 //find the uid of the person first 2042 //find the uid of the person first
2038 Addressee::List namelist; 2043 Addressee::List namelist;
2039 Addressee::List emaillist; 2044 Addressee::List emaillist;
2040 2045
2041 if (!name.isEmpty()) 2046 if (!name.isEmpty())
2042 namelist = mAddressBook->findByName( name ); 2047 namelist = mAddressBook->findByName( name );
2043 2048
2044 if (!email.isEmpty()) 2049 if (!email.isEmpty())
2045 emaillist = mAddressBook->findByEmail( email ); 2050 emaillist = mAddressBook->findByEmail( email );
2046 qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2051 qDebug("count %d %d ", namelist.count(),emaillist.count() );
2047 //check if we have a match in Namelist and Emaillist 2052 //check if we have a match in Namelist and Emaillist
2048 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2053 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2049 foundUid = emaillist[0].uid(); 2054 foundUid = emaillist[0].uid();
2050 } 2055 }
2051 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2056 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2052 foundUid = namelist[0].uid(); 2057 foundUid = namelist[0].uid();
2053 else 2058 else
2054 { 2059 {
2055 for (int i = 0; i < namelist.count(); i++) 2060 for (int i = 0; i < namelist.count(); i++)
2056 { 2061 {
2057 for (int j = 0; j < emaillist.count(); j++) 2062 for (int j = 0; j < emaillist.count(); j++)
2058 { 2063 {
2059 if (namelist[i] == emaillist[j]) 2064 if (namelist[i] == emaillist[j])
2060 { 2065 {
2061 foundUid = namelist[i].uid(); 2066 foundUid = namelist[i].uid();
2062 } 2067 }
2063 } 2068 }
2064 } 2069 }
2065 } 2070 }
2066 } 2071 }
2067 else 2072 else
2068 { 2073 {
2069 foundUid = uid; 2074 foundUid = uid;
2070 } 2075 }
2071 2076
2072 if (!foundUid.isEmpty()) 2077 if (!foundUid.isEmpty())
2073 { 2078 {
2074 2079
2075 // raise Ka/Pi if it is in the background 2080 // raise Ka/Pi if it is in the background
2076#ifndef DESKTOP_VERSION 2081#ifndef DESKTOP_VERSION
2077#ifndef KORG_NODCOP 2082#ifndef KORG_NODCOP
2078 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2083 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2079#endif 2084#endif
2080#endif 2085#endif
2081 2086
2082 mMainWindow->showMaximized(); 2087 mMainWindow->showMaximized();
2083 mMainWindow-> raise(); 2088 mMainWindow-> raise();
2084 2089
2085 mViewManager->setSelected( "", false); 2090 mViewManager->setSelected( "", false);
2086 mViewManager->refreshView( "" ); 2091 mViewManager->refreshView( "" );
2087 mViewManager->setSelected( foundUid, true ); 2092 mViewManager->setSelected( foundUid, true );
2088 mViewManager->refreshView( foundUid ); 2093 mViewManager->refreshView( foundUid );
2089 2094
2090 if ( !mMultipleViewsAtOnce ) 2095 if ( !mMultipleViewsAtOnce )
2091 { 2096 {
2092 setDetailsVisible( true ); 2097 setDetailsVisible( true );
2093 mActionDetails->setChecked(true); 2098 mActionDetails->setChecked(true);
2094 } 2099 }
2095 } 2100 }
2096} 2101}
2097 2102
2098 2103
2099void KABCore::faq() 2104void KABCore::faq()
2100{ 2105{
2101 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2106 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2102} 2107}
2103 2108
2104
2105void KABCore::fillSyncMenu()
2106{
2107 if ( syncMenu->count() )
2108 syncMenu->clear();
2109 syncMenu->insertItem( i18n("Configure..."), 0 );
2110 syncMenu->insertSeparator();
2111 syncMenu->insertItem( i18n("Multiple sync"), 1 );
2112 syncMenu->insertSeparator();
2113 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2114 config.setGroup("General");
2115 QStringList prof = config.readListEntry("SyncProfileNames");
2116 KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
2117 if ( prof.count() < 3 ) {
2118 prof.clear();
2119 prof << i18n("Sharp_DTM");
2120 prof << i18n("Local_file");
2121 prof << i18n("Last_file");
2122 KSyncProfile* temp = new KSyncProfile ();
2123 temp->setName( prof[0] );
2124 temp->writeConfig(&config);
2125 temp->setName( prof[1] );
2126 temp->writeConfig(&config);
2127 temp->setName( prof[2] );
2128 temp->writeConfig(&config);
2129 config.setGroup("General");
2130 config.writeEntry("SyncProfileNames",prof);
2131 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
2132 config.sync();
2133 delete temp;
2134 }
2135 KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
2136 KABPrefs::instance()->mSyncProfileNames = prof;
2137 int i;
2138 for ( i = 0; i < prof.count(); ++i ) {
2139
2140 syncMenu->insertItem( prof[i], 1000+i );
2141 if ( i == 2 )
2142 syncMenu->insertSeparator();
2143 }
2144 QDir app_dir;
2145 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
2146 syncMenu->setItemEnabled( false , 1000 );
2147 }
2148 //probaly useless
2149 //mView->setupExternSyncProfiles();
2150}
2151void KABCore::slotSyncMenu( int action )
2152{
2153 //qDebug("syncaction %d ", action);
2154 if ( action == 0 ) {
2155
2156 // seems to be a Qt2 event handling bug
2157 // syncmenu.clear causes a segfault at first time
2158 // when we call it after the main event loop, it is ok
2159 // same behaviour when calling OM/Pi via QCOP for the first time
2160 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
2161 //confSync();
2162
2163 return;
2164 }
2165 if ( action == 1 ) {
2166 multiSync( true );
2167 return;
2168 }
2169
2170 if (mBlockSaveFlag)
2171 return;
2172 mBlockSaveFlag = true;
2173 mCurrentSyncProfile = action - 1000 ;
2174 mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ;
2175 mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ;
2176 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2177 KSyncProfile* temp = new KSyncProfile ();
2178 temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2179 temp->readConfig(&config);
2180 KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
2181 KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
2182 KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
2183 KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
2184 KABPrefs::instance()->mWriteBackInFuture = 0;
2185 if ( temp->getWriteBackFuture() )
2186 KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
2187 KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
2188 if ( action == 1000 ) {
2189 syncSharp();
2190
2191 } else if ( action == 1001 ) {
2192 syncLocalFile();
2193
2194 } else if ( action == 1002 ) {
2195 quickSyncLocalFile();
2196
2197 } else if ( action >= 1003 ) {
2198 if ( temp->getIsLocalFileSync() ) {
2199 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
2200 KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
2201 } else {
2202 if ( temp->getIsPhoneSync() ) {
2203 KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
2204 KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
2205 KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
2206 syncPhone();
2207 } else
2208 syncRemote( temp );
2209
2210 }
2211 }
2212 delete temp;
2213 mBlockSaveFlag = false;
2214}
2215
2216void KABCore::syncLocalFile()
2217{
2218
2219 QString fn =KABPrefs::instance()->mLastSyncedLocalFile;
2220
2221 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
2222 if ( fn == "" )
2223 return;
2224 if ( syncWithFile( fn, false ) ) {
2225 qDebug("syncLocalFile() successful ");
2226 }
2227
2228}
2229bool KABCore::syncWithFile( QString fn , bool quick )
2230{
2231 bool ret = false;
2232 QFileInfo info;
2233 info.setFile( fn );
2234 QString mess;
2235 bool loadbup = true;
2236 if ( !info. exists() ) {
2237 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
2238 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2239 mess );
2240 return ret;
2241 }
2242 int result = 0;
2243 if ( !quick ) {
2244 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2245 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2246 mess,
2247 i18n("Sync"), i18n("Cancel"), 0,
2248 0, 1 );
2249 if ( result )
2250 return false;
2251 }
2252 if ( KABPrefs::instance()->mAskForPreferences )
2253 edit_sync_options();
2254 if ( result == 0 ) {
2255 //qDebug("Now sycing ... ");
2256 if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) )
2257 setCaption( i18n("Synchronization successful") );
2258 else
2259 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
2260 if ( ! quick )
2261 KABPrefs::instance()->mLastSyncedLocalFile = fn;
2262 setModified();
2263 }
2264 return ret;
2265}
2266void KABCore::quickSyncLocalFile()
2267{
2268
2269 if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) {
2270 qDebug("quick syncLocalFile() successful ");
2271
2272 }
2273}
2274void KABCore::multiSync( bool askforPrefs )
2275{
2276 if (mBlockSaveFlag)
2277 return;
2278 mBlockSaveFlag = true;
2279 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
2280 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2281 question,
2282 i18n("Yes"), i18n("No"),
2283 0, 0 ) != 0 ) {
2284 mBlockSaveFlag = false;
2285 setCaption(i18n("Aborted! Nothing synced!"));
2286 return;
2287 }
2288 mCurrentSyncDevice = i18n("Multiple profiles") ;
2289 KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs;
2290 if ( askforPrefs ) {
2291 edit_sync_options();
2292 KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs;
2293 }
2294 setCaption(i18n("Multiple sync started.") );
2295 qApp->processEvents();
2296 int num = ringSync() ;
2297 if ( num > 1 )
2298 ringSync();
2299 mBlockSaveFlag = false;
2300 if ( num )
2301 save();
2302 if ( num )
2303 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
2304 else
2305 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
2306 return;
2307}
2308int KABCore::ringSync()
2309{
2310 int syncedProfiles = 0;
2311 int i;
2312 QTime timer;
2313 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2314 QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames;
2315 KSyncProfile* temp = new KSyncProfile ();
2316 KABPrefs::instance()->mAskForPreferences = false;
2317 for ( i = 0; i < syncProfileNames.count(); ++i ) {
2318 mCurrentSyncProfile = i;
2319 temp->setName(syncProfileNames[mCurrentSyncProfile]);
2320 temp->readConfig(&config);
2321 if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) {
2322 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
2323 ++syncedProfiles;
2324 // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
2325 KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
2326 KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
2327 KABPrefs::instance()->mWriteBackInFuture = 0;
2328 if ( temp->getWriteBackFuture() )
2329 KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
2330 KABPrefs::instance()->mShowSyncSummary = false;
2331 mCurrentSyncDevice = syncProfileNames[i] ;
2332 mCurrentSyncName = KABPrefs::instance()->mLocalMachineName;
2333 if ( i == 0 ) {
2334 syncSharp();
2335 } else {
2336 if ( temp->getIsLocalFileSync() ) {
2337 if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) )
2338 KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
2339 } else {
2340 if ( temp->getIsPhoneSync() ) {
2341 KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
2342 KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
2343 KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
2344 syncPhone();
2345 } else
2346 syncRemote( temp, false );
2347
2348 }
2349 }
2350 timer.start();
2351 setCaption(i18n("Multiple sync in progress ... please wait!") );
2352 while ( timer.elapsed () < 2000 ) {
2353 qApp->processEvents();
2354#ifndef _WIN32_
2355 sleep (1);
2356#endif
2357 }
2358
2359 }
2360
2361 }
2362 delete temp;
2363 return syncedProfiles;
2364}
2365
2366void KABCore::syncRemote( KSyncProfile* prof, bool ask)
2367{
2368 QString question;
2369 if ( ask ) {
2370 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
2371 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2372 question,
2373 i18n("Yes"), i18n("No"),
2374 0, 0 ) != 0 )
2375 return;
2376 }
2377 QString command = prof->getPreSyncCommandAB();
2378 int fi;
2379 if ( (fi = command.find("$PWD$")) > 0 ) {
2380 QString pwd = getPassword();
2381 command = command.left( fi )+ pwd + command.mid( fi+5 );
2382
2383 }
2384 int maxlen = 30;
2385 if ( QApplication::desktop()->width() > 320 )
2386 maxlen += 25;
2387 setCaption ( i18n( "Copy remote file to local machine..." ) );
2388 int fileSize = 0;
2389 int result = system ( command );
2390 // 0 : okay
2391 // 256: no such file or dir
2392 //
2393 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2394 if ( result != 0 ) {
2395 int len = maxlen;
2396 while ( len < command.length() ) {
2397 command.insert( len , "\n" );
2398 len += maxlen +2;
2399 }
2400 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 (command) ;
2401 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2402 question,
2403 i18n("Okay!")) ;
2404 setCaption ("KO/Pi");
2405 return;
2406 }
2407 setCaption ( i18n( "Copying succeed." ) );
2408 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
2409 if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) {
2410// Event* e = mView->getLastSyncEvent();
2411// e->setReadOnly( false );
2412// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2413// e->setReadOnly( true );
2414 if ( KABPrefs::instance()->mWriteBackFile ) {
2415 command = prof->getPostSyncCommandAB();
2416 int fi;
2417 if ( (fi = command.find("$PWD$")) > 0 ) {
2418 QString pwd = getPassword();
2419 command = command.left( fi )+ pwd + command.mid( fi+5 );
2420
2421 }
2422 setCaption ( i18n( "Writing back file ..." ) );
2423 result = system ( command );
2424 qDebug("KO: Writing back file result: %d ", result);
2425 if ( result != 0 ) {
2426 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
2427 return;
2428 } else {
2429 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2430 }
2431 }
2432 }
2433 return;
2434}
2435#include <qpushbutton.h>
2436#include <qradiobutton.h>
2437#include <qbuttongroup.h>
2438void KABCore::edit_sync_options()
2439{
2440 //mDialogManager->showSyncOptions();
2441 //KABPrefs::instance()->mSyncAlgoPrefs
2442 QDialog dia( this, "dia", true );
2443 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
2444 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
2445 QVBoxLayout lay ( &dia );
2446 lay.setSpacing( 2 );
2447 lay.setMargin( 3 );
2448 lay.addWidget(&gr);
2449 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
2450 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
2451 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
2452 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
2453 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
2454 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
2455 //QRadioButton both( i18n("Take both on conflict"), &gr );
2456 QPushButton pb ( "OK", &dia);
2457 lay.addWidget( &pb );
2458 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2459 switch ( KABPrefs::instance()->mSyncAlgoPrefs ) {
2460 case 0:
2461 loc.setChecked( true);
2462 break;
2463 case 1:
2464 rem.setChecked( true );
2465 break;
2466 case 2:
2467 newest.setChecked( true);
2468 break;
2469 case 3:
2470 ask.setChecked( true);
2471 break;
2472 case 4:
2473 f_loc.setChecked( true);
2474 break;
2475 case 5:
2476 f_rem.setChecked( true);
2477 break;
2478 case 6:
2479 // both.setChecked( true);
2480 break;
2481 default:
2482 break;
2483 }
2484 if ( dia.exec() ) {
2485 KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
2486 }
2487
2488
2489}
2490QString KABCore::getPassword( )
2491{
2492 QString retfile = "";
2493 QDialog dia ( this, "input-dialog", true );
2494 QLineEdit lab ( &dia );
2495 lab.setEchoMode( QLineEdit::Password );
2496 QVBoxLayout lay( &dia );
2497 lay.setMargin(7);
2498 lay.setSpacing(7);
2499 lay.addWidget( &lab);
2500 dia.setFixedSize( 230,50 );
2501 dia.setCaption( i18n("Enter password") );
2502 QPushButton pb ( "OK", &dia);
2503 lay.addWidget( &pb );
2504 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2505 dia.show();
2506 int res = dia.exec();
2507 if ( res )
2508 retfile = lab.text();
2509 dia.hide();
2510 qApp->processEvents();
2511 return retfile;
2512
2513}
2514#include <libkcal/syncdefines.h> 2109#include <libkcal/syncdefines.h>
2515 2110
2516KABC::Addressee KABCore::getLastSyncAddressee() 2111KABC::Addressee KABCore::getLastSyncAddressee()
2517{ 2112{
2518 Addressee lse; 2113 Addressee lse;
2114 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2115
2519 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2116 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2520 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2117 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2521 if (lse.isEmpty()) { 2118 if (lse.isEmpty()) {
2522 qDebug("Creating new last-syncAddressee "); 2119 qDebug("Creating new last-syncAddressee ");
2523 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2120 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2524 QString sum = ""; 2121 QString sum = "";
2525 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2122 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2526 sum = "E: "; 2123 sum = "E: ";
2527 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2124 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2528 lse.setRevision( mLastAddressbookSync ); 2125 lse.setRevision( mLastAddressbookSync );
2529 lse.setCategories( i18n("SyncEvent") ); 2126 lse.setCategories( i18n("SyncEvent") );
2530 mAddressBook->insertAddressee( lse ); 2127 mAddressBook->insertAddressee( lse );
2531 } 2128 }
2532 return lse; 2129 return lse;
2533} 2130}
2534int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2131int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2535{ 2132{
2536 2133
2537 //void setZaurusId(int id); 2134 //void setZaurusId(int id);
2538 // int zaurusId() const; 2135 // int zaurusId() const;
2539 // void setZaurusUid(int id); 2136 // void setZaurusUid(int id);
2540 // int zaurusUid() const; 2137 // int zaurusUid() const;
2541 // void setZaurusStat(int id); 2138 // void setZaurusStat(int id);
2542 // int zaurusStat() const; 2139 // int zaurusStat() const;
2543 // 0 equal 2140 // 0 equal
2544 // 1 take local 2141 // 1 take local
2545 // 2 take remote 2142 // 2 take remote
2546 // 3 cancel 2143 // 3 cancel
2547 QDateTime lastSync = mLastAddressbookSync; 2144 QDateTime lastSync = mLastAddressbookSync;
2548 QDateTime localMod = local->revision(); 2145 QDateTime localMod = local->revision();
2549 QDateTime remoteMod = remote->revision(); 2146 QDateTime remoteMod = remote->revision();
2147
2148 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2149
2550 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2150 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2551 bool remCh, locCh; 2151 bool remCh, locCh;
2552 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2152 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2553 2153
2554 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2154 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2555 locCh = ( localMod > mLastAddressbookSync ); 2155 locCh = ( localMod > mLastAddressbookSync );
2556 if ( !remCh && ! locCh ) { 2156 if ( !remCh && ! locCh ) {
2557 //qDebug("both not changed "); 2157 //qDebug("both not changed ");
2558 lastSync = localMod.addDays(1); 2158 lastSync = localMod.addDays(1);
2559 if ( mode <= SYNC_PREF_ASK ) 2159 if ( mode <= SYNC_PREF_ASK )
2560 return 0; 2160 return 0;
2561 } else { 2161 } else {
2562 if ( locCh ) { 2162 if ( locCh ) {
2563 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2163 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2564 lastSync = localMod.addDays( -1 ); 2164 lastSync = localMod.addDays( -1 );
2565 if ( !remCh ) 2165 if ( !remCh )
2566 remoteMod =( lastSync.addDays( -1 ) ); 2166 remoteMod =( lastSync.addDays( -1 ) );
2567 } else { 2167 } else {
2568 //qDebug(" not loc changed "); 2168 //qDebug(" not loc changed ");
2569 lastSync = localMod.addDays( 1 ); 2169 lastSync = localMod.addDays( 1 );
2570 if ( remCh ) 2170 if ( remCh )
2571 remoteMod =( lastSync.addDays( 1 ) ); 2171 remoteMod =( lastSync.addDays( 1 ) );
2572 2172
2573 } 2173 }
2574 } 2174 }
2575 full = true; 2175 full = true;
2576 if ( mode < SYNC_PREF_ASK ) 2176 if ( mode < SYNC_PREF_ASK )
2577 mode = SYNC_PREF_ASK; 2177 mode = SYNC_PREF_ASK;
2578 } else { 2178 } else {
2579 if ( localMod == remoteMod ) 2179 if ( localMod == remoteMod )
2580 return 0; 2180 return 0;
2581 2181
2582 } 2182 }
2583 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 2183 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
2584 2184
2585 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); 2185 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
2586 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 2186 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
2587 //full = true; //debug only 2187 //full = true; //debug only
2588 if ( full ) { 2188 if ( full ) {
2589 bool equ = ( (*local) == (*remote) ); 2189 bool equ = ( (*local) == (*remote) );
2590 if ( equ ) { 2190 if ( equ ) {
2591 //qDebug("equal "); 2191 //qDebug("equal ");
2592 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2192 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2593 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2193 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2594 } 2194 }
2595 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2195 if ( mode < SYNC_PREF_FORCE_LOCAL )
2596 return 0; 2196 return 0;
2597 2197
2598 }//else //debug only 2198 }//else //debug only
2599 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2199 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2600 } 2200 }
2601 int result; 2201 int result;
2602 bool localIsNew; 2202 bool localIsNew;
2603 //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() ); 2203 //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() );
2604 2204
2605 if ( full && mode < SYNC_PREF_NEWEST ) 2205 if ( full && mode < SYNC_PREF_NEWEST )
2606 mode = SYNC_PREF_ASK; 2206 mode = SYNC_PREF_ASK;
2607 2207
2608 switch( mode ) { 2208 switch( mode ) {
2609 case SYNC_PREF_LOCAL: 2209 case SYNC_PREF_LOCAL:
2610 if ( lastSync > remoteMod ) 2210 if ( lastSync > remoteMod )
2611 return 1; 2211 return 1;
2612 if ( lastSync > localMod ) 2212 if ( lastSync > localMod )
2613 return 2; 2213 return 2;
2614 return 1; 2214 return 1;
2615 break; 2215 break;
2616 case SYNC_PREF_REMOTE: 2216 case SYNC_PREF_REMOTE:
2617 if ( lastSync > remoteMod ) 2217 if ( lastSync > remoteMod )
2618 return 1; 2218 return 1;
2619 if ( lastSync > localMod ) 2219 if ( lastSync > localMod )
2620 return 2; 2220 return 2;
2621 return 2; 2221 return 2;
2622 break; 2222 break;
2623 case SYNC_PREF_NEWEST: 2223 case SYNC_PREF_NEWEST:
2624 if ( localMod > remoteMod ) 2224 if ( localMod > remoteMod )
2625 return 1; 2225 return 1;
2626 else 2226 else
2627 return 2; 2227 return 2;
2628 break; 2228 break;
2629 case SYNC_PREF_ASK: 2229 case SYNC_PREF_ASK:
2630 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2230 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2631 if ( lastSync > remoteMod ) 2231 if ( lastSync > remoteMod )
2632 return 1; 2232 return 1;
2633 if ( lastSync > localMod ) 2233 if ( lastSync > localMod )
2634 return 2; 2234 return 2;
2635 localIsNew = localMod >= remoteMod; 2235 localIsNew = localMod >= remoteMod;
2636 //qDebug("conflict! ************************************** "); 2236 //qDebug("conflict! ************************************** ");
2637 { 2237 {
2638 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2238 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2639 result = acd.executeD(localIsNew); 2239 result = acd.executeD(localIsNew);
2640 return result; 2240 return result;
2641 } 2241 }
2642 break; 2242 break;
2643 case SYNC_PREF_FORCE_LOCAL: 2243 case SYNC_PREF_FORCE_LOCAL:
2644 return 1; 2244 return 1;
2645 break; 2245 break;
2646 case SYNC_PREF_FORCE_REMOTE: 2246 case SYNC_PREF_FORCE_REMOTE:
2647 return 2; 2247 return 2;
2648 break; 2248 break;
2649 2249
2650 default: 2250 default:
2651 // SYNC_PREF_TAKE_BOTH not implemented 2251 // SYNC_PREF_TAKE_BOTH not implemented
2652 break; 2252 break;
2653 } 2253 }
2654 return 0; 2254 return 0;
2655} 2255}
2256
2257
2656bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2258bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2657{ 2259{
2658 bool syncOK = true; 2260 bool syncOK = true;
2659 int addedAddressee = 0; 2261 int addedAddressee = 0;
2660 int addedAddresseeR = 0; 2262 int addedAddresseeR = 0;
2661 int deletedAddresseeR = 0; 2263 int deletedAddresseeR = 0;
2662 int deletedAddresseeL = 0; 2264 int deletedAddresseeL = 0;
2663 int changedLocal = 0; 2265 int changedLocal = 0;
2664 int changedRemote = 0; 2266 int changedRemote = 0;
2267
2268 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2269 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2270
2665 //QPtrList<Addressee> el = local->rawAddressees(); 2271 //QPtrList<Addressee> el = local->rawAddressees();
2666 Addressee addresseeR; 2272 Addressee addresseeR;
2667 QString uid; 2273 QString uid;
2668 int take; 2274 int take;
2669 Addressee addresseeL; 2275 Addressee addresseeL;
2670 Addressee addresseeRSync; 2276 Addressee addresseeRSync;
2671 Addressee addresseeLSync; 2277 Addressee addresseeLSync;
2672 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2278 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2673 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2279 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2674 bool fullDateRange = false; 2280 bool fullDateRange = false;
2675 local->resetTempSyncStat(); 2281 local->resetTempSyncStat();
2676 mLastAddressbookSync = QDateTime::currentDateTime(); 2282 mLastAddressbookSync = QDateTime::currentDateTime();
2677 QDateTime modifiedCalendar = mLastAddressbookSync;; 2283 QDateTime modifiedCalendar = mLastAddressbookSync;;
2678 addresseeLSync = getLastSyncAddressee(); 2284 addresseeLSync = getLastSyncAddressee();
2679 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2285 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2680 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2286 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2681 if ( !addresseeR.isEmpty() ) { 2287 if ( !addresseeR.isEmpty() ) {
2682 addresseeRSync = addresseeR; 2288 addresseeRSync = addresseeR;
2683 remote->removeAddressee(addresseeR ); 2289 remote->removeAddressee(addresseeR );
2684 2290
2685 } else { 2291 } else {
2686 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2292 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2687 addresseeRSync = addresseeLSync ; 2293 addresseeRSync = addresseeLSync ;
2688 } else { 2294 } else {
2689 qDebug("FULLDATE 1"); 2295 qDebug("FULLDATE 1");
2690 fullDateRange = true; 2296 fullDateRange = true;
2691 Addressee newAdd; 2297 Addressee newAdd;
2692 addresseeRSync = newAdd; 2298 addresseeRSync = newAdd;
2693 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2299 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2694 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2300 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2695 addresseeRSync.setRevision( mLastAddressbookSync ); 2301 addresseeRSync.setRevision( mLastAddressbookSync );
2696 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2302 addresseeRSync.setCategories( i18n("SyncAddressee") );
2697 } 2303 }
2698 } 2304 }
2699 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2305 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2700 qDebug("FULLDATE 2"); 2306 qDebug("FULLDATE 2");
2701 fullDateRange = true; 2307 fullDateRange = true;
2702 } 2308 }
2703 if ( ! fullDateRange ) { 2309 if ( ! fullDateRange ) {
2704 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2310 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2705 2311
2706 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2312 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2707 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2313 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2708 fullDateRange = true; 2314 fullDateRange = true;
2709 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2315 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2710 } 2316 }
2711 } 2317 }
2712 // fullDateRange = true; // debug only! 2318 // fullDateRange = true; // debug only!
2713 if ( fullDateRange ) 2319 if ( fullDateRange )
2714 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2320 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2715 else 2321 else
2716 mLastAddressbookSync = addresseeLSync.revision(); 2322 mLastAddressbookSync = addresseeLSync.revision();
2717 // for resyncing if own file has changed 2323 // for resyncing if own file has changed
2718 // PENDING fixme later when implemented 2324 // PENDING fixme later when implemented
2719#if 0 2325#if 0
2720 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2326 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2721 mLastAddressbookSync = loadedFileVersion; 2327 mLastAddressbookSync = loadedFileVersion;
2722 qDebug("setting mLastAddressbookSync "); 2328 qDebug("setting mLastAddressbookSync ");
2723 } 2329 }
2724#endif 2330#endif
2725 2331
2726 //qDebug("*************************** "); 2332 //qDebug("*************************** ");
2727 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2333 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2728 QStringList er = remote->uidList(); 2334 QStringList er = remote->uidList();
2729 Addressee inR ;//= er.first(); 2335 Addressee inR ;//= er.first();
2730 Addressee inL; 2336 Addressee inL;
2731 QProgressBar bar( er.count(),0 ); 2337 QProgressBar bar( er.count(),0 );
2732 bar.setCaption (i18n("Syncing - close to abort!") ); 2338 bar.setCaption (i18n("Syncing - close to abort!") );
2733 2339
2734 int w = 300; 2340 int w = 300;
2735 if ( QApplication::desktop()->width() < 320 ) 2341 if ( QApplication::desktop()->width() < 320 )
2736 w = 220; 2342 w = 220;
2737 int h = bar.sizeHint().height() ; 2343 int h = bar.sizeHint().height() ;
2738 int dw = QApplication::desktop()->width(); 2344 int dw = QApplication::desktop()->width();
2739 int dh = QApplication::desktop()->height(); 2345 int dh = QApplication::desktop()->height();
2740 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2346 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2741 bar.show(); 2347 bar.show();
2742 int modulo = (er.count()/10)+1; 2348 int modulo = (er.count()/10)+1;
2743 int incCounter = 0; 2349 int incCounter = 0;
2744 while ( incCounter < er.count()) { 2350 while ( incCounter < er.count()) {
2745 if ( ! bar.isVisible() ) 2351 if ( ! bar.isVisible() )
2746 return false; 2352 return false;
2747 if ( incCounter % modulo == 0 ) 2353 if ( incCounter % modulo == 0 )
2748 bar.setProgress( incCounter ); 2354 bar.setProgress( incCounter );
2749 uid = er[ incCounter ]; 2355 uid = er[ incCounter ];
2750 bool skipIncidence = false; 2356 bool skipIncidence = false;
2751 if ( uid.left(19) == QString("last-syncAddressee-") ) 2357 if ( uid.left(19) == QString("last-syncAddressee-") )
2752 skipIncidence = true; 2358 skipIncidence = true;
2753 QString idS,OidS; 2359 QString idS,OidS;
2754 qApp->processEvents(); 2360 qApp->processEvents();
2755 if ( !skipIncidence ) { 2361 if ( !skipIncidence ) {
2756 inL = local->findByUid( uid ); 2362 inL = local->findByUid( uid );
2757 inR = remote->findByUid( uid ); 2363 inR = remote->findByUid( uid );
2758 //inL.setResource( 0 ); 2364 //inL.setResource( 0 );
2759 //inR.setResource( 0 ); 2365 //inR.setResource( 0 );
2760 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2366 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2761 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { 2367 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
2762 //qDebug("take %d %s ", take, inL.summary().latin1()); 2368 //qDebug("take %d %s ", take, inL.summary().latin1());
2763 if ( take == 3 ) 2369 if ( take == 3 )
2764 return false; 2370 return false;
2765 if ( take == 1 ) {// take local 2371 if ( take == 1 ) {// take local
2766 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2372 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2767 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2373 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2768 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2374 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2769 local->insertAddressee( inL, false ); 2375 local->insertAddressee( inL, false );
2770 idS = inR.externalUID(); 2376 idS = inR.externalUID();
2771 OidS = inR.originalExternalUID(); 2377 OidS = inR.originalExternalUID();
2772 } 2378 }
2773 else 2379 else
2774 idS = inR.IDStr(); 2380 idS = inR.IDStr();
2775 remote->removeAddressee( inR ); 2381 remote->removeAddressee( inR );
2776 inR = inL; 2382 inR = inL;
2777 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2383 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2778 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2384 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2779 inR.setOriginalExternalUID( OidS ); 2385 inR.setOriginalExternalUID( OidS );
2780 inR.setExternalUID( idS ); 2386 inR.setExternalUID( idS );
2781 } else { 2387 } else {
2782 inR.setIDStr( idS ); 2388 inR.setIDStr( idS );
2783 } 2389 }
2784 inR.setResource( 0 ); 2390 inR.setResource( 0 );
2785 remote->insertAddressee( inR , false); 2391 remote->insertAddressee( inR , false);
2786 ++changedRemote; 2392 ++changedRemote;
2787 } else { // take == 2 take remote 2393 } else { // take == 2 take remote
2788 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2394 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2789 if ( inR.revision().date().year() < 2004 ) 2395 if ( inR.revision().date().year() < 2004 )
2790 inR.setRevision( modifiedCalendar ); 2396 inR.setRevision( modifiedCalendar );
2791 } 2397 }
2792 idS = inL.IDStr(); 2398 idS = inL.IDStr();
2793 local->removeAddressee( inL ); 2399 local->removeAddressee( inL );
2794 inL = inR; 2400 inL = inR;
2795 inL.setIDStr( idS ); 2401 inL.setIDStr( idS );
2796 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2402 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2797 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2403 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2798 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2404 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2799 } 2405 }
2800 inL.setResource( 0 ); 2406 inL.setResource( 0 );
2801 local->insertAddressee( inL , false ); 2407 local->insertAddressee( inL , false );
2802 ++changedLocal; 2408 ++changedLocal;
2803 } 2409 }
2804 } 2410 }
2805 } else { // no conflict 2411 } else { // no conflict
2806 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2412 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2807 QString des = addresseeLSync.note(); 2413 QString des = addresseeLSync.note();
2808 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2414 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2809 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2415 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2810 remote->insertAddressee( inR, false ); 2416 remote->insertAddressee( inR, false );
2811 ++deletedAddresseeR; 2417 ++deletedAddresseeR;
2812 } else { 2418 } else {
2813 inR.setRevision( modifiedCalendar ); 2419 inR.setRevision( modifiedCalendar );
2814 remote->insertAddressee( inR, false ); 2420 remote->insertAddressee( inR, false );
2815 inL = inR; 2421 inL = inR;
2816 inL.setResource( 0 ); 2422 inL.setResource( 0 );
2817 local->insertAddressee( inL , false); 2423 local->insertAddressee( inL , false);
2818 ++addedAddressee; 2424 ++addedAddressee;
2819 } 2425 }
2820 } else { 2426 } else {
2821 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2427 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2822 inR.setRevision( modifiedCalendar ); 2428 inR.setRevision( modifiedCalendar );
2823 remote->insertAddressee( inR, false ); 2429 remote->insertAddressee( inR, false );
2824 inR.setResource( 0 ); 2430 inR.setResource( 0 );
2825 local->insertAddressee( inR, false ); 2431 local->insertAddressee( inR, false );
2826 ++addedAddressee; 2432 ++addedAddressee;
2827 } else { 2433 } else {
2828 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2434 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2829 remote->removeAddressee( inR ); 2435 remote->removeAddressee( inR );
2830 ++deletedAddresseeR; 2436 ++deletedAddresseeR;
2831 } 2437 }
2832 } 2438 }
2833 } 2439 }
2834 } 2440 }
2835 ++incCounter; 2441 ++incCounter;
2836 } 2442 }
2837 er.clear(); 2443 er.clear();
2838 QStringList el = local->uidList(); 2444 QStringList el = local->uidList();
2839 modulo = (el.count()/10)+1; 2445 modulo = (el.count()/10)+1;
2840 bar.setCaption (i18n("Add / remove addressees") ); 2446 bar.setCaption (i18n("Add / remove addressees") );
2841 bar.setTotalSteps ( el.count() ) ; 2447 bar.setTotalSteps ( el.count() ) ;
2842 bar.show(); 2448 bar.show();
2843 incCounter = 0; 2449 incCounter = 0;
2844 while ( incCounter < el.count()) { 2450 while ( incCounter < el.count()) {
2845 qApp->processEvents(); 2451 qApp->processEvents();
2846 if ( ! bar.isVisible() ) 2452 if ( ! bar.isVisible() )
2847 return false; 2453 return false;
2848 if ( incCounter % modulo == 0 ) 2454 if ( incCounter % modulo == 0 )
2849 bar.setProgress( incCounter ); 2455 bar.setProgress( incCounter );
2850 uid = el[ incCounter ]; 2456 uid = el[ incCounter ];
2851 bool skipIncidence = false; 2457 bool skipIncidence = false;
2852 if ( uid.left(19) == QString("last-syncAddressee-") ) 2458 if ( uid.left(19) == QString("last-syncAddressee-") )
2853 skipIncidence = true; 2459 skipIncidence = true;
2854 if ( !skipIncidence ) { 2460 if ( !skipIncidence ) {
2855 inL = local->findByUid( uid ); 2461 inL = local->findByUid( uid );
2856 inR = remote->findByUid( uid ); 2462 inR = remote->findByUid( uid );
2857 if ( inR.isEmpty() ) { 2463 if ( inR.isEmpty() ) {
2858 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2464 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2859 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2465 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2860 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2466 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2861 local->removeAddressee( inL ); 2467 local->removeAddressee( inL );
2862 ++deletedAddresseeL; 2468 ++deletedAddresseeL;
2863 } else { 2469 } else {
2864 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { 2470 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) {
2865 inL.removeID(mCurrentSyncDevice ); 2471 inL.removeID(mCurrentSyncDevice );
2866 ++addedAddresseeR; 2472 ++addedAddresseeR;
2867 inL.setRevision( modifiedCalendar ); 2473 inL.setRevision( modifiedCalendar );
2868 local->insertAddressee( inL, false ); 2474 local->insertAddressee( inL, false );
2869 inR = inL; 2475 inR = inL;
2870 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2476 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2871 inR.setResource( 0 ); 2477 inR.setResource( 0 );
2872 remote->insertAddressee( inR, false ); 2478 remote->insertAddressee( inR, false );
2873 } 2479 }
2874 } 2480 }
2875 } else { 2481 } else {
2876 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2482 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2877 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2483 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2878 local->removeAddressee( inL ); 2484 local->removeAddressee( inL );
2879 ++deletedAddresseeL; 2485 ++deletedAddresseeL;
2880 } else { 2486 } else {
2881 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { 2487 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) {
2882 ++addedAddresseeR; 2488 ++addedAddresseeR;
2883 inL.setRevision( modifiedCalendar ); 2489 inL.setRevision( modifiedCalendar );
2884 local->insertAddressee( inL, false ); 2490 local->insertAddressee( inL, false );
2885 inR = inL; 2491 inR = inL;
2886 inR.setResource( 0 ); 2492 inR.setResource( 0 );
2887 remote->insertAddressee( inR, false ); 2493 remote->insertAddressee( inR, false );
2888 } 2494 }
2889 } 2495 }
2890 } 2496 }
2891 } 2497 }
2892 } 2498 }
2893 ++incCounter; 2499 ++incCounter;
2894 } 2500 }
2895 el.clear(); 2501 el.clear();
2896 bar.hide(); 2502 bar.hide();
2897 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2503 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2898 // get rid of micro seconds 2504 // get rid of micro seconds
2899 QTime t = mLastAddressbookSync.time(); 2505 QTime t = mLastAddressbookSync.time();
2900 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2506 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2901 addresseeLSync.setRevision( mLastAddressbookSync ); 2507 addresseeLSync.setRevision( mLastAddressbookSync );
2902 addresseeRSync.setRevision( mLastAddressbookSync ); 2508 addresseeRSync.setRevision( mLastAddressbookSync );
2903 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2509 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2904 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2510 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2905 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2511 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2906 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2512 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2907 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2513 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2908 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2514 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2909 addresseeRSync.setNote( "" ) ; 2515 addresseeRSync.setNote( "" ) ;
2910 addresseeLSync.setNote( "" ); 2516 addresseeLSync.setNote( "" );
2911 2517
2912 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2518 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2913 remote->insertAddressee( addresseeRSync, false ); 2519 remote->insertAddressee( addresseeRSync, false );
2914 local->insertAddressee( addresseeLSync, false ); 2520 local->insertAddressee( addresseeLSync, false );
2915 QString mes; 2521 QString mes;
2916 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2522 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2917 if ( KABPrefs::instance()->mShowSyncSummary ) { 2523 if ( KABPrefs::instance()->mShowSyncSummary ) {
2918 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2524 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2919 } 2525 }
2920 qDebug( mes ); 2526 qDebug( mes );
2921 return syncOK; 2527 return syncOK;
2922} 2528}
2923 2529
2924bool KABCore::syncAB(QString filename, int mode) 2530
2531//this is a overwritten callbackmethods from the syncinterface
2532bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2925{ 2533{
2926 2534
2927 //pending prepare addresseeview for output 2535 //pending prepare addresseeview for output
2928 //pending detect, if remote file has REV field. if not switch to external sync 2536 //pending detect, if remote file has REV field. if not switch to external sync
2929 mGlobalSyncMode = SYNC_MODE_NORMAL; 2537 mGlobalSyncMode = SYNC_MODE_NORMAL;
2538 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2539
2930 AddressBook abLocal(filename,"syncContact"); 2540 AddressBook abLocal(filename,"syncContact");
2931 bool syncOK = false; 2541 bool syncOK = false;
2932 if ( abLocal.load() ) { 2542 if ( abLocal.load() ) {
2933 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2543 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2934 bool external = false; 2544 bool external = false;
2935 bool isXML = false; 2545 bool isXML = false;
2936 if ( filename.right(4) == ".xml") { 2546 if ( filename.right(4) == ".xml") {
2937 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2547 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2938 isXML = true; 2548 isXML = true;
2939 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2549 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2940 } else { 2550 } else {
2941 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2551 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2942 if ( ! lse.isEmpty() ) { 2552 if ( ! lse.isEmpty() ) {
2943 if ( lse.familyName().left(4) == "!E: " ) 2553 if ( lse.familyName().left(4) == "!E: " )
2944 external = true; 2554 external = true;
2945 } else { 2555 } else {
2946 bool found = false; 2556 bool found = false;
2947 AddressBook::Iterator it; 2557 AddressBook::Iterator it;
2948 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2558 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2949 if ( (*it).revision().date().year() > 2003 ) { 2559 if ( (*it).revision().date().year() > 2003 ) {
2950 found = true; 2560 found = true;
2951 break; 2561 break;
2952 } 2562 }
2953 } 2563 }
2954 external = ! found; 2564 external = ! found;
2955 } 2565 }
2956 2566
2957 if ( external ) { 2567 if ( external ) {
2958 qDebug("Setting vcf mode to external "); 2568 qDebug("Setting vcf mode to external ");
2959 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2569 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2960 AddressBook::Iterator it; 2570 AddressBook::Iterator it;
2961 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2571 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2962 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2572 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2963 (*it).computeCsum( mCurrentSyncDevice ); 2573 (*it).computeCsum( mCurrentSyncDevice );
2964 } 2574 }
2965 } 2575 }
2966 } 2576 }
2967 //AddressBook::Iterator it; 2577 //AddressBook::Iterator it;
2968 //QStringList vcards; 2578 //QStringList vcards;
2969 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2579 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2970 // qDebug("Name %s ", (*it).familyName().latin1()); 2580 // qDebug("Name %s ", (*it).familyName().latin1());
2971 //} 2581 //}
2972 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2582 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2973 if ( syncOK ) { 2583 if ( syncOK ) {
2974 if ( KABPrefs::instance()->mWriteBackFile ) 2584 if ( KABPrefs::instance()->mWriteBackFile )
2975 { 2585 {
2976 if ( external ) 2586 if ( external )
2977 abLocal.removeSyncAddressees( !isXML); 2587 abLocal.removeSyncAddressees( !isXML);
2978 qDebug("Saving remote AB "); 2588 qDebug("Saving remote AB ");
2979 abLocal.saveAB(); 2589 abLocal.saveAB();
2980 if ( isXML ) { 2590 if ( isXML ) {
2981 // afterwrite processing 2591 // afterwrite processing
2982 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2592 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2983 } 2593 }
2984 } 2594 }
2985 } 2595 }
2986 setModified(); 2596 setModified();
2987 2597
2988 } 2598 }
2989 if ( syncOK ) 2599 if ( syncOK )
2990 mViewManager->refreshView(); 2600 mViewManager->refreshView();
2991 return syncOK; 2601 return syncOK;
2992#if 0 2602#if 0
2993 2603
2994 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 2604 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
2995 getEventViewerDialog()->setSyncMode( true ); 2605 getEventViewerDialog()->setSyncMode( true );
2996 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 2606 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
2997 getEventViewerDialog()->setSyncMode( false ); 2607 getEventViewerDialog()->setSyncMode( false );
2998 if ( syncOK ) { 2608 if ( syncOK ) {
2999 if ( KOPrefs::instance()->mWriteBackFile ) 2609 if ( KOPrefs::instance()->mWriteBackFile )
3000 { 2610 {
3001 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2611 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
3002 storage->save(); 2612 storage->save();
3003 } 2613 }
3004 } 2614 }
3005 setModified(); 2615 setModified();
3006 } 2616 }
3007 2617
3008#endif 2618#endif
3009} 2619}
3010 2620
3011void KABCore::confSync() 2621
3012{ 2622//this is a overwritten callbackmethods from the syncinterface
3013 static KSyncPrefsDialog* sp = 0; 2623bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3014 if ( ! sp ) {
3015 sp = new KSyncPrefsDialog( this, "syncprefs", true );
3016 }
3017 sp->usrReadConfig();
3018#ifndef DESKTOP_VERSION
3019 sp->showMaximized();
3020#else
3021 sp->show();
3022#endif
3023 sp->exec();
3024 KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
3025 KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
3026 fillSyncMenu();
3027}
3028void KABCore::syncSharp()
3029{
3030 if ( ! syncExternal("sharp") )
3031 qDebug("ERROR sync sharp ");;
3032}
3033bool KABCore::syncExternal(QString resource)
3034{ 2624{
3035 if ( mModified ) 2625 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3036 save(); 2626
3037 if ( KABPrefs::instance()->mAskForPreferences )
3038 edit_sync_options();
3039 qDebug("syncSharp() ");
3040 AddressBook abLocal( resource,"syncContact"); 2627 AddressBook abLocal( resource,"syncContact");
3041 bool syncOK = false; 2628 bool syncOK = false;
3042 if ( abLocal.load() ) { 2629 if ( abLocal.load() ) {
3043 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2630 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3044 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2631 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3045 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2632 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2633 qDebug("KABCore::syncExternal: why do we acces here KABPrefs and not somehow KSyncProfile? ");
3046 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, KABPrefs::instance()->mSyncAlgoPrefs ); 2634 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, KABPrefs::instance()->mSyncAlgoPrefs );
3047 if ( syncOK ) { 2635 if ( syncOK ) {
3048 if ( KABPrefs::instance()->mWriteBackFile ) { 2636 if ( KABPrefs::instance()->mWriteBackFile ) {
3049 abLocal.saveAB(); 2637 abLocal.saveAB();
3050 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2638 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
3051 } 2639 }
3052 } 2640 }
3053 setModified(); 2641 setModified();
3054 } 2642 }
3055 if ( syncOK ) 2643 if ( syncOK )
3056 mViewManager->refreshView(); 2644 mViewManager->refreshView();
3057 return syncOK; 2645 return syncOK;
3058 2646
3059} 2647}
3060void KABCore::syncPhone() 2648
2649//called by the syncmanager to indicate that the work has to marked as dirty.
2650void KABCore::sync_setModified()
3061{ 2651{
3062 if ( mModified ) 2652 setModified();
3063 save(); 2653}
3064 qDebug("pending syncPhone(); ");
3065 //mView->syncPhone();
3066 setModified();
3067 2654
2655//called by the syncmanager to ask if the dirty flag is set.
2656bool KABCore::sync_isModified()
2657{
2658 return mModified;
3068} 2659}
2660
2661
2662//called by the syncmanager to indicate that the work has to be saved.
2663void KABCore::sync_save()
2664{
2665 save();
2666}
2667
2668
2669
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index e89bf41..ef61d6d 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -1,485 +1,481 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KABCORE_H 24#ifndef KABCORE_H
25#define KABCORE_H 25#define KABCORE_H
26 26
27#include <kabc/field.h> 27#include <kabc/field.h>
28 28
29#ifndef KAB_EMBEDDED 29#ifndef KAB_EMBEDDED
30#endif //KAB_EMBEDDED 30#endif //KAB_EMBEDDED
31#include <qdict.h> 31#include <qdict.h>
32 32
33#include <qwidget.h> 33#include <qwidget.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <ksyncmanager.h>
35 36
36namespace KABC { 37namespace KABC {
37class AddressBook; 38class AddressBook;
38} 39}
39 40
40#ifndef KAB_EMBEDDED 41#ifndef KAB_EMBEDDED
41class KAboutData; 42class KAboutData;
42class KConfig; 43class KConfig;
43 44
44class KAddressBookService; 45class KAddressBookService;
45class LDAPSearchDialog; 46class LDAPSearchDialog;
46#else //KAB_EMBEDDED 47#else //KAB_EMBEDDED
47class KAddressBookMain; 48class KAddressBookMain;
48//US class QAction; 49//US class QAction;
49#endif //KAB_EMBEDDED 50#endif //KAB_EMBEDDED
50class KCMultiDialog; 51class KCMultiDialog;
51class KXMLGUIClient; 52class KXMLGUIClient;
52class ExtensionManager; 53class ExtensionManager;
53class XXPortManager; 54class XXPortManager;
54class JumpButtonBar; 55class JumpButtonBar;
55class IncSearchWidget; 56class IncSearchWidget;
56class KDGanttMinimizeSplitter; 57class KDGanttMinimizeSplitter;
57class KAction; 58class KAction;
58class KActionCollection; 59class KActionCollection;
59class KToggleAction; 60class KToggleAction;
60class KSyncProfile; 61class KSyncProfile;
61 62
62class QAction; 63class QAction;
63class QMenuBar; 64class QMenuBar;
64class QSplitter; 65class QSplitter;
65class ViewContainer; 66class ViewContainer;
66class ViewManager; 67class ViewManager;
67class AddresseeEditorDialog; 68class AddresseeEditorDialog;
68class Ir; 69class Ir;
69 70
70class KABCore : public QWidget 71class KABCore : public QWidget, public KSyncInterface
71{ 72{
72 Q_OBJECT 73 Q_OBJECT
73 74
74 public: 75 public:
75 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); 76 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 );
76 77
77 78
78 ~KABCore(); 79 ~KABCore();
79 80
80 81
81#ifdef KAB_EMBEDDED 82#ifdef KAB_EMBEDDED
82 //US added functionality 83 //US added functionality
83 QPopupMenu* getViewMenu() {return viewMenu;} 84 QPopupMenu* getViewMenu() {return viewMenu;}
84 QPopupMenu* getFilterMenu() {return filterMenu;} 85 QPopupMenu* getFilterMenu() {return filterMenu;}
85 QPopupMenu* getSettingsMenu() {return settingsMenu;} 86 QPopupMenu* getSettingsMenu() {return settingsMenu;}
86 void addActionsManually(); 87 void addActionsManually();
87#endif //KAB_EMBEDDED 88#endif //KAB_EMBEDDED
88 /** 89 /**
89 Restores the global settings. 90 Restores the global settings.
90 */ 91 */
91 void restoreSettings(); 92 void restoreSettings();
92 93
93 /** 94 /**
94 Saves the global settings. 95 Saves the global settings.
95 */ 96 */
96 void saveSettings(); 97 void saveSettings();
97 98
98 /** 99 /**
99 Returns a pointer to the StdAddressBook of the application. 100 Returns a pointer to the StdAddressBook of the application.
100 */ 101 */
101 KABC::AddressBook *addressBook() const; 102 KABC::AddressBook *addressBook() const;
102 103
103 /** 104 /**
104 Returns a pointer to the KConfig object of the application. 105 Returns a pointer to the KConfig object of the application.
105 */ 106 */
106 static KConfig *config(); 107 static KConfig *config();
107 108
108 /** 109 /**
109 Returns a pointer to the global KActionCollection object. So 110 Returns a pointer to the global KActionCollection object. So
110 other classes can register their actions easily. 111 other classes can register their actions easily.
111 */ 112 */
112 KActionCollection *actionCollection() const; 113 KActionCollection *actionCollection() const;
113 114
114 /** 115 /**
115 Returns the current search field of the Incremental Search Widget. 116 Returns the current search field of the Incremental Search Widget.
116 */ 117 */
117 KABC::Field *currentSearchField() const; 118 KABC::Field *currentSearchField() const;
118 119
119 /** 120 /**
120 Returns the uid list of the currently selected contacts. 121 Returns the uid list of the currently selected contacts.
121 */ 122 */
122 QStringList selectedUIDs() const; 123 QStringList selectedUIDs() const;
123 124
124 /** 125 /**
125 Displays the ResourceSelectDialog and returns the selected 126 Displays the ResourceSelectDialog and returns the selected
126 resource or a null pointer if no resource was selected by 127 resource or a null pointer if no resource was selected by
127 the user. 128 the user.
128 */ 129 */
129 KABC::Resource *requestResource( QWidget *parent ); 130 KABC::Resource *requestResource( QWidget *parent );
130 131
131#ifndef KAB_EMBEDDED 132#ifndef KAB_EMBEDDED
132 static KAboutData *createAboutData(); 133 static KAboutData *createAboutData();
133#endif //KAB_EMBEDDED 134#endif //KAB_EMBEDDED
134 135
135#ifdef KAB_EMBEDDED 136#ifdef KAB_EMBEDDED
136 inline QPopupMenu* getImportMenu() { return ImportMenu;} 137 inline QPopupMenu* getImportMenu() { return ImportMenu;}
137 inline QPopupMenu* getExportMenu() { return ExportMenu;} 138 inline QPopupMenu* getExportMenu() { return ExportMenu;}
138#endif //KAB_EMBEDDED 139#endif //KAB_EMBEDDED
139 140
140 public slots: 141 public slots:
141#ifdef KAB_EMBEDDED 142#ifdef KAB_EMBEDDED
142 void createAboutData(); 143 void createAboutData();
143#endif //KAB_EMBEDDED 144#endif //KAB_EMBEDDED
144 145
145 void statusMessage(QString, int time = 0 ); 146 void statusMessage(QString, int time = 0 );
146 void showLicence(); 147 void showLicence();
147 void faq(); 148 void faq();
148 149
149 /** 150 /**
150 Is called whenever a contact is selected in the view. 151 Is called whenever a contact is selected in the view.
151 */ 152 */
152 void setContactSelected( const QString &uid ); 153 void setContactSelected( const QString &uid );
153 154
154 /** 155 /**
155 Opens the preferred mail composer with all selected contacts as 156 Opens the preferred mail composer with all selected contacts as
156 arguments. 157 arguments.
157 */ 158 */
158 void sendMail(); 159 void sendMail();
159 160
160 /** 161 /**
161 Opens the preferred mail composer with the given contacts as 162 Opens the preferred mail composer with the given contacts as
162 arguments. 163 arguments.
163 */ 164 */
164 void sendMail( const QString& email ); 165 void sendMail( const QString& email );
165 166
166 167
167 void mailVCard(); 168 void mailVCard();
168 void mailVCard(const QStringList& uids); 169 void mailVCard(const QStringList& uids);
169 170
170 /** 171 /**
171 Beams the "WhoAmI contact. 172 Beams the "WhoAmI contact.
172 */ 173 */
173 void beamMySelf(); 174 void beamMySelf();
174 175
175 void beamVCard(); 176 void beamVCard();
176 void beamVCard(const QStringList& uids); 177 void beamVCard(const QStringList& uids);
177 void beamDone( Ir *ir ); 178 void beamDone( Ir *ir );
178 179
179 180
180 /** 181 /**
181 Starts the preferred web browser with the given URL as argument. 182 Starts the preferred web browser with the given URL as argument.
182 */ 183 */
183 void browse( const QString& url ); 184 void browse( const QString& url );
184 185
185 /** 186 /**
186 Select all contacts in the view. 187 Select all contacts in the view.
187 */ 188 */
188 void selectAllContacts(); 189 void selectAllContacts();
189 190
190 /** 191 /**
191 Deletes all selected contacts from the address book. 192 Deletes all selected contacts from the address book.
192 */ 193 */
193 void deleteContacts(); 194 void deleteContacts();
194 195
195 /** 196 /**
196 Deletes given contacts from the address book. 197 Deletes given contacts from the address book.
197 198
198 @param uids The uids of the contacts, which shall be deleted. 199 @param uids The uids of the contacts, which shall be deleted.
199 */ 200 */
200 void deleteContacts( const QStringList &uids ); 201 void deleteContacts( const QStringList &uids );
201 202
202 /** 203 /**
203 Copys the selected contacts into clipboard for later pasting. 204 Copys the selected contacts into clipboard for later pasting.
204 */ 205 */
205 void copyContacts(); 206 void copyContacts();
206 207
207 /** 208 /**
208 Cuts the selected contacts and stores them for later pasting. 209 Cuts the selected contacts and stores them for later pasting.
209 */ 210 */
210 void cutContacts(); 211 void cutContacts();
211 212
212 /** 213 /**
213 Paste contacts from clipboard into the address book. 214 Paste contacts from clipboard into the address book.
214 */ 215 */
215 void pasteContacts(); 216 void pasteContacts();
216 217
217 /** 218 /**
218 Paste given contacts into the address book. 219 Paste given contacts into the address book.
219 220
220 @param list The list of addressee, which shall be pasted. 221 @param list The list of addressee, which shall be pasted.
221 */ 222 */
222 void pasteContacts( KABC::Addressee::List &list ); 223 void pasteContacts( KABC::Addressee::List &list );
223 224
224 /** 225 /**
225 Sets the whoAmI contact, that is used by many other programs to 226 Sets the whoAmI contact, that is used by many other programs to
226 get personal information about the current user. 227 get personal information about the current user.
227 */ 228 */
228 void setWhoAmI(); 229 void setWhoAmI();
229 230
230 /** 231 /**
231 Displays the category dialog and applies the result to all 232 Displays the category dialog and applies the result to all
232 selected contacts. 233 selected contacts.
233 */ 234 */
234 void setCategories(); 235 void setCategories();
235 236
236 /** 237 /**
237 Sets the field list of the Incremental Search Widget. 238 Sets the field list of the Incremental Search Widget.
238 */ 239 */
239 void setSearchFields( const KABC::Field::List &fields ); 240 void setSearchFields( const KABC::Field::List &fields );
240 241
241 /** 242 /**
242 Search with the current search field for a contact, that matches 243 Search with the current search field for a contact, that matches
243 the given text, and selects it in the view. 244 the given text, and selects it in the view.
244 */ 245 */
245 void incrementalSearch( const QString& text ); 246 void incrementalSearch( const QString& text );
246 247
247 /** 248 /**
248 Marks the address book as modified. 249 Marks the address book as modified.
249 */ 250 */
250 void setModified(); 251 void setModified();
251 /** 252 /**
252 Marks the address book as modified without refreshing the view. 253 Marks the address book as modified without refreshing the view.
253 */ 254 */
254 void setModifiedWOrefresh(); 255 void setModifiedWOrefresh();
255 256
256 /** 257 /**
257 Marks the address book as modified concerning the argument. 258 Marks the address book as modified concerning the argument.
258 */ 259 */
259 void setModified( bool modified ); 260 void setModified( bool modified );
260 261
261 /** 262 /**
262 Returns whether the address book is modified. 263 Returns whether the address book is modified.
263 */ 264 */
264 bool modified() const; 265 bool modified() const;
265 266
266 /** 267 /**
267 Called whenever an contact is modified in the contact editor 268 Called whenever an contact is modified in the contact editor
268 dialog or the quick edit. 269 dialog or the quick edit.
269 */ 270 */
270 void contactModified( const KABC::Addressee &addr ); 271 void contactModified( const KABC::Addressee &addr );
271 272
272 /** 273 /**
273 DCOP METHODS. 274 DCOP METHODS.
274 */ 275 */
275 void addEmail( QString addr ); 276 void addEmail( QString addr );
276 void importVCard( const KURL& url, bool showPreview ); 277 void importVCard( const KURL& url, bool showPreview );
277 void importVCard( const QString& vCard, bool showPreview ); 278 void importVCard( const QString& vCard, bool showPreview );
278 void newContact(); 279 void newContact();
279 QString getNameByPhone( const QString& phone ); 280 QString getNameByPhone( const QString& phone );
280 /** 281 /**
281 END DCOP METHODS 282 END DCOP METHODS
282 */ 283 */
283 284
284 /** 285 /**
285 Saves the contents of the AddressBook back to disk. 286 Saves the contents of the AddressBook back to disk.
286 */ 287 */
287 void save(); 288 void save();
288 289
289 /** 290 /**
290 Undos the last command using the undo stack. 291 Undos the last command using the undo stack.
291 */ 292 */
292 void undo(); 293 void undo();
293 294
294 /** 295 /**
295 Redos the last command that was undone, using the redo stack. 296 Redos the last command that was undone, using the redo stack.
296 */ 297 */
297 void redo(); 298 void redo();
298 299
299 /** 300 /**
300 Shows the edit dialog for the given uid. If the uid is QString::null, 301 Shows the edit dialog for the given uid. If the uid is QString::null,
301 the method will try to find a selected addressee in the view. 302 the method will try to find a selected addressee in the view.
302 */ 303 */
303 void editContact( const QString &uid /*US = QString::null*/ ); 304 void editContact( const QString &uid /*US = QString::null*/ );
304//US added a second method without defaultparameter 305//US added a second method without defaultparameter
305 void editContact2(); 306 void editContact2();
306 307
307 /** 308 /**
308 Shows or edits the detail view for the given uid. If the uid is QString::null, 309 Shows or edits the detail view for the given uid. If the uid is QString::null,
309 the method will try to find a selected addressee in the view. 310 the method will try to find a selected addressee in the view.
310 */ 311 */
311 void executeContact( const QString &uid /*US = QString::null*/ ); 312 void executeContact( const QString &uid /*US = QString::null*/ );
312 313
313 /** 314 /**
314 Launches the configuration dialog. 315 Launches the configuration dialog.
315 */ 316 */
316 void openConfigDialog(); 317 void openConfigDialog();
317 318
318 /** 319 /**
319 Launches the ldap search dialog. 320 Launches the ldap search dialog.
320 */ 321 */
321 void openLDAPDialog(); 322 void openLDAPDialog();
322 323
323 /** 324 /**
324 Creates a KAddressBookPrinter, which will display the print 325 Creates a KAddressBookPrinter, which will display the print
325 dialog and do the printing. 326 dialog and do the printing.
326 */ 327 */
327 void print(); 328 void print();
328 329
329 /** 330 /**
330 Registers a new GUI client, so plugins can register its actions. 331 Registers a new GUI client, so plugins can register its actions.
331 */ 332 */
332 void addGUIClient( KXMLGUIClient *client ); 333 void addGUIClient( KXMLGUIClient *client );
333 334
334 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); 335 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
335 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 336 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
336 337
337 338
338 signals: 339 signals:
339 void contactSelected( const QString &name ); 340 void contactSelected( const QString &name );
340 void contactSelected( const QPixmap &pixmap ); 341 void contactSelected( const QPixmap &pixmap );
341 public slots: 342 public slots:
342 void setDetailsVisible( bool visible ); 343 void setDetailsVisible( bool visible );
343 void setDetailsToState(); 344 void setDetailsToState();
344 void slotSyncMenu( int ); 345 // void slotSyncMenu( int );
345 private slots: 346 private slots:
346 void setJumpButtonBarVisible( bool visible ); 347 void setJumpButtonBarVisible( bool visible );
347 void importFromOL(); 348 void importFromOL();
348 void extensionModified( const KABC::Addressee::List &list ); 349 void extensionModified( const KABC::Addressee::List &list );
349 void extensionChanged( int id ); 350 void extensionChanged( int id );
350 void clipboardDataChanged(); 351 void clipboardDataChanged();
351 void updateActionMenu(); 352 void updateActionMenu();
352 void configureKeyBindings(); 353 void configureKeyBindings();
353 void removeVoice(); 354 void removeVoice();
354#ifdef KAB_EMBEDDED 355#ifdef KAB_EMBEDDED
355 void configureResources(); 356 void configureResources();
356#endif //KAB_EMBEDDED 357#endif //KAB_EMBEDDED
357 358
358 void slotEditorDestroyed( const QString &uid ); 359 void slotEditorDestroyed( const QString &uid );
359 void configurationChanged(); 360 void configurationChanged();
360 void addressBookChanged(); 361 void addressBookChanged();
361 362
362 private: 363 private:
363 void initGUI(); 364 void initGUI();
364 void initActions(); 365 void initActions();
365 366
366 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 367 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
367 const char *name = 0 ); 368 const char *name = 0 );
368 369
369 KXMLGUIClient *mGUIClient; 370 KXMLGUIClient *mGUIClient;
370 371
371 KABC::AddressBook *mAddressBook; 372 KABC::AddressBook *mAddressBook;
372 373
373 ViewManager *mViewManager; 374 ViewManager *mViewManager;
374 // QSplitter *mDetailsSplitter; 375 // QSplitter *mDetailsSplitter;
375 KDGanttMinimizeSplitter *mExtensionBarSplitter; 376 KDGanttMinimizeSplitter *mExtensionBarSplitter;
376 ViewContainer *mDetails; 377 ViewContainer *mDetails;
377 KDGanttMinimizeSplitter* mMiniSplitter; 378 KDGanttMinimizeSplitter* mMiniSplitter;
378 XXPortManager *mXXPortManager; 379 XXPortManager *mXXPortManager;
379 JumpButtonBar *mJumpButtonBar; 380 JumpButtonBar *mJumpButtonBar;
380 IncSearchWidget *mIncSearchWidget; 381 IncSearchWidget *mIncSearchWidget;
381 ExtensionManager *mExtensionManager; 382 ExtensionManager *mExtensionManager;
382 383
383 KCMultiDialog *mConfigureDialog; 384 KCMultiDialog *mConfigureDialog;
384 385
385#ifndef KAB_EMBEDDED 386#ifndef KAB_EMBEDDED
386 LDAPSearchDialog *mLdapSearchDialog; 387 LDAPSearchDialog *mLdapSearchDialog;
387#endif //KAB_EMBEDDED 388#endif //KAB_EMBEDDED
388 // QDict<AddresseeEditorDialog> mEditorDict; 389 // QDict<AddresseeEditorDialog> mEditorDict;
389 AddresseeEditorDialog *mEditorDialog; 390 AddresseeEditorDialog *mEditorDialog;
390 bool mReadWrite; 391 bool mReadWrite;
391 bool mModified; 392 bool mModified;
392 bool mIsPart; 393 bool mIsPart;
393 bool mMultipleViewsAtOnce; 394 bool mMultipleViewsAtOnce;
394 395
395 396
396 //US file menu 397 //US file menu
397 KAction *mActionMail; 398 KAction *mActionMail;
398 KAction *mActionBeam; 399 KAction *mActionBeam;
399 KAction* mActionPrint; 400 KAction* mActionPrint;
400 KAction* mActionNewContact; 401 KAction* mActionNewContact;
401 KAction *mActionSave; 402 KAction *mActionSave;
402 KAction *mActionEditAddressee; 403 KAction *mActionEditAddressee;
403 KAction *mActionMailVCard; 404 KAction *mActionMailVCard;
404 KAction *mActionBeamVCard; 405 KAction *mActionBeamVCard;
405 406
406 KAction *mActionQuit; 407 KAction *mActionQuit;
407 408
408 //US edit menu 409 //US edit menu
409 KAction *mActionCopy; 410 KAction *mActionCopy;
410 KAction *mActionCut; 411 KAction *mActionCut;
411 KAction *mActionPaste; 412 KAction *mActionPaste;
412 KAction *mActionSelectAll; 413 KAction *mActionSelectAll;
413 KAction *mActionUndo; 414 KAction *mActionUndo;
414 KAction *mActionRedo; 415 KAction *mActionRedo;
415 KAction *mActionDelete; 416 KAction *mActionDelete;
416 417
417 //US settings menu 418 //US settings menu
418 KAction *mActionConfigResources; 419 KAction *mActionConfigResources;
419 KAction *mActionConfigKAddressbook; 420 KAction *mActionConfigKAddressbook;
420 KAction *mActionConfigShortcuts; 421 KAction *mActionConfigShortcuts;
421 KAction *mActionConfigureToolbars; 422 KAction *mActionConfigureToolbars;
422 KAction *mActionKeyBindings; 423 KAction *mActionKeyBindings;
423 KToggleAction *mActionJumpBar; 424 KToggleAction *mActionJumpBar;
424 KToggleAction *mActionDetails; 425 KToggleAction *mActionDetails;
425 KAction *mActionWhoAmI; 426 KAction *mActionWhoAmI;
426 KAction *mActionCategories; 427 KAction *mActionCategories;
427 KAction *mActionAboutKAddressbook; 428 KAction *mActionAboutKAddressbook;
428 KAction *mActionLicence; 429 KAction *mActionLicence;
429 KAction *mActionFaq; 430 KAction *mActionFaq;
430 431
431 KAction *mActionDeleteView; 432 KAction *mActionDeleteView;
432 433
433 QPopupMenu *viewMenu; 434 QPopupMenu *viewMenu;
434 QPopupMenu *filterMenu; 435 QPopupMenu *filterMenu;
435 QPopupMenu *settingsMenu; 436 QPopupMenu *settingsMenu;
436 QPopupMenu *changeMenu; 437 QPopupMenu *changeMenu;
437//US QAction *mActionSave; 438//US QAction *mActionSave;
438 QPopupMenu *ImportMenu; 439 QPopupMenu *ImportMenu;
439 QPopupMenu *ExportMenu; 440 QPopupMenu *ExportMenu;
440 //LR additional methods 441 //LR additional methods
441 KAction *mActionRemoveVoice; 442 KAction *mActionRemoveVoice;
442 KAction * mActionImportOL; 443 KAction * mActionImportOL;
443 444
444#ifndef KAB_EMBEDDED 445#ifndef KAB_EMBEDDED
445 KAddressBookService *mAddressBookService; 446 KAddressBookService *mAddressBookService;
446#endif //KAB_EMBEDDED 447#endif //KAB_EMBEDDED
447 448
448 class KABCorePrivate; 449 class KABCorePrivate;
449 KABCorePrivate *d; 450 KABCorePrivate *d;
450 bool mBlockSaveFlag; 451 //US bool mBlockSaveFlag;
451 452
452#ifdef KAB_EMBEDDED 453#ifdef KAB_EMBEDDED
453 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 454 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
454#endif //KAB_EMBEDDED 455#endif //KAB_EMBEDDED
456
457 //this are the overwritten callbackmethods from the syncinterface
458 virtual bool sync(KSyncManager* manager, QString filename, int mode);
459 virtual bool syncExternal(KSyncManager* manager, QString resource);
460
461 //called by the syncmanager to indicate that the work has to marked as dirty.
462 virtual void sync_setModified();
463 //called by the syncmanager to ask if the dirty flag is set.
464 virtual bool KABCore::sync_isModified();
465 //called by the syncmanager to indicate that the work has to be saved.
466 virtual void sync_save();
467
455 // LR ******************************* 468 // LR *******************************
456 // sync stuff! 469 // sync stuff!
457 QPopupMenu *syncMenu; 470 QPopupMenu *syncMenu;
458 void fillSyncMenu(); 471 KSyncManager* syncManager;
459 QString mCurrentSyncDevice;
460 QString mCurrentSyncName;
461 void quickSyncLocalFile();
462 bool syncWithFile( QString fn , bool quick );
463 void syncLocalFile();
464 void syncPhone();
465 void syncSharp();
466 bool syncExternal(QString);
467 void multiSync( bool askforPrefs );
468 int mCurrentSyncProfile ;
469 void syncRemote( KSyncProfile* prof, bool ask = true);
470 void edit_sync_options();
471 bool syncAB(QString filename, int mode);
472 int ringSync();
473 QString getPassword( );
474 int mGlobalSyncMode; 472 int mGlobalSyncMode;
475 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 473 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
476 KABC::Addressee getLastSyncAddressee(); 474 KABC::Addressee getLastSyncAddressee();
477 QDateTime mLastAddressbookSync; 475 QDateTime mLastAddressbookSync;
478 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); 476 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
479 public slots:
480 void confSync();
481 // ********************* 477 // *********************
482 478
483}; 479};
484 480
485#endif 481#endif
diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h
index 9926aa0..e4f359c 100644
--- a/kaddressbook/kabprefs.h
+++ b/kaddressbook/kabprefs.h
@@ -1,108 +1,92 @@
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#ifndef KABPREFS_H 24#ifndef KABPREFS_H
25#define KABPREFS_H 25#define KABPREFS_H
26 26
27#include <qstringlist.h> 27#include <qstringlist.h>
28 28
29#include <libkdepim/kpimprefs.h> 29#include <libkdepim/kpimprefs.h>
30 30
31class KConfig; 31class KConfig;
32 32
33class KABPrefs : public KPimPrefs 33class KABPrefs : public KPimPrefs
34{ 34{
35 public: 35 public:
36 virtual ~KABPrefs(); 36 virtual ~KABPrefs();
37 37
38 static KABPrefs *instance(); 38 static KABPrefs *instance();
39 39
40 // General 40 // General
41 bool mHonorSingleClick; 41 bool mHonorSingleClick;
42 bool mAutomaticNameParsing; 42 bool mAutomaticNameParsing;
43 int mCurrentIncSearchField; 43 int mCurrentIncSearchField;
44 44
45#ifdef KAB_EMBEDDED 45#ifdef KAB_EMBEDDED
46 // US introduce a nonconst way to return the config object. 46 // US introduce a nonconst way to return the config object.
47 KConfig* getConfig(); 47 KConfig* getConfig();
48 48
49 bool mToolBarHor; 49 bool mToolBarHor;
50 bool mToolBarUp; 50 bool mToolBarUp;
51 bool mAskForQuit; 51 bool mAskForQuit;
52 52
53 53
54 /** Set preferences to default values */ 54 /** Set preferences to default values */
55// void usrSetDefaults(); 55// void usrSetDefaults();
56 56
57 /** Read preferences from config file */ 57 /** Read preferences from config file */
58// void usrReadConfig(); 58// void usrReadConfig();
59 59
60 /** Write preferences to config file */ 60 /** Write preferences to config file */
61// void usrWriteConfig(); 61// void usrWriteConfig();
62#endif //KAB_EMBEDDED 62#endif //KAB_EMBEDDED
63 63
64 64
65 // GUI 65 // GUI
66 bool mJumpButtonBarVisible; 66 bool mJumpButtonBarVisible;
67 bool mDetailsPageVisible; 67 bool mDetailsPageVisible;
68 bool mMultipleViewsAtOnce; 68 bool mMultipleViewsAtOnce;
69 bool mSearchWithReturn; 69 bool mSearchWithReturn;
70 QValueList<int> mExtensionsSplitter; 70 QValueList<int> mExtensionsSplitter;
71 QValueList<int> mDetailsSplitter; 71 QValueList<int> mDetailsSplitter;
72 72
73 // Extensions stuff 73 // Extensions stuff
74 int mCurrentExtension; 74 int mCurrentExtension;
75 QStringList mActiveExtensions; 75 QStringList mActiveExtensions;
76 76
77 // Views stuff 77 // Views stuff
78 QString mCurrentView; 78 QString mCurrentView;
79 QStringList mViewNames; 79 QStringList mViewNames;
80 80
81 // Filter 81 // Filter
82 int mCurrentFilter; 82 int mCurrentFilter;
83 83
84 void setCategoryDefaults(); 84 void setCategoryDefaults();
85 // sync stuff 85
86 QString mLocalMachineName;
87 QStringList mExternSyncProfiles;
88 QStringList mSyncProfileNames;
89 bool mAskForPreferences;
90 bool mShowSyncSummary;
91 bool mShowSyncEvents;
92 bool mShowTodoInAgenda;
93 bool mWriteBackExistingOnly;
94 int mSyncAlgoPrefs;
95 int mRingSyncAlgoPrefs;
96 bool mWriteBackFile;
97 int mWriteBackInFuture;
98 QString mPhoneDevice;
99 QString mPhoneConnection;
100 QString mPhoneModel;
101 QString mLastSyncedLocalFile; // save!
102 private: 86 private:
103 KABPrefs(); 87 KABPrefs();
104 88
105 static KABPrefs *sInstance; 89 static KABPrefs *sInstance;
106}; 90};
107 91
108#endif 92#endif
diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h
index 860665b..01c57a3 100644
--- a/libkdepim/kpimprefs.h
+++ b/libkdepim/kpimprefs.h
@@ -1,64 +1,85 @@
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 30
31#ifndef KPIMPREFS_H 31#ifndef KPIMPREFS_H
32#define KPIMPREFS_H 32#define KPIMPREFS_H
33 33
34#include <qstringlist.h> 34#include <qstringlist.h>
35 35
36#include "kprefs.h" 36#include "kprefs.h"
37 37
38class KPimPrefs : public KPrefs 38class KPimPrefs : public KPrefs
39{ 39{
40 public: 40 public:
41 41
42 KPimPrefs( const QString &name = QString::null ); 42 KPimPrefs( const QString &name = QString::null );
43 43
44 virtual ~KPimPrefs(); 44 virtual ~KPimPrefs();
45 45
46 /** Set preferences to default values */ 46 /** Set preferences to default values */
47 void usrSetDefaults(); 47 void usrSetDefaults();
48 48
49 /** Read preferences from config file */ 49 /** Read preferences from config file */
50 void usrReadConfig(); 50 void usrReadConfig();
51 51
52 /** Write preferences to config file */ 52 /** Write preferences to config file */
53 void usrWriteConfig(); 53 void usrWriteConfig();
54 54
55 55
56 public: 56 public:
57 QStringList mCustomCategories; 57 QStringList mCustomCategories;
58 58
59 // sync stuff
60 QString mLocalMachineName;
61 QStringList mExternSyncProfiles;
62 QStringList mSyncProfileNames;
63 bool mAskForPreferences;
64 bool mShowSyncSummary;
65 bool mShowSyncEvents;
66 bool mShowTodoInAgenda;
67 bool mWriteBackExistingOnly;
68 int mSyncAlgoPrefs;
69 int mRingSyncAlgoPrefs;
70 bool mWriteBackFile;
71 int mWriteBackInFuture;
72 QString mPhoneDevice;
73 QString mPhoneConnection;
74 QString mPhoneModel;
75 QString mLastSyncedLocalFile; // save!
76
59 77
60 protected: 78 protected:
61 virtual void setCategoryDefaults(); 79 virtual void setCategoryDefaults();
80
81
82
62}; 83};
63 84
64#endif 85#endif
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 52e3bd9..87f200a 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,455 +1,529 @@
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 26
26KSyncManager::KSyncManager(TargetApp ta, QPopupMenu* syncmenu) 27#ifndef _WIN32_
27 : mSyncMenu(syncmenu), mTargetApp(ta) 28#include <unistd.h>
29#endif
30
31
32#include "ksyncprofile.h"
33#include "ksyncprefsdialog.h"
34#include "kpimprefs.h"
35
36#include <qdir.h>
37#include <qpopupmenu.h>
38#include <qpushbutton.h>
39#include <qradiobutton.h>
40#include <qbuttongroup.h>
41#include <qtimer.h>
42#include <qmessagebox.h>
43#include <qapplication.h>
44#include <qlineedit.h>
45#include <qdialog.h>
46#include <qlayout.h>
47
48#include <klocale.h>
49#include <kglobal.h>
50#include <kconfig.h>
51#include <kfiledialog.h>
52
53KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
54 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs), mSyncMenu(syncmenu)
28{ 55{
29 56
30} 57}
31 58
32KSyncManager::~KSyncManager() 59KSyncManager::~KSyncManager()
33{ 60{
34 61
35} 62}
36 63
37 64
38void KABCore::fillSyncMenu() 65void KSyncManager::fillSyncMenu()
39{ 66{
40 if ( mSyncMenu->count() ) 67 if ( mSyncMenu->count() )
41 msyncMenu->clear(); 68 mSyncMenu->clear();
42 69
43 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 70 mSyncMenu->insertItem( i18n("Configure..."), 0 );
44 mSyncMenu->insertSeparator(); 71 mSyncMenu->insertSeparator();
45 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 72 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
46 mSyncMenu->insertSeparator(); 73 mSyncMenu->insertSeparator();
47 74
48 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 75 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
49 config.setGroup("General"); 76 config.setGroup("General");
50 QStringList prof = config.readListEntry("SyncProfileNames"); 77 QStringList prof = config.readListEntry("SyncProfileNames");
51 //US KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 78 mPrefs->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
52 if ( prof.count() < 3 ) { 79 if ( prof.count() < 3 ) {
53 prof.clear(); 80 prof.clear();
54 prof << i18n("Sharp_DTM"); 81 prof << i18n("Sharp_DTM");
55 prof << i18n("Local_file"); 82 prof << i18n("Local_file");
56 prof << i18n("Last_file"); 83 prof << i18n("Last_file");
57 KSyncProfile* temp = new KSyncProfile (); 84 KSyncProfile* temp = new KSyncProfile ();
58 temp->setName( prof[0] ); 85 temp->setName( prof[0] );
59 temp->writeConfig(&config); 86 temp->writeConfig(&config);
60 temp->setName( prof[1] ); 87 temp->setName( prof[1] );
61 temp->writeConfig(&config); 88 temp->writeConfig(&config);
62 temp->setName( prof[2] ); 89 temp->setName( prof[2] );
63 temp->writeConfig(&config); 90 temp->writeConfig(&config);
64 config.setGroup("General"); 91 config.setGroup("General");
65 config.writeEntry("SyncProfileNames",prof); 92 config.writeEntry("SyncProfileNames",prof);
66 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 93 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
67 config.sync(); 94 config.sync();
68 delete temp; 95 delete temp;
69 } 96 }
70 /*US 97 mPrefs->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
71 KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 98 mPrefs->mSyncProfileNames = prof;
72 KABPrefs::instance()->mSyncProfileNames = prof; 99 unsigned int i;
73 */
74 int i;
75 for ( i = 0; i < prof.count(); ++i ) { 100 for ( i = 0; i < prof.count(); ++i ) {
76 101
77 mSyncMenu->insertItem( prof[i], 1000+i ); 102 mSyncMenu->insertItem( prof[i], 1000+i );
78 if ( i == 2 ) 103 if ( i == 2 )
79 mSyncMenu->insertSeparator(); 104 mSyncMenu->insertSeparator();
80 } 105 }
81 QDir app_dir; 106 QDir app_dir;
82 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 107 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
83 mSyncMenu->setItemEnabled( false , 1000 ); 108 mSyncMenu->setItemEnabled( false , 1000 );
84 } 109 }
85 //probaly useless 110 //probaly useless
86 //mView->setupExternSyncProfiles(); 111 //mView->setupExternSyncProfiles();
87} 112}
88void KABCore::slotSyncMenu( int action ) 113
114void KSyncManager::slotSyncMenu( int action )
89{ 115{
90 //qDebug("syncaction %d ", action); 116 //qDebug("syncaction %d ", action);
91 if ( action == 0 ) { 117 if ( action == 0 ) {
92 118
93 // seems to be a Qt2 event handling bug 119 // seems to be a Qt2 event handling bug
94 // syncmenu.clear causes a segfault at first time 120 // syncmenu.clear causes a segfault at first time
95 // when we call it after the main event loop, it is ok 121 // when we call it after the main event loop, it is ok
96 // same behaviour when calling OM/Pi via QCOP for the first time 122 // same behaviour when calling OM/Pi via QCOP for the first time
97 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 123 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
98 //confSync(); 124 //confSync();
99 125
100 return; 126 return;
101 } 127 }
102 if ( action == 1 ) { 128 if ( action == 1 ) {
103 multiSync( true ); 129 multiSync( true );
104 return; 130 return;
105 } 131 }
106 132
107 if (mBlockSaveFlag) 133 if (blockSave())
108 return; 134 return;
109 mBlockSaveFlag = true; 135
136 setBlockSave(true);
137
110 mCurrentSyncProfile = action - 1000 ; 138 mCurrentSyncProfile = action - 1000 ;
111 //US mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ; 139 mCurrentSyncDevice = mPrefs->mSyncProfileNames[mCurrentSyncProfile] ;
112 //US mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ; 140 mCurrentSyncName = mPrefs->mLocalMachineName ;
113 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 141 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
114 KSyncProfile* temp = new KSyncProfile (); 142 KSyncProfile* temp = new KSyncProfile ();
115 //US temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 143 temp->setName(mPrefs->mSyncProfileNames[mCurrentSyncProfile]);
116 temp->readConfig(&config); 144 temp->readConfig(&config);
117 /*US 145 mPrefs->mAskForPreferences = temp->getAskForPreferences();
118 KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 146 mPrefs->mSyncAlgoPrefs = temp->getSyncPrefs();
119 KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 147 mPrefs->mWriteBackFile = temp->getWriteBackFile();
120 KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 148 mPrefs->mWriteBackExistingOnly = temp->getWriteBackExisting();
121 KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 149 mPrefs->mWriteBackInFuture = 0;
122 KABPrefs::instance()->mWriteBackInFuture = 0;
123 if ( temp->getWriteBackFuture() ) 150 if ( temp->getWriteBackFuture() )
124 KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 151 mPrefs->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
125 KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 152 mPrefs->mShowSyncSummary = temp->getShowSummaryAfterSync();
126 */
127 if ( action == 1000 ) { 153 if ( action == 1000 ) {
128 syncSharp(); 154 syncSharp();
129 155
130 } else if ( action == 1001 ) { 156 } else if ( action == 1001 ) {
131 syncLocalFile(); 157 syncLocalFile();
132 158
133 } else if ( action == 1002 ) { 159 } else if ( action == 1002 ) {
134 quickSyncLocalFile(); 160 quickSyncLocalFile();
135 161
136 } else if ( action >= 1003 ) { 162 } else if ( action >= 1003 ) {
137 if ( temp->getIsLocalFileSync() ) { 163 if ( temp->getIsLocalFileSync() ) {
138 /*US if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 164 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
139 KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 165 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
140 */ 166
141 } else { 167 } else {
142 if ( temp->getIsPhoneSync() ) { 168 if ( temp->getIsPhoneSync() ) {
143 /* 169 mPrefs->mPhoneDevice = temp->getPhoneDevice( ) ;
144 KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 170 mPrefs->mPhoneConnection = temp->getPhoneConnection( );
145 KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 171 mPrefs->mPhoneModel = temp->getPhoneModel( );
146 KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
147 */
148 syncPhone(); 172 syncPhone();
149 } else 173 } else
150 syncRemote( temp ); 174 syncRemote( temp );
151 175
152 } 176 }
153 } 177 }
154 delete temp; 178 delete temp;
155 mBlockSaveFlag = false; 179 setBlockSave(false);
156} 180}
157 181
158void KABCore::syncLocalFile() 182void KSyncManager::syncLocalFile()
159{ 183{
160 184
161 QString fn =KABPrefs::instance()->mLastSyncedLocalFile; 185 QString fn =mPrefs->mLastSyncedLocalFile;
162 186
163 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 187 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), mParent );
164 if ( fn == "" ) 188 if ( fn == "" )
165 return; 189 return;
166 if ( syncWithFile( fn, false ) ) { 190 if ( syncWithFile( fn, false ) ) {
167 qDebug("syncLocalFile() successful "); 191 qDebug("syncLocalFile() successful ");
168 } 192 }
169 193
170} 194}
171bool KABCore::syncWithFile( QString fn , bool quick ) 195bool KSyncManager::syncWithFile( QString fn , bool quick )
172{ 196{
173 bool ret = false; 197 bool ret = false;
174 QFileInfo info; 198 QFileInfo info;
175 info.setFile( fn ); 199 info.setFile( fn );
176 QString mess; 200 QString mess;
177 bool loadbup = true; 201 bool loadbup = true;
178 if ( !info. exists() ) { 202 if ( !info. exists() ) {
179 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 203 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
180 int result = QMessageBox::warning( this, i18n("Warning!"), 204 int result = QMessageBox::warning( mParent, i18n("Warning!"),
181 mess ); 205 mess );
182 return ret; 206 return ret;
183 } 207 }
184 int result = 0; 208 int result = 0;
185 if ( !quick ) { 209 if ( !quick ) {
186 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 210 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
187 result = QMessageBox::warning( this, i18n("Warning!"), 211 result = QMessageBox::warning( mParent, i18n("Warning!"),
188 mess, 212 mess,
189 i18n("Sync"), i18n("Cancel"), 0, 213 i18n("Sync"), i18n("Cancel"), 0,
190 0, 1 ); 214 0, 1 );
191 if ( result ) 215 if ( result )
192 return false; 216 return false;
193 } 217 }
194 if ( KABPrefs::instance()->mAskForPreferences ) 218 if ( mPrefs->mAskForPreferences )
195 edit_sync_options(); 219 edit_sync_options();
196 if ( result == 0 ) { 220 if ( result == 0 ) {
197 //qDebug("Now sycing ... "); 221 //qDebug("Now sycing ... ");
198 if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) ) 222 if ( ret = mImplementation->sync( this, fn, mPrefs->mSyncAlgoPrefs ) )
199 setCaption( i18n("Synchronization successful") ); 223 mParent->setCaption( i18n("Synchronization successful") );
200 else 224 else
201 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 225 mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
202 if ( ! quick ) 226 if ( ! quick )
203 KABPrefs::instance()->mLastSyncedLocalFile = fn; 227 mPrefs->mLastSyncedLocalFile = fn;
204 setModified(); 228 mImplementation->sync_setModified();
205 } 229 }
206 return ret; 230 return ret;
207} 231}
208void KABCore::quickSyncLocalFile() 232void KSyncManager::quickSyncLocalFile()
209{ 233{
210 234
211 if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) { 235 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, false ) ) {
212 qDebug("quick syncLocalFile() successful "); 236 qDebug("quick syncLocalFile() successful ");
213 237
214 } 238 }
215} 239}
216void KABCore::multiSync( bool askforPrefs ) 240void KSyncManager::multiSync( bool askforPrefs )
217{ 241{
218 if (mBlockSaveFlag) 242 if (blockSave())
219 return; 243 return;
220 mBlockSaveFlag = true; 244 setBlockSave(true);
221 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 245 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
222 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 246 if ( QMessageBox::information( mParent, i18n("Sync"),
223 question, 247 question,
224 i18n("Yes"), i18n("No"), 248 i18n("Yes"), i18n("No"),
225 0, 0 ) != 0 ) { 249 0, 0 ) != 0 ) {
226 mBlockSaveFlag = false; 250 setBlockSave(false);
227 setCaption(i18n("Aborted! Nothing synced!")); 251 mParent->setCaption(i18n("Aborted! Nothing synced!"));
228 return; 252 return;
229 } 253 }
230 mCurrentSyncDevice = i18n("Multiple profiles") ; 254 mCurrentSyncDevice = i18n("Multiple profiles") ;
231 KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs; 255 mPrefs->mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
232 if ( askforPrefs ) { 256 if ( askforPrefs ) {
233 edit_sync_options(); 257 edit_sync_options();
234 KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs; 258 mPrefs->mRingSyncAlgoPrefs = mPrefs->mSyncAlgoPrefs;
235 } 259 }
236 setCaption(i18n("Multiple sync started.") ); 260 mParent->setCaption(i18n("Multiple sync started.") );
237 qApp->processEvents(); 261 qApp->processEvents();
238 int num = ringSync() ; 262 int num = ringSync() ;
239 if ( num > 1 ) 263 if ( num > 1 )
240 ringSync(); 264 ringSync();
241 mBlockSaveFlag = false; 265 setBlockSave(false);
242 if ( num ) 266 if ( num )
243 save(); 267 mImplementation->sync_save();
244 if ( num ) 268 if ( num )
245 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 269 mParent->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
246 else 270 else
247 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 271 mParent->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
248 return; 272 return;
249} 273}
250int KABCore::ringSync() 274int KSyncManager::ringSync()
251{ 275{
252 int syncedProfiles = 0; 276 int syncedProfiles = 0;
253 int i; 277 unsigned int i;
254 QTime timer; 278 QTime timer;
255 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 279 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
256 QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames; 280 QStringList syncProfileNames = mPrefs->mSyncProfileNames;
257 KSyncProfile* temp = new KSyncProfile (); 281 KSyncProfile* temp = new KSyncProfile ();
258 KABPrefs::instance()->mAskForPreferences = false; 282 mPrefs->mAskForPreferences = false;
259 for ( i = 0; i < syncProfileNames.count(); ++i ) { 283 for ( i = 0; i < syncProfileNames.count(); ++i ) {
260 mCurrentSyncProfile = i; 284 mCurrentSyncProfile = i;
261 temp->setName(syncProfileNames[mCurrentSyncProfile]); 285 temp->setName(syncProfileNames[mCurrentSyncProfile]);
262 temp->readConfig(&config); 286 temp->readConfig(&config);
263 if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) { 287 if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) {
264 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 288 mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
265 ++syncedProfiles; 289 ++syncedProfiles;
266 // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 290 // mPrefs->mAskForPreferences = temp->getAskForPreferences();
267 KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 291 mPrefs->mWriteBackFile = temp->getWriteBackFile();
268 KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 292 mPrefs->mWriteBackExistingOnly = temp->getWriteBackExisting();
269 KABPrefs::instance()->mWriteBackInFuture = 0; 293 mPrefs->mWriteBackInFuture = 0;
270 if ( temp->getWriteBackFuture() ) 294 if ( temp->getWriteBackFuture() )
271 KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 295 mPrefs->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
272 KABPrefs::instance()->mShowSyncSummary = false; 296 mPrefs->mShowSyncSummary = false;
273 mCurrentSyncDevice = syncProfileNames[i] ; 297 mCurrentSyncDevice = syncProfileNames[i] ;
274 mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; 298 mCurrentSyncName = mPrefs->mLocalMachineName;
275 if ( i == 0 ) { 299 if ( i == 0 ) {
276 syncSharp(); 300 syncSharp();
277 } else { 301 } else {
278 if ( temp->getIsLocalFileSync() ) { 302 if ( temp->getIsLocalFileSync() ) {
279 if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) ) 303 if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) )
280 KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 304 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
281 } else { 305 } else {
282 if ( temp->getIsPhoneSync() ) { 306 if ( temp->getIsPhoneSync() ) {
283 KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 307 mPrefs->mPhoneDevice = temp->getPhoneDevice( ) ;
284 KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 308 mPrefs->mPhoneConnection = temp->getPhoneConnection( );
285 KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 309 mPrefs->mPhoneModel = temp->getPhoneModel( );
286 syncPhone(); 310 syncPhone();
287 } else 311 } else
288 syncRemote( temp, false ); 312 syncRemote( temp, false );
289 313
290 } 314 }
291 } 315 }
292 timer.start(); 316 timer.start();
293 setCaption(i18n("Multiple sync in progress ... please wait!") ); 317 mParent->setCaption(i18n("Multiple sync in progress ... please wait!") );
294 while ( timer.elapsed () < 2000 ) { 318 while ( timer.elapsed () < 2000 ) {
295 qApp->processEvents(); 319 qApp->processEvents();
296#ifndef _WIN32_ 320#ifndef _WIN32_
297 sleep (1); 321 sleep (1);
298#endif 322#endif
299 } 323 }
300 324
301 } 325 }
302 326
303 } 327 }
304 delete temp; 328 delete temp;
305 return syncedProfiles; 329 return syncedProfiles;
306} 330}
307 331
308void KABCore::syncRemote( KSyncProfile* prof, bool ask) 332void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
309{ 333{
310 QString question; 334 QString question;
311 if ( ask ) { 335 if ( ask ) {
312 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 336 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
313 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 337 if ( QMessageBox::information( mParent, i18n("Sync"),
314 question, 338 question,
315 i18n("Yes"), i18n("No"), 339 i18n("Yes"), i18n("No"),
316 0, 0 ) != 0 ) 340 0, 0 ) != 0 )
317 return; 341 return;
318 } 342 }
319 QString command = prof->getPreSyncCommandAB(); 343 QString command = prof->getPreSyncCommandAB();
320 int fi; 344 int fi;
321 if ( (fi = command.find("$PWD$")) > 0 ) { 345 if ( (fi = command.find("$PWD$")) > 0 ) {
322 QString pwd = getPassword(); 346 QString pwd = getPassword();
323 command = command.left( fi )+ pwd + command.mid( fi+5 ); 347 command = command.left( fi )+ pwd + command.mid( fi+5 );
324 348
325 } 349 }
326 int maxlen = 30; 350 int maxlen = 30;
327 if ( QApplication::desktop()->width() > 320 ) 351 if ( QApplication::desktop()->width() > 320 )
328 maxlen += 25; 352 maxlen += 25;
329 setCaption ( i18n( "Copy remote file to local machine..." ) ); 353 mParent->setCaption ( i18n( "Copy remote file to local machine..." ) );
330 int fileSize = 0; 354 int fileSize = 0;
331 int result = system ( command ); 355 int result = system ( command );
332 // 0 : okay 356 // 0 : okay
333 // 256: no such file or dir 357 // 256: no such file or dir
334 // 358 //
335 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 359 qDebug("KO: Remote copy result(0 = okay): %d ",result );
336 if ( result != 0 ) { 360 if ( result != 0 ) {
337 int len = maxlen; 361 unsigned int len = maxlen;
338 while ( len < command.length() ) { 362 while ( len < command.length() ) {
339 command.insert( len , "\n" ); 363 command.insert( len , "\n" );
340 len += maxlen +2; 364 len += maxlen +2;
341 } 365 }
342 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 (command) ; 366 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 (command) ;
343 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 367 QMessageBox::information( mParent, i18n("Sync - ERROR"),
344 question, 368 question,
345 i18n("Okay!")) ; 369 i18n("Okay!")) ;
346 setCaption ("KO/Pi"); 370 mParent->setCaption ("");
347 return; 371 return;
348 } 372 }
349 setCaption ( i18n( "Copying succeed." ) ); 373 mParent->setCaption ( i18n( "Copying succeed." ) );
350 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 374 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
351 if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) { 375 if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) {
352// Event* e = mView->getLastSyncEvent(); 376// Event* e = mView->getLastSyncEvent();
353// e->setReadOnly( false ); 377// e->setReadOnly( false );
354// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 378// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
355// e->setReadOnly( true ); 379// e->setReadOnly( true );
356 if ( KABPrefs::instance()->mWriteBackFile ) { 380 if ( mPrefs->mWriteBackFile ) {
357 command = prof->getPostSyncCommandAB(); 381 command = prof->getPostSyncCommandAB();
358 int fi; 382 int fi;
359 if ( (fi = command.find("$PWD$")) > 0 ) { 383 if ( (fi = command.find("$PWD$")) > 0 ) {
360 QString pwd = getPassword(); 384 QString pwd = getPassword();
361 command = command.left( fi )+ pwd + command.mid( fi+5 ); 385 command = command.left( fi )+ pwd + command.mid( fi+5 );
362 386
363 } 387 }
364 setCaption ( i18n( "Writing back file ..." ) ); 388 mParent->setCaption ( i18n( "Writing back file ..." ) );
365 result = system ( command ); 389 result = system ( command );
366 qDebug("KO: Writing back file result: %d ", result); 390 qDebug("Writing back file result: %d ", result);
367 if ( result != 0 ) { 391 if ( result != 0 ) {
368 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 392 mParent->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
369 return; 393 return;
370 } else { 394 } else {
371 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 395 mParent->setCaption ( i18n( "Syncronization sucessfully completed" ) );
372 } 396 }
373 } 397 }
374 } 398 }
375 return; 399 return;
376} 400}
377#include <qpushbutton.h> 401
378#include <qradiobutton.h> 402void KSyncManager::edit_sync_options()
379#include <qbuttongroup.h>
380void KABCore::edit_sync_options()
381{ 403{
382 //mDialogManager->showSyncOptions(); 404 //mDialogManager->showSyncOptions();
383 //KABPrefs::instance()->mSyncAlgoPrefs 405 //mPrefs->mSyncAlgoPrefs
384 QDialog dia( this, "dia", true ); 406 QDialog dia( mParent, "dia", true );
385 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 407 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
386 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 408 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
387 QVBoxLayout lay ( &dia ); 409 QVBoxLayout lay ( &dia );
388 lay.setSpacing( 2 ); 410 lay.setSpacing( 2 );
389 lay.setMargin( 3 ); 411 lay.setMargin( 3 );
390 lay.addWidget(&gr); 412 lay.addWidget(&gr);
391 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 413 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
392 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 414 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
393 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 415 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
394 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 416 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
395 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 417 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
396 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 418 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
397 //QRadioButton both( i18n("Take both on conflict"), &gr ); 419 //QRadioButton both( i18n("Take both on conflict"), &gr );
398 QPushButton pb ( "OK", &dia); 420 QPushButton pb ( "OK", &dia);
399 lay.addWidget( &pb ); 421 lay.addWidget( &pb );
400 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 422 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
401 switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { 423 switch ( mPrefs->mSyncAlgoPrefs ) {
402 case 0: 424 case 0:
403 loc.setChecked( true); 425 loc.setChecked( true);
404 break; 426 break;
405 case 1: 427 case 1:
406 rem.setChecked( true ); 428 rem.setChecked( true );
407 break; 429 break;
408 case 2: 430 case 2:
409 newest.setChecked( true); 431 newest.setChecked( true);
410 break; 432 break;
411 case 3: 433 case 3:
412 ask.setChecked( true); 434 ask.setChecked( true);
413 break; 435 break;
414 case 4: 436 case 4:
415 f_loc.setChecked( true); 437 f_loc.setChecked( true);
416 break; 438 break;
417 case 5: 439 case 5:
418 f_rem.setChecked( true); 440 f_rem.setChecked( true);
419 break; 441 break;
420 case 6: 442 case 6:
421 // both.setChecked( true); 443 // both.setChecked( true);
422 break; 444 break;
423 default: 445 default:
424 break; 446 break;
425 } 447 }
426 if ( dia.exec() ) { 448 if ( dia.exec() ) {
427 KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 449 mPrefs->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
428 } 450 }
429 451
430 452
431} 453}
432QString KABCore::getPassword( ) 454QString KSyncManager::getPassword( )
433{ 455{
434 QString retfile = ""; 456 QString retfile = "";
435 QDialog dia ( this, "input-dialog", true ); 457 QDialog dia ( mParent, "input-dialog", true );
436 QLineEdit lab ( &dia ); 458 QLineEdit lab ( &dia );
437 lab.setEchoMode( QLineEdit::Password ); 459 lab.setEchoMode( QLineEdit::Password );
438 QVBoxLayout lay( &dia ); 460 QVBoxLayout lay( &dia );
439 lay.setMargin(7); 461 lay.setMargin(7);
440 lay.setSpacing(7); 462 lay.setSpacing(7);
441 lay.addWidget( &lab); 463 lay.addWidget( &lab);
442 dia.setFixedSize( 230,50 ); 464 dia.setFixedSize( 230,50 );
443 dia.setCaption( i18n("Enter password") ); 465 dia.setCaption( i18n("Enter password") );
444 QPushButton pb ( "OK", &dia); 466 QPushButton pb ( "OK", &dia);
445 lay.addWidget( &pb ); 467 lay.addWidget( &pb );
446 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 468 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
447 dia.show(); 469 dia.show();
448 int res = dia.exec(); 470 int res = dia.exec();
449 if ( res ) 471 if ( res )
450 retfile = lab.text(); 472 retfile = lab.text();
451 dia.hide(); 473 dia.hide();
452 qApp->processEvents(); 474 qApp->processEvents();
453 return retfile; 475 return retfile;
454 476
455} 477}
478
479
480void KSyncManager::confSync()
481{
482 static KSyncPrefsDialog* sp = 0;
483 if ( ! sp ) {
484 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
485 }
486 sp->usrReadConfig();
487#ifndef DESKTOP_VERSION
488 sp->showMaximized();
489#else
490 sp->show();
491#endif
492 sp->exec();
493 mPrefs->mSyncProfileNames = sp->getSyncProfileNames();
494 mPrefs->mLocalMachineName = sp->getLocalMachineName ();
495 fillSyncMenu();
496}
497
498void KSyncManager::syncSharp()
499{
500 if ( ! syncExternalApplication("sharp") )
501 qDebug("ERROR sync sharp ");;
502}
503
504bool KSyncManager::syncExternalApplication(QString resource)
505{
506 if ( mImplementation->sync_isModified() )
507 mImplementation->sync_save();
508
509 if ( mPrefs->mAskForPreferences )
510 edit_sync_options();
511
512 qDebug("sync %s", resource.latin1());
513
514 bool syncOK = mImplementation->syncExternal(this, resource);
515
516 return syncOK;
517
518}
519
520void KSyncManager::syncPhone()
521{
522 if ( mImplementation->sync_isModified() )
523 mImplementation->sync_save();
524
525 qDebug("pending syncPhone(); ");
526 //mView->syncPhone();
527 mImplementation->sync_setModified();
528
529}
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index d7c2a02..389a005 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,68 +1,119 @@
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 <qstring.h> 26#include <qstring.h>
26 27
27class QPopupMenu; 28class QPopupMenu;
28class KSyncProfile; 29class KSyncProfile;
30class KPimPrefs;
31class QWidget;
32class KSyncManager;
33class KSyncInterface;
29 34
30 35class KSyncManager : public QObject
31
32class KSyncManager
33{ 36{
34 37 Q_OBJECT
35 public:
36 KSyncManager(TargetApp ta, QPopupMenu* syncmenu);
37 ~KSyncManager() ;
38 38
39 public:
39 enum TargetApp { 40 enum TargetApp {
40 KOPI = 0, 41 KOPI = 0,
41 KAPI = 1, 42 KAPI = 1,
42 PWMPI = 2 }; 43 PWMPI = 2 };
43 44
44 private: 45
46 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
47 ~KSyncManager() ;
48
49 bool blockSave() { return mBlockSaveFlag; }
50 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
51
45 void fillSyncMenu(); 52 void fillSyncMenu();
46 void syncLocalFile(); 53
47 bool syncWithFile( QString fn , bool quick ); 54 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
55 QString getCurrentSyncName() { return mCurrentSyncName; }
56
57 public slots:
58 void slotSyncMenu( int );
59
60 private:
61 // LR *******************************
62 // sync stuff!
63 QString mCurrentSyncDevice;
64 QString mCurrentSyncName;
48 void quickSyncLocalFile(); 65 void quickSyncLocalFile();
66 bool syncWithFile( QString fn , bool quick );
67 void syncLocalFile();
68 void syncPhone();
69 void syncSharp();
70 bool syncExternalApplication(QString);
49 void multiSync( bool askforPrefs ); 71 void multiSync( bool askforPrefs );
50 int ringSync(); 72 int mCurrentSyncProfile ;
51 void syncRemote( KSyncProfile* prof, bool ask); 73 void syncRemote( KSyncProfile* prof, bool ask = true);
52 void edit_sync_options(); 74 void edit_sync_options();
53 QString getPassword(); 75 int ringSync();
76 QString getPassword( );
77
78 private slots:
79 void confSync();
80 // *********************
54 81
55 private: 82 private:
56 QPopupMenu* mSyncMenu; 83 bool mBlockSaveFlag;
84
85
86 QWidget* mParent;
87 KSyncInterface* mImplementation;
57 TargetApp mTargetApp; 88 TargetApp mTargetApp;
89 KPimPrefs* mPrefs;
90 QPopupMenu* mSyncMenu;
91
58 92
59 93
60 94
61 95
62 96
63 97
98};
99
100
101class KSyncInterface
102{
103 public:
104 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0;
105 virtual bool syncExternal(KSyncManager* manager, QString resource) = 0;
64 106
65 107
108 //called by the syncmanager to indicate that the work has to be marked as dirty.
109 virtual void sync_setModified() = 0;
110
111 //called by the syncmanager to ask if the dirty flag is set.
112 virtual bool sync_isModified() = 0;
113
114 //called by the syncmanager to indicate that the work has to be saved.
115 virtual void sync_save() = 0;
66}; 116};
67 117
118
68#endif 119#endif
diff --git a/libkdepim/libkdepimE.pro b/libkdepim/libkdepimE.pro
index 2a30ee8..156e247 100644
--- a/libkdepim/libkdepimE.pro
+++ b/libkdepim/libkdepimE.pro
@@ -1,53 +1,55 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG += qt warn_on 2 CONFIG += qt warn_on
3TARGET = microkdepim 3TARGET = microkdepim
4INCLUDEPATH += . $(KDEPIMDIR) $(KDEPIMDIR)/microkde $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kdeui $(QPEDIR)/include 4INCLUDEPATH += . $(KDEPIMDIR) $(KDEPIMDIR)/microkde $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kdeui $(QPEDIR)/include
5LIBS += -lmicrokde 5LIBS += -lmicrokde
6#LIBS += -lmicrokcal 6#LIBS += -lmicrokcal
7LIBS += -L$(QPEDIR)/lib 7LIBS += -L$(QPEDIR)/lib
8OBJECTS_DIR = obj/$(PLATFORM) 8OBJECTS_DIR = obj/$(PLATFORM)
9MOC_DIR = moc/$(PLATFORM) 9MOC_DIR = moc/$(PLATFORM)
10DESTDIR=$(QPEDIR)/lib 10DESTDIR=$(QPEDIR)/lib
11 11
12 12
13INTERFACES = \ 13INTERFACES = \
14 14
15HEADERS = \ 15HEADERS = \
16 categoryeditdialog.h \ 16 categoryeditdialog.h \
17 categoryeditdialog_base.h \ 17 categoryeditdialog_base.h \
18 categoryselectdialog.h \ 18 categoryselectdialog.h \
19 categoryselectdialog_base.h \ 19 categoryselectdialog_base.h \
20 externalapphandler.h \ 20 externalapphandler.h \
21 kdateedit.h \ 21 kdateedit.h \
22 kdatepicker.h \ 22 kdatepicker.h \
23 kinputdialog.h \ 23 kinputdialog.h \
24 kpimprefs.h \ 24 kpimprefs.h \
25 kpimglobalprefs.h \ 25 kpimglobalprefs.h \
26 kprefsdialog.h \ 26 kprefsdialog.h \
27 kprefswidget.h \ 27 kprefswidget.h \
28 ksyncmanager.h \
28 ksyncprofile.h \ 29 ksyncprofile.h \
29 ksyncprefsdialog.h \ 30 ksyncprefsdialog.h \
30 kcmconfigs/kcmkdepimconfig.h \ 31 kcmconfigs/kcmkdepimconfig.h \
31 kcmconfigs/kdepimconfigwidget.h 32 kcmconfigs/kdepimconfigwidget.h
32 33
33 34
34 35
35SOURCES = \ 36SOURCES = \
36 categoryeditdialog.cpp \ 37 categoryeditdialog.cpp \
37 categoryeditdialog_base.cpp \ 38 categoryeditdialog_base.cpp \
38 categoryselectdialog.cpp \ 39 categoryselectdialog.cpp \
39 categoryselectdialog_base.cpp \ 40 categoryselectdialog_base.cpp \
40 externalapphandler.cpp \ 41 externalapphandler.cpp \
41 kdateedit.cpp \ 42 kdateedit.cpp \
42 kinputdialog.cpp \ 43 kinputdialog.cpp \
43 kdatepicker.cpp \ 44 kdatepicker.cpp \
44 kpimprefs.cpp \ 45 kpimprefs.cpp \
45 kpimglobalprefs.cpp \ 46 kpimglobalprefs.cpp \
46 kprefsdialog.cpp \ 47 kprefsdialog.cpp \
47 kprefswidget.cpp \ 48 kprefswidget.cpp \
49 ksyncmanager.cpp \
48 ksyncprofile.cpp \ 50 ksyncprofile.cpp \
49 ksyncprefsdialog.cpp \ 51 ksyncprefsdialog.cpp \
50 kcmconfigs/kcmkdepimconfig.cpp \ 52 kcmconfigs/kcmkdepimconfig.cpp \
51 kcmconfigs/kdepimconfigwidget.cpp 53 kcmconfigs/kdepimconfigwidget.cpp
52 54
53 55