summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/korganizer/allday.pngbin0 -> 279 bytes
-rw-r--r--bin/kdepim/korganizer/icons16/allday.pngbin0 -> 271 bytes
-rw-r--r--bin/kdepim/korganizer/iconsmini/allday.pngbin0 -> 273 bytes
-rw-r--r--bin/kdepim/korganizer/iconsmini/configure.pngbin0 -> 763 bytes
-rw-r--r--kaddressbook/kabcore.cpp40
-rw-r--r--korganizer/calendarview.cpp21
-rw-r--r--korganizer/mainwindow.cpp3
-rw-r--r--libkdepim/ksyncmanager.cpp34
8 files changed, 50 insertions, 48 deletions
diff --git a/bin/kdepim/korganizer/allday.png b/bin/kdepim/korganizer/allday.png
new file mode 100644
index 0000000..735eae2
--- a/dev/null
+++ b/bin/kdepim/korganizer/allday.png
Binary files differ
diff --git a/bin/kdepim/korganizer/icons16/allday.png b/bin/kdepim/korganizer/icons16/allday.png
new file mode 100644
index 0000000..426d250
--- a/dev/null
+++ b/bin/kdepim/korganizer/icons16/allday.png
Binary files differ
diff --git a/bin/kdepim/korganizer/iconsmini/allday.png b/bin/kdepim/korganizer/iconsmini/allday.png
new file mode 100644
index 0000000..be9a2ba
--- a/dev/null
+++ b/bin/kdepim/korganizer/iconsmini/allday.png
Binary files differ
diff --git a/bin/kdepim/korganizer/iconsmini/configure.png b/bin/kdepim/korganizer/iconsmini/configure.png
new file mode 100644
index 0000000..ad965e2
--- a/dev/null
+++ b/bin/kdepim/korganizer/iconsmini/configure.png
Binary files differ
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 590cc82..ae0a068 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -174,1063 +174,1063 @@ class KABCatPrefs : public QDialog
174 { 174 {
175 setCaption( i18n("Manage new Categories") ); 175 setCaption( i18n("Manage new Categories") );
176 QVBoxLayout* lay = new QVBoxLayout( this ); 176 QVBoxLayout* lay = new QVBoxLayout( this );
177 lay->setSpacing( 3 ); 177 lay->setSpacing( 3 );
178 lay->setMargin( 3 ); 178 lay->setMargin( 3 );
179 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 179 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
180 lay->addWidget( lab ); 180 lay->addWidget( lab );
181 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 181 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
182 lay->addWidget( format ); 182 lay->addWidget( format );
183 format->setExclusive ( true ) ; 183 format->setExclusive ( true ) ;
184 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 184 addCatBut = new QRadioButton(i18n("Add to category list"), format );
185 new QRadioButton(i18n("Remove from addressees"), format ); 185 new QRadioButton(i18n("Remove from addressees"), format );
186 addCatBut->setChecked( true ); 186 addCatBut->setChecked( true );
187 QPushButton * ok = new QPushButton( i18n("OK"), this ); 187 QPushButton * ok = new QPushButton( i18n("OK"), this );
188 lay->addWidget( ok ); 188 lay->addWidget( ok );
189 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 189 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
190 lay->addWidget( cancel ); 190 lay->addWidget( cancel );
191 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 191 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
192 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 192 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
193 resize( 200, 200 ); 193 resize( 200, 200 );
194 } 194 }
195 195
196 bool addCat() { return addCatBut->isChecked(); } 196 bool addCat() { return addCatBut->isChecked(); }
197private: 197private:
198 QRadioButton* addCatBut; 198 QRadioButton* addCatBut;
199}; 199};
200 200
201class KABFormatPrefs : public QDialog 201class KABFormatPrefs : public QDialog
202{ 202{
203 public: 203 public:
204 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : 204 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) :
205 QDialog( parent, name, true ) 205 QDialog( parent, name, true )
206 { 206 {
207 setCaption( i18n("Set formatted name") ); 207 setCaption( i18n("Set formatted name") );
208 QVBoxLayout* lay = new QVBoxLayout( this ); 208 QVBoxLayout* lay = new QVBoxLayout( this );
209 lay->setSpacing( 3 ); 209 lay->setSpacing( 3 );
210 lay->setMargin( 3 ); 210 lay->setMargin( 3 );
211 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); 211 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this );
212 lay->addWidget( lab ); 212 lay->addWidget( lab );
213 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); 213 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this );
214 lay->addWidget( format ); 214 lay->addWidget( format );
215 format->setExclusive ( true ) ; 215 format->setExclusive ( true ) ;
216 simple = new QRadioButton(i18n("Simple: James Bond"), format ); 216 simple = new QRadioButton(i18n("Simple: James Bond"), format );
217 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); 217 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format );
218 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); 218 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format );
219 company = new QRadioButton(i18n("Organization: MI6"), format ); 219 company = new QRadioButton(i18n("Organization: MI6"), format );
220 simple->setChecked( true ); 220 simple->setChecked( true );
221 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); 221 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this);
222 lay->addWidget( setCompany ); 222 lay->addWidget( setCompany );
223 QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); 223 QPushButton * ok = new QPushButton( i18n("Select contact list"), this );
224 lay->addWidget( ok ); 224 lay->addWidget( ok );
225 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 225 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
226 lay->addWidget( cancel ); 226 lay->addWidget( cancel );
227 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 227 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
228 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 228 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
229 //resize( 200, 200 ); 229 //resize( 200, 200 );
230 230
231 } 231 }
232public: 232public:
233 QRadioButton* simple, *full, *reverse, *company; 233 QRadioButton* simple, *full, *reverse, *company;
234 QCheckBox* setCompany; 234 QCheckBox* setCompany;
235}; 235};
236 236
237 237
238 238
239class KAex2phonePrefs : public QDialog 239class KAex2phonePrefs : public QDialog
240{ 240{
241 public: 241 public:
242 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 242 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
243 QDialog( parent, name, true ) 243 QDialog( parent, name, true )
244 { 244 {
245 setCaption( i18n("Export to phone options") ); 245 setCaption( i18n("Export to phone options") );
246 QVBoxLayout* lay = new QVBoxLayout( this ); 246 QVBoxLayout* lay = new QVBoxLayout( this );
247 lay->setSpacing( 3 ); 247 lay->setSpacing( 3 );
248 lay->setMargin( 3 ); 248 lay->setMargin( 3 );
249 QLabel *lab; 249 QLabel *lab;
250 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 250 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
251 lab->setAlignment (AlignHCenter ); 251 lab->setAlignment (AlignHCenter );
252 QHBox* temphb; 252 QHBox* temphb;
253 temphb = new QHBox( this ); 253 temphb = new QHBox( this );
254 new QLabel( i18n("I/O device: "), temphb ); 254 new QLabel( i18n("I/O device: "), temphb );
255 mPhoneDevice = new QLineEdit( temphb); 255 mPhoneDevice = new QLineEdit( temphb);
256 lay->addWidget( temphb ); 256 lay->addWidget( temphb );
257 temphb = new QHBox( this ); 257 temphb = new QHBox( this );
258 new QLabel( i18n("Connection: "), temphb ); 258 new QLabel( i18n("Connection: "), temphb );
259 mPhoneConnection = new QLineEdit( temphb); 259 mPhoneConnection = new QLineEdit( temphb);
260 lay->addWidget( temphb ); 260 lay->addWidget( temphb );
261 temphb = new QHBox( this ); 261 temphb = new QHBox( this );
262 new QLabel( i18n("Model(opt.): "), temphb ); 262 new QLabel( i18n("Model(opt.): "), temphb );
263 mPhoneModel = new QLineEdit( temphb); 263 mPhoneModel = new QLineEdit( temphb);
264 lay->addWidget( temphb ); 264 lay->addWidget( temphb );
265 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 265 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
266 // lay->addWidget( mWriteToSim ); 266 // lay->addWidget( mWriteToSim );
267 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 267 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
268 lab->setAlignment (AlignHCenter); 268 lab->setAlignment (AlignHCenter);
269 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 269 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
270 lay->addWidget( ok ); 270 lay->addWidget( ok );
271 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 271 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
272 lay->addWidget( cancel ); 272 lay->addWidget( cancel );
273 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 273 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
274 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 274 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
275 resize( 220, 240 ); 275 resize( 220, 240 );
276 276
277 } 277 }
278 278
279public: 279public:
280 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 280 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
281 QCheckBox* mWriteToSim; 281 QCheckBox* mWriteToSim;
282}; 282};
283 283
284 284
285bool pasteWithNewUid = true; 285bool pasteWithNewUid = true;
286 286
287#ifdef KAB_EMBEDDED 287#ifdef KAB_EMBEDDED
288KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 288KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
289 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 289 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
290 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 290 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
291 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 291 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
292#else //KAB_EMBEDDED 292#else //KAB_EMBEDDED
293KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 293KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
294 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 294 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
295 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 295 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
296 mReadWrite( readWrite ), mModified( false ) 296 mReadWrite( readWrite ), mModified( false )
297#endif //KAB_EMBEDDED 297#endif //KAB_EMBEDDED
298{ 298{
299 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 299 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
300 // syncManager->setBlockSave(false); 300 // syncManager->setBlockSave(false);
301 mMiniSplitter = 0; 301 mMiniSplitter = 0;
302 mExtensionBarSplitter = 0; 302 mExtensionBarSplitter = 0;
303 mIsPart = !parent->inherits( "KAddressBookMain" ); 303 mIsPart = !parent->inherits( "KAddressBookMain" );
304 mAddressBook = KABC::StdAddressBook::self(); 304 mAddressBook = KABC::StdAddressBook::self();
305 KABC::StdAddressBook::setAutomaticSave( false ); 305 KABC::StdAddressBook::setAutomaticSave( false );
306 306
307#ifndef KAB_EMBEDDED 307#ifndef KAB_EMBEDDED
308 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 308 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
309#endif //KAB_EMBEDDED 309#endif //KAB_EMBEDDED
310 310
311 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 311 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
312 SLOT( addressBookChanged() ) ); 312 SLOT( addressBookChanged() ) );
313 313
314#if 0 314#if 0
315 // LP moved to addressbook init method 315 // LP moved to addressbook init method
316 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 316 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
317 "X-Department", "KADDRESSBOOK" ); 317 "X-Department", "KADDRESSBOOK" );
318 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 318 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
319 "X-Profession", "KADDRESSBOOK" ); 319 "X-Profession", "KADDRESSBOOK" );
320 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 320 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
321 "X-AssistantsName", "KADDRESSBOOK" ); 321 "X-AssistantsName", "KADDRESSBOOK" );
322 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 322 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
323 "X-ManagersName", "KADDRESSBOOK" ); 323 "X-ManagersName", "KADDRESSBOOK" );
324 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 324 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
325 "X-SpousesName", "KADDRESSBOOK" ); 325 "X-SpousesName", "KADDRESSBOOK" );
326 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 326 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
327 "X-Office", "KADDRESSBOOK" ); 327 "X-Office", "KADDRESSBOOK" );
328 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 328 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
329 "X-IMAddress", "KADDRESSBOOK" ); 329 "X-IMAddress", "KADDRESSBOOK" );
330 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 330 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
331 "X-Anniversary", "KADDRESSBOOK" ); 331 "X-Anniversary", "KADDRESSBOOK" );
332 332
333 //US added this field to become compatible with Opie/qtopia addressbook 333 //US added this field to become compatible with Opie/qtopia addressbook
334 // values can be "female" or "male" or "". An empty field represents undefined. 334 // values can be "female" or "male" or "". An empty field represents undefined.
335 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 335 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
336 "X-Gender", "KADDRESSBOOK" ); 336 "X-Gender", "KADDRESSBOOK" );
337 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 337 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
338 "X-Children", "KADDRESSBOOK" ); 338 "X-Children", "KADDRESSBOOK" );
339 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 339 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
340 "X-FreeBusyUrl", "KADDRESSBOOK" ); 340 "X-FreeBusyUrl", "KADDRESSBOOK" );
341#endif 341#endif
342 initGUI(); 342 initGUI();
343 343
344 mIncSearchWidget->setFocus(); 344 mIncSearchWidget->setFocus();
345 345
346 346
347 connect( mViewManager, SIGNAL( selected( const QString& ) ), 347 connect( mViewManager, SIGNAL( selected( const QString& ) ),
348 SLOT( setContactSelected( const QString& ) ) ); 348 SLOT( setContactSelected( const QString& ) ) );
349 connect( mViewManager, SIGNAL( executed( const QString& ) ), 349 connect( mViewManager, SIGNAL( executed( const QString& ) ),
350 SLOT( executeContact( const QString& ) ) ); 350 SLOT( executeContact( const QString& ) ) );
351 351
352 connect( mViewManager, SIGNAL( deleteRequest( ) ), 352 connect( mViewManager, SIGNAL( deleteRequest( ) ),
353 SLOT( deleteContacts( ) ) ); 353 SLOT( deleteContacts( ) ) );
354 connect( mViewManager, SIGNAL( modified() ), 354 connect( mViewManager, SIGNAL( modified() ),
355 SLOT( setModified() ) ); 355 SLOT( setModified() ) );
356 356
357 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 357 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
358 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 358 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
359 359
360 connect( mXXPortManager, SIGNAL( modified() ), 360 connect( mXXPortManager, SIGNAL( modified() ),
361 SLOT( setModified() ) ); 361 SLOT( setModified() ) );
362 362
363 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 363 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
364 SLOT( incrementalSearch( const QString& ) ) ); 364 SLOT( incrementalSearch( const QString& ) ) );
365 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 365 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
366 mJumpButtonBar, SLOT( recreateButtons() ) ); 366 mJumpButtonBar, SLOT( recreateButtons() ) );
367 367
368 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 368 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
369 SLOT( sendMail( const QString& ) ) ); 369 SLOT( sendMail( const QString& ) ) );
370 370
371 371
372 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 372 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
373 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&))); 373 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&)));
374 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 374 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
375 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 375 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
376 376
377 377
378#ifndef KAB_EMBEDDED 378#ifndef KAB_EMBEDDED
379 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 379 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
380 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 380 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
381 381
382 connect( mDetails, SIGNAL( browse( const QString& ) ), 382 connect( mDetails, SIGNAL( browse( const QString& ) ),
383 SLOT( browse( const QString& ) ) ); 383 SLOT( browse( const QString& ) ) );
384 384
385 385
386 mAddressBookService = new KAddressBookService( this ); 386 mAddressBookService = new KAddressBookService( this );
387 387
388#endif //KAB_EMBEDDED 388#endif //KAB_EMBEDDED
389 389
390 mMessageTimer = new QTimer( this ); 390 mMessageTimer = new QTimer( this );
391 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 391 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
392 mEditorDialog = 0; 392 mEditorDialog = 0;
393 createAddresseeEditorDialog( this ); 393 createAddresseeEditorDialog( this );
394 setModified( false ); 394 setModified( false );
395 mBRdisabled = false; 395 mBRdisabled = false;
396#ifndef DESKTOP_VERSION 396#ifndef DESKTOP_VERSION
397 infrared = 0; 397 infrared = 0;
398#endif 398#endif
399 //toggleBeamReceive( ); 399 //toggleBeamReceive( );
400 //mMainWindow->toolBar()->show(); 400 //mMainWindow->toolBar()->show();
401 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 401 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
402 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 402 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
403} 403}
404 404
405void KABCore::updateToolBar() 405void KABCore::updateToolBar()
406{ 406{
407 static int iii = 0; 407 static int iii = 0;
408 ++iii; 408 ++iii;
409 mMainWindow->toolBar()->repaintMe(); 409 mMainWindow->toolBar()->repaintMe();
410 if ( iii < 3 ) 410 if ( iii < 3 )
411 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 411 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
412} 412}
413KABCore::~KABCore() 413KABCore::~KABCore()
414{ 414{
415 // save(); 415 // save();
416 //saveSettings(); 416 //saveSettings();
417 //KABPrefs::instance()->writeConfig(); 417 //KABPrefs::instance()->writeConfig();
418 delete AddresseeConfig::instance(); 418 delete AddresseeConfig::instance();
419 mAddressBook = 0; 419 mAddressBook = 0;
420 KABC::StdAddressBook::close(); 420 KABC::StdAddressBook::close();
421 421
422 delete syncManager; 422 delete syncManager;
423#ifndef DESKTOP_VERSION 423#ifndef DESKTOP_VERSION
424 if ( infrared ) 424 if ( infrared )
425 delete infrared; 425 delete infrared;
426#endif 426#endif
427} 427}
428void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 428void KABCore::receive( const QCString& cmsg, const QByteArray& data )
429{ 429{
430 qDebug("KA: QCOP message received: %s ", cmsg.data() ); 430 //qDebug("KA: QCOP message received: %s ", cmsg.data() );
431 if ( cmsg == "setDocument(QString)" ) { 431 if ( cmsg == "setDocument(QString)" ) {
432 QDataStream stream( data, IO_ReadOnly ); 432 QDataStream stream( data, IO_ReadOnly );
433 QString fileName; 433 QString fileName;
434 stream >> fileName; 434 stream >> fileName;
435 recieve( fileName ); 435 recieve( fileName );
436 return; 436 return;
437 } 437 }
438} 438}
439void KABCore::toggleBeamReceive( ) 439void KABCore::toggleBeamReceive( )
440{ 440{
441 if ( mBRdisabled ) 441 if ( mBRdisabled )
442 return; 442 return;
443#ifndef DESKTOP_VERSION 443#ifndef DESKTOP_VERSION
444 if ( infrared ) { 444 if ( infrared ) {
445 qDebug("AB disable BeamReceive "); 445 qDebug("KA: AB disable BeamReceive ");
446 delete infrared; 446 delete infrared;
447 infrared = 0; 447 infrared = 0;
448 mActionBR->setChecked(false); 448 mActionBR->setChecked(false);
449 return; 449 return;
450 } 450 }
451 qDebug("AB enable BeamReceive "); 451 qDebug("KA: AB enable BeamReceive ");
452 mActionBR->setChecked(true); 452 mActionBR->setChecked(true);
453 453
454 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 454 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
455 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 455 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
456#endif 456#endif
457} 457}
458 458
459 459
460void KABCore::disableBR(bool b) 460void KABCore::disableBR(bool b)
461{ 461{
462#ifndef DESKTOP_VERSION 462#ifndef DESKTOP_VERSION
463 if ( b ) { 463 if ( b ) {
464 if ( infrared ) { 464 if ( infrared ) {
465 toggleBeamReceive( ); 465 toggleBeamReceive( );
466 } 466 }
467 mBRdisabled = true; 467 mBRdisabled = true;
468 } else { 468 } else {
469 if ( mBRdisabled ) { 469 if ( mBRdisabled ) {
470 mBRdisabled = false; 470 mBRdisabled = false;
471 //toggleBeamReceive( ); 471 //toggleBeamReceive( );
472 } 472 }
473 } 473 }
474#endif 474#endif
475 475
476} 476}
477void KABCore::recieve( QString fn ) 477void KABCore::recieve( QString fn )
478{ 478{
479 //qDebug("KABCore::recieve "); 479 //qDebug("KABCore::recieve ");
480 int count = mAddressBook->importFromFile( fn, true ); 480 int count = mAddressBook->importFromFile( fn, true );
481 if ( count ) 481 if ( count )
482 setModified( true ); 482 setModified( true );
483 mViewManager->refreshView(); 483 mViewManager->refreshView();
484 message(i18n("%1 contact(s) received!").arg( count )); 484 message(i18n("%1 contact(s) received!").arg( count ));
485 topLevelWidget()->showMaximized(); 485 topLevelWidget()->showMaximized();
486 topLevelWidget()->raise(); 486 topLevelWidget()->raise();
487} 487}
488void KABCore::restoreSettings() 488void KABCore::restoreSettings()
489{ 489{
490 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 490 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
491 491
492 bool state; 492 bool state;
493 493
494 if (mMultipleViewsAtOnce) 494 if (mMultipleViewsAtOnce)
495 state = KABPrefs::instance()->mDetailsPageVisible; 495 state = KABPrefs::instance()->mDetailsPageVisible;
496 else 496 else
497 state = false; 497 state = false;
498 498
499 mActionDetails->setChecked( state ); 499 mActionDetails->setChecked( state );
500 setDetailsVisible( state ); 500 setDetailsVisible( state );
501 501
502 state = KABPrefs::instance()->mJumpButtonBarVisible; 502 state = KABPrefs::instance()->mJumpButtonBarVisible;
503 503
504 mActionJumpBar->setChecked( state ); 504 mActionJumpBar->setChecked( state );
505 setJumpButtonBarVisible( state ); 505 setJumpButtonBarVisible( state );
506/*US 506/*US
507 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 507 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
508 if ( splitterSize.count() == 0 ) { 508 if ( splitterSize.count() == 0 ) {
509 splitterSize.append( width() / 2 ); 509 splitterSize.append( width() / 2 );
510 splitterSize.append( width() / 2 ); 510 splitterSize.append( width() / 2 );
511 } 511 }
512 mMiniSplitter->setSizes( splitterSize ); 512 mMiniSplitter->setSizes( splitterSize );
513 if ( mExtensionBarSplitter ) { 513 if ( mExtensionBarSplitter ) {
514 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 514 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
515 if ( splitterSize.count() == 0 ) { 515 if ( splitterSize.count() == 0 ) {
516 splitterSize.append( width() / 2 ); 516 splitterSize.append( width() / 2 );
517 splitterSize.append( width() / 2 ); 517 splitterSize.append( width() / 2 );
518 } 518 }
519 mExtensionBarSplitter->setSizes( splitterSize ); 519 mExtensionBarSplitter->setSizes( splitterSize );
520 520
521 } 521 }
522*/ 522*/
523 mViewManager->restoreSettings(); 523 mViewManager->restoreSettings();
524 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 524 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
525 mExtensionManager->restoreSettings(); 525 mExtensionManager->restoreSettings();
526#ifdef DESKTOP_VERSION 526#ifdef DESKTOP_VERSION
527 int wid = width(); 527 int wid = width();
528 if ( wid < 10 ) 528 if ( wid < 10 )
529 wid = 400; 529 wid = 400;
530#else 530#else
531 int wid = QApplication::desktop()->width(); 531 int wid = QApplication::desktop()->width();
532 if ( wid < 640 ) 532 if ( wid < 640 )
533 wid = QApplication::desktop()->height(); 533 wid = QApplication::desktop()->height();
534#endif 534#endif
535 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 535 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
536 if ( true /*splitterSize.count() == 0*/ ) { 536 if ( true /*splitterSize.count() == 0*/ ) {
537 splitterSize.append( wid / 2 ); 537 splitterSize.append( wid / 2 );
538 splitterSize.append( wid / 2 ); 538 splitterSize.append( wid / 2 );
539 } 539 }
540 mMiniSplitter->setSizes( splitterSize ); 540 mMiniSplitter->setSizes( splitterSize );
541 if ( mExtensionBarSplitter ) { 541 if ( mExtensionBarSplitter ) {
542 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 542 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
543 if ( true /*splitterSize.count() == 0*/ ) { 543 if ( true /*splitterSize.count() == 0*/ ) {
544 splitterSize.append( wid / 2 ); 544 splitterSize.append( wid / 2 );
545 splitterSize.append( wid / 2 ); 545 splitterSize.append( wid / 2 );
546 } 546 }
547 mExtensionBarSplitter->setSizes( splitterSize ); 547 mExtensionBarSplitter->setSizes( splitterSize );
548 548
549 } 549 }
550 550
551 551
552} 552}
553 553
554void KABCore::saveSettings() 554void KABCore::saveSettings()
555{ 555{
556 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 556 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
557 if ( mExtensionBarSplitter ) 557 if ( mExtensionBarSplitter )
558 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 558 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
559 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 559 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
560 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 560 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
561#ifndef KAB_EMBEDDED 561#ifndef KAB_EMBEDDED
562 562
563 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 563 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
564 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 564 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
565#endif //KAB_EMBEDDED 565#endif //KAB_EMBEDDED
566 mExtensionManager->saveSettings(); 566 mExtensionManager->saveSettings();
567 mViewManager->saveSettings(); 567 mViewManager->saveSettings();
568 568
569 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 569 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
570 KABPrefs::instance()->writeConfig(); 570 KABPrefs::instance()->writeConfig();
571 qDebug("KABCore::saveSettings() "); 571 qDebug("KA: KABCore::saveSettings() ");
572} 572}
573 573
574KABC::AddressBook *KABCore::addressBook() const 574KABC::AddressBook *KABCore::addressBook() const
575{ 575{
576 return mAddressBook; 576 return mAddressBook;
577} 577}
578 578
579KConfig *KABCore::config() 579KConfig *KABCore::config()
580{ 580{
581#ifndef KAB_EMBEDDED 581#ifndef KAB_EMBEDDED
582 return KABPrefs::instance()->config(); 582 return KABPrefs::instance()->config();
583#else //KAB_EMBEDDED 583#else //KAB_EMBEDDED
584 return KABPrefs::instance()->getConfig(); 584 return KABPrefs::instance()->getConfig();
585#endif //KAB_EMBEDDED 585#endif //KAB_EMBEDDED
586} 586}
587 587
588KActionCollection *KABCore::actionCollection() const 588KActionCollection *KABCore::actionCollection() const
589{ 589{
590 return mGUIClient->actionCollection(); 590 return mGUIClient->actionCollection();
591} 591}
592 592
593KABC::Field *KABCore::currentSearchField() const 593KABC::Field *KABCore::currentSearchField() const
594{ 594{
595 if (mIncSearchWidget) 595 if (mIncSearchWidget)
596 return mIncSearchWidget->currentField(); 596 return mIncSearchWidget->currentField();
597 else 597 else
598 return 0; 598 return 0;
599} 599}
600 600
601QStringList KABCore::selectedUIDs() const 601QStringList KABCore::selectedUIDs() const
602{ 602{
603 return mViewManager->selectedUids(); 603 return mViewManager->selectedUids();
604} 604}
605 605
606KABC::Resource *KABCore::requestResource( QWidget *parent ) 606KABC::Resource *KABCore::requestResource( QWidget *parent )
607{ 607{
608 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 608 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
609 609
610 QPtrList<KRES::Resource> kresResources; 610 QPtrList<KRES::Resource> kresResources;
611 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 611 QPtrListIterator<KABC::Resource> resIt( kabcResources );
612 KABC::Resource *resource; 612 KABC::Resource *resource;
613 while ( ( resource = resIt.current() ) != 0 ) { 613 while ( ( resource = resIt.current() ) != 0 ) {
614 ++resIt; 614 ++resIt;
615 if ( !resource->readOnly() ) { 615 if ( !resource->readOnly() ) {
616 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 616 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
617 if ( res ) 617 if ( res )
618 kresResources.append( res ); 618 kresResources.append( res );
619 } 619 }
620 } 620 }
621 621
622 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 622 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
623 return static_cast<KABC::Resource*>( res ); 623 return static_cast<KABC::Resource*>( res );
624} 624}
625 625
626#ifndef KAB_EMBEDDED 626#ifndef KAB_EMBEDDED
627KAboutData *KABCore::createAboutData() 627KAboutData *KABCore::createAboutData()
628#else //KAB_EMBEDDED 628#else //KAB_EMBEDDED
629void KABCore::createAboutData() 629void KABCore::createAboutData()
630#endif //KAB_EMBEDDED 630#endif //KAB_EMBEDDED
631{ 631{
632#ifndef KAB_EMBEDDED 632#ifndef KAB_EMBEDDED
633 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 633 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
634 "3.1", I18N_NOOP( "The KDE Address Book" ), 634 "3.1", I18N_NOOP( "The KDE Address Book" ),
635 KAboutData::License_GPL_V2, 635 KAboutData::License_GPL_V2,
636 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 636 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
637 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 637 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
638 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 638 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
639 about->addAuthor( "Cornelius Schumacher", 639 about->addAuthor( "Cornelius Schumacher",
640 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 640 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
641 "schumacher@kde.org" ); 641 "schumacher@kde.org" );
642 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 642 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
643 "mpilone@slac.com" ); 643 "mpilone@slac.com" );
644 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 644 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
645 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 645 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
646 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 646 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
647 "michel@klaralvdalens-datakonsult.se" ); 647 "michel@klaralvdalens-datakonsult.se" );
648 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 648 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
649 "hansen@kde.org" ); 649 "hansen@kde.org" );
650 650
651 return about; 651 return about;
652#endif //KAB_EMBEDDED 652#endif //KAB_EMBEDDED
653 653
654 QString version; 654 QString version;
655#include <../version> 655#include <../version>
656 QMessageBox::about( this, "About KAddressbook/Pi", 656 QMessageBox::about( this, "About KAddressbook/Pi",
657 "KAddressbook/Platform-independent\n" 657 "KAddressbook/Platform-independent\n"
658 "(KA/Pi) " +version + " - " + 658 "(KA/Pi) " +version + " - " +
659#ifdef DESKTOP_VERSION 659#ifdef DESKTOP_VERSION
660 "Desktop Edition\n" 660 "Desktop Edition\n"
661#else 661#else
662 "PDA-Edition\n" 662 "PDA-Edition\n"
663 "for: Zaurus 5500 / 7x0 / 8x0\n" 663 "for: Zaurus 5500 / 7x0 / 8x0\n"
664#endif 664#endif
665 665
666 "(c) 2004 Ulf Schenk\n" 666 "(c) 2004 Ulf Schenk\n"
667 "(c) 2004 Lutz Rogowski\n" 667 "(c) 2004 Lutz Rogowski\n"
668 "(c) 1997-2003, The KDE PIM Team\n" 668 "(c) 1997-2003, The KDE PIM Team\n"
669 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 669 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
670 "Don Sanders Original author\n" 670 "Don Sanders Original author\n"
671 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 671 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
672 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 672 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
673 "Greg Stern DCOP interface\n" 673 "Greg Stern DCOP interface\n"
674 "Mark Westcot Contact pinning\n" 674 "Mark Westcot Contact pinning\n"
675 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 675 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
676 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 676 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
677#ifdef _WIN32_ 677#ifdef _WIN32_
678 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 678 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
679#endif 679#endif
680 ); 680 );
681} 681}
682 682
683void KABCore::setContactSelected( const QString &uid ) 683void KABCore::setContactSelected( const QString &uid )
684{ 684{
685 KABC::Addressee addr = mAddressBook->findByUid( uid ); 685 KABC::Addressee addr = mAddressBook->findByUid( uid );
686 if ( !mDetails->isHidden() ) 686 if ( !mDetails->isHidden() )
687 mDetails->setAddressee( addr ); 687 mDetails->setAddressee( addr );
688 688
689 if ( !addr.isEmpty() ) { 689 if ( !addr.isEmpty() ) {
690 emit contactSelected( addr.formattedName() ); 690 emit contactSelected( addr.formattedName() );
691 KABC::Picture pic = addr.photo(); 691 KABC::Picture pic = addr.photo();
692 if ( pic.isIntern() ) { 692 if ( pic.isIntern() ) {
693//US emit contactSelected( pic.data() ); 693//US emit contactSelected( pic.data() );
694//US instead use: 694//US instead use:
695 QPixmap px; 695 QPixmap px;
696 if (pic.data().isNull() != true) 696 if (pic.data().isNull() != true)
697 { 697 {
698 px.convertFromImage(pic.data()); 698 px.convertFromImage(pic.data());
699 } 699 }
700 700
701 emit contactSelected( px ); 701 emit contactSelected( px );
702 } 702 }
703 } 703 }
704 704
705 705
706 mExtensionManager->setSelectionChanged(); 706 mExtensionManager->setSelectionChanged();
707 707
708 // update the actions 708 // update the actions
709 bool selected = !uid.isEmpty(); 709 bool selected = !uid.isEmpty();
710 710
711 if ( mReadWrite ) { 711 if ( mReadWrite ) {
712 mActionCut->setEnabled( selected ); 712 mActionCut->setEnabled( selected );
713 mActionPaste->setEnabled( selected ); 713 mActionPaste->setEnabled( selected );
714 } 714 }
715 715
716 mActionCopy->setEnabled( selected ); 716 mActionCopy->setEnabled( selected );
717 mActionDelete->setEnabled( selected ); 717 mActionDelete->setEnabled( selected );
718 mActionEditAddressee->setEnabled( selected ); 718 mActionEditAddressee->setEnabled( selected );
719 mActionMail->setEnabled( selected ); 719 mActionMail->setEnabled( selected );
720 mActionMailVCard->setEnabled( selected ); 720 mActionMailVCard->setEnabled( selected );
721 //if (mActionBeam) 721 //if (mActionBeam)
722 //mActionBeam->setEnabled( selected ); 722 //mActionBeam->setEnabled( selected );
723 mActionWhoAmI->setEnabled( selected ); 723 mActionWhoAmI->setEnabled( selected );
724} 724}
725 725
726void KABCore::sendMail() 726void KABCore::sendMail()
727{ 727{
728 sendMail( mViewManager->selectedEmails().join( ", " ) ); 728 sendMail( mViewManager->selectedEmails().join( ", " ) );
729} 729}
730 730
731void KABCore::sendMail( const QString& emaillist ) 731void KABCore::sendMail( const QString& emaillist )
732{ 732{
733 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 733 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
734 if (emaillist.contains(",") > 0) 734 if (emaillist.contains(",") > 0)
735 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 735 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
736 else 736 else
737 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 737 ExternalAppHandler::instance()->mailToOneContact( emaillist );
738} 738}
739 739
740 740
741 741
742void KABCore::mailVCard() 742void KABCore::mailVCard()
743{ 743{
744 QStringList uids = mViewManager->selectedUids(); 744 QStringList uids = mViewManager->selectedUids();
745 if ( !uids.isEmpty() ) 745 if ( !uids.isEmpty() )
746 mailVCard( uids ); 746 mailVCard( uids );
747} 747}
748 748
749void KABCore::mailVCard( const QStringList& uids ) 749void KABCore::mailVCard( const QStringList& uids )
750{ 750{
751 QStringList urls; 751 QStringList urls;
752 752
753// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 753// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
754 754
755 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 755 QString dirName = "/tmp/" + KApplication::randomString( 8 );
756 756
757 757
758 758
759 QDir().mkdir( dirName, true ); 759 QDir().mkdir( dirName, true );
760 760
761 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 761 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
762 KABC::Addressee a = mAddressBook->findByUid( *it ); 762 KABC::Addressee a = mAddressBook->findByUid( *it );
763 763
764 if ( a.isEmpty() ) 764 if ( a.isEmpty() )
765 continue; 765 continue;
766 766
767 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 767 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
768 768
769 QString fileName = dirName + "/" + name; 769 QString fileName = dirName + "/" + name;
770 770
771 QFile outFile(fileName); 771 QFile outFile(fileName);
772 772
773 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 773 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
774 KABC::VCardConverter converter; 774 KABC::VCardConverter converter;
775 QString vcard; 775 QString vcard;
776 776
777 converter.addresseeToVCard( a, vcard ); 777 converter.addresseeToVCard( a, vcard );
778 778
779 QTextStream t( &outFile ); // use a text stream 779 QTextStream t( &outFile ); // use a text stream
780 t.setEncoding( QTextStream::UnicodeUTF8 ); 780 t.setEncoding( QTextStream::UnicodeUTF8 );
781 t << vcard; 781 t << vcard;
782 782
783 outFile.close(); 783 outFile.close();
784 784
785 urls.append( fileName ); 785 urls.append( fileName );
786 } 786 }
787 } 787 }
788 788
789 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 789 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
790 790
791 791
792/*US 792/*US
793 kapp->invokeMailer( QString::null, QString::null, QString::null, 793 kapp->invokeMailer( QString::null, QString::null, QString::null,
794 QString::null, // subject 794 QString::null, // subject
795 QString::null, // body 795 QString::null, // body
796 QString::null, 796 QString::null,
797 urls ); // attachments 797 urls ); // attachments
798*/ 798*/
799 799
800} 800}
801 801
802/** 802/**
803 Beams the "WhoAmI contact. 803 Beams the "WhoAmI contact.
804*/ 804*/
805void KABCore::beamMySelf() 805void KABCore::beamMySelf()
806{ 806{
807 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 807 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
808 if (!a.isEmpty()) 808 if (!a.isEmpty())
809 { 809 {
810 QStringList uids; 810 QStringList uids;
811 uids << a.uid(); 811 uids << a.uid();
812 812
813 beamVCard(uids); 813 beamVCard(uids);
814 } else { 814 } else {
815 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 815 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
816 816
817 817
818 } 818 }
819} 819}
820void KABCore::updateMainWindow() 820void KABCore::updateMainWindow()
821{ 821{
822 822
823 mMainWindow->showMaximized(); 823 mMainWindow->showMaximized();
824 mMainWindow->update(); 824 mMainWindow->update();
825} 825}
826void KABCore::resizeEvent(QResizeEvent* e ) 826void KABCore::resizeEvent(QResizeEvent* e )
827{ 827{
828 if ( !mMiniSplitter ) 828 if ( !mMiniSplitter )
829 return; 829 return;
830 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); 830 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) ");
831 if ( QApplication::desktop()->width() >= 480 ) { 831 if ( QApplication::desktop()->width() >= 480 ) {
832 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 832 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
833 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 833 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
834 mMiniSplitter->setOrientation( Qt::Horizontal); 834 mMiniSplitter->setOrientation( Qt::Horizontal);
835 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 835 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
836 if ( QApplication::desktop()->width() <= 640 ) { 836 if ( QApplication::desktop()->width() <= 640 ) {
837 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 837 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
838 mViewManager->getFilterAction()->setComboWidth( 150 ); 838 mViewManager->getFilterAction()->setComboWidth( 150 );
839 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 839 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
840 } 840 }
841 } 841 }
842 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 842 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
843 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 843 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
844 mMiniSplitter->setOrientation( Qt::Vertical ); 844 mMiniSplitter->setOrientation( Qt::Vertical );
845 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 845 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
846 if ( QApplication::desktop()->width() <= 640 ) { 846 if ( QApplication::desktop()->width() <= 640 ) {
847 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 847 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
848 mMainWindow->showMinimized(); 848 mMainWindow->showMinimized();
849 mViewManager->getFilterAction()->setComboWidth( 0 ); 849 mViewManager->getFilterAction()->setComboWidth( 0 );
850 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 850 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
851 } 851 }
852 } 852 }
853 } 853 }
854 } 854 }
855 855
856} 856}
857void KABCore::export2phone() 857void KABCore::export2phone()
858{ 858{
859 859
860 QStringList uids; 860 QStringList uids;
861 XXPortSelectDialog dlg( this, false, this ); 861 XXPortSelectDialog dlg( this, false, this );
862 if ( dlg.exec() ) 862 if ( dlg.exec() )
863 uids = dlg.uids(); 863 uids = dlg.uids();
864 else 864 else
865 return; 865 return;
866 if ( uids.isEmpty() ) 866 if ( uids.isEmpty() )
867 return; 867 return;
868 // qDebug("count %d ", uids.count()); 868 // qDebug("count %d ", uids.count());
869 869
870 KAex2phonePrefs ex2phone; 870 KAex2phonePrefs ex2phone;
871 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 871 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
872 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 872 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
873 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 873 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
874 874
875 if ( !ex2phone.exec() ) { 875 if ( !ex2phone.exec() ) {
876 return; 876 return;
877 } 877 }
878 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 878 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
879 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 879 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
880 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 880 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
881 881
882 882
883 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 883 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
884 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 884 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
885 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 885 KPimGlobalPrefs::instance()->mEx2PhoneModel );
886 886
887 QString fileName = getPhoneFile(); 887 QString fileName = getPhoneFile();
888 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 888 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
889 return; 889 return;
890 890
891 message(i18n("Exporting to phone...")); 891 message(i18n("Exporting to phone..."));
892 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 892 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
893 893
894} 894}
895QString KABCore::getPhoneFile() 895QString KABCore::getPhoneFile()
896{ 896{
897#ifdef DESKTOP_VERSION 897#ifdef DESKTOP_VERSION
898 return locateLocal("tmp", "phonefile.vcf"); 898 return locateLocal("tmp", "phonefile.vcf");
899#else 899#else
900 return "/tmp/phonefile.vcf"; 900 return "/tmp/phonefile.vcf";
901#endif 901#endif
902 902
903} 903}
904void KABCore::writeToPhone( ) 904void KABCore::writeToPhone( )
905{ 905{
906 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 906 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
907 message(i18n("Export to phone finished!")); 907 message(i18n("Export to phone finished!"));
908 else 908 else
909 qDebug(i18n("Error exporting to phone")); 909 qDebug(i18n("KA: Error exporting to phone"));
910} 910}
911void KABCore::beamVCard() 911void KABCore::beamVCard()
912{ 912{
913 QStringList uids; 913 QStringList uids;
914 XXPortSelectDialog dlg( this, false, this ); 914 XXPortSelectDialog dlg( this, false, this );
915 if ( dlg.exec() ) 915 if ( dlg.exec() )
916 uids = dlg.uids(); 916 uids = dlg.uids();
917 else 917 else
918 return; 918 return;
919 if ( uids.isEmpty() ) 919 if ( uids.isEmpty() )
920 return; 920 return;
921 beamVCard( uids ); 921 beamVCard( uids );
922} 922}
923 923
924 924
925void KABCore::beamVCard(const QStringList& uids) 925void KABCore::beamVCard(const QStringList& uids)
926{ 926{
927 927
928 // LR: we should use the /tmp dir on the Zaurus, 928 // LR: we should use the /tmp dir on the Zaurus,
929 // because: /tmp = RAM, (HOME)/kdepim = flash memory 929 // because: /tmp = RAM, (HOME)/kdepim = flash memory
930 930
931#ifdef DESKTOP_VERSION 931#ifdef DESKTOP_VERSION
932 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 932 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
933#else 933#else
934 QString fileName = "/tmp/kapibeamfile.vcf"; 934 QString fileName = "/tmp/kapibeamfile.vcf";
935#endif 935#endif
936 936
937 KABC::VCardConverter converter; 937 KABC::VCardConverter converter;
938 QString description; 938 QString description;
939 QString datastream; 939 QString datastream;
940 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 940 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
941 KABC::Addressee a = mAddressBook->findByUid( *it ); 941 KABC::Addressee a = mAddressBook->findByUid( *it );
942 942
943 if ( a.isEmpty() ) 943 if ( a.isEmpty() )
944 continue; 944 continue;
945 945
946 if (description.isEmpty()) 946 if (description.isEmpty())
947 description = a.formattedName(); 947 description = a.formattedName();
948 948
949 QString vcard; 949 QString vcard;
950 converter.addresseeToVCard( a, vcard ); 950 converter.addresseeToVCard( a, vcard );
951 int start = 0; 951 int start = 0;
952 int next; 952 int next;
953 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 953 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
954 int semi = vcard.find(";", next); 954 int semi = vcard.find(";", next);
955 int dopp = vcard.find(":", next); 955 int dopp = vcard.find(":", next);
956 int sep; 956 int sep;
957 if ( semi < dopp && semi >= 0 ) 957 if ( semi < dopp && semi >= 0 )
958 sep = semi ; 958 sep = semi ;
959 else 959 else
960 sep = dopp; 960 sep = dopp;
961 datastream +=vcard.mid( start, next - start); 961 datastream +=vcard.mid( start, next - start);
962 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 962 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
963 start = sep; 963 start = sep;
964 } 964 }
965 datastream += vcard.mid( start,vcard.length() ); 965 datastream += vcard.mid( start,vcard.length() );
966 } 966 }
967#ifndef DESKTOP_VERSION 967#ifndef DESKTOP_VERSION
968 QFile outFile(fileName); 968 QFile outFile(fileName);
969 if ( outFile.open(IO_WriteOnly) ) { 969 if ( outFile.open(IO_WriteOnly) ) {
970 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 970 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
971 QTextStream t( &outFile ); // use a text stream 971 QTextStream t( &outFile ); // use a text stream
972 //t.setEncoding( QTextStream::UnicodeUTF8 ); 972 //t.setEncoding( QTextStream::UnicodeUTF8 );
973 t.setEncoding( QTextStream::Latin1 ); 973 t.setEncoding( QTextStream::Latin1 );
974 t <<datastream.latin1(); 974 t <<datastream.latin1();
975 outFile.close(); 975 outFile.close();
976 Ir *ir = new Ir( this ); 976 Ir *ir = new Ir( this );
977 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 977 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
978 ir->send( fileName, description, "text/x-vCard" ); 978 ir->send( fileName, description, "text/x-vCard" );
979 } else { 979 } else {
980 qDebug("Error open temp beam file "); 980 qDebug("KA: Error open temp beam file ");
981 return; 981 return;
982 } 982 }
983#endif 983#endif
984 984
985} 985}
986 986
987void KABCore::beamDone( Ir *ir ) 987void KABCore::beamDone( Ir *ir )
988{ 988{
989#ifndef DESKTOP_VERSION 989#ifndef DESKTOP_VERSION
990 delete ir; 990 delete ir;
991#endif 991#endif
992 topLevelWidget()->raise(); 992 topLevelWidget()->raise();
993 message( i18n("Beaming finished!") ); 993 message( i18n("Beaming finished!") );
994} 994}
995 995
996 996
997void KABCore::browse( const QString& url ) 997void KABCore::browse( const QString& url )
998{ 998{
999#ifndef KAB_EMBEDDED 999#ifndef KAB_EMBEDDED
1000 kapp->invokeBrowser( url ); 1000 kapp->invokeBrowser( url );
1001#else //KAB_EMBEDDED 1001#else //KAB_EMBEDDED
1002 qDebug("KABCore::browse must be fixed"); 1002 qDebug("KABCore::browse must be fixed");
1003#endif //KAB_EMBEDDED 1003#endif //KAB_EMBEDDED
1004} 1004}
1005 1005
1006void KABCore::selectAllContacts() 1006void KABCore::selectAllContacts()
1007{ 1007{
1008 mViewManager->setSelected( QString::null, true ); 1008 mViewManager->setSelected( QString::null, true );
1009} 1009}
1010 1010
1011void KABCore::deleteContacts() 1011void KABCore::deleteContacts()
1012{ 1012{
1013 QStringList uidList = mViewManager->selectedUids(); 1013 QStringList uidList = mViewManager->selectedUids();
1014 deleteContacts( uidList ); 1014 deleteContacts( uidList );
1015} 1015}
1016 1016
1017void KABCore::deleteContacts( const QStringList &uids ) 1017void KABCore::deleteContacts( const QStringList &uids )
1018{ 1018{
1019 if ( uids.count() > 0 ) { 1019 if ( uids.count() > 0 ) {
1020 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 1020 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
1021 UndoStack::instance()->push( command ); 1021 UndoStack::instance()->push( command );
1022 RedoStack::instance()->clear(); 1022 RedoStack::instance()->clear();
1023 1023
1024 // now if we deleted anything, refresh 1024 // now if we deleted anything, refresh
1025 setContactSelected( QString::null ); 1025 setContactSelected( QString::null );
1026 setModified( true ); 1026 setModified( true );
1027 } 1027 }
1028} 1028}
1029 1029
1030void KABCore::copyContacts() 1030void KABCore::copyContacts()
1031{ 1031{
1032 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1032 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1033 1033
1034 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 1034 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
1035 1035
1036 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 1036 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
1037 1037
1038 QClipboard *cb = QApplication::clipboard(); 1038 QClipboard *cb = QApplication::clipboard();
1039 cb->setText( clipText ); 1039 cb->setText( clipText );
1040} 1040}
1041 1041
1042void KABCore::cutContacts() 1042void KABCore::cutContacts()
1043{ 1043{
1044 QStringList uidList = mViewManager->selectedUids(); 1044 QStringList uidList = mViewManager->selectedUids();
1045 1045
1046//US if ( uidList.size() > 0 ) { 1046//US if ( uidList.size() > 0 ) {
1047 if ( uidList.count() > 0 ) { 1047 if ( uidList.count() > 0 ) {
1048 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1048 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1049 UndoStack::instance()->push( command ); 1049 UndoStack::instance()->push( command );
1050 RedoStack::instance()->clear(); 1050 RedoStack::instance()->clear();
1051 1051
1052 setModified( true ); 1052 setModified( true );
1053 } 1053 }
1054} 1054}
1055 1055
1056void KABCore::pasteContacts() 1056void KABCore::pasteContacts()
1057{ 1057{
1058 QClipboard *cb = QApplication::clipboard(); 1058 QClipboard *cb = QApplication::clipboard();
1059 1059
1060 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1060 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1061 1061
1062 pasteContacts( list ); 1062 pasteContacts( list );
1063} 1063}
1064 1064
1065void KABCore::pasteContacts( KABC::Addressee::List &list ) 1065void KABCore::pasteContacts( KABC::Addressee::List &list )
1066{ 1066{
1067 KABC::Resource *resource = requestResource( this ); 1067 KABC::Resource *resource = requestResource( this );
1068 KABC::Addressee::List::Iterator it; 1068 KABC::Addressee::List::Iterator it;
1069 for ( it = list.begin(); it != list.end(); ++it ) 1069 for ( it = list.begin(); it != list.end(); ++it )
1070 (*it).setResource( resource ); 1070 (*it).setResource( resource );
1071 1071
1072 PwPasteCommand *command = new PwPasteCommand( this, list ); 1072 PwPasteCommand *command = new PwPasteCommand( this, list );
1073 UndoStack::instance()->push( command ); 1073 UndoStack::instance()->push( command );
1074 RedoStack::instance()->clear(); 1074 RedoStack::instance()->clear();
1075 1075
1076 setModified( true ); 1076 setModified( true );
1077} 1077}
1078 1078
1079void KABCore::setWhoAmI() 1079void KABCore::setWhoAmI()
1080{ 1080{
1081 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1081 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1082 1082
1083 if ( addrList.count() > 1 ) { 1083 if ( addrList.count() > 1 ) {
1084 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1084 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1085 return; 1085 return;
1086 } 1086 }
1087 1087
1088 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1088 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1089 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 1089 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
1090 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1090 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1091} 1091}
1092void KABCore::editCategories() 1092void KABCore::editCategories()
1093{ 1093{
1094 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1094 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1095 dlg.exec(); 1095 dlg.exec();
1096} 1096}
1097void KABCore::setCategories() 1097void KABCore::setCategories()
1098{ 1098{
1099 1099
1100 QStringList uids; 1100 QStringList uids;
1101 XXPortSelectDialog dlgx( this, false, this ); 1101 XXPortSelectDialog dlgx( this, false, this );
1102 if ( dlgx.exec() ) 1102 if ( dlgx.exec() )
1103 uids = dlgx.uids(); 1103 uids = dlgx.uids();
1104 else 1104 else
1105 return; 1105 return;
1106 if ( uids.isEmpty() ) 1106 if ( uids.isEmpty() )
1107 return; 1107 return;
1108 // qDebug("count %d ", uids.count()); 1108 // qDebug("count %d ", uids.count());
1109 1109
1110 1110
1111 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1111 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1112 if ( !dlg.exec() ) { 1112 if ( !dlg.exec() ) {
1113 message( i18n("Setting categories cancelled") ); 1113 message( i18n("Setting categories cancelled") );
1114 return; 1114 return;
1115 } 1115 }
1116 bool merge = false; 1116 bool merge = false;
1117 QString msg = i18n( "Merge with existing categories?" ); 1117 QString msg = i18n( "Merge with existing categories?" );
1118 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1118 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1119 merge = true; 1119 merge = true;
1120 1120
1121 message( i18n("Setting categories ... please wait!") ); 1121 message( i18n("Setting categories ... please wait!") );
1122 QStringList categories = dlg.selectedCategories(); 1122 QStringList categories = dlg.selectedCategories();
1123 1123
1124 //QStringList uids = mViewManager->selectedUids(); 1124 //QStringList uids = mViewManager->selectedUids();
1125 QStringList::Iterator it; 1125 QStringList::Iterator it;
1126 for ( it = uids.begin(); it != uids.end(); ++it ) { 1126 for ( it = uids.begin(); it != uids.end(); ++it ) {
1127 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1127 KABC::Addressee addr = mAddressBook->findByUid( *it );
1128 if ( !addr.isEmpty() ) { 1128 if ( !addr.isEmpty() ) {
1129 if ( !merge ) 1129 if ( !merge )
1130 addr.setCategories( categories ); 1130 addr.setCategories( categories );
1131 else { 1131 else {
1132 QStringList addrCategories = addr.categories(); 1132 QStringList addrCategories = addr.categories();
1133 QStringList::Iterator catIt; 1133 QStringList::Iterator catIt;
1134 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1134 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1135 if ( !addrCategories.contains( *catIt ) ) 1135 if ( !addrCategories.contains( *catIt ) )
1136 addrCategories.append( *catIt ); 1136 addrCategories.append( *catIt );
1137 } 1137 }
1138 addr.setCategories( addrCategories ); 1138 addr.setCategories( addrCategories );
1139 } 1139 }
1140 mAddressBook->insertAddressee( addr ); 1140 mAddressBook->insertAddressee( addr );
1141 } 1141 }
1142 } 1142 }
1143 1143
1144 if ( uids.count() > 0 ) 1144 if ( uids.count() > 0 )
1145 setModified( true ); 1145 setModified( true );
1146 message( i18n("Setting categories completed!") ); 1146 message( i18n("Setting categories completed!") );
1147} 1147}
1148 1148
1149void KABCore::setSearchFields( const KABC::Field::List &fields ) 1149void KABCore::setSearchFields( const KABC::Field::List &fields )
1150{ 1150{
1151 mIncSearchWidget->setFields( fields ); 1151 mIncSearchWidget->setFields( fields );
1152} 1152}
1153 1153
1154void KABCore::incrementalSearch( const QString& text ) 1154void KABCore::incrementalSearch( const QString& text )
1155{ 1155{
1156 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1156 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1157} 1157}
1158 1158
1159void KABCore::setModified() 1159void KABCore::setModified()
1160{ 1160{
1161 setModified( true ); 1161 setModified( true );
1162} 1162}
1163 1163
1164void KABCore::setModifiedWOrefresh() 1164void KABCore::setModifiedWOrefresh()
1165{ 1165{
1166 // qDebug("KABCore::setModifiedWOrefresh() "); 1166 // qDebug("KABCore::setModifiedWOrefresh() ");
1167 mModified = true; 1167 mModified = true;
1168 mActionSave->setEnabled( mModified ); 1168 mActionSave->setEnabled( mModified );
1169 1169
1170 1170
1171} 1171}
1172void KABCore::setModified( bool modified ) 1172void KABCore::setModified( bool modified )
1173{ 1173{
1174 mModified = modified; 1174 mModified = modified;
1175 mActionSave->setEnabled( mModified ); 1175 mActionSave->setEnabled( mModified );
1176 1176
1177 if ( modified ) 1177 if ( modified )
1178 mJumpButtonBar->recreateButtons(); 1178 mJumpButtonBar->recreateButtons();
1179 1179
1180 mViewManager->refreshView(); 1180 mViewManager->refreshView();
1181 1181
1182} 1182}
1183 1183
1184bool KABCore::modified() const 1184bool KABCore::modified() const
1185{ 1185{
1186 return mModified; 1186 return mModified;
1187} 1187}
1188 1188
1189void KABCore::contactModified( const KABC::Addressee &addr ) 1189void KABCore::contactModified( const KABC::Addressee &addr )
1190{ 1190{
1191 addrModified( addr ); 1191 addrModified( addr );
1192#if 0 // debug only 1192#if 0 // debug only
1193 KABC::Addressee ad = addr; 1193 KABC::Addressee ad = addr;
1194 ad.computeCsum( "123"); 1194 ad.computeCsum( "123");
1195#endif 1195#endif
1196} 1196}
1197 1197
1198void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) 1198void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
1199{ 1199{
1200 1200
1201 Command *command = 0; 1201 Command *command = 0;
1202 QString uid; 1202 QString uid;
1203 1203
1204 // check if it exists already 1204 // check if it exists already
1205 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1205 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1206 if ( origAddr.isEmpty() ) 1206 if ( origAddr.isEmpty() )
1207 command = new PwNewCommand( mAddressBook, addr ); 1207 command = new PwNewCommand( mAddressBook, addr );
1208 else { 1208 else {
1209 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1209 command = new PwEditCommand( mAddressBook, origAddr, addr );
1210 uid = addr.uid(); 1210 uid = addr.uid();
1211 } 1211 }
1212 1212
1213 UndoStack::instance()->push( command ); 1213 UndoStack::instance()->push( command );
1214 RedoStack::instance()->clear(); 1214 RedoStack::instance()->clear();
1215 if ( updateDetails ) 1215 if ( updateDetails )
1216 mDetails->setAddressee( addr ); 1216 mDetails->setAddressee( addr );
1217 setModified( true ); 1217 setModified( true );
1218} 1218}
1219 1219
1220void KABCore::newContact() 1220void KABCore::newContact()
1221{ 1221{
1222 1222
1223 1223
1224 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1224 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1225 1225
1226 QPtrList<KRES::Resource> kresResources; 1226 QPtrList<KRES::Resource> kresResources;
1227 QPtrListIterator<KABC::Resource> it( kabcResources ); 1227 QPtrListIterator<KABC::Resource> it( kabcResources );
1228 KABC::Resource *resource; 1228 KABC::Resource *resource;
1229 while ( ( resource = it.current() ) != 0 ) { 1229 while ( ( resource = it.current() ) != 0 ) {
1230 ++it; 1230 ++it;
1231 if ( !resource->readOnly() ) { 1231 if ( !resource->readOnly() ) {
1232 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1232 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1233 if ( res ) 1233 if ( res )
1234 kresResources.append( res ); 1234 kresResources.append( res );
1235 } 1235 }
1236 } 1236 }
@@ -2431,891 +2431,891 @@ void KABCore::clipboardDataChanged()
2431 2431
2432} 2432}
2433 2433
2434void KABCore::updateActionMenu() 2434void KABCore::updateActionMenu()
2435{ 2435{
2436 UndoStack *undo = UndoStack::instance(); 2436 UndoStack *undo = UndoStack::instance();
2437 RedoStack *redo = RedoStack::instance(); 2437 RedoStack *redo = RedoStack::instance();
2438 2438
2439 if ( undo->isEmpty() ) 2439 if ( undo->isEmpty() )
2440 mActionUndo->setText( i18n( "Undo" ) ); 2440 mActionUndo->setText( i18n( "Undo" ) );
2441 else 2441 else
2442 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2442 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2443 2443
2444 mActionUndo->setEnabled( !undo->isEmpty() ); 2444 mActionUndo->setEnabled( !undo->isEmpty() );
2445 2445
2446 if ( !redo->top() ) 2446 if ( !redo->top() )
2447 mActionRedo->setText( i18n( "Redo" ) ); 2447 mActionRedo->setText( i18n( "Redo" ) );
2448 else 2448 else
2449 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2449 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2450 2450
2451 mActionRedo->setEnabled( !redo->isEmpty() ); 2451 mActionRedo->setEnabled( !redo->isEmpty() );
2452} 2452}
2453 2453
2454void KABCore::configureKeyBindings() 2454void KABCore::configureKeyBindings()
2455{ 2455{
2456#ifndef KAB_EMBEDDED 2456#ifndef KAB_EMBEDDED
2457 KKeyDialog::configure( actionCollection(), true ); 2457 KKeyDialog::configure( actionCollection(), true );
2458#else //KAB_EMBEDDED 2458#else //KAB_EMBEDDED
2459 qDebug("KABCore::configureKeyBindings() not implemented"); 2459 qDebug("KABCore::configureKeyBindings() not implemented");
2460#endif //KAB_EMBEDDED 2460#endif //KAB_EMBEDDED
2461} 2461}
2462 2462
2463#ifdef KAB_EMBEDDED 2463#ifdef KAB_EMBEDDED
2464void KABCore::configureResources() 2464void KABCore::configureResources()
2465{ 2465{
2466 KRES::KCMKResources dlg( this, "" , 0 ); 2466 KRES::KCMKResources dlg( this, "" , 0 );
2467 2467
2468 if ( !dlg.exec() ) 2468 if ( !dlg.exec() )
2469 return; 2469 return;
2470 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2470 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2471} 2471}
2472#endif //KAB_EMBEDDED 2472#endif //KAB_EMBEDDED
2473 2473
2474 2474
2475/* this method will be called through the QCop interface from Ko/Pi to select addresses 2475/* this method will be called through the QCop interface from Ko/Pi to select addresses
2476 * for the attendees list of an event. 2476 * for the attendees list of an event.
2477 */ 2477 */
2478void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2478void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2479{ 2479{
2480 QStringList nameList; 2480 QStringList nameList;
2481 QStringList emailList; 2481 QStringList emailList;
2482 QStringList uidList; 2482 QStringList uidList;
2483 2483
2484 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2484 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2485 uint i=0; 2485 uint i=0;
2486 for (i=0; i < list.count(); i++) 2486 for (i=0; i < list.count(); i++)
2487 { 2487 {
2488 nameList.append(list[i].realName()); 2488 nameList.append(list[i].realName());
2489 emailList.append(list[i].preferredEmail()); 2489 emailList.append(list[i].preferredEmail());
2490 uidList.append(list[i].uid()); 2490 uidList.append(list[i].uid());
2491 } 2491 }
2492 2492
2493 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2493 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2494 2494
2495} 2495}
2496 2496
2497/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2497/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2498 * to put them into the calendar. 2498 * to put them into the calendar.
2499 */ 2499 */
2500void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2500void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2501{ 2501{
2502 // qDebug("KABCore::requestForBirthdayList"); 2502 // qDebug("KABCore::requestForBirthdayList");
2503 QStringList birthdayList; 2503 QStringList birthdayList;
2504 QStringList anniversaryList; 2504 QStringList anniversaryList;
2505 QStringList realNameList; 2505 QStringList realNameList;
2506 QStringList preferredEmailList; 2506 QStringList preferredEmailList;
2507 QStringList assembledNameList; 2507 QStringList assembledNameList;
2508 QStringList uidList; 2508 QStringList uidList;
2509 2509
2510 KABC::AddressBook::Iterator it; 2510 KABC::AddressBook::Iterator it;
2511 2511
2512 int count = 0; 2512 int count = 0;
2513 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2513 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2514 ++count; 2514 ++count;
2515 } 2515 }
2516 QProgressBar bar(count,0 ); 2516 QProgressBar bar(count,0 );
2517 int w = 300; 2517 int w = 300;
2518 if ( QApplication::desktop()->width() < 320 ) 2518 if ( QApplication::desktop()->width() < 320 )
2519 w = 220; 2519 w = 220;
2520 int h = bar.sizeHint().height() ; 2520 int h = bar.sizeHint().height() ;
2521 int dw = QApplication::desktop()->width(); 2521 int dw = QApplication::desktop()->width();
2522 int dh = QApplication::desktop()->height(); 2522 int dh = QApplication::desktop()->height();
2523 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2523 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2524 bar.show(); 2524 bar.show();
2525 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2525 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2526 qApp->processEvents(); 2526 qApp->processEvents();
2527 2527
2528 QDate bday; 2528 QDate bday;
2529 QString anni; 2529 QString anni;
2530 QString formattedbday; 2530 QString formattedbday;
2531 2531
2532 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2532 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2533 { 2533 {
2534 if ( ! bar.isVisible() ) 2534 if ( ! bar.isVisible() )
2535 return; 2535 return;
2536 bar.setProgress( count++ ); 2536 bar.setProgress( count++ );
2537 qApp->processEvents(); 2537 qApp->processEvents();
2538 bday = (*it).birthday().date(); 2538 bday = (*it).birthday().date();
2539 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2539 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2540 2540
2541 if ( bday.isValid() || !anni.isEmpty()) 2541 if ( bday.isValid() || !anni.isEmpty())
2542 { 2542 {
2543 if (bday.isValid()) 2543 if (bday.isValid())
2544 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2544 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2545 else 2545 else
2546 formattedbday = "NOTVALID"; 2546 formattedbday = "NOTVALID";
2547 if (anni.isEmpty()) 2547 if (anni.isEmpty())
2548 anni = "INVALID"; 2548 anni = "INVALID";
2549 2549
2550 birthdayList.append(formattedbday); 2550 birthdayList.append(formattedbday);
2551 anniversaryList.append(anni); //should be ISODate 2551 anniversaryList.append(anni); //should be ISODate
2552 realNameList.append((*it).realName()); 2552 realNameList.append((*it).realName());
2553 preferredEmailList.append((*it).preferredEmail()); 2553 preferredEmailList.append((*it).preferredEmail());
2554 assembledNameList.append((*it).assembledName()); 2554 assembledNameList.append((*it).assembledName());
2555 uidList.append((*it).uid()); 2555 uidList.append((*it).uid());
2556 2556
2557 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2557 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2558 } 2558 }
2559 } 2559 }
2560 2560
2561 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2561 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2562 2562
2563} 2563}
2564 2564
2565/* this method will be called through the QCop interface from other apps to show details of a contact. 2565/* this method will be called through the QCop interface from other apps to show details of a contact.
2566 */ 2566 */
2567void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2567void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2568{ 2568{
2569 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2569 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2570 2570
2571 QString foundUid = QString::null; 2571 QString foundUid = QString::null;
2572 if ( ! uid.isEmpty() ) { 2572 if ( ! uid.isEmpty() ) {
2573 Addressee adrr = mAddressBook->findByUid( uid ); 2573 Addressee adrr = mAddressBook->findByUid( uid );
2574 if ( !adrr.isEmpty() ) { 2574 if ( !adrr.isEmpty() ) {
2575 foundUid = uid; 2575 foundUid = uid;
2576 } 2576 }
2577 if ( email == "sendbacklist" ) { 2577 if ( email == "sendbacklist" ) {
2578 //qDebug("ssssssssssssssssssssssend "); 2578 //qDebug("ssssssssssssssssssssssend ");
2579 QStringList nameList; 2579 QStringList nameList;
2580 QStringList emailList; 2580 QStringList emailList;
2581 QStringList uidList; 2581 QStringList uidList;
2582 nameList.append(adrr.realName()); 2582 nameList.append(adrr.realName());
2583 emailList = adrr.emails(); 2583 emailList = adrr.emails();
2584 uidList.append( adrr.preferredEmail()); 2584 uidList.append( adrr.preferredEmail());
2585 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2585 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2586 return; 2586 return;
2587 } 2587 }
2588 2588
2589 } 2589 }
2590 2590
2591 if ( email == "sendbacklist" ) 2591 if ( email == "sendbacklist" )
2592 return; 2592 return;
2593 if (foundUid.isEmpty()) 2593 if (foundUid.isEmpty())
2594 { 2594 {
2595 //find the uid of the person first 2595 //find the uid of the person first
2596 Addressee::List namelist; 2596 Addressee::List namelist;
2597 Addressee::List emaillist; 2597 Addressee::List emaillist;
2598 2598
2599 if (!name.isEmpty()) 2599 if (!name.isEmpty())
2600 namelist = mAddressBook->findByName( name ); 2600 namelist = mAddressBook->findByName( name );
2601 2601
2602 if (!email.isEmpty()) 2602 if (!email.isEmpty())
2603 emaillist = mAddressBook->findByEmail( email ); 2603 emaillist = mAddressBook->findByEmail( email );
2604 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2604 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2605 //check if we have a match in Namelist and Emaillist 2605 //check if we have a match in Namelist and Emaillist
2606 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2606 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2607 foundUid = emaillist[0].uid(); 2607 foundUid = emaillist[0].uid();
2608 } 2608 }
2609 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2609 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2610 foundUid = namelist[0].uid(); 2610 foundUid = namelist[0].uid();
2611 else 2611 else
2612 { 2612 {
2613 for (int i = 0; i < namelist.count(); i++) 2613 for (int i = 0; i < namelist.count(); i++)
2614 { 2614 {
2615 for (int j = 0; j < emaillist.count(); j++) 2615 for (int j = 0; j < emaillist.count(); j++)
2616 { 2616 {
2617 if (namelist[i] == emaillist[j]) 2617 if (namelist[i] == emaillist[j])
2618 { 2618 {
2619 foundUid = namelist[i].uid(); 2619 foundUid = namelist[i].uid();
2620 } 2620 }
2621 } 2621 }
2622 } 2622 }
2623 } 2623 }
2624 } 2624 }
2625 else 2625 else
2626 { 2626 {
2627 foundUid = uid; 2627 foundUid = uid;
2628 } 2628 }
2629 2629
2630 if (!foundUid.isEmpty()) 2630 if (!foundUid.isEmpty())
2631 { 2631 {
2632 2632
2633 // raise Ka/Pi if it is in the background 2633 // raise Ka/Pi if it is in the background
2634#ifndef DESKTOP_VERSION 2634#ifndef DESKTOP_VERSION
2635#ifndef KORG_NODCOP 2635#ifndef KORG_NODCOP
2636 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2636 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2637#endif 2637#endif
2638#endif 2638#endif
2639 2639
2640 mMainWindow->showMaximized(); 2640 mMainWindow->showMaximized();
2641 mMainWindow-> raise(); 2641 mMainWindow-> raise();
2642 2642
2643 mViewManager->setSelected( "", false); 2643 mViewManager->setSelected( "", false);
2644 mViewManager->refreshView( "" ); 2644 mViewManager->refreshView( "" );
2645 mViewManager->setSelected( foundUid, true ); 2645 mViewManager->setSelected( foundUid, true );
2646 mViewManager->refreshView( foundUid ); 2646 mViewManager->refreshView( foundUid );
2647 2647
2648 if ( !mMultipleViewsAtOnce ) 2648 if ( !mMultipleViewsAtOnce )
2649 { 2649 {
2650 setDetailsVisible( true ); 2650 setDetailsVisible( true );
2651 mActionDetails->setChecked(true); 2651 mActionDetails->setChecked(true);
2652 } 2652 }
2653 } 2653 }
2654} 2654}
2655 2655
2656void KABCore::whatsnew() 2656void KABCore::whatsnew()
2657{ 2657{
2658 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2658 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2659} 2659}
2660void KABCore::synchowto() 2660void KABCore::synchowto()
2661{ 2661{
2662 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2662 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2663} 2663}
2664void KABCore::kdesynchowto() 2664void KABCore::kdesynchowto()
2665{ 2665{
2666 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2666 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2667} 2667}
2668void KABCore::multisynchowto() 2668void KABCore::multisynchowto()
2669{ 2669{
2670 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2670 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2671} 2671}
2672void KABCore::faq() 2672void KABCore::faq()
2673{ 2673{
2674 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2674 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2675} 2675}
2676 2676
2677#include <libkcal/syncdefines.h> 2677#include <libkcal/syncdefines.h>
2678 2678
2679KABC::Addressee KABCore::getLastSyncAddressee() 2679KABC::Addressee KABCore::getLastSyncAddressee()
2680{ 2680{
2681 Addressee lse; 2681 Addressee lse;
2682 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2682 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2683 2683
2684 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2684 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2685 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2685 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2686 if (lse.isEmpty()) { 2686 if (lse.isEmpty()) {
2687 qDebug("Creating new last-syncAddressee "); 2687 qDebug("KA: Creating new last-syncAddressee ");
2688 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2688 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2689 QString sum = ""; 2689 QString sum = "";
2690 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2690 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2691 sum = "E: "; 2691 sum = "E: ";
2692 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2692 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2693 lse.setRevision( mLastAddressbookSync ); 2693 lse.setRevision( mLastAddressbookSync );
2694 lse.setCategories( i18n("SyncEvent") ); 2694 lse.setCategories( i18n("SyncEvent") );
2695 mAddressBook->insertAddressee( lse ); 2695 mAddressBook->insertAddressee( lse );
2696 } 2696 }
2697 return lse; 2697 return lse;
2698} 2698}
2699int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2699int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2700{ 2700{
2701 2701
2702 //void setZaurusId(int id); 2702 //void setZaurusId(int id);
2703 // int zaurusId() const; 2703 // int zaurusId() const;
2704 // void setZaurusUid(int id); 2704 // void setZaurusUid(int id);
2705 // int zaurusUid() const; 2705 // int zaurusUid() const;
2706 // void setZaurusStat(int id); 2706 // void setZaurusStat(int id);
2707 // int zaurusStat() const; 2707 // int zaurusStat() const;
2708 // 0 equal 2708 // 0 equal
2709 // 1 take local 2709 // 1 take local
2710 // 2 take remote 2710 // 2 take remote
2711 // 3 cancel 2711 // 3 cancel
2712 QDateTime lastSync = mLastAddressbookSync; 2712 QDateTime lastSync = mLastAddressbookSync;
2713 QDateTime localMod = local->revision(); 2713 QDateTime localMod = local->revision();
2714 QDateTime remoteMod = remote->revision(); 2714 QDateTime remoteMod = remote->revision();
2715 2715
2716 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2716 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2717 2717
2718 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2718 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2719 bool remCh, locCh; 2719 bool remCh, locCh;
2720 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2720 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2721 if ( remCh ) 2721 //if ( remCh )
2722 qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2722 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2723 locCh = ( localMod > mLastAddressbookSync ); 2723 locCh = ( localMod > mLastAddressbookSync );
2724 //qDebug("cahnged rem %d loc %d",remCh, locCh ); 2724 //qDebug("cahnged rem %d loc %d",remCh, locCh );
2725 if ( !remCh && ! locCh ) { 2725 if ( !remCh && ! locCh ) {
2726 //qDebug("both not changed "); 2726 //qDebug("both not changed ");
2727 lastSync = localMod.addDays(1); 2727 lastSync = localMod.addDays(1);
2728 if ( mode <= SYNC_PREF_ASK ) 2728 if ( mode <= SYNC_PREF_ASK )
2729 return 0; 2729 return 0;
2730 } else { 2730 } else {
2731 if ( locCh ) { 2731 if ( locCh ) {
2732 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2732 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2733 lastSync = localMod.addDays( -1 ); 2733 lastSync = localMod.addDays( -1 );
2734 if ( !remCh ) 2734 if ( !remCh )
2735 remoteMod =( lastSync.addDays( -1 ) ); 2735 remoteMod =( lastSync.addDays( -1 ) );
2736 } else { 2736 } else {
2737 //qDebug(" not loc changed "); 2737 //qDebug(" not loc changed ");
2738 lastSync = localMod.addDays( 1 ); 2738 lastSync = localMod.addDays( 1 );
2739 if ( remCh ) { 2739 if ( remCh ) {
2740 //qDebug("rem changed "); 2740 //qDebug("rem changed ");
2741 remoteMod =( lastSync.addDays( 1 ) ); 2741 remoteMod =( lastSync.addDays( 1 ) );
2742 } 2742 }
2743 2743
2744 } 2744 }
2745 } 2745 }
2746 full = true; 2746 full = true;
2747 if ( mode < SYNC_PREF_ASK ) 2747 if ( mode < SYNC_PREF_ASK )
2748 mode = SYNC_PREF_ASK; 2748 mode = SYNC_PREF_ASK;
2749 } else { 2749 } else {
2750 if ( localMod == remoteMod ) 2750 if ( localMod == remoteMod )
2751 return 0; 2751 return 0;
2752 2752
2753 } 2753 }
2754 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2754 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2755 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2755 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2756 //full = true; //debug only 2756 //full = true; //debug only
2757 if ( full ) { 2757 if ( full ) {
2758 bool equ = ( (*local) == (*remote) ); 2758 bool equ = ( (*local) == (*remote) );
2759 if ( equ ) { 2759 if ( equ ) {
2760 //qDebug("equal "); 2760 //qDebug("equal ");
2761 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2761 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2762 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2762 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2763 } 2763 }
2764 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2764 if ( mode < SYNC_PREF_FORCE_LOCAL )
2765 return 0; 2765 return 0;
2766 2766
2767 }//else //debug only 2767 }//else //debug only
2768 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2768 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2769 } 2769 }
2770 int result; 2770 int result;
2771 bool localIsNew; 2771 bool localIsNew;
2772 //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() ); 2772 //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() );
2773 2773
2774 if ( full && mode < SYNC_PREF_NEWEST ) 2774 if ( full && mode < SYNC_PREF_NEWEST )
2775 mode = SYNC_PREF_ASK; 2775 mode = SYNC_PREF_ASK;
2776 2776
2777 switch( mode ) { 2777 switch( mode ) {
2778 case SYNC_PREF_LOCAL: 2778 case SYNC_PREF_LOCAL:
2779 if ( lastSync > remoteMod ) 2779 if ( lastSync > remoteMod )
2780 return 1; 2780 return 1;
2781 if ( lastSync > localMod ) 2781 if ( lastSync > localMod )
2782 return 2; 2782 return 2;
2783 return 1; 2783 return 1;
2784 break; 2784 break;
2785 case SYNC_PREF_REMOTE: 2785 case SYNC_PREF_REMOTE:
2786 if ( lastSync > remoteMod ) 2786 if ( lastSync > remoteMod )
2787 return 1; 2787 return 1;
2788 if ( lastSync > localMod ) 2788 if ( lastSync > localMod )
2789 return 2; 2789 return 2;
2790 return 2; 2790 return 2;
2791 break; 2791 break;
2792 case SYNC_PREF_NEWEST: 2792 case SYNC_PREF_NEWEST:
2793 if ( localMod > remoteMod ) 2793 if ( localMod > remoteMod )
2794 return 1; 2794 return 1;
2795 else 2795 else
2796 return 2; 2796 return 2;
2797 break; 2797 break;
2798 case SYNC_PREF_ASK: 2798 case SYNC_PREF_ASK:
2799 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2799 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2800 if ( lastSync > remoteMod ) 2800 if ( lastSync > remoteMod )
2801 return 1; 2801 return 1;
2802 if ( lastSync > localMod ) { 2802 if ( lastSync > localMod ) {
2803 return 2; 2803 return 2;
2804 } 2804 }
2805 localIsNew = localMod >= remoteMod; 2805 localIsNew = localMod >= remoteMod;
2806 //qDebug("conflict! ************************************** "); 2806 //qDebug("conflict! ************************************** ");
2807 { 2807 {
2808 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2808 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2809 result = acd.executeD(localIsNew); 2809 result = acd.executeD(localIsNew);
2810 return result; 2810 return result;
2811 } 2811 }
2812 break; 2812 break;
2813 case SYNC_PREF_FORCE_LOCAL: 2813 case SYNC_PREF_FORCE_LOCAL:
2814 return 1; 2814 return 1;
2815 break; 2815 break;
2816 case SYNC_PREF_FORCE_REMOTE: 2816 case SYNC_PREF_FORCE_REMOTE:
2817 return 2; 2817 return 2;
2818 break; 2818 break;
2819 2819
2820 default: 2820 default:
2821 // SYNC_PREF_TAKE_BOTH not implemented 2821 // SYNC_PREF_TAKE_BOTH not implemented
2822 break; 2822 break;
2823 } 2823 }
2824 return 0; 2824 return 0;
2825} 2825}
2826 2826
2827 2827
2828bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2828bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2829{ 2829{
2830 bool syncOK = true; 2830 bool syncOK = true;
2831 int addedAddressee = 0; 2831 int addedAddressee = 0;
2832 int addedAddresseeR = 0; 2832 int addedAddresseeR = 0;
2833 int deletedAddresseeR = 0; 2833 int deletedAddresseeR = 0;
2834 int deletedAddresseeL = 0; 2834 int deletedAddresseeL = 0;
2835 int changedLocal = 0; 2835 int changedLocal = 0;
2836 int changedRemote = 0; 2836 int changedRemote = 0;
2837 int filteredIN = 0; 2837 int filteredIN = 0;
2838 int filteredOUT = 0; 2838 int filteredOUT = 0;
2839 2839
2840 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2840 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2841 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2841 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2842 2842
2843 //QPtrList<Addressee> el = local->rawAddressees(); 2843 //QPtrList<Addressee> el = local->rawAddressees();
2844 Addressee addresseeR; 2844 Addressee addresseeR;
2845 QString uid; 2845 QString uid;
2846 int take; 2846 int take;
2847 Addressee addresseeL; 2847 Addressee addresseeL;
2848 Addressee addresseeRSync; 2848 Addressee addresseeRSync;
2849 Addressee addresseeLSync; 2849 Addressee addresseeLSync;
2850 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2850 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2851 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2851 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2852 bool fullDateRange = false; 2852 bool fullDateRange = false;
2853 local->resetTempSyncStat(); 2853 local->resetTempSyncStat();
2854 mLastAddressbookSync = QDateTime::currentDateTime(); 2854 mLastAddressbookSync = QDateTime::currentDateTime();
2855 if ( syncManager->syncWithDesktop() ) { 2855 if ( syncManager->syncWithDesktop() ) {
2856 // remote->removeSyncInfo( QString());//remove all info 2856 // remote->removeSyncInfo( QString());//remove all info
2857 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2857 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2858 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2858 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2859 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2859 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2860 } else { 2860 } else {
2861 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 2861 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime ");
2862 } 2862 }
2863 } 2863 }
2864 QDateTime modifiedCalendar = mLastAddressbookSync; 2864 QDateTime modifiedCalendar = mLastAddressbookSync;
2865 addresseeLSync = getLastSyncAddressee(); 2865 addresseeLSync = getLastSyncAddressee();
2866 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2866 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1());
2867 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2867 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2868 if ( !addresseeR.isEmpty() ) { 2868 if ( !addresseeR.isEmpty() ) {
2869 addresseeRSync = addresseeR; 2869 addresseeRSync = addresseeR;
2870 remote->removeAddressee(addresseeR ); 2870 remote->removeAddressee(addresseeR );
2871 2871
2872 } else { 2872 } else {
2873 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2873 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2874 addresseeRSync = addresseeLSync ; 2874 addresseeRSync = addresseeLSync ;
2875 } else { 2875 } else {
2876 //qDebug("FULLDATE 1"); 2876 //qDebug("FULLDATE 1");
2877 fullDateRange = true; 2877 fullDateRange = true;
2878 Addressee newAdd; 2878 Addressee newAdd;
2879 addresseeRSync = newAdd; 2879 addresseeRSync = newAdd;
2880 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2880 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2881 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2881 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2882 addresseeRSync.setRevision( mLastAddressbookSync ); 2882 addresseeRSync.setRevision( mLastAddressbookSync );
2883 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2883 addresseeRSync.setCategories( i18n("SyncAddressee") );
2884 } 2884 }
2885 } 2885 }
2886 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2886 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2887 // qDebug("FULLDATE 2"); 2887 // qDebug("FULLDATE 2");
2888 fullDateRange = true; 2888 fullDateRange = true;
2889 } 2889 }
2890 if ( ! fullDateRange ) { 2890 if ( ! fullDateRange ) {
2891 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2891 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2892 2892
2893 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2893 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2894 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2894 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2895 fullDateRange = true; 2895 fullDateRange = true;
2896 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2896 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2897 } 2897 }
2898 } 2898 }
2899 // fullDateRange = true; // debug only! 2899 // fullDateRange = true; // debug only!
2900 if ( fullDateRange ) 2900 if ( fullDateRange )
2901 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2901 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2902 else 2902 else
2903 mLastAddressbookSync = addresseeLSync.revision(); 2903 mLastAddressbookSync = addresseeLSync.revision();
2904 // for resyncing if own file has changed 2904 // for resyncing if own file has changed
2905 // PENDING fixme later when implemented 2905 // PENDING fixme later when implemented
2906#if 0 2906#if 0
2907 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2907 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2908 mLastAddressbookSync = loadedFileVersion; 2908 mLastAddressbookSync = loadedFileVersion;
2909 qDebug("setting mLastAddressbookSync "); 2909 qDebug("setting mLastAddressbookSync ");
2910 } 2910 }
2911#endif 2911#endif
2912 2912
2913 2913
2914 // ********** setting filters **************** 2914 // ********** setting filters ****************
2915 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); 2915 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB );
2916 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); 2916 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB );
2917 2917
2918 //qDebug("*************************** "); 2918 //qDebug("*************************** ");
2919 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2919 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2920 QStringList er = remote->uidList(); 2920 QStringList er = remote->uidList();
2921 Addressee inR ;//= er.first(); 2921 Addressee inR ;//= er.first();
2922 Addressee inL; 2922 Addressee inL;
2923 2923
2924 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2924 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2925 2925
2926 int modulo = (er.count()/10)+1; 2926 int modulo = (er.count()/10)+1;
2927 int incCounter = 0; 2927 int incCounter = 0;
2928 while ( incCounter < er.count()) { 2928 while ( incCounter < er.count()) {
2929 if (syncManager->isProgressBarCanceled()) 2929 if (syncManager->isProgressBarCanceled())
2930 return false; 2930 return false;
2931 if ( incCounter % modulo == 0 ) 2931 if ( incCounter % modulo == 0 )
2932 syncManager->showProgressBar(incCounter); 2932 syncManager->showProgressBar(incCounter);
2933 2933
2934 uid = er[ incCounter ]; 2934 uid = er[ incCounter ];
2935 bool skipIncidence = false; 2935 bool skipIncidence = false;
2936 if ( uid.left(19) == QString("last-syncAddressee-") ) 2936 if ( uid.left(19) == QString("last-syncAddressee-") )
2937 skipIncidence = true; 2937 skipIncidence = true;
2938 QString idS,OidS; 2938 QString idS,OidS;
2939 qApp->processEvents(); 2939 qApp->processEvents();
2940 if ( !skipIncidence ) { 2940 if ( !skipIncidence ) {
2941 inL = local->findByUid( uid ); 2941 inL = local->findByUid( uid );
2942 inR = remote->findByUid( uid ); 2942 inR = remote->findByUid( uid );
2943 //inL.setResource( 0 ); 2943 //inL.setResource( 0 );
2944 //inR.setResource( 0 ); 2944 //inR.setResource( 0 );
2945 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2945 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2946 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2946 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2947 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 2947 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
2948 //qDebug("take %d %s ", take, inL.summary().latin1()); 2948 //qDebug("take %d %s ", take, inL.summary().latin1());
2949 if ( take == 3 ) 2949 if ( take == 3 )
2950 return false; 2950 return false;
2951 if ( take == 1 ) {// take local ********************** 2951 if ( take == 1 ) {// take local **********************
2952 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2952 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2953 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2953 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2954 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2954 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2955 local->insertAddressee( inL, false ); 2955 local->insertAddressee( inL, false );
2956 idS = inR.externalUID(); 2956 idS = inR.externalUID();
2957 OidS = inR.originalExternalUID(); 2957 OidS = inR.originalExternalUID();
2958 } 2958 }
2959 else 2959 else
2960 idS = inR.IDStr(); 2960 idS = inR.IDStr();
2961 remote->removeAddressee( inR ); 2961 remote->removeAddressee( inR );
2962 inR = inL; 2962 inR = inL;
2963 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2963 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2964 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2964 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2965 inR.setOriginalExternalUID( OidS ); 2965 inR.setOriginalExternalUID( OidS );
2966 inR.setExternalUID( idS ); 2966 inR.setExternalUID( idS );
2967 if ( syncManager->syncWithDesktop() ) { 2967 if ( syncManager->syncWithDesktop() ) {
2968 inR.setIDStr("changed" ); 2968 inR.setIDStr("changed" );
2969 } 2969 }
2970 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 2970 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
2971 } else { 2971 } else {
2972 inR.setIDStr( idS ); 2972 inR.setIDStr( idS );
2973 } 2973 }
2974 inR.setResource( 0 ); 2974 inR.setResource( 0 );
2975 remote->insertAddressee( inR , false); 2975 remote->insertAddressee( inR , false);
2976 ++changedRemote; 2976 ++changedRemote;
2977 } else { // take == 2 take remote ********************** 2977 } else { // take == 2 take remote **********************
2978 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2978 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2979 if ( inR.revision().date().year() < 2004 ) 2979 if ( inR.revision().date().year() < 2004 )
2980 inR.setRevision( modifiedCalendar ); 2980 inR.setRevision( modifiedCalendar );
2981 } 2981 }
2982 idS = inL.IDStr(); 2982 idS = inL.IDStr();
2983 local->removeAddressee( inL ); 2983 local->removeAddressee( inL );
2984 inL = inR; 2984 inL = inR;
2985 inL.setIDStr( idS ); 2985 inL.setIDStr( idS );
2986 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2986 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2987 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2987 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2988 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2988 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2989 } 2989 }
2990 inL.setResource( 0 ); 2990 inL.setResource( 0 );
2991 local->insertAddressee( inL , false ); 2991 local->insertAddressee( inL , false );
2992 ++changedLocal; 2992 ++changedLocal;
2993 } 2993 }
2994 } 2994 }
2995 } 2995 }
2996 } else { // no conflict ********** add or delete remote 2996 } else { // no conflict ********** add or delete remote
2997 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { 2997 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
2998 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2998 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2999 QString des = addresseeLSync.note(); 2999 QString des = addresseeLSync.note();
3000 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 3000 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
3001 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 3001 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
3002 remote->insertAddressee( inR, false ); 3002 remote->insertAddressee( inR, false );
3003 ++deletedAddresseeR; 3003 ++deletedAddresseeR;
3004 } else { 3004 } else {
3005 inR.setRevision( modifiedCalendar ); 3005 inR.setRevision( modifiedCalendar );
3006 remote->insertAddressee( inR, false ); 3006 remote->insertAddressee( inR, false );
3007 inL = inR; 3007 inL = inR;
3008 inL.setIDStr( ":" ); 3008 inL.setIDStr( ":" );
3009 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3009 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3010 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3010 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3011 inL.setResource( 0 ); 3011 inL.setResource( 0 );
3012 local->insertAddressee( inL , false); 3012 local->insertAddressee( inL , false);
3013 ++addedAddressee; 3013 ++addedAddressee;
3014 } 3014 }
3015 } else { 3015 } else {
3016 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 3016 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
3017 inR.setRevision( modifiedCalendar ); 3017 inR.setRevision( modifiedCalendar );
3018 remote->insertAddressee( inR, false ); 3018 remote->insertAddressee( inR, false );
3019 inR.setResource( 0 ); 3019 inR.setResource( 0 );
3020 local->insertAddressee( inR, false ); 3020 local->insertAddressee( inR, false );
3021 ++addedAddressee; 3021 ++addedAddressee;
3022 } else { 3022 } else {
3023 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 3023 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
3024 remote->removeAddressee( inR ); 3024 remote->removeAddressee( inR );
3025 ++deletedAddresseeR; 3025 ++deletedAddresseeR;
3026 } 3026 }
3027 } 3027 }
3028 } else { 3028 } else {
3029 ++filteredIN; 3029 ++filteredIN;
3030 } 3030 }
3031 } 3031 }
3032 } 3032 }
3033 ++incCounter; 3033 ++incCounter;
3034 } 3034 }
3035 er.clear(); 3035 er.clear();
3036 QStringList el = local->uidList(); 3036 QStringList el = local->uidList();
3037 modulo = (el.count()/10)+1; 3037 modulo = (el.count()/10)+1;
3038 3038
3039 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3039 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3040 incCounter = 0; 3040 incCounter = 0;
3041 while ( incCounter < el.count()) { 3041 while ( incCounter < el.count()) {
3042 qApp->processEvents(); 3042 qApp->processEvents();
3043 if (syncManager->isProgressBarCanceled()) 3043 if (syncManager->isProgressBarCanceled())
3044 return false; 3044 return false;
3045 if ( incCounter % modulo == 0 ) 3045 if ( incCounter % modulo == 0 )
3046 syncManager->showProgressBar(incCounter); 3046 syncManager->showProgressBar(incCounter);
3047 uid = el[ incCounter ]; 3047 uid = el[ incCounter ];
3048 bool skipIncidence = false; 3048 bool skipIncidence = false;
3049 if ( uid.left(19) == QString("last-syncAddressee-") ) 3049 if ( uid.left(19) == QString("last-syncAddressee-") )
3050 skipIncidence = true; 3050 skipIncidence = true;
3051 if ( !skipIncidence ) { 3051 if ( !skipIncidence ) {
3052 inL = local->findByUid( uid ); 3052 inL = local->findByUid( uid );
3053 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3053 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3054 inR = remote->findByUid( uid ); 3054 inR = remote->findByUid( uid );
3055 if ( inR.isEmpty() ){ 3055 if ( inR.isEmpty() ){
3056 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { 3056 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) {
3057 // no conflict ********** add or delete local 3057 // no conflict ********** add or delete local
3058 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3058 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3059 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3059 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
3060 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3060 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3061 local->removeAddressee( inL ); 3061 local->removeAddressee( inL );
3062 ++deletedAddresseeL; 3062 ++deletedAddresseeL;
3063 } else { 3063 } else {
3064 if ( ! syncManager->mWriteBackExistingOnly ) { 3064 if ( ! syncManager->mWriteBackExistingOnly ) {
3065 inL.removeID(mCurrentSyncDevice ); 3065 inL.removeID(mCurrentSyncDevice );
3066 ++addedAddresseeR; 3066 ++addedAddresseeR;
3067 inL.setRevision( modifiedCalendar ); 3067 inL.setRevision( modifiedCalendar );
3068 local->insertAddressee( inL, false ); 3068 local->insertAddressee( inL, false );
3069 inR = inL; 3069 inR = inL;
3070 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3070 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
3071 inR.setResource( 0 ); 3071 inR.setResource( 0 );
3072 remote->insertAddressee( inR, false ); 3072 remote->insertAddressee( inR, false );
3073 } 3073 }
3074 } 3074 }
3075 } else { 3075 } else {
3076 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3076 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
3077 //qDebug("data %s ", inL.revision().toString().latin1()); 3077 //qDebug("data %s ", inL.revision().toString().latin1());
3078 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3078 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3079 local->removeAddressee( inL ); 3079 local->removeAddressee( inL );
3080 ++deletedAddresseeL; 3080 ++deletedAddresseeL;
3081 } else { 3081 } else {
3082 if ( ! syncManager->mWriteBackExistingOnly ) { 3082 if ( ! syncManager->mWriteBackExistingOnly ) {
3083 ++addedAddresseeR; 3083 ++addedAddresseeR;
3084 inL.setRevision( modifiedCalendar ); 3084 inL.setRevision( modifiedCalendar );
3085 local->insertAddressee( inL, false ); 3085 local->insertAddressee( inL, false );
3086 inR = inL; 3086 inR = inL;
3087 inR.setIDStr( ":" ); 3087 inR.setIDStr( ":" );
3088 inR.setResource( 0 ); 3088 inR.setResource( 0 );
3089 remote->insertAddressee( inR, false ); 3089 remote->insertAddressee( inR, false );
3090 } 3090 }
3091 } 3091 }
3092 } 3092 }
3093 } else { 3093 } else {
3094 ++filteredOUT; 3094 ++filteredOUT;
3095 } 3095 }
3096 } 3096 }
3097 } 3097 }
3098 } 3098 }
3099 ++incCounter; 3099 ++incCounter;
3100 } 3100 }
3101 el.clear(); 3101 el.clear();
3102 syncManager->hideProgressBar(); 3102 syncManager->hideProgressBar();
3103 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3103 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
3104 // get rid of micro seconds 3104 // get rid of micro seconds
3105 QTime t = mLastAddressbookSync.time(); 3105 QTime t = mLastAddressbookSync.time();
3106 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3106 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3107 addresseeLSync.setRevision( mLastAddressbookSync ); 3107 addresseeLSync.setRevision( mLastAddressbookSync );
3108 addresseeRSync.setRevision( mLastAddressbookSync ); 3108 addresseeRSync.setRevision( mLastAddressbookSync );
3109 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3109 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
3110 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3110 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
3111 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3111 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
3112 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3112 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
3113 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3113 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
3114 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3114 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
3115 addresseeRSync.setNote( "" ) ; 3115 addresseeRSync.setNote( "" ) ;
3116 addresseeLSync.setNote( "" ); 3116 addresseeLSync.setNote( "" );
3117 3117
3118 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3118 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
3119 remote->insertAddressee( addresseeRSync, false ); 3119 remote->insertAddressee( addresseeRSync, false );
3120 local->insertAddressee( addresseeLSync, false ); 3120 local->insertAddressee( addresseeLSync, false );
3121 QString mes; 3121 QString mes;
3122 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); 3122 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT );
3123 qDebug( mes ); 3123 qDebug( mes );
3124 mes = i18n("Local addressbook changed!\n") +mes; 3124 mes = i18n("Local addressbook changed!\n") +mes;
3125 if ( syncManager->mShowSyncSummary ) { 3125 if ( syncManager->mShowSyncSummary ) {
3126 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 3126 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
3127 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 3127 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
3128 qDebug("cancelled "); 3128 qDebug("KA: WB cancelled ");
3129 return false; 3129 return false;
3130 } 3130 }
3131 } 3131 }
3132 return syncOK; 3132 return syncOK;
3133} 3133}
3134 3134
3135 3135
3136//this is a overwritten callbackmethods from the syncinterface 3136//this is a overwritten callbackmethods from the syncinterface
3137bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3137bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3138{ 3138{
3139 3139
3140 //pending prepare addresseeview for output 3140 //pending prepare addresseeview for output
3141 //pending detect, if remote file has REV field. if not switch to external sync 3141 //pending detect, if remote file has REV field. if not switch to external sync
3142 mGlobalSyncMode = SYNC_MODE_NORMAL; 3142 mGlobalSyncMode = SYNC_MODE_NORMAL;
3143 if ( manager != syncManager ) 3143 if ( manager != syncManager )
3144 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3144 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3145 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3145 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3146 3146
3147 AddressBook abLocal(filename,"syncContact"); 3147 AddressBook abLocal(filename,"syncContact");
3148 bool syncOK = false; 3148 bool syncOK = false;
3149 if ( abLocal.load() ) { 3149 if ( abLocal.load() ) {
3150 qDebug("Sync:AB loaded %s,sync mode %d",filename.latin1(), mode ); 3150 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode );
3151 bool external = false; 3151 bool external = false;
3152 bool isXML = false; 3152 bool isXML = false;
3153 if ( filename.right(4) == ".xml") { 3153 if ( filename.right(4) == ".xml") {
3154 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3154 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3155 isXML = true; 3155 isXML = true;
3156 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3156 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3157 } else { 3157 } else {
3158 external = !manager->mIsKapiFile; 3158 external = !manager->mIsKapiFile;
3159 if ( external ) { 3159 if ( external ) {
3160 qDebug("Sync:Setting vcf mode to external "); 3160 qDebug("KA: Sync::Setting vcf mode to external ");
3161 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3161 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3162 AddressBook::Iterator it; 3162 AddressBook::Iterator it;
3163 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3163 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3164 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3164 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3165 (*it).computeCsum( mCurrentSyncDevice ); 3165 (*it).computeCsum( mCurrentSyncDevice );
3166 } 3166 }
3167 } 3167 }
3168 } 3168 }
3169 //AddressBook::Iterator it; 3169 //AddressBook::Iterator it;
3170 //QStringList vcards; 3170 //QStringList vcards;
3171 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3171 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3172 // qDebug("Name %s ", (*it).familyName().latin1()); 3172 // qDebug("Name %s ", (*it).familyName().latin1());
3173 //} 3173 //}
3174 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3174 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3175 if ( syncOK ) { 3175 if ( syncOK ) {
3176 if ( syncManager->mWriteBackFile ) 3176 if ( syncManager->mWriteBackFile )
3177 { 3177 {
3178 if ( external ) 3178 if ( external )
3179 abLocal.removeSyncAddressees( !isXML); 3179 abLocal.removeSyncAddressees( !isXML);
3180 qDebug("Sync:Saving remote AB "); 3180 qDebug("KA: Sync::Saving remote AB ");
3181 if ( ! abLocal.saveAB()) 3181 if ( ! abLocal.saveAB())
3182 qDebug("Error writing back AB to file "); 3182 qDebug("KA: sync::Error writing back AB to file ");
3183 if ( external ) { 3183 if ( external ) {
3184 // afterwrite processing 3184 // afterwrite processing
3185 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3185 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3186 } 3186 }
3187 } 3187 }
3188 } 3188 }
3189 setModified(); 3189 setModified();
3190 3190
3191 } 3191 }
3192 abLocal.removeResources(); 3192 abLocal.removeResources();
3193 if ( syncOK ) 3193 if ( syncOK )
3194 mViewManager->refreshView(); 3194 mViewManager->refreshView();
3195 return syncOK; 3195 return syncOK;
3196 3196
3197} 3197}
3198void KABCore::removeSyncInfo( QString syncProfile) 3198void KABCore::removeSyncInfo( QString syncProfile)
3199{ 3199{
3200 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3200 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3201 mAddressBook->removeSyncInfo( syncProfile ); 3201 mAddressBook->removeSyncInfo( syncProfile );
3202 setModified(); 3202 setModified();
3203} 3203}
3204 3204
3205 3205
3206//this is a overwritten callbackmethods from the syncinterface 3206//this is a overwritten callbackmethods from the syncinterface
3207bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3207bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3208{ 3208{
3209 if ( resource == "phone" ) 3209 if ( resource == "phone" )
3210 return syncPhone(); 3210 return syncPhone();
3211 disableBR( true ); 3211 disableBR( true );
3212 if ( manager != syncManager ) 3212 if ( manager != syncManager )
3213 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3213 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3214 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3214 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3215 3215
3216 AddressBook abLocal( resource,"syncContact"); 3216 AddressBook abLocal( resource,"syncContact");
3217 bool syncOK = false; 3217 bool syncOK = false;
3218 message(i18n("Loading DTM address data..."), false); 3218 message(i18n("Loading DTM address data..."), false);
3219 if ( abLocal.load() ) { 3219 if ( abLocal.load() ) {
3220 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3220 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3221 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3221 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3222 message(i18n("Sync preprocessing..."),false); 3222 message(i18n("Sync preprocessing..."),false);
3223 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3223 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3224 message(i18n("Synchronizing..."),false); 3224 message(i18n("Synchronizing..."),false);
3225 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3225 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3226 if ( syncOK ) { 3226 if ( syncOK ) {
3227 if ( syncManager->mWriteBackFile ) { 3227 if ( syncManager->mWriteBackFile ) {
3228 abLocal.removeSyncAddressees( false ); 3228 abLocal.removeSyncAddressees( false );
3229 message(i18n("Saving DTM address data..."),false); 3229 message(i18n("Saving DTM address data..."),false);
3230 abLocal.saveAB(); 3230 abLocal.saveAB();
3231 message(i18n("Sync postprocessing..."),false); 3231 message(i18n("Sync postprocessing..."),false);
3232 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3232 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3233 } 3233 }
3234 } else 3234 } else
3235 message( i18n("Sync cancelled or failed.") ); 3235 message( i18n("Sync cancelled or failed.") );
3236 setModified(); 3236 setModified();
3237 } 3237 }
3238 abLocal.removeResources(); 3238 abLocal.removeResources();
3239 if ( syncOK ) { 3239 if ( syncOK ) {
3240 mViewManager->refreshView(); 3240 mViewManager->refreshView();
3241 message(i18n("DTM syncing finished.")); 3241 message(i18n("DTM syncing finished."));
3242 } 3242 }
3243 disableBR( false ); 3243 disableBR( false );
3244 return syncOK; 3244 return syncOK;
3245 3245
3246} 3246}
3247void KABCore::message( QString m, bool startTimer) 3247void KABCore::message( QString m, bool startTimer)
3248{ 3248{
3249 topLevelWidget()->setCaption( m ); 3249 topLevelWidget()->setCaption( m );
3250 qApp->processEvents(); 3250 qApp->processEvents();
3251 if ( startTimer ) 3251 if ( startTimer )
3252 mMessageTimer->start( 15000, true ); 3252 mMessageTimer->start( 15000, true );
3253 else 3253 else
3254 mMessageTimer->stop(); 3254 mMessageTimer->stop();
3255} 3255}
3256bool KABCore::syncPhone() 3256bool KABCore::syncPhone()
3257{ 3257{
3258 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3258 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3259 QString fileName = getPhoneFile(); 3259 QString fileName = getPhoneFile();
3260 if ( !PhoneAccess::readFromPhone( fileName) ) { 3260 if ( !PhoneAccess::readFromPhone( fileName) ) {
3261 message(i18n("Phone access failed!")); 3261 message(i18n("Phone access failed!"));
3262 return false; 3262 return false;
3263 } 3263 }
3264 AddressBook abLocal( fileName,"syncContact"); 3264 AddressBook abLocal( fileName,"syncContact");
3265 bool syncOK = false; 3265 bool syncOK = false;
3266 { 3266 {
3267 abLocal.importFromFile( fileName ); 3267 abLocal.importFromFile( fileName );
3268 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3268 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3269 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3269 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3270 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3270 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3271 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3271 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3272 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3272 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3273 if ( syncOK ) { 3273 if ( syncOK ) {
3274 if ( syncManager->mWriteBackFile ) { 3274 if ( syncManager->mWriteBackFile ) {
3275 abLocal.removeSyncAddressees( true ); 3275 abLocal.removeSyncAddressees( true );
3276 abLocal.saveABphone( fileName ); 3276 abLocal.saveABphone( fileName );
3277 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3277 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3278 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3278 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3279 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3279 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3280 } 3280 }
3281 } 3281 }
3282 setModified(); 3282 setModified();
3283 } 3283 }
3284 abLocal.removeResources(); 3284 abLocal.removeResources();
3285 if ( syncOK ) 3285 if ( syncOK )
3286 mViewManager->refreshView(); 3286 mViewManager->refreshView();
3287 return syncOK; 3287 return syncOK;
3288} 3288}
3289void KABCore::getFile( bool success ) 3289void KABCore::getFile( bool success )
3290{ 3290{
3291 if ( ! success ) { 3291 if ( ! success ) {
3292 message( i18n("Error receiving file. Nothing changed!") ); 3292 message( i18n("Error receiving file. Nothing changed!") );
3293 return; 3293 return;
3294 } 3294 }
3295 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3295 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3296 if ( count ) 3296 if ( count )
3297 setModified( true ); 3297 setModified( true );
3298 message( i18n("Pi-Sync successful!") ); 3298 message( i18n("Pi-Sync successful!") );
3299 mViewManager->refreshView(); 3299 mViewManager->refreshView();
3300} 3300}
3301void KABCore::syncFileRequest() 3301void KABCore::syncFileRequest()
3302{ 3302{
3303 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3303 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3304 syncManager->slotSyncMenu( 999 ); 3304 syncManager->slotSyncMenu( 999 );
3305 } 3305 }
3306 mAddressBook->export2File( sentSyncFile() ); 3306 mAddressBook->export2File( sentSyncFile() );
3307} 3307}
3308QString KABCore::sentSyncFile() 3308QString KABCore::sentSyncFile()
3309{ 3309{
3310#ifdef DESKTOP_VERSION 3310#ifdef DESKTOP_VERSION
3311 return locateLocal( "tmp", "copysyncab.vcf" ); 3311 return locateLocal( "tmp", "copysyncab.vcf" );
3312#else 3312#else
3313 return QString( "/tmp/copysyncab.vcf" ); 3313 return QString( "/tmp/copysyncab.vcf" );
3314#endif 3314#endif
3315} 3315}
3316 3316
3317void KABCore::setCaptionBack() 3317void KABCore::setCaptionBack()
3318{ 3318{
3319 mMessageTimer->stop(); 3319 mMessageTimer->stop();
3320 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 3320 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
3321} 3321}
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 038da54..06454c2 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -695,1012 +695,1013 @@ QDate CalendarView::startDate()
695 DateList dates = mNavigator->selectedDates(); 695 DateList dates = mNavigator->selectedDates();
696 696
697 return dates.first(); 697 return dates.first();
698} 698}
699 699
700QDate CalendarView::endDate() 700QDate CalendarView::endDate()
701{ 701{
702 DateList dates = mNavigator->selectedDates(); 702 DateList dates = mNavigator->selectedDates();
703 703
704 return dates.last(); 704 return dates.last();
705} 705}
706 706
707 707
708void CalendarView::createPrinter() 708void CalendarView::createPrinter()
709{ 709{
710#ifndef KORG_NOPRINTER 710#ifndef KORG_NOPRINTER
711 if (!mCalPrinter) { 711 if (!mCalPrinter) {
712 mCalPrinter = new CalPrinter(this, mCalendar); 712 mCalPrinter = new CalPrinter(this, mCalendar);
713 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 713 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
714 } 714 }
715#endif 715#endif
716} 716}
717 717
718 718
719//KOPrefs::instance()->mWriteBackFile 719//KOPrefs::instance()->mWriteBackFile
720//KOPrefs::instance()->mWriteBackExistingOnly 720//KOPrefs::instance()->mWriteBackExistingOnly
721 721
722// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 722// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
723// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 723// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
724// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 724// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
725// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 725// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
726// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 726// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
727// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 727// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
728 728
729int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 729int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
730{ 730{
731 731
732 // 0 equal 732 // 0 equal
733 // 1 take local 733 // 1 take local
734 // 2 take remote 734 // 2 take remote
735 // 3 cancel 735 // 3 cancel
736 QDateTime lastSync = mLastCalendarSync; 736 QDateTime lastSync = mLastCalendarSync;
737 QDateTime localMod = local->lastModified(); 737 QDateTime localMod = local->lastModified();
738 QDateTime remoteMod = remote->lastModified(); 738 QDateTime remoteMod = remote->lastModified();
739 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 739 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
740 bool remCh, locCh; 740 bool remCh, locCh;
741 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 741 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
742 //if ( remCh ) 742 //if ( remCh )
743 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 743 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
744 locCh = ( localMod > mLastCalendarSync ); 744 locCh = ( localMod > mLastCalendarSync );
745 if ( !remCh && ! locCh ) { 745 if ( !remCh && ! locCh ) {
746 //qDebug("both not changed "); 746 //qDebug("both not changed ");
747 lastSync = localMod.addDays(1); 747 lastSync = localMod.addDays(1);
748 if ( mode <= SYNC_PREF_ASK ) 748 if ( mode <= SYNC_PREF_ASK )
749 return 0; 749 return 0;
750 } else { 750 } else {
751 if ( locCh ) { 751 if ( locCh ) {
752 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 752 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
753 lastSync = localMod.addDays( -1 ); 753 lastSync = localMod.addDays( -1 );
754 if ( !remCh ) 754 if ( !remCh )
755 remoteMod = ( lastSync.addDays( -1 ) ); 755 remoteMod = ( lastSync.addDays( -1 ) );
756 } else { 756 } else {
757 //qDebug(" not loc changed "); 757 //qDebug(" not loc changed ");
758 lastSync = localMod.addDays( 1 ); 758 lastSync = localMod.addDays( 1 );
759 if ( remCh ) 759 if ( remCh )
760 remoteMod =( lastSync.addDays( 1 ) ); 760 remoteMod =( lastSync.addDays( 1 ) );
761 761
762 } 762 }
763 } 763 }
764 full = true; 764 full = true;
765 if ( mode < SYNC_PREF_ASK ) 765 if ( mode < SYNC_PREF_ASK )
766 mode = SYNC_PREF_ASK; 766 mode = SYNC_PREF_ASK;
767 } else { 767 } else {
768 if ( localMod == remoteMod ) 768 if ( localMod == remoteMod )
769 // if ( local->revision() == remote->revision() ) 769 // if ( local->revision() == remote->revision() )
770 return 0; 770 return 0;
771 771
772 } 772 }
773 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 773 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
774 774
775 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 775 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
776 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 776 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
777 //full = true; //debug only 777 //full = true; //debug only
778 if ( full ) { 778 if ( full ) {
779 bool equ = false; 779 bool equ = false;
780 if ( local->type() == "Event" ) { 780 if ( local->type() == "Event" ) {
781 equ = (*((Event*) local) == *((Event*) remote)); 781 equ = (*((Event*) local) == *((Event*) remote));
782 } 782 }
783 else if ( local->type() =="Todo" ) 783 else if ( local->type() =="Todo" )
784 equ = (*((Todo*) local) == (*(Todo*) remote)); 784 equ = (*((Todo*) local) == (*(Todo*) remote));
785 else if ( local->type() =="Journal" ) 785 else if ( local->type() =="Journal" )
786 equ = (*((Journal*) local) == *((Journal*) remote)); 786 equ = (*((Journal*) local) == *((Journal*) remote));
787 if ( equ ) { 787 if ( equ ) {
788 //qDebug("equal "); 788 //qDebug("equal ");
789 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 789 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
790 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 790 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
791 } 791 }
792 if ( mode < SYNC_PREF_FORCE_LOCAL ) 792 if ( mode < SYNC_PREF_FORCE_LOCAL )
793 return 0; 793 return 0;
794 794
795 }//else //debug only 795 }//else //debug only
796 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 796 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
797 } 797 }
798 int result; 798 int result;
799 bool localIsNew; 799 bool localIsNew;
800 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 800 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
801 801
802 if ( full && mode < SYNC_PREF_NEWEST ) 802 if ( full && mode < SYNC_PREF_NEWEST )
803 mode = SYNC_PREF_ASK; 803 mode = SYNC_PREF_ASK;
804 804
805 switch( mode ) { 805 switch( mode ) {
806 case SYNC_PREF_LOCAL: 806 case SYNC_PREF_LOCAL:
807 if ( lastSync > remoteMod ) 807 if ( lastSync > remoteMod )
808 return 1; 808 return 1;
809 if ( lastSync > localMod ) 809 if ( lastSync > localMod )
810 return 2; 810 return 2;
811 return 1; 811 return 1;
812 break; 812 break;
813 case SYNC_PREF_REMOTE: 813 case SYNC_PREF_REMOTE:
814 if ( lastSync > remoteMod ) 814 if ( lastSync > remoteMod )
815 return 1; 815 return 1;
816 if ( lastSync > localMod ) 816 if ( lastSync > localMod )
817 return 2; 817 return 2;
818 return 2; 818 return 2;
819 break; 819 break;
820 case SYNC_PREF_NEWEST: 820 case SYNC_PREF_NEWEST:
821 if ( localMod > remoteMod ) 821 if ( localMod > remoteMod )
822 return 1; 822 return 1;
823 else 823 else
824 return 2; 824 return 2;
825 break; 825 break;
826 case SYNC_PREF_ASK: 826 case SYNC_PREF_ASK:
827 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 827 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
828 if ( lastSync > remoteMod ) 828 if ( lastSync > remoteMod )
829 return 1; 829 return 1;
830 if ( lastSync > localMod ) 830 if ( lastSync > localMod )
831 return 2; 831 return 2;
832 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 832 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
833 localIsNew = localMod >= remoteMod; 833 localIsNew = localMod >= remoteMod;
834 if ( localIsNew ) 834 if ( localIsNew )
835 getEventViewerDialog()->setColorMode( 1 ); 835 getEventViewerDialog()->setColorMode( 1 );
836 else 836 else
837 getEventViewerDialog()->setColorMode( 2 ); 837 getEventViewerDialog()->setColorMode( 2 );
838 getEventViewerDialog()->setIncidence(local); 838 getEventViewerDialog()->setIncidence(local);
839 if ( localIsNew ) 839 if ( localIsNew )
840 getEventViewerDialog()->setColorMode( 2 ); 840 getEventViewerDialog()->setColorMode( 2 );
841 else 841 else
842 getEventViewerDialog()->setColorMode( 1 ); 842 getEventViewerDialog()->setColorMode( 1 );
843 getEventViewerDialog()->addIncidence(remote); 843 getEventViewerDialog()->addIncidence(remote);
844 getEventViewerDialog()->setColorMode( 0 ); 844 getEventViewerDialog()->setColorMode( 0 );
845 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 845 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
846 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 846 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
847 getEventViewerDialog()->showMe(); 847 getEventViewerDialog()->showMe();
848 result = getEventViewerDialog()->executeS( localIsNew ); 848 result = getEventViewerDialog()->executeS( localIsNew );
849 return result; 849 return result;
850 850
851 break; 851 break;
852 case SYNC_PREF_FORCE_LOCAL: 852 case SYNC_PREF_FORCE_LOCAL:
853 return 1; 853 return 1;
854 break; 854 break;
855 case SYNC_PREF_FORCE_REMOTE: 855 case SYNC_PREF_FORCE_REMOTE:
856 return 2; 856 return 2;
857 break; 857 break;
858 858
859 default: 859 default:
860 // SYNC_PREF_TAKE_BOTH not implemented 860 // SYNC_PREF_TAKE_BOTH not implemented
861 break; 861 break;
862 } 862 }
863 return 0; 863 return 0;
864} 864}
865Event* CalendarView::getLastSyncEvent() 865Event* CalendarView::getLastSyncEvent()
866{ 866{
867 Event* lse; 867 Event* lse;
868 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 868 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
869 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 869 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
870 if (!lse) { 870 if (!lse) {
871 lse = new Event(); 871 lse = new Event();
872 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 872 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
873 QString sum = ""; 873 QString sum = "";
874 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 874 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
875 sum = "E: "; 875 sum = "E: ";
876 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 876 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
877 lse->setDtStart( mLastCalendarSync ); 877 lse->setDtStart( mLastCalendarSync );
878 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 878 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
879 lse->setCategories( i18n("SyncEvent") ); 879 lse->setCategories( i18n("SyncEvent") );
880 lse->setReadOnly( true ); 880 lse->setReadOnly( true );
881 mCalendar->addEvent( lse ); 881 mCalendar->addEvent( lse );
882 } 882 }
883 883
884 return lse; 884 return lse;
885 885
886} 886}
887 887
888// we check, if the to delete event has a id for a profile 888// we check, if the to delete event has a id for a profile
889// if yes, we set this id in the profile to delete 889// if yes, we set this id in the profile to delete
890void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 890void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
891{ 891{
892 if ( lastSync.count() == 0 ) { 892 if ( lastSync.count() == 0 ) {
893 //qDebug(" lastSync.count() == 0"); 893 //qDebug(" lastSync.count() == 0");
894 return; 894 return;
895 } 895 }
896 if ( toDelete->type() == "Journal" ) 896 if ( toDelete->type() == "Journal" )
897 return; 897 return;
898 898
899 Event* eve = lastSync.first(); 899 Event* eve = lastSync.first();
900 900
901 while ( eve ) { 901 while ( eve ) {
902 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 902 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
903 if ( !id.isEmpty() ) { 903 if ( !id.isEmpty() ) {
904 QString des = eve->description(); 904 QString des = eve->description();
905 QString pref = "e"; 905 QString pref = "e";
906 if ( toDelete->type() == "Todo" ) 906 if ( toDelete->type() == "Todo" )
907 pref = "t"; 907 pref = "t";
908 des += pref+ id + ","; 908 des += pref+ id + ",";
909 eve->setReadOnly( false ); 909 eve->setReadOnly( false );
910 eve->setDescription( des ); 910 eve->setDescription( des );
911 //qDebug("setdes %s ", des.latin1()); 911 //qDebug("setdes %s ", des.latin1());
912 eve->setReadOnly( true ); 912 eve->setReadOnly( true );
913 } 913 }
914 eve = lastSync.next(); 914 eve = lastSync.next();
915 } 915 }
916 916
917} 917}
918void CalendarView::checkExternalId( Incidence * inc ) 918void CalendarView::checkExternalId( Incidence * inc )
919{ 919{
920 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 920 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
921 checkExternSyncEvent( lastSync, inc ); 921 checkExternSyncEvent( lastSync, inc );
922 922
923} 923}
924bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 924bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
925{ 925{
926 bool syncOK = true; 926 bool syncOK = true;
927 int addedEvent = 0; 927 int addedEvent = 0;
928 int addedEventR = 0; 928 int addedEventR = 0;
929 int deletedEventR = 0; 929 int deletedEventR = 0;
930 int deletedEventL = 0; 930 int deletedEventL = 0;
931 int changedLocal = 0; 931 int changedLocal = 0;
932 int changedRemote = 0; 932 int changedRemote = 0;
933 int filteredIN = 0; 933 int filteredIN = 0;
934 int filteredOUT = 0; 934 int filteredOUT = 0;
935 //QPtrList<Event> el = local->rawEvents(); 935 //QPtrList<Event> el = local->rawEvents();
936 Event* eventR; 936 Event* eventR;
937 QString uid; 937 QString uid;
938 int take; 938 int take;
939 Event* eventL; 939 Event* eventL;
940 Event* eventRSync; 940 Event* eventRSync;
941 Event* eventLSync; 941 Event* eventLSync;
942 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 942 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
943 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 943 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
944 bool fullDateRange = false; 944 bool fullDateRange = false;
945 local->resetTempSyncStat(); 945 local->resetTempSyncStat();
946 mLastCalendarSync = QDateTime::currentDateTime(); 946 mLastCalendarSync = QDateTime::currentDateTime();
947 if ( mSyncManager->syncWithDesktop() ) { 947 if ( mSyncManager->syncWithDesktop() ) {
948 remote->resetPilotStat(1); 948 remote->resetPilotStat(1);
949 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 949 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
950 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 950 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
951 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 951 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
952 } else { 952 } else {
953 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 953 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
954 } 954 }
955 } 955 }
956 QDateTime modifiedCalendar = mLastCalendarSync; 956 QDateTime modifiedCalendar = mLastCalendarSync;
957 eventLSync = getLastSyncEvent(); 957 eventLSync = getLastSyncEvent();
958 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 958 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
959 if ( eventR ) { 959 if ( eventR ) {
960 eventRSync = (Event*) eventR->clone(); 960 eventRSync = (Event*) eventR->clone();
961 remote->deleteEvent(eventR ); 961 remote->deleteEvent(eventR );
962 962
963 } else { 963 } else {
964 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 964 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
965 eventRSync = (Event*)eventLSync->clone(); 965 eventRSync = (Event*)eventLSync->clone();
966 } else { 966 } else {
967 fullDateRange = true; 967 fullDateRange = true;
968 eventRSync = new Event(); 968 eventRSync = new Event();
969 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 969 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
970 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 970 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
971 eventRSync->setDtStart( mLastCalendarSync ); 971 eventRSync->setDtStart( mLastCalendarSync );
972 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 972 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
973 eventRSync->setCategories( i18n("SyncEvent") ); 973 eventRSync->setCategories( i18n("SyncEvent") );
974 } 974 }
975 } 975 }
976 if ( eventLSync->dtStart() == mLastCalendarSync ) 976 if ( eventLSync->dtStart() == mLastCalendarSync )
977 fullDateRange = true; 977 fullDateRange = true;
978 978
979 if ( ! fullDateRange ) { 979 if ( ! fullDateRange ) {
980 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 980 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
981 981
982 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 982 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
983 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 983 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
984 fullDateRange = true; 984 fullDateRange = true;
985 } 985 }
986 } 986 }
987 if ( mSyncManager->syncWithDesktop() ) { 987 if ( mSyncManager->syncWithDesktop() ) {
988 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 988 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
989 } 989 }
990 if ( fullDateRange ) 990 if ( fullDateRange )
991 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 991 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
992 else 992 else
993 mLastCalendarSync = eventLSync->dtStart(); 993 mLastCalendarSync = eventLSync->dtStart();
994 // for resyncing if own file has changed 994 // for resyncing if own file has changed
995 if ( mCurrentSyncDevice == "deleteaftersync" ) { 995 if ( mCurrentSyncDevice == "deleteaftersync" ) {
996 mLastCalendarSync = loadedFileVersion; 996 mLastCalendarSync = loadedFileVersion;
997 //qDebug("setting mLastCalendarSync "); 997 //qDebug("setting mLastCalendarSync ");
998 } 998 }
999 //qDebug("*************************** "); 999 //qDebug("*************************** ");
1000 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1000 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1001 QPtrList<Incidence> er = remote->rawIncidences(); 1001 QPtrList<Incidence> er = remote->rawIncidences();
1002 Incidence* inR = er.first(); 1002 Incidence* inR = er.first();
1003 Incidence* inL; 1003 Incidence* inL;
1004 QProgressBar bar( er.count(),0 ); 1004 QProgressBar bar( er.count(),0 );
1005 bar.setCaption (i18n("Syncing - close to abort!") ); 1005 bar.setCaption (i18n("Syncing - close to abort!") );
1006 1006
1007 // ************** setting up filter ************* 1007 // ************** setting up filter *************
1008 CalFilter *filterIN = 0; 1008 CalFilter *filterIN = 0;
1009 CalFilter *filterOUT = 0; 1009 CalFilter *filterOUT = 0;
1010 CalFilter *filter = mFilters.first(); 1010 CalFilter *filter = mFilters.first();
1011 while(filter) { 1011 while(filter) {
1012 if ( filter->name() == mSyncManager->mFilterInCal ) 1012 if ( filter->name() == mSyncManager->mFilterInCal )
1013 filterIN = filter; 1013 filterIN = filter;
1014 if ( filter->name() == mSyncManager->mFilterOutCal ) 1014 if ( filter->name() == mSyncManager->mFilterOutCal )
1015 filterOUT = filter; 1015 filterOUT = filter;
1016 filter = mFilters.next(); 1016 filter = mFilters.next();
1017 } 1017 }
1018 int w = 300; 1018 int w = 300;
1019 if ( QApplication::desktop()->width() < 320 ) 1019 if ( QApplication::desktop()->width() < 320 )
1020 w = 220; 1020 w = 220;
1021 int h = bar.sizeHint().height() ; 1021 int h = bar.sizeHint().height() ;
1022 int dw = QApplication::desktop()->width(); 1022 int dw = QApplication::desktop()->width();
1023 int dh = QApplication::desktop()->height(); 1023 int dh = QApplication::desktop()->height();
1024 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1024 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1025 bar.show(); 1025 bar.show();
1026 int modulo = (er.count()/10)+1; 1026 int modulo = (er.count()/10)+1;
1027 int incCounter = 0; 1027 int incCounter = 0;
1028 while ( inR ) { 1028 while ( inR ) {
1029 if ( ! bar.isVisible() ) 1029 if ( ! bar.isVisible() )
1030 return false; 1030 return false;
1031 if ( incCounter % modulo == 0 ) 1031 if ( incCounter % modulo == 0 )
1032 bar.setProgress( incCounter ); 1032 bar.setProgress( incCounter );
1033 ++incCounter; 1033 ++incCounter;
1034 uid = inR->uid(); 1034 uid = inR->uid();
1035 bool skipIncidence = false; 1035 bool skipIncidence = false;
1036 if ( uid.left(15) == QString("last-syncEvent-") ) 1036 if ( uid.left(15) == QString("last-syncEvent-") )
1037 skipIncidence = true; 1037 skipIncidence = true;
1038 QString idS; 1038 QString idS;
1039 qApp->processEvents(); 1039 qApp->processEvents();
1040 if ( !skipIncidence ) { 1040 if ( !skipIncidence ) {
1041 inL = local->incidence( uid ); 1041 inL = local->incidence( uid );
1042 if ( inL ) { // maybe conflict - same uid in both calendars 1042 if ( inL ) { // maybe conflict - same uid in both calendars
1043 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1043 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1044 //qDebug("take %d %s ", take, inL->summary().latin1()); 1044 //qDebug("take %d %s ", take, inL->summary().latin1());
1045 if ( take == 3 ) 1045 if ( take == 3 )
1046 return false; 1046 return false;
1047 if ( take == 1 ) {// take local ********************** 1047 if ( take == 1 ) {// take local **********************
1048 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1048 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1049 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1049 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1050 else 1050 else
1051 idS = inR->IDStr(); 1051 idS = inR->IDStr();
1052 remote->deleteIncidence( inR ); 1052 remote->deleteIncidence( inR );
1053 inR = inL->clone(); 1053 inR = inL->clone();
1054 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1054 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1055 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1055 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1056 inR->setIDStr( idS ); 1056 inR->setIDStr( idS );
1057 remote->addIncidence( inR ); 1057 remote->addIncidence( inR );
1058 if ( mSyncManager->syncWithDesktop() ) 1058 if ( mSyncManager->syncWithDesktop() )
1059 inR->setPilotId( 2 ); 1059 inR->setPilotId( 2 );
1060 ++changedRemote; 1060 ++changedRemote;
1061 } else {// take remote ********************** 1061 } else {// take remote **********************
1062 idS = inL->IDStr(); 1062 idS = inL->IDStr();
1063 int pid = inL->pilotId(); 1063 int pid = inL->pilotId();
1064 local->deleteIncidence( inL ); 1064 local->deleteIncidence( inL );
1065 inL = inR->clone(); 1065 inL = inR->clone();
1066 if ( mSyncManager->syncWithDesktop() ) 1066 if ( mSyncManager->syncWithDesktop() )
1067 inL->setPilotId( pid ); 1067 inL->setPilotId( pid );
1068 inL->setIDStr( idS ); 1068 inL->setIDStr( idS );
1069 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1069 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1070 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1070 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1071 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1071 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1072 } 1072 }
1073 local->addIncidence( inL ); 1073 local->addIncidence( inL );
1074 ++changedLocal; 1074 ++changedLocal;
1075 } 1075 }
1076 } 1076 }
1077 } else { // no conflict ********** add or delete remote 1077 } else { // no conflict ********** add or delete remote
1078 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1078 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1079 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1079 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1080 QString des = eventLSync->description(); 1080 QString des = eventLSync->description();
1081 QString pref = "e"; 1081 QString pref = "e";
1082 if ( inR->type() == "Todo" ) 1082 if ( inR->type() == "Todo" )
1083 pref = "t"; 1083 pref = "t";
1084 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1084 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1085 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1085 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1086 //remote->deleteIncidence( inR ); 1086 //remote->deleteIncidence( inR );
1087 ++deletedEventR; 1087 ++deletedEventR;
1088 } else { 1088 } else {
1089 inR->setLastModified( modifiedCalendar ); 1089 inR->setLastModified( modifiedCalendar );
1090 inL = inR->clone(); 1090 inL = inR->clone();
1091 inL->setIDStr( ":" ); 1091 inL->setIDStr( ":" );
1092 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1092 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1093 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1093 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1094 local->addIncidence( inL ); 1094 local->addIncidence( inL );
1095 ++addedEvent; 1095 ++addedEvent;
1096 1096
1097 } 1097 }
1098 } else { 1098 } else {
1099 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1099 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1100 inR->setLastModified( modifiedCalendar ); 1100 inR->setLastModified( modifiedCalendar );
1101 inL = inR->clone(); 1101 inL = inR->clone();
1102 inL->setIDStr( ":" ); 1102 inL->setIDStr( ":" );
1103 local->addIncidence( inL ); 1103 local->addIncidence( inL );
1104 ++addedEvent; 1104 ++addedEvent;
1105 1105
1106 } else { 1106 } else {
1107 checkExternSyncEvent(eventRSyncSharp, inR); 1107 checkExternSyncEvent(eventRSyncSharp, inR);
1108 remote->deleteIncidence( inR ); 1108 remote->deleteIncidence( inR );
1109 ++deletedEventR; 1109 ++deletedEventR;
1110 } 1110 }
1111 } 1111 }
1112 } else { 1112 } else {
1113 ++filteredIN; 1113 ++filteredIN;
1114 } 1114 }
1115 } 1115 }
1116 } 1116 }
1117 inR = er.next(); 1117 inR = er.next();
1118 } 1118 }
1119 QPtrList<Incidence> el = local->rawIncidences(); 1119 QPtrList<Incidence> el = local->rawIncidences();
1120 inL = el.first(); 1120 inL = el.first();
1121 modulo = (el.count()/10)+1; 1121 modulo = (el.count()/10)+1;
1122 bar.setCaption (i18n("Add / remove events") ); 1122 bar.setCaption (i18n("Add / remove events") );
1123 bar.setTotalSteps ( el.count() ) ; 1123 bar.setTotalSteps ( el.count() ) ;
1124 bar.show(); 1124 bar.show();
1125 incCounter = 0; 1125 incCounter = 0;
1126 1126
1127 while ( inL ) { 1127 while ( inL ) {
1128 1128
1129 qApp->processEvents(); 1129 qApp->processEvents();
1130 if ( ! bar.isVisible() ) 1130 if ( ! bar.isVisible() )
1131 return false; 1131 return false;
1132 if ( incCounter % modulo == 0 ) 1132 if ( incCounter % modulo == 0 )
1133 bar.setProgress( incCounter ); 1133 bar.setProgress( incCounter );
1134 ++incCounter; 1134 ++incCounter;
1135 uid = inL->uid(); 1135 uid = inL->uid();
1136 bool skipIncidence = false; 1136 bool skipIncidence = false;
1137 if ( uid.left(15) == QString("last-syncEvent-") ) 1137 if ( uid.left(15) == QString("last-syncEvent-") )
1138 skipIncidence = true; 1138 skipIncidence = true;
1139 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1139 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1140 skipIncidence = true; 1140 skipIncidence = true;
1141 if ( !skipIncidence ) { 1141 if ( !skipIncidence ) {
1142 inR = remote->incidence( uid ); 1142 inR = remote->incidence( uid );
1143 if ( ! inR ) { 1143 if ( ! inR ) {
1144 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1144 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1145 // no conflict ********** add or delete local 1145 // no conflict ********** add or delete local
1146 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1146 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1147 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1147 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1148 checkExternSyncEvent(eventLSyncSharp, inL); 1148 checkExternSyncEvent(eventLSyncSharp, inL);
1149 local->deleteIncidence( inL ); 1149 local->deleteIncidence( inL );
1150 ++deletedEventL; 1150 ++deletedEventL;
1151 } else { 1151 } else {
1152 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1152 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1153 inL->removeID(mCurrentSyncDevice ); 1153 inL->removeID(mCurrentSyncDevice );
1154 ++addedEventR; 1154 ++addedEventR;
1155 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1155 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1156 inL->setLastModified( modifiedCalendar ); 1156 inL->setLastModified( modifiedCalendar );
1157 inR = inL->clone(); 1157 inR = inL->clone();
1158 inR->setIDStr( ":" ); 1158 inR->setIDStr( ":" );
1159 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1159 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1160 remote->addIncidence( inR ); 1160 remote->addIncidence( inR );
1161 } 1161 }
1162 } 1162 }
1163 } else { 1163 } else {
1164 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1164 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1165 checkExternSyncEvent(eventLSyncSharp, inL); 1165 checkExternSyncEvent(eventLSyncSharp, inL);
1166 local->deleteIncidence( inL ); 1166 local->deleteIncidence( inL );
1167 ++deletedEventL; 1167 ++deletedEventL;
1168 } else { 1168 } else {
1169 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1169 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1170 ++addedEventR; 1170 ++addedEventR;
1171 inL->setLastModified( modifiedCalendar ); 1171 inL->setLastModified( modifiedCalendar );
1172 inR = inL->clone(); 1172 inR = inL->clone();
1173 inR->setIDStr( ":" ); 1173 inR->setIDStr( ":" );
1174 remote->addIncidence( inR ); 1174 remote->addIncidence( inR );
1175 } 1175 }
1176 } 1176 }
1177 } 1177 }
1178 } else { 1178 } else {
1179 ++filteredOUT; 1179 ++filteredOUT;
1180 } 1180 }
1181 } 1181 }
1182 } 1182 }
1183 inL = el.next(); 1183 inL = el.next();
1184 } 1184 }
1185 int delFut = 0; 1185 int delFut = 0;
1186 int remRem = 0; 1186 int remRem = 0;
1187 if ( mSyncManager->mWriteBackInFuture ) { 1187 if ( mSyncManager->mWriteBackInFuture ) {
1188 er = remote->rawIncidences(); 1188 er = remote->rawIncidences();
1189 remRem = er.count(); 1189 remRem = er.count();
1190 inR = er.first(); 1190 inR = er.first();
1191 QDateTime dt; 1191 QDateTime dt;
1192 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1192 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1193 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1193 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1194 while ( inR ) { 1194 while ( inR ) {
1195 if ( inR->type() == "Todo" ) { 1195 if ( inR->type() == "Todo" ) {
1196 Todo * t = (Todo*)inR; 1196 Todo * t = (Todo*)inR;
1197 if ( t->hasDueDate() ) 1197 if ( t->hasDueDate() )
1198 dt = t->dtDue(); 1198 dt = t->dtDue();
1199 else 1199 else
1200 dt = cur.addSecs( 62 ); 1200 dt = cur.addSecs( 62 );
1201 } 1201 }
1202 else if (inR->type() == "Event" ) { 1202 else if (inR->type() == "Event" ) {
1203 bool ok; 1203 bool ok;
1204 dt = inR->getNextOccurence( cur, &ok ); 1204 dt = inR->getNextOccurence( cur, &ok );
1205 if ( !ok ) 1205 if ( !ok )
1206 dt = cur.addSecs( -62 ); 1206 dt = cur.addSecs( -62 );
1207 } 1207 }
1208 else 1208 else
1209 dt = inR->dtStart(); 1209 dt = inR->dtStart();
1210 if ( dt < cur || dt > end ) { 1210 if ( dt < cur || dt > end ) {
1211 remote->deleteIncidence( inR ); 1211 remote->deleteIncidence( inR );
1212 ++delFut; 1212 ++delFut;
1213 } 1213 }
1214 inR = er.next(); 1214 inR = er.next();
1215 } 1215 }
1216 } 1216 }
1217 bar.hide(); 1217 bar.hide();
1218 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1218 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1219 eventLSync->setReadOnly( false ); 1219 eventLSync->setReadOnly( false );
1220 eventLSync->setDtStart( mLastCalendarSync ); 1220 eventLSync->setDtStart( mLastCalendarSync );
1221 eventRSync->setDtStart( mLastCalendarSync ); 1221 eventRSync->setDtStart( mLastCalendarSync );
1222 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1222 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1223 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1223 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1224 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1224 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1225 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1225 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1226 eventLSync->setReadOnly( true ); 1226 eventLSync->setReadOnly( true );
1227 qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); 1227 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1228 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1228 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1229 remote->addEvent( eventRSync ); 1229 remote->addEvent( eventRSync );
1230 else 1230 else
1231 delete eventRSync; 1231 delete eventRSync;
1232 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1232 QString mes; 1233 QString mes;
1233 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1234 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1234 QString delmess; 1235 QString delmess;
1235 if ( delFut ) { 1236 if ( delFut ) {
1236 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1237 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1237 mes += delmess; 1238 mes += delmess;
1238 } 1239 }
1239 mes = i18n("Local calendar changed!\n") +mes; 1240 mes = i18n("Local calendar changed!\n") +mes;
1240 mCalendar->checkAlarmForIncidence( 0, true ); 1241 mCalendar->checkAlarmForIncidence( 0, true );
1241 qDebug( mes ); 1242 qDebug( mes );
1242 if ( mSyncManager->mShowSyncSummary ) { 1243 if ( mSyncManager->mShowSyncSummary ) {
1243 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1244 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1244 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1245 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1245 qDebug("cancelled "); 1246 qDebug("KO: WB cancelled ");
1246 return false; 1247 return false;
1247 } 1248 }
1248 } 1249 }
1249 return syncOK; 1250 return syncOK;
1250} 1251}
1251 1252
1252void CalendarView::setSyncDevice( QString s ) 1253void CalendarView::setSyncDevice( QString s )
1253{ 1254{
1254 mCurrentSyncDevice= s; 1255 mCurrentSyncDevice= s;
1255} 1256}
1256void CalendarView::setSyncName( QString s ) 1257void CalendarView::setSyncName( QString s )
1257{ 1258{
1258 mCurrentSyncName= s; 1259 mCurrentSyncName= s;
1259} 1260}
1260bool CalendarView::syncCalendar(QString filename, int mode) 1261bool CalendarView::syncCalendar(QString filename, int mode)
1261{ 1262{
1262 //qDebug("syncCalendar %s ", filename.latin1()); 1263 //qDebug("syncCalendar %s ", filename.latin1());
1263 mGlobalSyncMode = SYNC_MODE_NORMAL; 1264 mGlobalSyncMode = SYNC_MODE_NORMAL;
1264 CalendarLocal* calendar = new CalendarLocal(); 1265 CalendarLocal* calendar = new CalendarLocal();
1265 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1266 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1266 FileStorage* storage = new FileStorage( calendar ); 1267 FileStorage* storage = new FileStorage( calendar );
1267 bool syncOK = false; 1268 bool syncOK = false;
1268 storage->setFileName( filename ); 1269 storage->setFileName( filename );
1269 // qDebug("loading ... "); 1270 // qDebug("loading ... ");
1270 if ( storage->load() ) { 1271 if ( storage->load() ) {
1271 getEventViewerDialog()->setSyncMode( true ); 1272 getEventViewerDialog()->setSyncMode( true );
1272 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1273 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1273 getEventViewerDialog()->setSyncMode( false ); 1274 getEventViewerDialog()->setSyncMode( false );
1274 if ( syncOK ) { 1275 if ( syncOK ) {
1275 if ( mSyncManager->mWriteBackFile ) 1276 if ( mSyncManager->mWriteBackFile )
1276 { 1277 {
1277 storage->setSaveFormat( new ICalFormat() ); 1278 storage->setSaveFormat( new ICalFormat() );
1278 storage->save(); 1279 storage->save();
1279 } 1280 }
1280 } 1281 }
1281 setModified( true ); 1282 setModified( true );
1282 } 1283 }
1283 delete storage; 1284 delete storage;
1284 delete calendar; 1285 delete calendar;
1285 if ( syncOK ) 1286 if ( syncOK )
1286 updateView(); 1287 updateView();
1287 return syncOK; 1288 return syncOK;
1288} 1289}
1289 1290
1290void CalendarView::syncExternal( int mode ) 1291void CalendarView::syncExternal( int mode )
1291{ 1292{
1292 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1293 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1293 1294
1294 qApp->processEvents(); 1295 qApp->processEvents();
1295 CalendarLocal* calendar = new CalendarLocal(); 1296 CalendarLocal* calendar = new CalendarLocal();
1296 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1297 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1297 bool syncOK = false; 1298 bool syncOK = false;
1298 bool loadSuccess = false; 1299 bool loadSuccess = false;
1299 PhoneFormat* phoneFormat = 0; 1300 PhoneFormat* phoneFormat = 0;
1300 emit tempDisableBR(true); 1301 emit tempDisableBR(true);
1301#ifndef DESKTOP_VERSION 1302#ifndef DESKTOP_VERSION
1302 SharpFormat* sharpFormat = 0; 1303 SharpFormat* sharpFormat = 0;
1303 if ( mode == 0 ) { // sharp 1304 if ( mode == 0 ) { // sharp
1304 sharpFormat = new SharpFormat () ; 1305 sharpFormat = new SharpFormat () ;
1305 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1306 loadSuccess = sharpFormat->load( calendar, mCalendar );
1306 1307
1307 } else 1308 } else
1308#endif 1309#endif
1309 if ( mode == 1 ) { // phone 1310 if ( mode == 1 ) { // phone
1310 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1311 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1311 mSyncManager->mPhoneDevice, 1312 mSyncManager->mPhoneDevice,
1312 mSyncManager->mPhoneConnection, 1313 mSyncManager->mPhoneConnection,
1313 mSyncManager->mPhoneModel); 1314 mSyncManager->mPhoneModel);
1314 loadSuccess = phoneFormat->load( calendar,mCalendar); 1315 loadSuccess = phoneFormat->load( calendar,mCalendar);
1315 1316
1316 } else { 1317 } else {
1317 emit tempDisableBR(false); 1318 emit tempDisableBR(false);
1318 return; 1319 return;
1319 } 1320 }
1320 if ( loadSuccess ) { 1321 if ( loadSuccess ) {
1321 getEventViewerDialog()->setSyncMode( true ); 1322 getEventViewerDialog()->setSyncMode( true );
1322 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1323 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1323 getEventViewerDialog()->setSyncMode( false ); 1324 getEventViewerDialog()->setSyncMode( false );
1324 qApp->processEvents(); 1325 qApp->processEvents();
1325 if ( syncOK ) { 1326 if ( syncOK ) {
1326 if ( mSyncManager->mWriteBackFile ) 1327 if ( mSyncManager->mWriteBackFile )
1327 { 1328 {
1328 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1329 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1329 Incidence* inc = iL.first(); 1330 Incidence* inc = iL.first();
1330 if ( phoneFormat ) { 1331 if ( phoneFormat ) {
1331 while ( inc ) { 1332 while ( inc ) {
1332 inc->removeID(mCurrentSyncDevice); 1333 inc->removeID(mCurrentSyncDevice);
1333 inc = iL.next(); 1334 inc = iL.next();
1334 } 1335 }
1335 } 1336 }
1336#ifndef DESKTOP_VERSION 1337#ifndef DESKTOP_VERSION
1337 if ( sharpFormat ) 1338 if ( sharpFormat )
1338 sharpFormat->save(calendar); 1339 sharpFormat->save(calendar);
1339#endif 1340#endif
1340 if ( phoneFormat ) 1341 if ( phoneFormat )
1341 phoneFormat->save(calendar); 1342 phoneFormat->save(calendar);
1342 iL = calendar->rawIncidences(); 1343 iL = calendar->rawIncidences();
1343 inc = iL.first(); 1344 inc = iL.first();
1344 Incidence* loc; 1345 Incidence* loc;
1345 while ( inc ) { 1346 while ( inc ) {
1346 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1347 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1347 loc = mCalendar->incidence(inc->uid() ); 1348 loc = mCalendar->incidence(inc->uid() );
1348 if ( loc ) { 1349 if ( loc ) {
1349 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1350 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1350 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1351 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1351 } 1352 }
1352 } 1353 }
1353 inc = iL.next(); 1354 inc = iL.next();
1354 } 1355 }
1355 Incidence* lse = getLastSyncEvent(); 1356 Incidence* lse = getLastSyncEvent();
1356 if ( lse ) { 1357 if ( lse ) {
1357 lse->setReadOnly( false ); 1358 lse->setReadOnly( false );
1358 lse->setDescription( "" ); 1359 lse->setDescription( "" );
1359 lse->setReadOnly( true ); 1360 lse->setReadOnly( true );
1360 } 1361 }
1361 } 1362 }
1362 } else { 1363 } else {
1363 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1364 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1364 } 1365 }
1365 setModified( true ); 1366 setModified( true );
1366 } else { 1367 } else {
1367 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1368 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1368 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1369 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1369 question, i18n("Ok")) ; 1370 question, i18n("Ok")) ;
1370 1371
1371 } 1372 }
1372 delete calendar; 1373 delete calendar;
1373 updateView(); 1374 updateView();
1374 emit tempDisableBR(false); 1375 emit tempDisableBR(false);
1375 return ;//syncOK; 1376 return ;//syncOK;
1376 1377
1377} 1378}
1378 1379
1379bool CalendarView::importBday() 1380bool CalendarView::importBday()
1380{ 1381{
1381#ifndef KORG_NOKABC 1382#ifndef KORG_NOKABC
1382 1383
1383#ifdef DESKTOP_VERSION 1384#ifdef DESKTOP_VERSION
1384 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1385 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1385 KABC::AddressBook::Iterator it; 1386 KABC::AddressBook::Iterator it;
1386 int count = 0; 1387 int count = 0;
1387 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1388 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1388 ++count; 1389 ++count;
1389 } 1390 }
1390 QProgressBar bar(count,0 ); 1391 QProgressBar bar(count,0 );
1391 int w = 300; 1392 int w = 300;
1392 if ( QApplication::desktop()->width() < 320 ) 1393 if ( QApplication::desktop()->width() < 320 )
1393 w = 220; 1394 w = 220;
1394 int h = bar.sizeHint().height() ; 1395 int h = bar.sizeHint().height() ;
1395 int dw = QApplication::desktop()->width(); 1396 int dw = QApplication::desktop()->width();
1396 int dh = QApplication::desktop()->height(); 1397 int dh = QApplication::desktop()->height();
1397 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1398 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1398 bar.show(); 1399 bar.show();
1399 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1400 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1400 qApp->processEvents(); 1401 qApp->processEvents();
1401 count = 0; 1402 count = 0;
1402 int addCount = 0; 1403 int addCount = 0;
1403 KCal::Attendee* a = 0; 1404 KCal::Attendee* a = 0;
1404 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1405 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1405 if ( ! bar.isVisible() ) 1406 if ( ! bar.isVisible() )
1406 return false; 1407 return false;
1407 bar.setProgress( count++ ); 1408 bar.setProgress( count++ );
1408 qApp->processEvents(); 1409 qApp->processEvents();
1409 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1410 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1410 if ( (*it).birthday().date().isValid() ){ 1411 if ( (*it).birthday().date().isValid() ){
1411 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1412 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1412 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1413 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1413 ++addCount; 1414 ++addCount;
1414 } 1415 }
1415 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1416 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1416 if ( anni.isValid() ){ 1417 if ( anni.isValid() ){
1417 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1418 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1418 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1419 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1419 ++addCount; 1420 ++addCount;
1420 } 1421 }
1421 } 1422 }
1422 updateView(); 1423 updateView();
1423 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1424 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1424#else //DESKTOP_VERSION 1425#else //DESKTOP_VERSION
1425 1426
1426 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1427 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1427 // the result should now arrive through method insertBirthdays 1428 // the result should now arrive through method insertBirthdays
1428 1429
1429#endif //DESKTOP_VERSION 1430#endif //DESKTOP_VERSION
1430 1431
1431#endif //KORG_NOKABC 1432#endif //KORG_NOKABC
1432 1433
1433 1434
1434 return true; 1435 return true;
1435} 1436}
1436 1437
1437// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1438// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1438void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1439void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1439 const QStringList& anniversaryList, const QStringList& realNameList, 1440 const QStringList& anniversaryList, const QStringList& realNameList,
1440 const QStringList& emailList, const QStringList& assembledNameList, 1441 const QStringList& emailList, const QStringList& assembledNameList,
1441 const QStringList& uidList) 1442 const QStringList& uidList)
1442{ 1443{
1443 qDebug("CalendarView::insertBirthdays"); 1444 //qDebug("KO::CalendarView::insertBirthdays");
1444 if (uid == this->name()) 1445 if (uid == this->name())
1445 { 1446 {
1446 int count = birthdayList.count(); 1447 int count = birthdayList.count();
1447 int addCount = 0; 1448 int addCount = 0;
1448 KCal::Attendee* a = 0; 1449 KCal::Attendee* a = 0;
1449 1450
1450 qDebug("CalView 1 %i", count); 1451 //qDebug("CalView 1 %i", count);
1451 1452
1452 QProgressBar bar(count,0 ); 1453 QProgressBar bar(count,0 );
1453 int w = 300; 1454 int w = 300;
1454 if ( QApplication::desktop()->width() < 320 ) 1455 if ( QApplication::desktop()->width() < 320 )
1455 w = 220; 1456 w = 220;
1456 int h = bar.sizeHint().height() ; 1457 int h = bar.sizeHint().height() ;
1457 int dw = QApplication::desktop()->width(); 1458 int dw = QApplication::desktop()->width();
1458 int dh = QApplication::desktop()->height(); 1459 int dh = QApplication::desktop()->height();
1459 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1460 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1460 bar.show(); 1461 bar.show();
1461 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1462 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1462 qApp->processEvents(); 1463 qApp->processEvents();
1463 1464
1464 QDate birthday; 1465 QDate birthday;
1465 QDate anniversary; 1466 QDate anniversary;
1466 QString realName; 1467 QString realName;
1467 QString email; 1468 QString email;
1468 QString assembledName; 1469 QString assembledName;
1469 QString uid; 1470 QString uid;
1470 bool ok = true; 1471 bool ok = true;
1471 for ( int i = 0; i < count; i++) 1472 for ( int i = 0; i < count; i++)
1472 { 1473 {
1473 if ( ! bar.isVisible() ) 1474 if ( ! bar.isVisible() )
1474 return; 1475 return;
1475 bar.setProgress( i ); 1476 bar.setProgress( i );
1476 qApp->processEvents(); 1477 qApp->processEvents();
1477 1478
1478 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1479 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1479 if (!ok) { 1480 if (!ok) {
1480 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1481 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1481 } 1482 }
1482 1483
1483 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1484 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1484 if (!ok) { 1485 if (!ok) {
1485 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1486 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1486 } 1487 }
1487 realName = realNameList[i]; 1488 realName = realNameList[i];
1488 email = emailList[i]; 1489 email = emailList[i];
1489 assembledName = assembledNameList[i]; 1490 assembledName = assembledNameList[i];
1490 uid = uidList[i]; 1491 uid = uidList[i];
1491 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 1492 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1492 1493
1493 if ( birthday.isValid() ){ 1494 if ( birthday.isValid() ){
1494 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1495 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1495 KCal::Attendee::ReqParticipant,uid) ; 1496 KCal::Attendee::ReqParticipant,uid) ;
1496 if ( addAnniversary( birthday, assembledName, a, true ) ) 1497 if ( addAnniversary( birthday, assembledName, a, true ) )
1497 ++addCount; 1498 ++addCount;
1498 } 1499 }
1499 1500
1500 if ( anniversary.isValid() ){ 1501 if ( anniversary.isValid() ){
1501 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1502 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1502 KCal::Attendee::ReqParticipant,uid) ; 1503 KCal::Attendee::ReqParticipant,uid) ;
1503 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1504 if ( addAnniversary( anniversary, assembledName, a, false ) )
1504 ++addCount; 1505 ++addCount;
1505 } 1506 }
1506 } 1507 }
1507 1508
1508 updateView(); 1509 updateView();
1509 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1510 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1510 1511
1511 } 1512 }
1512 1513
1513} 1514}
1514 1515
1515 1516
1516 1517
1517bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1518bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1518{ 1519{
1519 //qDebug("addAnni "); 1520 //qDebug("addAnni ");
1520 Event * ev = new Event(); 1521 Event * ev = new Event();
1521 if ( a ) { 1522 if ( a ) {
1522 ev->addAttendee( a ); 1523 ev->addAttendee( a );
1523 } 1524 }
1524 QString kind; 1525 QString kind;
1525 if ( birthday ) 1526 if ( birthday )
1526 kind = i18n( "Birthday" ); 1527 kind = i18n( "Birthday" );
1527 else 1528 else
1528 kind = i18n( "Anniversary" ); 1529 kind = i18n( "Anniversary" );
1529 ev->setSummary( name + " - " + kind ); 1530 ev->setSummary( name + " - " + kind );
1530 ev->setOrganizer(a->email()); 1531 ev->setOrganizer(a->email());
1531 ev->setCategories( kind ); 1532 ev->setCategories( kind );
1532 ev->setDtStart( QDateTime(date) ); 1533 ev->setDtStart( QDateTime(date) );
1533 ev->setDtEnd( QDateTime(date) ); 1534 ev->setDtEnd( QDateTime(date) );
1534 ev->setFloats( true ); 1535 ev->setFloats( true );
1535 Recurrence * rec = ev->recurrence(); 1536 Recurrence * rec = ev->recurrence();
1536 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1537 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1537 rec->addYearlyNum( date.month() ); 1538 rec->addYearlyNum( date.month() );
1538 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1539 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1539 delete ev; 1540 delete ev;
1540 return false; 1541 return false;
1541 } 1542 }
1542 return true; 1543 return true;
1543 1544
1544} 1545}
1545bool CalendarView::importQtopia( const QString &categories, 1546bool CalendarView::importQtopia( const QString &categories,
1546 const QString &datebook, 1547 const QString &datebook,
1547 const QString &todolist ) 1548 const QString &todolist )
1548{ 1549{
1549 1550
1550 QtopiaFormat qtopiaFormat; 1551 QtopiaFormat qtopiaFormat;
1551 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1552 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1552 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1553 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1553 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1554 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1554 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1555 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1555 1556
1556 updateView(); 1557 updateView();
1557 return true; 1558 return true;
1558 1559
1559#if 0 1560#if 0
1560 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1561 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1561 mCurrentSyncDevice = "qtopia-XML"; 1562 mCurrentSyncDevice = "qtopia-XML";
1562 if ( mSyncManager->mAskForPreferences ) 1563 if ( mSyncManager->mAskForPreferences )
1563 edit_sync_options(); 1564 edit_sync_options();
1564 qApp->processEvents(); 1565 qApp->processEvents();
1565 CalendarLocal* calendar = new CalendarLocal(); 1566 CalendarLocal* calendar = new CalendarLocal();
1566 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1567 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1567 bool syncOK = false; 1568 bool syncOK = false;
1568 QtopiaFormat qtopiaFormat; 1569 QtopiaFormat qtopiaFormat;
1569 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1570 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1570 bool loadOk = true; 1571 bool loadOk = true;
1571 if ( !categories.isEmpty() ) 1572 if ( !categories.isEmpty() )
1572 loadOk = qtopiaFormat.load( calendar, categories ); 1573 loadOk = qtopiaFormat.load( calendar, categories );
1573 if ( loadOk && !datebook.isEmpty() ) 1574 if ( loadOk && !datebook.isEmpty() )
1574 loadOk = qtopiaFormat.load( calendar, datebook ); 1575 loadOk = qtopiaFormat.load( calendar, datebook );
1575 if ( loadOk && !todolist.isEmpty() ) 1576 if ( loadOk && !todolist.isEmpty() )
1576 loadOk = qtopiaFormat.load( calendar, todolist ); 1577 loadOk = qtopiaFormat.load( calendar, todolist );
1577 1578
1578 if ( loadOk ) { 1579 if ( loadOk ) {
1579 getEventViewerDialog()->setSyncMode( true ); 1580 getEventViewerDialog()->setSyncMode( true );
1580 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1581 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1581 getEventViewerDialog()->setSyncMode( false ); 1582 getEventViewerDialog()->setSyncMode( false );
1582 qApp->processEvents(); 1583 qApp->processEvents();
1583 if ( syncOK ) { 1584 if ( syncOK ) {
1584 if ( mSyncManager->mWriteBackFile ) 1585 if ( mSyncManager->mWriteBackFile )
1585 { 1586 {
1586 // write back XML file 1587 // write back XML file
1587 1588
1588 } 1589 }
1589 setModified( true ); 1590 setModified( true );
1590 } 1591 }
1591 } else { 1592 } else {
1592 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1593 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1593 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1594 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1594 question, i18n("Ok")) ; 1595 question, i18n("Ok")) ;
1595 } 1596 }
1596 delete calendar; 1597 delete calendar;
1597 updateView(); 1598 updateView();
1598 return syncOK; 1599 return syncOK;
1599 1600
1600 1601
1601#endif 1602#endif
1602 1603
1603} 1604}
1604 1605
1605void CalendarView::setSyncEventsReadOnly() 1606void CalendarView::setSyncEventsReadOnly()
1606{ 1607{
1607 Event * ev; 1608 Event * ev;
1608 QPtrList<Event> eL = mCalendar->rawEvents(); 1609 QPtrList<Event> eL = mCalendar->rawEvents();
1609 ev = eL.first(); 1610 ev = eL.first();
1610 while ( ev ) { 1611 while ( ev ) {
1611 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1612 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1612 ev->setReadOnly( true ); 1613 ev->setReadOnly( true );
1613 ev = eL.next(); 1614 ev = eL.next();
1614 } 1615 }
1615} 1616}
1616bool CalendarView::openCalendar(QString filename, bool merge) 1617bool CalendarView::openCalendar(QString filename, bool merge)
1617{ 1618{
1618 1619
1619 if (filename.isEmpty()) { 1620 if (filename.isEmpty()) {
1620 return false; 1621 return false;
1621 } 1622 }
1622 1623
1623 if (!QFile::exists(filename)) { 1624 if (!QFile::exists(filename)) {
1624 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1625 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1625 return false; 1626 return false;
1626 } 1627 }
1627 1628
1628 globalFlagBlockAgenda = 1; 1629 globalFlagBlockAgenda = 1;
1629 if (!merge) mCalendar->close(); 1630 if (!merge) mCalendar->close();
1630 1631
1631 mStorage->setFileName( filename ); 1632 mStorage->setFileName( filename );
1632 1633
1633 if ( mStorage->load() ) { 1634 if ( mStorage->load() ) {
1634 if ( merge ) ;//setModified( true ); 1635 if ( merge ) ;//setModified( true );
1635 else { 1636 else {
1636 //setModified( true ); 1637 //setModified( true );
1637 mViewManager->setDocumentId( filename ); 1638 mViewManager->setDocumentId( filename );
1638 mDialogManager->setDocumentId( filename ); 1639 mDialogManager->setDocumentId( filename );
1639 mTodoList->setDocumentId( filename ); 1640 mTodoList->setDocumentId( filename );
1640 } 1641 }
1641 globalFlagBlockAgenda = 2; 1642 globalFlagBlockAgenda = 2;
1642 // if ( getLastSyncEvent() ) 1643 // if ( getLastSyncEvent() )
1643 // getLastSyncEvent()->setReadOnly( true ); 1644 // getLastSyncEvent()->setReadOnly( true );
1644 mCalendar->reInitAlarmSettings(); 1645 mCalendar->reInitAlarmSettings();
1645 setSyncEventsReadOnly(); 1646 setSyncEventsReadOnly();
1646 updateUnmanagedViews(); 1647 updateUnmanagedViews();
1647 updateView(); 1648 updateView();
1648 if ( filename != MainWindow::defaultFileName() ) { 1649 if ( filename != MainWindow::defaultFileName() ) {
1649 saveCalendar( MainWindow::defaultFileName() ); 1650 saveCalendar( MainWindow::defaultFileName() );
1650 } else { 1651 } else {
1651 QFileInfo finf ( MainWindow::defaultFileName()); 1652 QFileInfo finf ( MainWindow::defaultFileName());
1652 if ( finf.exists() ) { 1653 if ( finf.exists() ) {
1653 setLoadedFileVersion( finf.lastModified () ); 1654 setLoadedFileVersion( finf.lastModified () );
1654 } 1655 }
1655 } 1656 }
1656 return true; 1657 return true;
1657 } else { 1658 } else {
1658 // while failing to load, the calendar object could 1659 // while failing to load, the calendar object could
1659 // have become partially populated. Clear it out. 1660 // have become partially populated. Clear it out.
1660 if ( !merge ) { 1661 if ( !merge ) {
1661 mCalendar->close(); 1662 mCalendar->close();
1662 mViewManager->setDocumentId( filename ); 1663 mViewManager->setDocumentId( filename );
1663 mDialogManager->setDocumentId( filename ); 1664 mDialogManager->setDocumentId( filename );
1664 mTodoList->setDocumentId( filename ); 1665 mTodoList->setDocumentId( filename );
1665 } 1666 }
1666 1667
1667 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1668 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1668 1669
1669 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1670 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1670 globalFlagBlockAgenda = 2; 1671 globalFlagBlockAgenda = 2;
1671 mCalendar->reInitAlarmSettings(); 1672 mCalendar->reInitAlarmSettings();
1672 setSyncEventsReadOnly(); 1673 setSyncEventsReadOnly();
1673 updateUnmanagedViews(); 1674 updateUnmanagedViews();
1674 updateView(); 1675 updateView();
1675 } 1676 }
1676 return false; 1677 return false;
1677} 1678}
1678void CalendarView::showOpenError() 1679void CalendarView::showOpenError()
1679{ 1680{
1680 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1681 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1681} 1682}
1682void CalendarView::setLoadedFileVersion(QDateTime dt) 1683void CalendarView::setLoadedFileVersion(QDateTime dt)
1683{ 1684{
1684 loadedFileVersion = dt; 1685 loadedFileVersion = dt;
1685} 1686}
1686bool CalendarView::checkFileChanged(QString fn) 1687bool CalendarView::checkFileChanged(QString fn)
1687{ 1688{
1688 QFileInfo finf ( fn ); 1689 QFileInfo finf ( fn );
1689 if ( !finf.exists() ) 1690 if ( !finf.exists() )
1690 return true; 1691 return true;
1691 QDateTime dt = finf.lastModified (); 1692 QDateTime dt = finf.lastModified ();
1692 if ( dt <= loadedFileVersion ) 1693 if ( dt <= loadedFileVersion )
1693 return false; 1694 return false;
1694 return true; 1695 return true;
1695 1696
1696} 1697}
1697void CalendarView::watchSavedFile() 1698void CalendarView::watchSavedFile()
1698{ 1699{
1699 QFileInfo finf ( MainWindow::defaultFileName()); 1700 QFileInfo finf ( MainWindow::defaultFileName());
1700 if ( !finf.exists() ) 1701 if ( !finf.exists() )
1701 return; 1702 return;
1702 QDateTime dt = finf.lastModified (); 1703 QDateTime dt = finf.lastModified ();
1703 if ( dt < loadedFileVersion ) { 1704 if ( dt < loadedFileVersion ) {
1704 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1705 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1705 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1706 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1706 return; 1707 return;
@@ -2256,528 +2257,528 @@ void CalendarView::slotSelectPickerDate( QDate d)
2256 mDateFrame->hide(); 2257 mDateFrame->hide();
2257 if ( mDatePickerMode == 1 ) { 2258 if ( mDatePickerMode == 1 ) {
2258 mNavigator->slotDaySelect( d ); 2259 mNavigator->slotDaySelect( d );
2259 } else if ( mDatePickerMode == 2 ) { 2260 } else if ( mDatePickerMode == 2 ) {
2260 if ( mMoveIncidence->type() == "Todo" ) { 2261 if ( mMoveIncidence->type() == "Todo" ) {
2261 Todo * to = (Todo *) mMoveIncidence; 2262 Todo * to = (Todo *) mMoveIncidence;
2262 QTime tim; 2263 QTime tim;
2263 if ( to->hasDueDate() ) 2264 if ( to->hasDueDate() )
2264 tim = to->dtDue().time(); 2265 tim = to->dtDue().time();
2265 else { 2266 else {
2266 tim = QTime ( 0,0,0 ); 2267 tim = QTime ( 0,0,0 );
2267 to->setFloats( true ); 2268 to->setFloats( true );
2268 to->setHasDueDate( true ); 2269 to->setHasDueDate( true );
2269 } 2270 }
2270 QDateTime dt ( d,tim ); 2271 QDateTime dt ( d,tim );
2271 to->setDtDue( dt ); 2272 to->setDtDue( dt );
2272 todoChanged( to ); 2273 todoChanged( to );
2273 } else { 2274 } else {
2274 if ( mMoveIncidence->doesRecur() ) { 2275 if ( mMoveIncidence->doesRecur() ) {
2275#if 0 2276#if 0
2276 // PENDING implement this 2277 // PENDING implement this
2277 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2278 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2278 mCalendar()->addIncidence( newInc ); 2279 mCalendar()->addIncidence( newInc );
2279 if ( mMoveIncidence->type() == "Todo" ) 2280 if ( mMoveIncidence->type() == "Todo" )
2280 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2281 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2281 else 2282 else
2282 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2283 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2283 mMoveIncidence = newInc; 2284 mMoveIncidence = newInc;
2284 2285
2285#endif 2286#endif
2286 } 2287 }
2287 QTime tim = mMoveIncidence->dtStart().time(); 2288 QTime tim = mMoveIncidence->dtStart().time();
2288 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2289 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2289 QDateTime dt ( d,tim ); 2290 QDateTime dt ( d,tim );
2290 mMoveIncidence->setDtStart( dt ); 2291 mMoveIncidence->setDtStart( dt );
2291 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2292 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2292 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2293 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2293 } 2294 }
2294 2295
2295 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2296 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2296 } 2297 }
2297} 2298}
2298 2299
2299void CalendarView::removeCategories() 2300void CalendarView::removeCategories()
2300{ 2301{
2301 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2302 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2302 QStringList catList = KOPrefs::instance()->mCustomCategories; 2303 QStringList catList = KOPrefs::instance()->mCustomCategories;
2303 QStringList catIncList; 2304 QStringList catIncList;
2304 QStringList newCatList; 2305 QStringList newCatList;
2305 Incidence* inc = incList.first(); 2306 Incidence* inc = incList.first();
2306 int i; 2307 int i;
2307 int count = 0; 2308 int count = 0;
2308 while ( inc ) { 2309 while ( inc ) {
2309 newCatList.clear(); 2310 newCatList.clear();
2310 catIncList = inc->categories() ; 2311 catIncList = inc->categories() ;
2311 for( i = 0; i< catIncList.count(); ++i ) { 2312 for( i = 0; i< catIncList.count(); ++i ) {
2312 if ( catList.contains (catIncList[i])) 2313 if ( catList.contains (catIncList[i]))
2313 newCatList.append( catIncList[i] ); 2314 newCatList.append( catIncList[i] );
2314 } 2315 }
2315 newCatList.sort(); 2316 newCatList.sort();
2316 inc->setCategories( newCatList.join(",") ); 2317 inc->setCategories( newCatList.join(",") );
2317 inc = incList.next(); 2318 inc = incList.next();
2318 } 2319 }
2319} 2320}
2320 2321
2321int CalendarView::addCategories() 2322int CalendarView::addCategories()
2322{ 2323{
2323 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2324 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2324 QStringList catList = KOPrefs::instance()->mCustomCategories; 2325 QStringList catList = KOPrefs::instance()->mCustomCategories;
2325 QStringList catIncList; 2326 QStringList catIncList;
2326 Incidence* inc = incList.first(); 2327 Incidence* inc = incList.first();
2327 int i; 2328 int i;
2328 int count = 0; 2329 int count = 0;
2329 while ( inc ) { 2330 while ( inc ) {
2330 catIncList = inc->categories() ; 2331 catIncList = inc->categories() ;
2331 for( i = 0; i< catIncList.count(); ++i ) { 2332 for( i = 0; i< catIncList.count(); ++i ) {
2332 if ( !catList.contains (catIncList[i])) { 2333 if ( !catList.contains (catIncList[i])) {
2333 catList.append( catIncList[i] ); 2334 catList.append( catIncList[i] );
2334 //qDebug("add cat %s ", catIncList[i].latin1()); 2335 //qDebug("add cat %s ", catIncList[i].latin1());
2335 ++count; 2336 ++count;
2336 } 2337 }
2337 } 2338 }
2338 inc = incList.next(); 2339 inc = incList.next();
2339 } 2340 }
2340 catList.sort(); 2341 catList.sort();
2341 KOPrefs::instance()->mCustomCategories = catList; 2342 KOPrefs::instance()->mCustomCategories = catList;
2342 return count; 2343 return count;
2343} 2344}
2344 2345
2345void CalendarView::manageCategories() 2346void CalendarView::manageCategories()
2346{ 2347{
2347 KOCatPrefs* cp = new KOCatPrefs(); 2348 KOCatPrefs* cp = new KOCatPrefs();
2348 cp->show(); 2349 cp->show();
2349 int w =cp->sizeHint().width() ; 2350 int w =cp->sizeHint().width() ;
2350 int h = cp->sizeHint().height() ; 2351 int h = cp->sizeHint().height() ;
2351 int dw = QApplication::desktop()->width(); 2352 int dw = QApplication::desktop()->width();
2352 int dh = QApplication::desktop()->height(); 2353 int dh = QApplication::desktop()->height();
2353 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2354 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2354 if ( !cp->exec() ) { 2355 if ( !cp->exec() ) {
2355 delete cp; 2356 delete cp;
2356 return; 2357 return;
2357 } 2358 }
2358 int count = 0; 2359 int count = 0;
2359 if ( cp->addCat() ) { 2360 if ( cp->addCat() ) {
2360 count = addCategories(); 2361 count = addCategories();
2361 if ( count ) { 2362 if ( count ) {
2362 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2363 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2363 writeSettings(); 2364 writeSettings();
2364 } else 2365 } else
2365 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2366 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2366 } else { 2367 } else {
2367 removeCategories(); 2368 removeCategories();
2368 updateView(); 2369 updateView();
2369 } 2370 }
2370 delete cp; 2371 delete cp;
2371} 2372}
2372 2373
2373void CalendarView::beamIncidence(Incidence * Inc) 2374void CalendarView::beamIncidence(Incidence * Inc)
2374{ 2375{
2375 QPtrList<Incidence> delSel ; 2376 QPtrList<Incidence> delSel ;
2376 delSel.append(Inc); 2377 delSel.append(Inc);
2377 beamIncidenceList( delSel ); 2378 beamIncidenceList( delSel );
2378} 2379}
2379void CalendarView::beamCalendar() 2380void CalendarView::beamCalendar()
2380{ 2381{
2381 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2382 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2382 //qDebug("beamCalendar() "); 2383 //qDebug("beamCalendar() ");
2383 beamIncidenceList( delSel ); 2384 beamIncidenceList( delSel );
2384} 2385}
2385void CalendarView::beamFilteredCalendar() 2386void CalendarView::beamFilteredCalendar()
2386{ 2387{
2387 QPtrList<Incidence> delSel = mCalendar->incidences(); 2388 QPtrList<Incidence> delSel = mCalendar->incidences();
2388 //qDebug("beamFilteredCalendar() "); 2389 //qDebug("beamFilteredCalendar() ");
2389 beamIncidenceList( delSel ); 2390 beamIncidenceList( delSel );
2390} 2391}
2391void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2392void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2392{ 2393{
2393 if ( beamDialog->exec () == QDialog::Rejected ) 2394 if ( beamDialog->exec () == QDialog::Rejected )
2394 return; 2395 return;
2395#ifdef DESKTOP_VERSION 2396#ifdef DESKTOP_VERSION
2396 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2397 QString fn = locateLocal( "tmp", "kopibeamfile" );
2397#else 2398#else
2398 QString fn = "/tmp/kopibeamfile"; 2399 QString fn = "/tmp/kopibeamfile";
2399#endif 2400#endif
2400 QString mes; 2401 QString mes;
2401 bool createbup = true; 2402 bool createbup = true;
2402 if ( createbup ) { 2403 if ( createbup ) {
2403 QString description = "\n"; 2404 QString description = "\n";
2404 CalendarLocal* cal = new CalendarLocal(); 2405 CalendarLocal* cal = new CalendarLocal();
2405 if ( beamDialog->beamLocal() ) 2406 if ( beamDialog->beamLocal() )
2406 cal->setLocalTime(); 2407 cal->setLocalTime();
2407 else 2408 else
2408 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2409 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2409 Incidence *incidence = delSel.first(); 2410 Incidence *incidence = delSel.first();
2410 bool addText = false; 2411 bool addText = false;
2411 if ( delSel.count() < 10 ) 2412 if ( delSel.count() < 10 )
2412 addText = true; 2413 addText = true;
2413 else { 2414 else {
2414 description.sprintf(i18n(" %d items?"),delSel.count() ); 2415 description.sprintf(i18n(" %d items?"),delSel.count() );
2415 } 2416 }
2416 while ( incidence ) { 2417 while ( incidence ) {
2417 Incidence *in = incidence->clone(); 2418 Incidence *in = incidence->clone();
2418 if ( ! in->summary().isEmpty() ) { 2419 if ( ! in->summary().isEmpty() ) {
2419 in->setDescription(""); 2420 in->setDescription("");
2420 } else { 2421 } else {
2421 in->setSummary( in->description().left(20)); 2422 in->setSummary( in->description().left(20));
2422 in->setDescription(""); 2423 in->setDescription("");
2423 } 2424 }
2424 if ( addText ) 2425 if ( addText )
2425 description += in->summary() + "\n"; 2426 description += in->summary() + "\n";
2426 cal->addIncidence( in ); 2427 cal->addIncidence( in );
2427 incidence = delSel.next(); 2428 incidence = delSel.next();
2428 } 2429 }
2429 if ( beamDialog->beamVcal() ) { 2430 if ( beamDialog->beamVcal() ) {
2430 fn += ".vcs"; 2431 fn += ".vcs";
2431 FileStorage storage( cal, fn, new VCalFormat ); 2432 FileStorage storage( cal, fn, new VCalFormat );
2432 storage.save(); 2433 storage.save();
2433 } else { 2434 } else {
2434 fn += ".ics"; 2435 fn += ".ics";
2435 FileStorage storage( cal, fn, new ICalFormat( ) ); 2436 FileStorage storage( cal, fn, new ICalFormat( ) );
2436 storage.save(); 2437 storage.save();
2437 } 2438 }
2438 delete cal; 2439 delete cal;
2439 mes = i18n("KO/Pi: Ready for beaming"); 2440 mes = i18n("KO/Pi: Ready for beaming");
2440 topLevelWidget()->setCaption(mes); 2441 topLevelWidget()->setCaption(mes);
2441 KApplication::convert2latin1( fn ); 2442 KApplication::convert2latin1( fn );
2442#ifndef DESKTOP_VERSION 2443#ifndef DESKTOP_VERSION
2443 Ir *ir = new Ir( this ); 2444 Ir *ir = new Ir( this );
2444 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2445 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2445 ir->send( fn, description, "text/x-vCalendar" ); 2446 ir->send( fn, description, "text/x-vCalendar" );
2446#endif 2447#endif
2447 } 2448 }
2448} 2449}
2449void CalendarView::beamDone( Ir *ir ) 2450void CalendarView::beamDone( Ir *ir )
2450{ 2451{
2451#ifndef DESKTOP_VERSION 2452#ifndef DESKTOP_VERSION
2452 delete ir; 2453 delete ir;
2453#endif 2454#endif
2454 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2455 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2455 topLevelWidget()->raise(); 2456 topLevelWidget()->raise();
2456} 2457}
2457 2458
2458void CalendarView::moveIncidence(Incidence * inc ) 2459void CalendarView::moveIncidence(Incidence * inc )
2459{ 2460{
2460 if ( !inc ) return; 2461 if ( !inc ) return;
2461 // qDebug("showDatePickerForIncidence( ) "); 2462 // qDebug("showDatePickerForIncidence( ) ");
2462 if ( mDateFrame->isVisible() ) 2463 if ( mDateFrame->isVisible() )
2463 mDateFrame->hide(); 2464 mDateFrame->hide();
2464 else { 2465 else {
2465 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2466 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2466 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2467 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2467 int dw = QApplication::desktop()->width(); 2468 int dw = QApplication::desktop()->width();
2468 int dh = QApplication::desktop()->height(); 2469 int dh = QApplication::desktop()->height();
2469 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2470 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2470 mDateFrame->show(); 2471 mDateFrame->show();
2471 } 2472 }
2472 mDatePickerMode = 2; 2473 mDatePickerMode = 2;
2473 mMoveIncidence = inc ; 2474 mMoveIncidence = inc ;
2474 QDate da; 2475 QDate da;
2475 if ( mMoveIncidence->type() == "Todo" ) { 2476 if ( mMoveIncidence->type() == "Todo" ) {
2476 Todo * to = (Todo *) mMoveIncidence; 2477 Todo * to = (Todo *) mMoveIncidence;
2477 if ( to->hasDueDate() ) 2478 if ( to->hasDueDate() )
2478 da = to->dtDue().date(); 2479 da = to->dtDue().date();
2479 else 2480 else
2480 da = QDate::currentDate(); 2481 da = QDate::currentDate();
2481 } else { 2482 } else {
2482 da = mMoveIncidence->dtStart().date(); 2483 da = mMoveIncidence->dtStart().date();
2483 } 2484 }
2484 //PENDING set date for recurring incidence to date of recurrence 2485 //PENDING set date for recurring incidence to date of recurrence
2485 //mMoveIncidenceOldDate; 2486 //mMoveIncidenceOldDate;
2486 mDatePicker->setDate( da ); 2487 mDatePicker->setDate( da );
2487} 2488}
2488void CalendarView::showDatePicker( ) 2489void CalendarView::showDatePicker( )
2489{ 2490{
2490 //qDebug("CalendarView::showDatePicker( ) "); 2491 //qDebug("CalendarView::showDatePicker( ) ");
2491 if ( mDateFrame->isVisible() ) 2492 if ( mDateFrame->isVisible() )
2492 mDateFrame->hide(); 2493 mDateFrame->hide();
2493 else { 2494 else {
2494 int w =mDatePicker->sizeHint().width() ; 2495 int w =mDatePicker->sizeHint().width() ;
2495 int h = mDatePicker->sizeHint().height() ; 2496 int h = mDatePicker->sizeHint().height() ;
2496 int dw = QApplication::desktop()->width(); 2497 int dw = QApplication::desktop()->width();
2497 int dh = QApplication::desktop()->height(); 2498 int dh = QApplication::desktop()->height();
2498 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2499 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2499 mDateFrame->show(); 2500 mDateFrame->show();
2500 } 2501 }
2501 mDatePickerMode = 1; 2502 mDatePickerMode = 1;
2502 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2503 mDatePicker->setDate( mNavigator->selectedDates().first() );
2503} 2504}
2504 2505
2505void CalendarView::showEventEditor() 2506void CalendarView::showEventEditor()
2506{ 2507{
2507#ifdef DESKTOP_VERSION 2508#ifdef DESKTOP_VERSION
2508 mEventEditor->show(); 2509 mEventEditor->show();
2509#else 2510#else
2510 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2511 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2511 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2512 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2512 qDebug("CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2513 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2513 delete mEventEditor; 2514 delete mEventEditor;
2514 mEventEditor = mDialogManager->getEventEditor(); 2515 mEventEditor = mDialogManager->getEventEditor();
2515 } 2516 }
2516 mEventEditor->showMaximized(); 2517 mEventEditor->showMaximized();
2517 topLevelWidget()->setCaption( i18n("") ); 2518 topLevelWidget()->setCaption( i18n("") );
2518#endif 2519#endif
2519} 2520}
2520void CalendarView::showTodoEditor() 2521void CalendarView::showTodoEditor()
2521{ 2522{
2522#ifdef DESKTOP_VERSION 2523#ifdef DESKTOP_VERSION
2523 mTodoEditor->show(); 2524 mTodoEditor->show();
2524#else 2525#else
2525 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2526 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2526 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2527 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2527 qDebug("CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2528 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2528 delete mTodoEditor; 2529 delete mTodoEditor;
2529 mTodoEditor = mDialogManager->getTodoEditor(); 2530 mTodoEditor = mDialogManager->getTodoEditor();
2530 } 2531 }
2531 mTodoEditor->showMaximized(); 2532 mTodoEditor->showMaximized();
2532 topLevelWidget()->setCaption( i18n("") ); 2533 topLevelWidget()->setCaption( i18n("") );
2533#endif 2534#endif
2534} 2535}
2535 2536
2536void CalendarView::cloneIncidence() 2537void CalendarView::cloneIncidence()
2537{ 2538{
2538 Incidence *incidence = currentSelection(); 2539 Incidence *incidence = currentSelection();
2539 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2540 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2540 if ( incidence ) { 2541 if ( incidence ) {
2541 cloneIncidence(incidence); 2542 cloneIncidence(incidence);
2542 } 2543 }
2543} 2544}
2544void CalendarView::moveIncidence() 2545void CalendarView::moveIncidence()
2545{ 2546{
2546 Incidence *incidence = currentSelection(); 2547 Incidence *incidence = currentSelection();
2547 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2548 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2548 if ( incidence ) { 2549 if ( incidence ) {
2549 moveIncidence(incidence); 2550 moveIncidence(incidence);
2550 } 2551 }
2551} 2552}
2552void CalendarView::beamIncidence() 2553void CalendarView::beamIncidence()
2553{ 2554{
2554 Incidence *incidence = currentSelection(); 2555 Incidence *incidence = currentSelection();
2555 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2556 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2556 if ( incidence ) { 2557 if ( incidence ) {
2557 beamIncidence(incidence); 2558 beamIncidence(incidence);
2558 } 2559 }
2559} 2560}
2560void CalendarView::toggleCancelIncidence() 2561void CalendarView::toggleCancelIncidence()
2561{ 2562{
2562 Incidence *incidence = currentSelection(); 2563 Incidence *incidence = currentSelection();
2563 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2564 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2564 if ( incidence ) { 2565 if ( incidence ) {
2565 cancelIncidence(incidence); 2566 cancelIncidence(incidence);
2566 } 2567 }
2567} 2568}
2568 2569
2569 2570
2570void CalendarView::cancelIncidence(Incidence * inc ) 2571void CalendarView::cancelIncidence(Incidence * inc )
2571{ 2572{
2572 inc->setCancelled( ! inc->cancelled() ); 2573 inc->setCancelled( ! inc->cancelled() );
2573 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2574 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2574 updateView(); 2575 updateView();
2575} 2576}
2576void CalendarView::cloneIncidence(Incidence * orgInc ) 2577void CalendarView::cloneIncidence(Incidence * orgInc )
2577{ 2578{
2578 Incidence * newInc = orgInc->clone(); 2579 Incidence * newInc = orgInc->clone();
2579 newInc->recreate(); 2580 newInc->recreate();
2580 2581
2581 if ( newInc->type() == "Todo" ) { 2582 if ( newInc->type() == "Todo" ) {
2582 Todo* t = (Todo*) newInc; 2583 Todo* t = (Todo*) newInc;
2583 showTodoEditor(); 2584 showTodoEditor();
2584 mTodoEditor->editTodo( t ); 2585 mTodoEditor->editTodo( t );
2585 if ( mTodoEditor->exec() ) { 2586 if ( mTodoEditor->exec() ) {
2586 mCalendar->addTodo( t ); 2587 mCalendar->addTodo( t );
2587 updateView(); 2588 updateView();
2588 } else { 2589 } else {
2589 delete t; 2590 delete t;
2590 } 2591 }
2591 } 2592 }
2592 else { 2593 else {
2593 Event* e = (Event*) newInc; 2594 Event* e = (Event*) newInc;
2594 showEventEditor(); 2595 showEventEditor();
2595 mEventEditor->editEvent( e ); 2596 mEventEditor->editEvent( e );
2596 if ( mEventEditor->exec() ) { 2597 if ( mEventEditor->exec() ) {
2597 mCalendar->addEvent( e ); 2598 mCalendar->addEvent( e );
2598 updateView(); 2599 updateView();
2599 } else { 2600 } else {
2600 delete e; 2601 delete e;
2601 } 2602 }
2602 } 2603 }
2603} 2604}
2604 2605
2605void CalendarView::newEvent() 2606void CalendarView::newEvent()
2606{ 2607{
2607 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2608 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2608 KOAgendaView *aView = mViewManager->agendaView(); 2609 KOAgendaView *aView = mViewManager->agendaView();
2609 if (aView) { 2610 if (aView) {
2610 if (aView->selectionStart().isValid()) { 2611 if (aView->selectionStart().isValid()) {
2611 if (aView->selectedIsAllDay()) { 2612 if (aView->selectedIsAllDay()) {
2612 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2613 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2613 } else { 2614 } else {
2614 newEvent(aView->selectionStart(),aView->selectionEnd()); 2615 newEvent(aView->selectionStart(),aView->selectionEnd());
2615 } 2616 }
2616 return; 2617 return;
2617 } 2618 }
2618 } 2619 }
2619 2620
2620 QDate date = mNavigator->selectedDates().first(); 2621 QDate date = mNavigator->selectedDates().first();
2621 QDateTime current = QDateTime::currentDateTime(); 2622 QDateTime current = QDateTime::currentDateTime();
2622 if ( date <= current.date() ) { 2623 if ( date <= current.date() ) {
2623 int hour = current.time().hour() +1; 2624 int hour = current.time().hour() +1;
2624 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2625 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2625 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2626 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2626 } else 2627 } else
2627 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2628 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2628 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2629 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2629 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2630 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2630} 2631}
2631 2632
2632void CalendarView::newEvent(QDateTime fh) 2633void CalendarView::newEvent(QDateTime fh)
2633{ 2634{
2634 newEvent(fh, 2635 newEvent(fh,
2635 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2636 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2636} 2637}
2637 2638
2638void CalendarView::newEvent(QDate dt) 2639void CalendarView::newEvent(QDate dt)
2639{ 2640{
2640 newEvent(QDateTime(dt, QTime(0,0,0)), 2641 newEvent(QDateTime(dt, QTime(0,0,0)),
2641 QDateTime(dt, QTime(0,0,0)), true); 2642 QDateTime(dt, QTime(0,0,0)), true);
2642} 2643}
2643 2644
2644void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2645void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2645{ 2646{
2646 2647
2647 showEventEditor(); 2648 showEventEditor();
2648 mEventEditor->newEvent(fromHint,toHint,allDay); 2649 mEventEditor->newEvent(fromHint,toHint,allDay);
2649 if ( mFilterView->filtersEnabled() ) { 2650 if ( mFilterView->filtersEnabled() ) {
2650 CalFilter *filter = mFilterView->selectedFilter(); 2651 CalFilter *filter = mFilterView->selectedFilter();
2651 if (filter && filter->showCategories()) { 2652 if (filter && filter->showCategories()) {
2652 mEventEditor->setCategories(filter->categoryList().join(",") ); 2653 mEventEditor->setCategories(filter->categoryList().join(",") );
2653 } 2654 }
2654 if ( filter ) 2655 if ( filter )
2655 mEventEditor->setSecrecy( filter->getSecrecy() ); 2656 mEventEditor->setSecrecy( filter->getSecrecy() );
2656 } 2657 }
2657} 2658}
2658void CalendarView::todoAdded(Todo * t) 2659void CalendarView::todoAdded(Todo * t)
2659{ 2660{
2660 2661
2661 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2662 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2662 updateTodoViews(); 2663 updateTodoViews();
2663} 2664}
2664void CalendarView::todoChanged(Todo * t) 2665void CalendarView::todoChanged(Todo * t)
2665{ 2666{
2666 emit todoModified( t, 4 ); 2667 emit todoModified( t, 4 );
2667 // updateTodoViews(); 2668 // updateTodoViews();
2668} 2669}
2669void CalendarView::todoToBeDeleted(Todo *) 2670void CalendarView::todoToBeDeleted(Todo *)
2670{ 2671{
2671 //qDebug("todoToBeDeleted(Todo *) "); 2672 //qDebug("todoToBeDeleted(Todo *) ");
2672 updateTodoViews(); 2673 updateTodoViews();
2673} 2674}
2674void CalendarView::todoDeleted() 2675void CalendarView::todoDeleted()
2675{ 2676{
2676 //qDebug(" todoDeleted()"); 2677 //qDebug(" todoDeleted()");
2677 updateTodoViews(); 2678 updateTodoViews();
2678} 2679}
2679 2680
2680 2681
2681 2682
2682void CalendarView::newTodo() 2683void CalendarView::newTodo()
2683{ 2684{
2684 2685
2685 showTodoEditor(); 2686 showTodoEditor();
2686 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2687 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2687 if ( mFilterView->filtersEnabled() ) { 2688 if ( mFilterView->filtersEnabled() ) {
2688 CalFilter *filter = mFilterView->selectedFilter(); 2689 CalFilter *filter = mFilterView->selectedFilter();
2689 if (filter && filter->showCategories()) { 2690 if (filter && filter->showCategories()) {
2690 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2691 mTodoEditor->setCategories(filter->categoryList().join(",") );
2691 } 2692 }
2692 if ( filter ) 2693 if ( filter )
2693 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2694 mTodoEditor->setSecrecy( filter->getSecrecy() );
2694 } 2695 }
2695} 2696}
2696 2697
2697void CalendarView::newSubTodo() 2698void CalendarView::newSubTodo()
2698{ 2699{
2699 Todo *todo = selectedTodo(); 2700 Todo *todo = selectedTodo();
2700 if ( todo ) newSubTodo( todo ); 2701 if ( todo ) newSubTodo( todo );
2701} 2702}
2702 2703
2703void CalendarView::newSubTodo(Todo *parentEvent) 2704void CalendarView::newSubTodo(Todo *parentEvent)
2704{ 2705{
2705 2706
2706 showTodoEditor(); 2707 showTodoEditor();
2707 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2708 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2708} 2709}
2709 2710
2710void CalendarView::newFloatingEvent() 2711void CalendarView::newFloatingEvent()
2711{ 2712{
2712 DateList tmpList = mNavigator->selectedDates(); 2713 DateList tmpList = mNavigator->selectedDates();
2713 QDate date = tmpList.first(); 2714 QDate date = tmpList.first();
2714 2715
2715 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2716 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2716 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2717 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2717} 2718}
2718 2719
2719 2720
2720void CalendarView::editEvent( Event *event ) 2721void CalendarView::editEvent( Event *event )
2721{ 2722{
2722 2723
2723 if ( !event ) return; 2724 if ( !event ) return;
2724 if ( event->isReadOnly() ) { 2725 if ( event->isReadOnly() ) {
2725 showEvent( event ); 2726 showEvent( event );
2726 return; 2727 return;
2727 } 2728 }
2728 showEventEditor(); 2729 showEventEditor();
2729 mEventEditor->editEvent( event , mFlagEditDescription); 2730 mEventEditor->editEvent( event , mFlagEditDescription);
2730} 2731}
2731void CalendarView::editJournal( Journal *jour ) 2732void CalendarView::editJournal( Journal *jour )
2732{ 2733{
2733 if ( !jour ) return; 2734 if ( !jour ) return;
2734 mDialogManager->hideSearchDialog(); 2735 mDialogManager->hideSearchDialog();
2735 mViewManager->showJournalView(); 2736 mViewManager->showJournalView();
2736 mNavigator->slotDaySelect( jour->dtStart().date() ); 2737 mNavigator->slotDaySelect( jour->dtStart().date() );
2737} 2738}
2738void CalendarView::editTodo( Todo *todo ) 2739void CalendarView::editTodo( Todo *todo )
2739{ 2740{
2740 if ( !todo ) return; 2741 if ( !todo ) return;
2741 2742
2742 if ( todo->isReadOnly() ) { 2743 if ( todo->isReadOnly() ) {
2743 showTodo( todo ); 2744 showTodo( todo );
2744 return; 2745 return;
2745 } 2746 }
2746 showTodoEditor(); 2747 showTodoEditor();
2747 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2748 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2748 2749
2749} 2750}
2750 2751
2751KOEventViewerDialog* CalendarView::getEventViewerDialog() 2752KOEventViewerDialog* CalendarView::getEventViewerDialog()
2752{ 2753{
2753 if ( !mEventViewerDialog ) { 2754 if ( !mEventViewerDialog ) {
2754 mEventViewerDialog = new KOEventViewerDialog(this); 2755 mEventViewerDialog = new KOEventViewerDialog(this);
2755 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2756 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2756 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2757 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2757 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2758 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2758 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2759 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2759 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2760 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2760 viewManager(), SLOT( showAgendaView( bool ) ) ); 2761 viewManager(), SLOT( showAgendaView( bool ) ) );
2761 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 2762 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
2762 this, SLOT( todoChanged(Todo *) ) ); 2763 this, SLOT( todoChanged(Todo *) ) );
2763 mEventViewerDialog->resize( 640, 480 ); 2764 mEventViewerDialog->resize( 640, 480 );
2764 2765
2765 } 2766 }
2766 return mEventViewerDialog; 2767 return mEventViewerDialog;
2767} 2768}
2768void CalendarView::showEvent(Event *event) 2769void CalendarView::showEvent(Event *event)
2769{ 2770{
2770 getEventViewerDialog()->setEvent(event); 2771 getEventViewerDialog()->setEvent(event);
2771 getEventViewerDialog()->showMe(); 2772 getEventViewerDialog()->showMe();
2772} 2773}
2773 2774
2774void CalendarView::showTodo(Todo *event) 2775void CalendarView::showTodo(Todo *event)
2775{ 2776{
2776 getEventViewerDialog()->setTodo(event); 2777 getEventViewerDialog()->setTodo(event);
2777 getEventViewerDialog()->showMe(); 2778 getEventViewerDialog()->showMe();
2778} 2779}
2779void CalendarView::showJournal( Journal *jour ) 2780void CalendarView::showJournal( Journal *jour )
2780{ 2781{
2781 getEventViewerDialog()->setJournal(jour); 2782 getEventViewerDialog()->setJournal(jour);
2782 getEventViewerDialog()->showMe(); 2783 getEventViewerDialog()->showMe();
2783 2784
@@ -3604,302 +3605,302 @@ void CalendarView::takeOverCalendar()
3604 3605
3605 QPtrList<Journal> journals = mCalendar->journals(); 3606 QPtrList<Journal> journals = mCalendar->journals();
3606 for(uint i=0; i<journals.count(); ++i) { 3607 for(uint i=0; i<journals.count(); ++i) {
3607 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3608 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3608 journals.at(i)->recreate(); 3609 journals.at(i)->recreate();
3609 journals.at(i)->setReadOnly(false); 3610 journals.at(i)->setReadOnly(false);
3610 } 3611 }
3611 3612
3612 updateView(); 3613 updateView();
3613} 3614}
3614 3615
3615void CalendarView::showIntro() 3616void CalendarView::showIntro()
3616{ 3617{
3617 kdDebug() << "To be implemented." << endl; 3618 kdDebug() << "To be implemented." << endl;
3618} 3619}
3619 3620
3620QWidgetStack *CalendarView::viewStack() 3621QWidgetStack *CalendarView::viewStack()
3621{ 3622{
3622 return mRightFrame; 3623 return mRightFrame;
3623} 3624}
3624 3625
3625QWidget *CalendarView::leftFrame() 3626QWidget *CalendarView::leftFrame()
3626{ 3627{
3627 return mLeftFrame; 3628 return mLeftFrame;
3628} 3629}
3629 3630
3630DateNavigator *CalendarView::dateNavigator() 3631DateNavigator *CalendarView::dateNavigator()
3631{ 3632{
3632 return mNavigator; 3633 return mNavigator;
3633} 3634}
3634 3635
3635KDateNavigator* CalendarView::dateNavigatorWidget() 3636KDateNavigator* CalendarView::dateNavigatorWidget()
3636{ 3637{
3637 return mDateNavigator; 3638 return mDateNavigator;
3638} 3639}
3639void CalendarView::toggleDateNavigatorWidget() 3640void CalendarView::toggleDateNavigatorWidget()
3640{ 3641{
3641 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 3642 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
3642 if (!KOPrefs::instance()->mShowDateNavigator ) 3643 if (!KOPrefs::instance()->mShowDateNavigator )
3643 mDateNavigator->hide(); 3644 mDateNavigator->hide();
3644 else 3645 else
3645 mDateNavigator->show(); 3646 mDateNavigator->show();
3646} 3647}
3647void CalendarView::addView(KOrg::BaseView *view) 3648void CalendarView::addView(KOrg::BaseView *view)
3648{ 3649{
3649 mViewManager->addView(view); 3650 mViewManager->addView(view);
3650} 3651}
3651 3652
3652void CalendarView::showView(KOrg::BaseView *view) 3653void CalendarView::showView(KOrg::BaseView *view)
3653{ 3654{
3654 mViewManager->showView(view, mLeftFrame->isVisible()); 3655 mViewManager->showView(view, mLeftFrame->isVisible());
3655} 3656}
3656 3657
3657Incidence *CalendarView::currentSelection() 3658Incidence *CalendarView::currentSelection()
3658{ 3659{
3659 return mViewManager->currentSelection(); 3660 return mViewManager->currentSelection();
3660} 3661}
3661void CalendarView::toggleAllDaySize() 3662void CalendarView::toggleAllDaySize()
3662{ 3663{
3663 /* 3664 /*
3664 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3665 if ( KOPrefs::instance()->mAllDaySize > 47 )
3665 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3666 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3666 else 3667 else
3667 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3668 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3668 */ 3669 */
3669 viewManager()->agendaView()->toggleAllDay(); 3670 viewManager()->agendaView()->toggleAllDay();
3670} 3671}
3671void CalendarView::toggleExpand() 3672void CalendarView::toggleExpand()
3672{ 3673{
3673 // if ( mLeftFrame->isHidden() ) { 3674 // if ( mLeftFrame->isHidden() ) {
3674 // mLeftFrame->show(); 3675 // mLeftFrame->show();
3675 // emit calendarViewExpanded( false ); 3676 // emit calendarViewExpanded( false );
3676 // } else { 3677 // } else {
3677 // mLeftFrame->hide(); 3678 // mLeftFrame->hide();
3678 // emit calendarViewExpanded( true ); 3679 // emit calendarViewExpanded( true );
3679 // } 3680 // }
3680 3681
3681 globalFlagBlockAgenda = 1; 3682 globalFlagBlockAgenda = 1;
3682 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3683 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3683 globalFlagBlockAgenda = 5; 3684 globalFlagBlockAgenda = 5;
3684 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3685 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3685 //mViewManager->showView( 0, true ); 3686 //mViewManager->showView( 0, true );
3686} 3687}
3687 3688
3688void CalendarView::calendarModified( bool modified, Calendar * ) 3689void CalendarView::calendarModified( bool modified, Calendar * )
3689{ 3690{
3690 setModified( modified ); 3691 setModified( modified );
3691} 3692}
3692 3693
3693Todo *CalendarView::selectedTodo() 3694Todo *CalendarView::selectedTodo()
3694{ 3695{
3695 Incidence *incidence = currentSelection(); 3696 Incidence *incidence = currentSelection();
3696 if ( incidence && incidence->type() == "Todo" ) { 3697 if ( incidence && incidence->type() == "Todo" ) {
3697 return static_cast<Todo *>( incidence ); 3698 return static_cast<Todo *>( incidence );
3698 } 3699 }
3699 3700
3700 incidence = mTodoList->selectedIncidences().first(); 3701 incidence = mTodoList->selectedIncidences().first();
3701 if ( incidence && incidence->type() == "Todo" ) { 3702 if ( incidence && incidence->type() == "Todo" ) {
3702 return static_cast<Todo *>( incidence ); 3703 return static_cast<Todo *>( incidence );
3703 } 3704 }
3704 3705
3705 return 0; 3706 return 0;
3706} 3707}
3707 3708
3708void CalendarView::dialogClosing(Incidence *in) 3709void CalendarView::dialogClosing(Incidence *in)
3709{ 3710{
3710 // mDialogList.remove(in); 3711 // mDialogList.remove(in);
3711} 3712}
3712 3713
3713void CalendarView::showIncidence() 3714void CalendarView::showIncidence()
3714{ 3715{
3715 Incidence *incidence = currentSelection(); 3716 Incidence *incidence = currentSelection();
3716 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3717 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3717 if ( incidence ) { 3718 if ( incidence ) {
3718 ShowIncidenceVisitor v; 3719 ShowIncidenceVisitor v;
3719 v.act( incidence, this ); 3720 v.act( incidence, this );
3720 } 3721 }
3721} 3722}
3722void CalendarView::editIncidenceDescription() 3723void CalendarView::editIncidenceDescription()
3723{ 3724{
3724 mFlagEditDescription = true; 3725 mFlagEditDescription = true;
3725 editIncidence(); 3726 editIncidence();
3726 mFlagEditDescription = false; 3727 mFlagEditDescription = false;
3727} 3728}
3728void CalendarView::editIncidence() 3729void CalendarView::editIncidence()
3729{ 3730{
3730 // qDebug("editIncidence() "); 3731 // qDebug("editIncidence() ");
3731 Incidence *incidence = currentSelection(); 3732 Incidence *incidence = currentSelection();
3732 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3733 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3733 if ( incidence ) { 3734 if ( incidence ) {
3734 EditIncidenceVisitor v; 3735 EditIncidenceVisitor v;
3735 v.act( incidence, this ); 3736 v.act( incidence, this );
3736 } 3737 }
3737} 3738}
3738 3739
3739void CalendarView::deleteIncidence() 3740void CalendarView::deleteIncidence()
3740{ 3741{
3741 Incidence *incidence = currentSelection(); 3742 Incidence *incidence = currentSelection();
3742 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3743 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3743 if ( incidence ) { 3744 if ( incidence ) {
3744 deleteIncidence(incidence); 3745 deleteIncidence(incidence);
3745 } 3746 }
3746} 3747}
3747 3748
3748void CalendarView::showIncidence(Incidence *incidence) 3749void CalendarView::showIncidence(Incidence *incidence)
3749{ 3750{
3750 if ( incidence ) { 3751 if ( incidence ) {
3751 ShowIncidenceVisitor v; 3752 ShowIncidenceVisitor v;
3752 v.act( incidence, this ); 3753 v.act( incidence, this );
3753 } 3754 }
3754} 3755}
3755 3756
3756void CalendarView::editIncidence(Incidence *incidence) 3757void CalendarView::editIncidence(Incidence *incidence)
3757{ 3758{
3758 if ( incidence ) { 3759 if ( incidence ) {
3759 3760
3760 EditIncidenceVisitor v; 3761 EditIncidenceVisitor v;
3761 v.act( incidence, this ); 3762 v.act( incidence, this );
3762 3763
3763 } 3764 }
3764} 3765}
3765 3766
3766void CalendarView::deleteIncidence(Incidence *incidence) 3767void CalendarView::deleteIncidence(Incidence *incidence)
3767{ 3768{
3768 //qDebug(" CalendarView::deleteIncidence "); 3769 //qDebug(" CalendarView::deleteIncidence ");
3769 if ( incidence ) { 3770 if ( incidence ) {
3770 DeleteIncidenceVisitor v; 3771 DeleteIncidenceVisitor v;
3771 v.act( incidence, this ); 3772 v.act( incidence, this );
3772 } 3773 }
3773} 3774}
3774 3775
3775 3776
3776void CalendarView::lookForOutgoingMessages() 3777void CalendarView::lookForOutgoingMessages()
3777{ 3778{
3778 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3779 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3779 ogd->loadMessages(); 3780 ogd->loadMessages();
3780} 3781}
3781 3782
3782void CalendarView::lookForIncomingMessages() 3783void CalendarView::lookForIncomingMessages()
3783{ 3784{
3784 IncomingDialog *icd = mDialogManager->incomingDialog(); 3785 IncomingDialog *icd = mDialogManager->incomingDialog();
3785 icd->retrieve(); 3786 icd->retrieve();
3786} 3787}
3787 3788
3788bool CalendarView::removeCompletedSubTodos( Todo* t ) 3789bool CalendarView::removeCompletedSubTodos( Todo* t )
3789{ 3790{
3790 bool deleteTodo = true; 3791 bool deleteTodo = true;
3791 QPtrList<Incidence> subTodos; 3792 QPtrList<Incidence> subTodos;
3792 Incidence *aTodo; 3793 Incidence *aTodo;
3793 subTodos = t->relations(); 3794 subTodos = t->relations();
3794 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3795 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3795 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3796 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3796 deleteTodo = false; 3797 deleteTodo = false;
3797 } 3798 }
3798 if ( deleteTodo ) { 3799 if ( deleteTodo ) {
3799 if ( t->isCompleted() ) { 3800 if ( t->isCompleted() ) {
3800 checkExternalId( t ); 3801 checkExternalId( t );
3801 mCalendar->deleteTodo( t ); 3802 mCalendar->deleteTodo( t );
3802 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3803 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3803 } 3804 }
3804 else 3805 else
3805 deleteTodo = false; 3806 deleteTodo = false;
3806 } 3807 }
3807 return deleteTodo; 3808 return deleteTodo;
3808 3809
3809} 3810}
3810void CalendarView::purgeCompleted() 3811void CalendarView::purgeCompleted()
3811{ 3812{
3812 int result = KMessageBox::warningContinueCancel(this, 3813 int result = KMessageBox::warningContinueCancel(this,
3813 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3814 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3814 3815
3815 if (result == KMessageBox::Continue) { 3816 if (result == KMessageBox::Continue) {
3816 3817
3817 QPtrList<Todo> todoCal; 3818 QPtrList<Todo> todoCal;
3818 QPtrList<Todo> rootTodos; 3819 QPtrList<Todo> rootTodos;
3819 //QPtrList<Incidence> rel; 3820 //QPtrList<Incidence> rel;
3820 Todo *aTodo;//, *rTodo; 3821 Todo *aTodo;//, *rTodo;
3821 Incidence *rIncidence; 3822 Incidence *rIncidence;
3822 bool childDelete = false; 3823 bool childDelete = false;
3823 bool deletedOne = true; 3824 bool deletedOne = true;
3824 todoCal = calendar()->todos(); 3825 todoCal = calendar()->todos();
3825 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3826 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3826 if ( !aTodo->relatedTo() ) 3827 if ( !aTodo->relatedTo() )
3827 rootTodos.append( aTodo ); 3828 rootTodos.append( aTodo );
3828 } 3829 }
3829 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3830 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3830 removeCompletedSubTodos( aTodo ); 3831 removeCompletedSubTodos( aTodo );
3831 } 3832 }
3832 3833
3833 updateView(); 3834 updateView();
3834 } 3835 }
3835} 3836}
3836 3837
3837void CalendarView::slotCalendarChanged() 3838void CalendarView::slotCalendarChanged()
3838{ 3839{
3839 ; 3840 ;
3840} 3841}
3841 3842
3842NavigatorBar *CalendarView::navigatorBar() 3843NavigatorBar *CalendarView::navigatorBar()
3843{ 3844{
3844 return mNavigatorBar; 3845 return mNavigatorBar;
3845} 3846}
3846 3847
3847 3848
3848 3849
3849void CalendarView::keyPressEvent ( QKeyEvent *e) 3850void CalendarView::keyPressEvent ( QKeyEvent *e)
3850{ 3851{
3851 //qDebug(" alendarView::keyPressEvent "); 3852 //qDebug(" alendarView::keyPressEvent ");
3852 e->ignore(); 3853 e->ignore();
3853} 3854}
3854 3855
3855 3856
3856bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 3857bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3857{ 3858{
3858 // mSyncManager = manager; 3859 // mSyncManager = manager;
3859 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 3860 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
3860 qDebug("SyncKDE request detected!"); 3861 qDebug("KO: SyncKDE request detected!");
3861 } 3862 }
3862 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3863 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3863 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3864 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3864 return syncCalendar( filename, mode ); 3865 return syncCalendar( filename, mode );
3865} 3866}
3866bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 3867bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
3867{ 3868{
3868 //mSyncManager = manager; 3869 //mSyncManager = manager;
3869 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3870 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3870 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3871 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3871 if ( resource == "sharp" ) 3872 if ( resource == "sharp" )
3872 syncExternal( 0 ); 3873 syncExternal( 0 );
3873 if ( resource == "phone" ) 3874 if ( resource == "phone" )
3874 syncExternal( 1 ); 3875 syncExternal( 1 );
3875 // pending setmodified 3876 // pending setmodified
3876 return true; 3877 return true;
3877} 3878}
3878void CalendarView::setSyncManager(KSyncManager* manager) 3879void CalendarView::setSyncManager(KSyncManager* manager)
3879{ 3880{
3880 mSyncManager = manager; 3881 mSyncManager = manager;
3881} 3882}
3882 3883
3883void CalendarView::removeSyncInfo( QString syncProfile) 3884void CalendarView::removeSyncInfo( QString syncProfile)
3884{ 3885{
3885 qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); 3886 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
3886 mCalendar->removeSyncInfo( syncProfile ); 3887 mCalendar->removeSyncInfo( syncProfile );
3887 3888
3888} 3889}
3889 3890
3890void CalendarView::undo_delete() 3891void CalendarView::undo_delete()
3891{ 3892{
3892 //qDebug("undo_delete() "); 3893 //qDebug("undo_delete() ");
3893 Incidence* undo = mCalendar->undoIncidence(); 3894 Incidence* undo = mCalendar->undoIncidence();
3894 if ( !undo ) { 3895 if ( !undo ) {
3895 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 3896 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
3896 i18n("KO/Pi")); 3897 i18n("KO/Pi"));
3897 return; 3898 return;
3898 } 3899 }
3899 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 3900 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
3900 i18n("\nAre you sure you want\nto restore this?"), 3901 i18n("\nAre you sure you want\nto restore this?"),
3901 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 3902 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
3902 mCalendar->undoDeleteIncidence(); 3903 mCalendar->undoDeleteIncidence();
3903 updateView(); 3904 updateView();
3904 } 3905 }
3905} 3906}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 26ea1e2..877b6f2 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -354,513 +354,514 @@ void MainWindow::showMaximized ()
354#endif 354#endif
355 QWidget::showMaximized () ; 355 QWidget::showMaximized () ;
356 mClosed = false; 356 mClosed = false;
357} 357}
358void MainWindow::closeEvent( QCloseEvent* ce ) 358void MainWindow::closeEvent( QCloseEvent* ce )
359{ 359{
360 360
361 361
362 362
363 if ( ! KOPrefs::instance()->mAskForQuit ) { 363 if ( ! KOPrefs::instance()->mAskForQuit ) {
364 saveOnClose(); 364 saveOnClose();
365 mClosed = true; 365 mClosed = true;
366 ce->accept(); 366 ce->accept();
367 return; 367 return;
368 368
369 } 369 }
370 370
371 switch( QMessageBox::information( this, "KO/Pi", 371 switch( QMessageBox::information( this, "KO/Pi",
372 i18n("Do you really want\nto close KO/Pi?"), 372 i18n("Do you really want\nto close KO/Pi?"),
373 i18n("Close"), i18n("No"), 373 i18n("Close"), i18n("No"),
374 0, 0 ) ) { 374 0, 0 ) ) {
375 case 0: 375 case 0:
376 saveOnClose(); 376 saveOnClose();
377 mClosed = true; 377 mClosed = true;
378 ce->accept(); 378 ce->accept();
379 break; 379 break;
380 case 1: 380 case 1:
381 ce->ignore(); 381 ce->ignore();
382 break; 382 break;
383 case 2: 383 case 2:
384 384
385 default: 385 default:
386 break; 386 break;
387 } 387 }
388 388
389 389
390} 390}
391 391
392void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 392void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
393{ 393{
394 QDataStream stream( data, IO_ReadOnly ); 394 QDataStream stream( data, IO_ReadOnly );
395 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 395 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
396 //QString datamess; 396 //QString datamess;
397 //qDebug("message "); 397 //qDebug("message ");
398 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 398 qDebug("KO: QCOP message received: %s ", cmsg.data() );
399 399
400 if ( cmsg == "setDocument(QString)" ) { 400 if ( cmsg == "setDocument(QString)" ) {
401 QDataStream stream( data, IO_ReadOnly ); 401 QDataStream stream( data, IO_ReadOnly );
402 QString fileName; 402 QString fileName;
403 stream >> fileName; 403 stream >> fileName;
404 //qDebug("filename %s ", fileName.latin1()); 404 //qDebug("filename %s ", fileName.latin1());
405 showMaximized(); 405 showMaximized();
406 raise(); 406 raise();
407 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 407 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
408 mSyncManager->slotSyncMenu( 1002 ); 408 mSyncManager->slotSyncMenu( 1002 );
409 return; 409 return;
410 } 410 }
411 411
412 if ( cmsg == "-writeFile" ) { 412 if ( cmsg == "-writeFile" ) {
413 // I made from the "-writeFile" an "-writeAlarm" 413 // I made from the "-writeFile" an "-writeAlarm"
414 mView->viewManager()->showWhatsNextView(); 414 mView->viewManager()->showWhatsNextView();
415 mCalendar->checkAlarmForIncidence( 0, true); 415 mCalendar->checkAlarmForIncidence( 0, true);
416 showMaximized(); 416 showMaximized();
417 raise(); 417 raise();
418 return; 418 return;
419 419
420 } 420 }
421 if ( cmsg == "-writeFileSilent" ) { 421 if ( cmsg == "-writeFileSilent" ) {
422 // I made from the "-writeFile" an "-writeAlarm" 422 // I made from the "-writeFile" an "-writeAlarm"
423 // mView->viewManager()->showWhatsNextView(); 423 // mView->viewManager()->showWhatsNextView();
424 mCalendar->checkAlarmForIncidence( 0, true); 424 mCalendar->checkAlarmForIncidence( 0, true);
425 //showMaximized(); 425 //showMaximized();
426 //raise(); 426 //raise();
427 hide(); 427 hide();
428 return; 428 return;
429 } 429 }
430 if ( cmsg == "-newCountdown" ) { 430 if ( cmsg == "-newCountdown" ) {
431 qDebug("newCountdown "); 431 qDebug("newCountdown ");
432 432
433 } 433 }
434 QString msg ; 434 QString msg ;
435 QString allmsg = cmsg; 435 QString allmsg = cmsg;
436 while ( allmsg.length() > 0 ) { 436 while ( allmsg.length() > 0 ) {
437 int nextC = allmsg.find( "-", 1 ); 437 int nextC = allmsg.find( "-", 1 );
438 if ( nextC == -1 ) { 438 if ( nextC == -1 ) {
439 msg = allmsg; 439 msg = allmsg;
440 allmsg = ""; 440 allmsg = "";
441 } else{ 441 } else{
442 msg = allmsg.left( nextC ); 442 msg = allmsg.left( nextC );
443 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 443 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
444 } 444 }
445 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 445 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
446 if ( msg == "-newEvent" ) { 446 if ( msg == "-newEvent" ) {
447 mView->newEvent(); 447 mView->newEvent();
448 } 448 }
449 if ( msg == "-newTodo" ) { 449 if ( msg == "-newTodo" ) {
450 mView->newTodo(); 450 mView->newTodo();
451 451
452 } 452 }
453 if ( msg == "-showWN" ) { 453 if ( msg == "-showWN" ) {
454 mView->viewManager()->showWhatsNextView(); 454 mView->viewManager()->showWhatsNextView();
455 } 455 }
456 if ( msg == "-showTodo" ) { 456 if ( msg == "-showTodo" ) {
457 mView->viewManager()->showTodoView(); 457 mView->viewManager()->showTodoView();
458 } 458 }
459 if ( msg == "-showList" ) { 459 if ( msg == "-showList" ) {
460 mView->viewManager()->showListView(); 460 mView->viewManager()->showListView();
461 } 461 }
462 else if ( msg == "-showDay" ) { 462 else if ( msg == "-showDay" ) {
463 mView->viewManager()->showDayView(); 463 mView->viewManager()->showDayView();
464 } 464 }
465 else if ( msg == "-showWWeek" ) { 465 else if ( msg == "-showWWeek" ) {
466 mView->viewManager()->showWorkWeekView(); 466 mView->viewManager()->showWorkWeekView();
467 } 467 }
468 else if ( msg == "-ringSync" ) { 468 else if ( msg == "-ringSync" ) {
469 mSyncManager->multiSync( false ); 469 mSyncManager->multiSync( false );
470 } 470 }
471 else if ( msg == "-showWeek" ) { 471 else if ( msg == "-showWeek" ) {
472 mView->viewManager()->showWeekView(); 472 mView->viewManager()->showWeekView();
473 } 473 }
474 else if ( msg == "-showTodo" ) { 474 else if ( msg == "-showTodo" ) {
475 mView->viewManager()->showTodoView(); 475 mView->viewManager()->showTodoView();
476 } 476 }
477 else if ( msg == "-showJournal" ) { 477 else if ( msg == "-showJournal" ) {
478 mView->dateNavigator()->selectDates( 1 ); 478 mView->dateNavigator()->selectDates( 1 );
479 mView->dateNavigator()->selectToday(); 479 mView->dateNavigator()->selectToday();
480 mView->viewManager()->showJournalView(); 480 mView->viewManager()->showJournalView();
481 } 481 }
482 else if ( msg == "-showKO" ) { 482 else if ( msg == "-showKO" ) {
483 mView->viewManager()->showNextXView(); 483 mView->viewManager()->showNextXView();
484 } 484 }
485 else if ( msg == "-showWNext" || msg == "nextView()" ) { 485 else if ( msg == "-showWNext" || msg == "nextView()" ) {
486 mView->viewManager()->showWhatsNextView(); 486 mView->viewManager()->showWhatsNextView();
487 } 487 }
488 else if ( msg == "-showNextXView" ) { 488 else if ( msg == "-showNextXView" ) {
489 mView->viewManager()->showNextXView(); 489 mView->viewManager()->showNextXView();
490 } 490 }
491 491
492 492
493 } 493 }
494 494
495 showMaximized(); 495 showMaximized();
496 raise(); 496 raise();
497} 497}
498 498
499QPixmap MainWindow::loadPixmap( QString name ) 499QPixmap MainWindow::loadPixmap( QString name )
500{ 500{
501 return SmallIcon( name ); 501 return SmallIcon( name );
502 502
503} 503}
504void MainWindow::initActions() 504void MainWindow::initActions()
505{ 505{
506 //KOPrefs::instance()->mShowFullMenu 506 //KOPrefs::instance()->mShowFullMenu
507 iconToolBar->clear(); 507 iconToolBar->clear();
508 KOPrefs *p = KOPrefs::instance(); 508 KOPrefs *p = KOPrefs::instance();
509 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 509 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
510 510
511 QPopupMenu *viewMenu = new QPopupMenu( this ); 511 QPopupMenu *viewMenu = new QPopupMenu( this );
512 QPopupMenu *actionMenu = new QPopupMenu( this ); 512 QPopupMenu *actionMenu = new QPopupMenu( this );
513 QPopupMenu *importMenu = new QPopupMenu( this ); 513 QPopupMenu *importMenu = new QPopupMenu( this );
514 selectFilterMenu = new QPopupMenu( this ); 514 selectFilterMenu = new QPopupMenu( this );
515 selectFilterMenu->setCheckable( true ); 515 selectFilterMenu->setCheckable( true );
516 syncMenu = new QPopupMenu( this ); 516 syncMenu = new QPopupMenu( this );
517 configureAgendaMenu = new QPopupMenu( this ); 517 configureAgendaMenu = new QPopupMenu( this );
518 configureToolBarMenu = new QPopupMenu( this ); 518 configureToolBarMenu = new QPopupMenu( this );
519 QPopupMenu *helpMenu = new QPopupMenu( this ); 519 QPopupMenu *helpMenu = new QPopupMenu( this );
520 if ( KOPrefs::instance()->mShowFullMenu ) { 520 if ( KOPrefs::instance()->mShowFullMenu ) {
521 QMenuBar *menuBar1; 521 QMenuBar *menuBar1;
522 menuBar1 = menuBar(); 522 menuBar1 = menuBar();
523 menuBar1->insertItem( i18n("File"), importMenu ); 523 menuBar1->insertItem( i18n("File"), importMenu );
524 menuBar1->insertItem( i18n("View"), viewMenu ); 524 menuBar1->insertItem( i18n("View"), viewMenu );
525 menuBar1->insertItem( i18n("Actions"), actionMenu ); 525 menuBar1->insertItem( i18n("Actions"), actionMenu );
526 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 526 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
527 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 527 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
528 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 528 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
529 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 529 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
530 menuBar1->insertItem( i18n("Help"), helpMenu ); 530 menuBar1->insertItem( i18n("Help"), helpMenu );
531 } else { 531 } else {
532 QPEMenuBar *menuBar1; 532 QPEMenuBar *menuBar1;
533 menuBar1 = new QPEMenuBar( iconToolBar ); 533 menuBar1 = new QPEMenuBar( iconToolBar );
534 QPopupMenu *menuBar = new QPopupMenu( this ); 534 QPopupMenu *menuBar = new QPopupMenu( this );
535 menuBar1->insertItem( i18n("ME"), menuBar); 535 menuBar1->insertItem( i18n("ME"), menuBar);
536 menuBar->insertItem( i18n("File"), importMenu ); 536 menuBar->insertItem( i18n("File"), importMenu );
537 menuBar->insertItem( i18n("View"), viewMenu ); 537 menuBar->insertItem( i18n("View"), viewMenu );
538 menuBar->insertItem( i18n("Actions"), actionMenu ); 538 menuBar->insertItem( i18n("Actions"), actionMenu );
539 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 539 menuBar->insertItem( i18n("Synchronize"), syncMenu );
540 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 540 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
541 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 541 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
542 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 542 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
543 menuBar->insertItem( i18n("Help"), helpMenu ); 543 menuBar->insertItem( i18n("Help"), helpMenu );
544 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 544 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
545 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 545 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
546 } 546 }
547 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 547 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
548 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); 548 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) );
549 549
550 // ****************** 550 // ******************
551 QAction *action; 551 QAction *action;
552 QIconSet icon; 552 QIconSet icon;
553 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 553 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
554 configureToolBarMenu->setCheckable( true ); 554 configureToolBarMenu->setCheckable( true );
555 555
556 QString pathString = ""; 556 QString pathString = "";
557 if ( !p->mToolBarMiniIcons ) { 557 if ( !p->mToolBarMiniIcons ) {
558 if ( QApplication::desktop()->width() < 480 ) 558 if ( QApplication::desktop()->width() < 480 )
559 pathString += "icons16/"; 559 pathString += "icons16/";
560 } else 560 } else
561 pathString += "iconsmini/"; 561 pathString += "iconsmini/";
562 configureAgendaMenu->setCheckable( true ); 562 configureAgendaMenu->setCheckable( true );
563 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 563 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
564 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 564 configureAgendaMenu->insertItem(i18n("Small"), 6 );
565 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 565 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
566 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 566 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
567 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 567 configureAgendaMenu->insertItem(i18n("Large"), 12 );
568 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 568 configureAgendaMenu->insertItem(i18n("Big"), 14 );
569 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 569 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
570 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 570 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
571 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 571 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
572 572
573 icon = loadPixmap( pathString + "configure" ); 573 icon = loadPixmap( pathString + "configure" );
574 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 574 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
575 action->addTo( actionMenu ); 575 action->addTo( actionMenu );
576 connect( action, SIGNAL( activated() ), 576 connect( action, SIGNAL( activated() ),
577 mView, SLOT( edit_options() ) ); 577 mView, SLOT( edit_options() ) );
578 actionMenu->insertSeparator(); 578 actionMenu->insertSeparator();
579 579
580 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); 580 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
581 action->addTo( actionMenu ); 581 action->addTo( actionMenu );
582 connect( action, SIGNAL( activated() ), 582 connect( action, SIGNAL( activated() ),
583 mView, SLOT( undo_delete() ) ); 583 mView, SLOT( undo_delete() ) );
584 actionMenu->insertSeparator(); 584 actionMenu->insertSeparator();
585 585
586 icon = loadPixmap( pathString + "newevent" ); 586 icon = loadPixmap( pathString + "newevent" );
587 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 587 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
588 configureToolBarMenu->insertSeparator(); 588 configureToolBarMenu->insertSeparator();
589 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 589 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
590 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 590 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
591 ne_action->addTo( actionMenu ); 591 ne_action->addTo( actionMenu );
592 connect( ne_action, SIGNAL( activated() ), 592 connect( ne_action, SIGNAL( activated() ),
593 mView, SLOT( newEvent() ) ); 593 mView, SLOT( newEvent() ) );
594 icon = loadPixmap( pathString + "newtodo" ); 594 icon = loadPixmap( pathString + "newtodo" );
595 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 595 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
596 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 596 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
597 nt_action->addTo( actionMenu ); 597 nt_action->addTo( actionMenu );
598 connect( nt_action, SIGNAL( activated() ), 598 connect( nt_action, SIGNAL( activated() ),
599 mView, SLOT( newTodo() ) ); 599 mView, SLOT( newTodo() ) );
600 icon = loadPixmap( pathString + "navi" ); 600 icon = loadPixmap( pathString + "navi" );
601 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 601 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
602 action->addTo( viewMenu ); 602 action->addTo( viewMenu );
603 connect( action, SIGNAL( activated() ), 603 connect( action, SIGNAL( activated() ),
604 mView, SLOT( toggleDateNavigatorWidget() ) ); 604 mView, SLOT( toggleDateNavigatorWidget() ) );
605 icon = loadPixmap( pathString + "filter" ); 605 icon = loadPixmap( pathString + "filter" );
606 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 606 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
607 action->addTo( viewMenu ); 607 action->addTo( viewMenu );
608 connect( action, SIGNAL( activated() ), 608 connect( action, SIGNAL( activated() ),
609 mView, SLOT( toggleFilter() ) ); 609 mView, SLOT( toggleFilter() ) );
610 action = new QAction( i18n("Toggle Allday"), i18n("Toggle Allday"), 0, this ); 610 icon = loadPixmap( pathString + "allday" );
611 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this );
611 action->addTo( viewMenu ); 612 action->addTo( viewMenu );
612 connect( action, SIGNAL( activated() ), 613 connect( action, SIGNAL( activated() ),
613 mView, SLOT( toggleAllDaySize() ) ); 614 mView, SLOT( toggleAllDaySize() ) );
614 615
615 viewMenu->insertSeparator(); 616 viewMenu->insertSeparator();
616 icon = loadPixmap( pathString + "picker" ); 617 icon = loadPixmap( pathString + "picker" );
617 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 618 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
618 action->addTo( viewMenu ); 619 action->addTo( viewMenu );
619 connect( action, SIGNAL( activated() ), 620 connect( action, SIGNAL( activated() ),
620 mView, SLOT( showDatePicker() ) ); 621 mView, SLOT( showDatePicker() ) );
621 action->addTo( iconToolBar ); 622 action->addTo( iconToolBar );
622 viewMenu->insertSeparator(); 623 viewMenu->insertSeparator();
623 icon = loadPixmap( pathString + "list" ); 624 icon = loadPixmap( pathString + "list" );
624 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 625 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
625 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 626 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
626 showlist_action->addTo( viewMenu ); 627 showlist_action->addTo( viewMenu );
627 connect( showlist_action, SIGNAL( activated() ), 628 connect( showlist_action, SIGNAL( activated() ),
628 mView->viewManager(), SLOT( showListView() ) ); 629 mView->viewManager(), SLOT( showListView() ) );
629 630
630 631
631 icon = loadPixmap( pathString + "day" ); 632 icon = loadPixmap( pathString + "day" );
632 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 633 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
633 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 634 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
634 day1_action->addTo( viewMenu ); 635 day1_action->addTo( viewMenu );
635 // action->addTo( toolBar ); 636 // action->addTo( toolBar );
636 connect( day1_action, SIGNAL( activated() ), 637 connect( day1_action, SIGNAL( activated() ),
637 mView->viewManager(), SLOT( showDayView() ) ); 638 mView->viewManager(), SLOT( showDayView() ) );
638 639
639 icon = loadPixmap( pathString + "workweek" ); 640 icon = loadPixmap( pathString + "workweek" );
640 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 641 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
641 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 642 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
642 day5_action->addTo( viewMenu ); 643 day5_action->addTo( viewMenu );
643 connect( day5_action, SIGNAL( activated() ), 644 connect( day5_action, SIGNAL( activated() ),
644 mView->viewManager(), SLOT( showWorkWeekView() ) ); 645 mView->viewManager(), SLOT( showWorkWeekView() ) );
645 646
646 icon = loadPixmap( pathString + "week" ); 647 icon = loadPixmap( pathString + "week" );
647 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 648 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
648 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 649 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
649 day7_action->addTo( viewMenu ); 650 day7_action->addTo( viewMenu );
650 connect( day7_action, SIGNAL( activated() ), 651 connect( day7_action, SIGNAL( activated() ),
651 mView->viewManager(), SLOT( showWeekView() ) ); 652 mView->viewManager(), SLOT( showWeekView() ) );
652 653
653 icon = loadPixmap( pathString + "month" ); 654 icon = loadPixmap( pathString + "month" );
654 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 655 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
655 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 656 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
656 month_action->addTo( viewMenu ); 657 month_action->addTo( viewMenu );
657 connect( month_action, SIGNAL( activated() ), 658 connect( month_action, SIGNAL( activated() ),
658 mView->viewManager(), SLOT( showMonthView() ) ); 659 mView->viewManager(), SLOT( showMonthView() ) );
659 660
660 icon = loadPixmap( pathString + "todo" ); 661 icon = loadPixmap( pathString + "todo" );
661 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 662 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
662 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 663 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
663 todoview_action->addTo( viewMenu ); 664 todoview_action->addTo( viewMenu );
664 connect( todoview_action, SIGNAL( activated() ), 665 connect( todoview_action, SIGNAL( activated() ),
665 mView->viewManager(), SLOT( showTodoView() ) ); 666 mView->viewManager(), SLOT( showTodoView() ) );
666 667
667 icon = loadPixmap( pathString + "journal" ); 668 icon = loadPixmap( pathString + "journal" );
668 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 669 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
669 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 670 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
670 viewjournal_action->addTo( viewMenu ); 671 viewjournal_action->addTo( viewMenu );
671 connect( viewjournal_action, SIGNAL( activated() ), 672 connect( viewjournal_action, SIGNAL( activated() ),
672 mView->viewManager(), SLOT( showJournalView() ) ); 673 mView->viewManager(), SLOT( showJournalView() ) );
673 674
674 icon = loadPixmap( pathString + "xdays" ); 675 icon = loadPixmap( pathString + "xdays" );
675 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 676 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
676 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 677 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
677 xdays_action->addTo( viewMenu ); 678 xdays_action->addTo( viewMenu );
678 connect( xdays_action, SIGNAL( activated() ), 679 connect( xdays_action, SIGNAL( activated() ),
679 mView->viewManager(), SLOT( showNextXView() ) ); 680 mView->viewManager(), SLOT( showNextXView() ) );
680 681
681 icon = loadPixmap( pathString + "whatsnext" ); 682 icon = loadPixmap( pathString + "whatsnext" );
682 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 683 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
683 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 684 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
684 whatsnext_action->addTo( viewMenu ); 685 whatsnext_action->addTo( viewMenu );
685 connect( whatsnext_action, SIGNAL( activated() ), 686 connect( whatsnext_action, SIGNAL( activated() ),
686 mView->viewManager(), SLOT( showWhatsNextView() ) ); 687 mView->viewManager(), SLOT( showWhatsNextView() ) );
687 688
688#if 0 689#if 0
689 action = new QAction( "view_timespan", "Time Span", 0, this ); 690 action = new QAction( "view_timespan", "Time Span", 0, this );
690 action->addTo( viewMenu ); 691 action->addTo( viewMenu );
691 connect( action, SIGNAL( activated() ), 692 connect( action, SIGNAL( activated() ),
692 mView->viewManager(), SLOT( showTimeSpanView() ) ); 693 mView->viewManager(), SLOT( showTimeSpanView() ) );
693#endif 694#endif
694 695
695 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 696 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
696 this ); 697 this );
697 mNewSubTodoAction->addTo( actionMenu ); 698 mNewSubTodoAction->addTo( actionMenu );
698 connect( mNewSubTodoAction, SIGNAL( activated() ), 699 connect( mNewSubTodoAction, SIGNAL( activated() ),
699 mView, SLOT( newSubTodo() ) ); 700 mView, SLOT( newSubTodo() ) );
700 701
701 actionMenu->insertSeparator(); 702 actionMenu->insertSeparator();
702 703
703 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 704 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
704 mShowAction->addTo( actionMenu ); 705 mShowAction->addTo( actionMenu );
705 connect( mShowAction, SIGNAL( activated() ), 706 connect( mShowAction, SIGNAL( activated() ),
706 mView, SLOT( showIncidence() ) ); 707 mView, SLOT( showIncidence() ) );
707 708
708 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 709 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
709 mEditAction->addTo( actionMenu ); 710 mEditAction->addTo( actionMenu );
710 connect( mEditAction, SIGNAL( activated() ), 711 connect( mEditAction, SIGNAL( activated() ),
711 mView, SLOT( editIncidence() ) ); 712 mView, SLOT( editIncidence() ) );
712 713
713 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 714 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
714 mDeleteAction->addTo( actionMenu ); 715 mDeleteAction->addTo( actionMenu );
715 connect( mDeleteAction, SIGNAL( activated() ), 716 connect( mDeleteAction, SIGNAL( activated() ),
716 mView, SLOT( deleteIncidence() ) ); 717 mView, SLOT( deleteIncidence() ) );
717 718
718 719
719 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 720 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
720 mCloneAction->addTo( actionMenu ); 721 mCloneAction->addTo( actionMenu );
721 connect( mCloneAction, SIGNAL( activated() ), 722 connect( mCloneAction, SIGNAL( activated() ),
722 mView, SLOT( cloneIncidence() ) ); 723 mView, SLOT( cloneIncidence() ) );
723 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 724 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
724 mMoveAction->addTo( actionMenu ); 725 mMoveAction->addTo( actionMenu );
725 connect( mMoveAction, SIGNAL( activated() ), 726 connect( mMoveAction, SIGNAL( activated() ),
726 mView, SLOT( moveIncidence() ) ); 727 mView, SLOT( moveIncidence() ) );
727 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 728 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
728 mBeamAction->addTo( actionMenu ); 729 mBeamAction->addTo( actionMenu );
729 connect( mBeamAction, SIGNAL( activated() ), 730 connect( mBeamAction, SIGNAL( activated() ),
730 mView, SLOT( beamIncidence() ) ); 731 mView, SLOT( beamIncidence() ) );
731 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 732 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
732 mCancelAction->addTo( actionMenu ); 733 mCancelAction->addTo( actionMenu );
733 connect( mCancelAction, SIGNAL( activated() ), 734 connect( mCancelAction, SIGNAL( activated() ),
734 mView, SLOT( toggleCancelIncidence() ) ); 735 mView, SLOT( toggleCancelIncidence() ) );
735 736
736 actionMenu->insertSeparator(); 737 actionMenu->insertSeparator();
737 738
738 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 739 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
739 this ); 740 this );
740 action->addTo( actionMenu ); 741 action->addTo( actionMenu );
741 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 742 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
742 743
743 icon = loadPixmap( pathString + "search" ); 744 icon = loadPixmap( pathString + "search" );
744 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 745 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
745 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 746 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
746 search_action->addTo( actionMenu ); 747 search_action->addTo( actionMenu );
747 connect( search_action, SIGNAL( activated() ), 748 connect( search_action, SIGNAL( activated() ),
748 mView->dialogManager(), SLOT( showSearchDialog() ) ); 749 mView->dialogManager(), SLOT( showSearchDialog() ) );
749 750
750 icon = loadPixmap( pathString + "today" ); 751 icon = loadPixmap( pathString + "today" );
751 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 752 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
752 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 753 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
753 today_action->addTo( actionMenu ); 754 today_action->addTo( actionMenu );
754 connect( today_action, SIGNAL( activated() ), 755 connect( today_action, SIGNAL( activated() ),
755 mView, SLOT( goToday() ) ); 756 mView, SLOT( goToday() ) );
756 757
757 if ( KOPrefs::instance()->mShowFullMenu ) { 758 if ( KOPrefs::instance()->mShowFullMenu ) {
758 actionMenu->insertSeparator(); 759 actionMenu->insertSeparator();
759 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 760 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
760 761
761 } 762 }
762 // actionMenu->insertSeparator(); 763 // actionMenu->insertSeparator();
763 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 764 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
764 this ); 765 this );
765 action->addTo( importMenu ); 766 action->addTo( importMenu );
766 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 767 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
767 action = new QAction( "import_quick", i18n("Import last file"), 0, 768 action = new QAction( "import_quick", i18n("Import last file"), 0,
768 this ); 769 this );
769 action->addTo( importMenu ); 770 action->addTo( importMenu );
770 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 771 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
771 importMenu->insertSeparator(); 772 importMenu->insertSeparator();
772 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 773 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
773 this ); 774 this );
774 action->addTo( importMenu ); 775 action->addTo( importMenu );
775 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 776 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
776#ifndef DESKTOP_VERSION 777#ifndef DESKTOP_VERSION
777 importMenu->insertSeparator(); 778 importMenu->insertSeparator();
778 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 779 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
779 this ); 780 this );
780 action->addTo( importMenu ); 781 action->addTo( importMenu );
781 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 782 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
782#else 783#else
783#ifdef _OL_IMPORT_ 784#ifdef _OL_IMPORT_
784 importMenu->insertSeparator(); 785 importMenu->insertSeparator();
785 action = new QAction( "import_ol", i18n("Import from OL"), 0, 786 action = new QAction( "import_ol", i18n("Import from OL"), 0,
786 this ); 787 this );
787 action->addTo( importMenu ); 788 action->addTo( importMenu );
788 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 789 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
789#endif 790#endif
790#endif 791#endif
791 792
792 importMenu->insertSeparator(); 793 importMenu->insertSeparator();
793 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 794 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
794 this ); 795 this );
795 action->addTo( importMenu ); 796 action->addTo( importMenu );
796 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 797 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
797 798
798 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 799 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
799 this ); 800 this );
800 action->addTo( importMenu ); 801 action->addTo( importMenu );
801 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 802 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
802 803
803 importMenu->insertSeparator(); 804 importMenu->insertSeparator();
804 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 805 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
805 this ); 806 this );
806 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 807 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
807 808
808 809
809 //LR 810 //LR
810 QPopupMenu *ex2phone = new QPopupMenu( this ); 811 QPopupMenu *ex2phone = new QPopupMenu( this );
811 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 812 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
812 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 813 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
813 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 814 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
814 importMenu->insertItem( i18n("Export to phone"), ex2phone ); 815 importMenu->insertItem( i18n("Export to phone"), ex2phone );
815 816
816 importMenu->insertSeparator(); 817 importMenu->insertSeparator();
817 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 818 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
818 this ); 819 this );
819 action->addTo( importMenu ); 820 action->addTo( importMenu );
820 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 821 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
821#ifndef DESKTOP_VERSION 822#ifndef DESKTOP_VERSION
822 importMenu->insertSeparator(); 823 importMenu->insertSeparator();
823 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 824 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
824 this ); 825 this );
825 brAction->addTo( importMenu ); 826 brAction->addTo( importMenu );
826 brAction->setToggleAction (true ) ; 827 brAction->setToggleAction (true ) ;
827 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 828 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
828 829
829 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 830 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
830 this ); 831 this );
831 action->addTo( importMenu ); 832 action->addTo( importMenu );
832 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 833 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
833 834
834 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 835 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
835 this ); 836 this );
836 action->addTo( importMenu ); 837 action->addTo( importMenu );
837 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 838 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
838#else 839#else
839 importMenu->insertSeparator(); 840 importMenu->insertSeparator();
840 icon = loadPixmap( pathString + "print" ); 841 icon = loadPixmap( pathString + "print" );
841 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 842 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
842 action->addTo( importMenu ); 843 action->addTo( importMenu );
843 connect( action, SIGNAL( activated() ), 844 connect( action, SIGNAL( activated() ),
844 this, SLOT( printCal() ) ); 845 this, SLOT( printCal() ) );
845 846
846 icon = loadPixmap( pathString + "print" ); 847 icon = loadPixmap( pathString + "print" );
847 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 848 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
848 action->addTo( importMenu ); 849 action->addTo( importMenu );
849 connect( action, SIGNAL( activated() ), 850 connect( action, SIGNAL( activated() ),
850 this, SLOT( printSel() ) ); 851 this, SLOT( printSel() ) );
851 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); 852 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
852 action->addTo( importMenu ); 853 action->addTo( importMenu );
853 connect( action, SIGNAL( activated() ), 854 connect( action, SIGNAL( activated() ),
854 mView->viewManager(), SIGNAL( printWNV() ) ); 855 mView->viewManager(), SIGNAL( printWNV() ) );
855#endif 856#endif
856 importMenu->insertSeparator(); 857 importMenu->insertSeparator();
857 action = new QAction( "beam all", i18n("Save"), 0, 858 action = new QAction( "beam all", i18n("Save"), 0,
858 this ); 859 this );
859 action->addTo( importMenu ); 860 action->addTo( importMenu );
860 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 861 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
861 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 862 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
862 this ); 863 this );
863 action->addTo( importMenu ); 864 action->addTo( importMenu );
864 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 865 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
865 866
866 //menuBar->insertItem( "Configure",configureMenu ); 867 //menuBar->insertItem( "Configure",configureMenu );
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index f488a07..3adbf61 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,1485 +1,1485 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21// $Id$ 21// $Id$
22 22
23#include "ksyncmanager.h" 23#include "ksyncmanager.h"
24 24
25#include <stdlib.h> 25#include <stdlib.h>
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#include <unistd.h> 28#include <unistd.h>
29#endif 29#endif
30 30
31 31
32#include "ksyncprofile.h" 32#include "ksyncprofile.h"
33#include "ksyncprefsdialog.h" 33#include "ksyncprefsdialog.h"
34#include "kpimprefs.h" 34#include "kpimprefs.h"
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <qdir.h> 37#include <qdir.h>
38#include <qprogressbar.h> 38#include <qprogressbar.h>
39#include <qpopupmenu.h> 39#include <qpopupmenu.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qradiobutton.h> 41#include <qradiobutton.h>
42#include <qbuttongroup.h> 42#include <qbuttongroup.h>
43#include <qtimer.h> 43#include <qtimer.h>
44#include <qmessagebox.h> 44#include <qmessagebox.h>
45#include <qapplication.h> 45#include <qapplication.h>
46#include <qlineedit.h> 46#include <qlineedit.h>
47#include <qdialog.h> 47#include <qdialog.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qtextcodec.h> 49#include <qtextcodec.h>
50#include <qlabel.h> 50#include <qlabel.h>
51#include <qcheckbox.h> 51#include <qcheckbox.h>
52 52
53#include <klocale.h> 53#include <klocale.h>
54#include <kglobal.h> 54#include <kglobal.h>
55#include <kconfig.h> 55#include <kconfig.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57 57
58QDateTime KSyncManager::mRequestedSyncEvent; 58QDateTime KSyncManager::mRequestedSyncEvent;
59 59
60 60
61KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 61KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
62 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) 62 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu)
63{ 63{
64 mServerSocket = 0; 64 mServerSocket = 0;
65 bar = new QProgressBar ( 1, 0 ); 65 bar = new QProgressBar ( 1, 0 );
66 bar->setCaption (""); 66 bar->setCaption ("");
67 mWriteBackInPast = 2; 67 mWriteBackInPast = 2;
68 int w = 300; 68 int w = 300;
69 if ( QApplication::desktop()->width() < 320 ) 69 if ( QApplication::desktop()->width() < 320 )
70 w = 220; 70 w = 220;
71 int h = bar->sizeHint().height() ; 71 int h = bar->sizeHint().height() ;
72 int dw = QApplication::desktop()->width(); 72 int dw = QApplication::desktop()->width();
73 int dh = QApplication::desktop()->height(); 73 int dh = QApplication::desktop()->height();
74 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 74 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
75 if ( mPrefs->mPassiveSyncAutoStart ) 75 if ( mPrefs->mPassiveSyncAutoStart )
76 enableQuick( false ); 76 enableQuick( false );
77 77
78} 78}
79 79
80KSyncManager::~KSyncManager() 80KSyncManager::~KSyncManager()
81{ 81{
82 delete bar; 82 delete bar;
83} 83}
84 84
85 85
86void KSyncManager::fillSyncMenu() 86void KSyncManager::fillSyncMenu()
87{ 87{
88 if ( mSyncMenu->count() ) 88 if ( mSyncMenu->count() )
89 mSyncMenu->clear(); 89 mSyncMenu->clear();
90 90
91 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 91 mSyncMenu->insertItem( i18n("Configure..."), 0 );
92 mSyncMenu->insertSeparator(); 92 mSyncMenu->insertSeparator();
93 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); 93 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu );
94 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); 94 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 );
95 clearMenu->insertItem( i18n("For all profiles"), 1 ); 95 clearMenu->insertItem( i18n("For all profiles"), 1 );
96 clearMenu->insertSeparator(); 96 clearMenu->insertSeparator();
97 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); 97 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) );
98 mSyncMenu->insertSeparator(); 98 mSyncMenu->insertSeparator();
99 if ( mServerSocket == 0 ) { 99 if ( mServerSocket == 0 ) {
100 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 100 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
101 } else { 101 } else {
102 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 102 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
103 } 103 }
104 mSyncMenu->insertSeparator(); 104 mSyncMenu->insertSeparator();
105 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 105 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
106 mSyncMenu->insertSeparator(); 106 mSyncMenu->insertSeparator();
107 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 107 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
108 config.setGroup("General"); 108 config.setGroup("General");
109 QStringList prof = config.readListEntry("SyncProfileNames"); 109 QStringList prof = config.readListEntry("SyncProfileNames");
110 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 110 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
111 if ( prof.count() < 2 ) { 111 if ( prof.count() < 2 ) {
112 prof.clear(); 112 prof.clear();
113 QString externalName; 113 QString externalName;
114#ifdef DESKTOP_VERSION 114#ifdef DESKTOP_VERSION
115#ifdef _WIN32_ 115#ifdef _WIN32_
116 externalName = "OutLook(not_implemented)"; 116 externalName = "OutLook(not_implemented)";
117#else 117#else
118 externalName = "KDE_Desktop"; 118 externalName = "KDE_Desktop";
119#endif 119#endif
120#else 120#else
121 externalName = "Sharp_DTM"; 121 externalName = "Sharp_DTM";
122#endif 122#endif
123 prof << externalName; 123 prof << externalName;
124 prof << i18n("Local_file"); 124 prof << i18n("Local_file");
125 prof << i18n("Last_file"); 125 prof << i18n("Last_file");
126 KSyncProfile* temp = new KSyncProfile (); 126 KSyncProfile* temp = new KSyncProfile ();
127 temp->setName( prof[0] ); 127 temp->setName( prof[0] );
128 temp->writeConfig(&config); 128 temp->writeConfig(&config);
129 temp->setName( prof[1] ); 129 temp->setName( prof[1] );
130 temp->writeConfig(&config); 130 temp->writeConfig(&config);
131 temp->setName( prof[2] ); 131 temp->setName( prof[2] );
132 temp->writeConfig(&config); 132 temp->writeConfig(&config);
133 config.setGroup("General"); 133 config.setGroup("General");
134 config.writeEntry("SyncProfileNames",prof); 134 config.writeEntry("SyncProfileNames",prof);
135 config.writeEntry("ExternSyncProfiles",externalName); 135 config.writeEntry("ExternSyncProfiles",externalName);
136 config.sync(); 136 config.sync();
137 delete temp; 137 delete temp;
138 } 138 }
139 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 139 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
140 mSyncProfileNames = prof; 140 mSyncProfileNames = prof;
141 unsigned int i; 141 unsigned int i;
142 for ( i = 0; i < prof.count(); ++i ) { 142 for ( i = 0; i < prof.count(); ++i ) {
143 mSyncMenu->insertItem( prof[i], 1000+i ); 143 mSyncMenu->insertItem( prof[i], 1000+i );
144 clearMenu->insertItem( prof[i], 1000+i ); 144 clearMenu->insertItem( prof[i], 1000+i );
145 if ( i == 2 ) 145 if ( i == 2 )
146 mSyncMenu->insertSeparator(); 146 mSyncMenu->insertSeparator();
147 } 147 }
148 QDir app_dir; 148 QDir app_dir;
149 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 149 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
150 if ( mTargetApp == PWMPI) { 150 if ( mTargetApp == PWMPI) {
151 mSyncMenu->removeItem( 1000 ); 151 mSyncMenu->removeItem( 1000 );
152 clearMenu->removeItem( 1000 ); 152 clearMenu->removeItem( 1000 );
153 } 153 }
154#ifndef DESKTOP_VERSION 154#ifndef DESKTOP_VERSION
155 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 155 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
156 mSyncMenu->removeItem( 1000 ); 156 mSyncMenu->removeItem( 1000 );
157 clearMenu->removeItem( 1000 ); 157 clearMenu->removeItem( 1000 );
158 } 158 }
159#endif 159#endif
160 mSyncMenu->removeItem( 1002 ); 160 mSyncMenu->removeItem( 1002 );
161 clearMenu->removeItem( 1002 ); 161 clearMenu->removeItem( 1002 );
162} 162}
163void KSyncManager::slotClearMenu( int action ) 163void KSyncManager::slotClearMenu( int action )
164{ 164{
165 QString syncDevice; 165 QString syncDevice;
166 if ( action > 999 ) { 166 if ( action > 999 ) {
167 syncDevice = mSyncProfileNames[action - 1000] ; 167 syncDevice = mSyncProfileNames[action - 1000] ;
168 } 168 }
169 169
170 170
171 171
172 int result = 0; 172 int result = 0;
173 QString sd; 173 QString sd;
174 if ( syncDevice.isEmpty() ) 174 if ( syncDevice.isEmpty() )
175 sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); 175 sd = i18n("Do you want to\nclear all sync info\nof all profiles?");
176 else 176 else
177 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); 177 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice );
178 178
179 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, 179 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0,
180 0, 1 ); 180 0, 1 );
181 if ( result ) 181 if ( result )
182 return; 182 return;
183 mImplementation->removeSyncInfo( syncDevice ); 183 mImplementation->removeSyncInfo( syncDevice );
184} 184}
185void KSyncManager::slotSyncMenu( int action ) 185void KSyncManager::slotSyncMenu( int action )
186{ 186{
187 qDebug("syncaction %d ", action); 187 qDebug("KSM::syncaction %d ", action);
188 if ( action == 5000 ) 188 if ( action == 5000 )
189 return; 189 return;
190 mSyncWithDesktop = false; 190 mSyncWithDesktop = false;
191 if ( action == 0 ) { 191 if ( action == 0 ) {
192 192
193 // seems to be a Qt2 event handling bug 193 // seems to be a Qt2 event handling bug
194 // syncmenu.clear causes a segfault at first time 194 // syncmenu.clear causes a segfault at first time
195 // when we call it after the main event loop, it is ok 195 // when we call it after the main event loop, it is ok
196 // same behaviour when calling OM/Pi via QCOP for the first time 196 // same behaviour when calling OM/Pi via QCOP for the first time
197 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 197 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
198 //confSync(); 198 //confSync();
199 199
200 return; 200 return;
201 } 201 }
202 if ( action == 1 ) { 202 if ( action == 1 ) {
203 multiSync( true ); 203 multiSync( true );
204 return; 204 return;
205 } 205 }
206 if ( action == 2 ) { 206 if ( action == 2 ) {
207 enableQuick(); 207 enableQuick();
208 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 208 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
209 return; 209 return;
210 } 210 }
211 if ( action == 3 ) { 211 if ( action == 3 ) {
212 delete mServerSocket; 212 delete mServerSocket;
213 mServerSocket = 0; 213 mServerSocket = 0;
214 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 214 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
215 return; 215 return;
216 } 216 }
217 217
218 if (blockSave()) 218 if (blockSave())
219 return; 219 return;
220 220
221 setBlockSave(true); 221 setBlockSave(true);
222 bool silent = false; 222 bool silent = false;
223 if ( action == 999 ) { 223 if ( action == 999 ) {
224 //special mode for silent syncing 224 //special mode for silent syncing
225 action = 1000; 225 action = 1000;
226 silent = true; 226 silent = true;
227 } 227 }
228 228
229 mCurrentSyncProfile = action - 1000 ; 229 mCurrentSyncProfile = action - 1000 ;
230 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 230 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
231 mCurrentSyncName = mLocalMachineName ; 231 mCurrentSyncName = mLocalMachineName ;
232 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 232 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
233 KSyncProfile* temp = new KSyncProfile (); 233 KSyncProfile* temp = new KSyncProfile ();
234 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 234 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
235 temp->readConfig(&config); 235 temp->readConfig(&config);
236 if (silent) { 236 if (silent) {
237 mAskForPreferences = false; 237 mAskForPreferences = false;
238 mShowSyncSummary = false; 238 mShowSyncSummary = false;
239 mWriteBackFile = true; 239 mWriteBackFile = true;
240 mSyncAlgoPrefs = 2;// take newest 240 mSyncAlgoPrefs = 2;// take newest
241 } 241 }
242 else { 242 else {
243 mAskForPreferences = temp->getAskForPreferences(); 243 mAskForPreferences = temp->getAskForPreferences();
244 mShowSyncSummary = temp->getShowSummaryAfterSync(); 244 mShowSyncSummary = temp->getShowSummaryAfterSync();
245 mWriteBackFile = temp->getWriteBackFile(); 245 mWriteBackFile = temp->getWriteBackFile();
246 mSyncAlgoPrefs = temp->getSyncPrefs(); 246 mSyncAlgoPrefs = temp->getSyncPrefs();
247 } 247 }
248 mWriteBackExistingOnly = temp->getWriteBackExisting(); 248 mWriteBackExistingOnly = temp->getWriteBackExisting();
249 mIsKapiFile = temp->getIsKapiFile(); 249 mIsKapiFile = temp->getIsKapiFile();
250 mWriteBackInFuture = 0; 250 mWriteBackInFuture = 0;
251 if ( temp->getWriteBackFuture() ) { 251 if ( temp->getWriteBackFuture() ) {
252 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 252 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
253 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 253 mWriteBackInPast = temp->getWriteBackPastWeeks( );
254 } 254 }
255 mFilterInCal = temp->getFilterInCal(); 255 mFilterInCal = temp->getFilterInCal();
256 mFilterOutCal = temp->getFilterOutCal(); 256 mFilterOutCal = temp->getFilterOutCal();
257 mFilterInAB = temp->getFilterInAB(); 257 mFilterInAB = temp->getFilterInAB();
258 mFilterOutAB = temp->getFilterOutAB(); 258 mFilterOutAB = temp->getFilterOutAB();
259 259
260 if ( action == 1000 ) { 260 if ( action == 1000 ) {
261 mIsKapiFile = false; 261 mIsKapiFile = false;
262#ifdef DESKTOP_VERSION 262#ifdef DESKTOP_VERSION
263 syncKDE(); 263 syncKDE();
264#else 264#else
265 syncSharp(); 265 syncSharp();
266#endif 266#endif
267 267
268 } else if ( action == 1001 ) { 268 } else if ( action == 1001 ) {
269 syncLocalFile(); 269 syncLocalFile();
270 270
271 } else if ( action == 1002 ) { 271 } else if ( action == 1002 ) {
272 mWriteBackFile = false; 272 mWriteBackFile = false;
273 mAskForPreferences = false; 273 mAskForPreferences = false;
274 mShowSyncSummary = false; 274 mShowSyncSummary = false;
275 mSyncAlgoPrefs = 3; 275 mSyncAlgoPrefs = 3;
276 quickSyncLocalFile(); 276 quickSyncLocalFile();
277 277
278 } else if ( action >= 1003 ) { 278 } else if ( action >= 1003 ) {
279 if ( temp->getIsLocalFileSync() ) { 279 if ( temp->getIsLocalFileSync() ) {
280 switch(mTargetApp) 280 switch(mTargetApp)
281 { 281 {
282 case (KAPI): 282 case (KAPI):
283 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 283 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
284 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 284 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
285 break; 285 break;
286 case (KOPI): 286 case (KOPI):
287 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 287 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
288 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 288 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
289 break; 289 break;
290 case (PWMPI): 290 case (PWMPI):
291 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 291 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
292 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 292 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
293 break; 293 break;
294 default: 294 default:
295 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 295 qDebug("KSM::slotSyncMenu: invalid apptype selected");
296 break; 296 break;
297 297
298 } 298 }
299 } else { 299 } else {
300 if ( temp->getIsPhoneSync() ) { 300 if ( temp->getIsPhoneSync() ) {
301 mPhoneDevice = temp->getPhoneDevice( ) ; 301 mPhoneDevice = temp->getPhoneDevice( ) ;
302 mPhoneConnection = temp->getPhoneConnection( ); 302 mPhoneConnection = temp->getPhoneConnection( );
303 mPhoneModel = temp->getPhoneModel( ); 303 mPhoneModel = temp->getPhoneModel( );
304 syncPhone(); 304 syncPhone();
305 } else if ( temp->getIsPiSync() ) { 305 } else if ( temp->getIsPiSync() ) {
306 if ( mTargetApp == KAPI ) { 306 if ( mTargetApp == KAPI ) {
307 mPassWordPiSync = temp->getRemotePwAB(); 307 mPassWordPiSync = temp->getRemotePwAB();
308 mActiveSyncPort = temp->getRemotePortAB(); 308 mActiveSyncPort = temp->getRemotePortAB();
309 mActiveSyncIP = temp->getRemoteIPAB(); 309 mActiveSyncIP = temp->getRemoteIPAB();
310 } else if ( mTargetApp == KOPI ) { 310 } else if ( mTargetApp == KOPI ) {
311 mPassWordPiSync = temp->getRemotePw(); 311 mPassWordPiSync = temp->getRemotePw();
312 mActiveSyncPort = temp->getRemotePort(); 312 mActiveSyncPort = temp->getRemotePort();
313 mActiveSyncIP = temp->getRemoteIP(); 313 mActiveSyncIP = temp->getRemoteIP();
314 } else { 314 } else {
315 mPassWordPiSync = temp->getRemotePwPWM(); 315 mPassWordPiSync = temp->getRemotePwPWM();
316 mActiveSyncPort = temp->getRemotePortPWM(); 316 mActiveSyncPort = temp->getRemotePortPWM();
317 mActiveSyncIP = temp->getRemoteIPPWM(); 317 mActiveSyncIP = temp->getRemoteIPPWM();
318 } 318 }
319 syncPi(); 319 syncPi();
320 while ( !mPisyncFinished ) { 320 while ( !mPisyncFinished ) {
321 //qDebug("waiting "); 321 //qDebug("waiting ");
322 qApp->processEvents(); 322 qApp->processEvents();
323 } 323 }
324 } else 324 } else
325 syncRemote( temp ); 325 syncRemote( temp );
326 326
327 } 327 }
328 } 328 }
329 delete temp; 329 delete temp;
330 setBlockSave(false); 330 setBlockSave(false);
331} 331}
332 332
333void KSyncManager::enableQuick( bool ask ) 333void KSyncManager::enableQuick( bool ask )
334{ 334{
335 bool autoStart; 335 bool autoStart;
336 bool changed = false; 336 bool changed = false;
337 if ( ask ) { 337 if ( ask ) {
338 QDialog dia ( 0, "input-dialog", true ); 338 QDialog dia ( 0, "input-dialog", true );
339 QLineEdit lab ( &dia ); 339 QLineEdit lab ( &dia );
340 QVBoxLayout lay( &dia ); 340 QVBoxLayout lay( &dia );
341 lab.setText( mPrefs->mPassiveSyncPort ); 341 lab.setText( mPrefs->mPassiveSyncPort );
342 lay.setMargin(7); 342 lay.setMargin(7);
343 lay.setSpacing(7); 343 lay.setSpacing(7);
344 int po = 9197+mTargetApp; 344 int po = 9197+mTargetApp;
345 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 345 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
346 lay.addWidget( &label); 346 lay.addWidget( &label);
347 lay.addWidget( &lab); 347 lay.addWidget( &lab);
348 348
349 QLineEdit lepw ( &dia ); 349 QLineEdit lepw ( &dia );
350 lepw.setText( mPrefs->mPassiveSyncPw ); 350 lepw.setText( mPrefs->mPassiveSyncPw );
351 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 351 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
352 lay.addWidget( &label2); 352 lay.addWidget( &label2);
353 lay.addWidget( &lepw); 353 lay.addWidget( &lepw);
354 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); 354 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia );
355 lay.addWidget( &autostart); 355 lay.addWidget( &autostart);
356 autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); 356 autostart.setChecked( mPrefs->mPassiveSyncAutoStart );
357#ifdef DESKTOP_VERSION 357#ifdef DESKTOP_VERSION
358#ifdef _WIN32_ 358#ifdef _WIN32_
359 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); 359 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia );
360 syncdesktop.hide();// not implemented! 360 syncdesktop.hide();// not implemented!
361#else 361#else
362 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); 362 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia );
363#endif 363#endif
364 lay.addWidget( &syncdesktop); 364 lay.addWidget( &syncdesktop);
365#else 365#else
366 mPrefs->mPassiveSyncWithDesktop = false; 366 mPrefs->mPassiveSyncWithDesktop = false;
367 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); 367 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
368 syncdesktop.hide(); 368 syncdesktop.hide();
369#endif 369#endif
370 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); 370 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
371 371
372 dia.setFixedSize( 230,120 ); 372 dia.setFixedSize( 230,120 );
373 dia.setCaption( i18n("Enter port for Pi-Sync") ); 373 dia.setCaption( i18n("Enter port for Pi-Sync") );
374 QPushButton pb ( "OK", &dia); 374 QPushButton pb ( "OK", &dia);
375 lay.addWidget( &pb ); 375 lay.addWidget( &pb );
376 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 376 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
377 dia.show(); 377 dia.show();
378 if ( ! dia.exec() ) 378 if ( ! dia.exec() )
379 return; 379 return;
380 dia.hide(); 380 dia.hide();
381 qApp->processEvents(); 381 qApp->processEvents();
382 if ( mPrefs->mPassiveSyncPw != lepw.text() ) { 382 if ( mPrefs->mPassiveSyncPw != lepw.text() ) {
383 changed = true; 383 changed = true;
384 mPrefs->mPassiveSyncPw = lepw.text(); 384 mPrefs->mPassiveSyncPw = lepw.text();
385 } 385 }
386 if ( mPrefs->mPassiveSyncPort != lab.text() ) { 386 if ( mPrefs->mPassiveSyncPort != lab.text() ) {
387 mPrefs->mPassiveSyncPort = lab.text(); 387 mPrefs->mPassiveSyncPort = lab.text();
388 changed = true; 388 changed = true;
389 } 389 }
390 autoStart = autostart.isChecked(); 390 autoStart = autostart.isChecked();
391 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { 391 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) {
392 changed = true; 392 changed = true;
393 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); 393 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked();
394 } 394 }
395 } 395 }
396 else 396 else
397 autoStart = mPrefs->mPassiveSyncAutoStart; 397 autoStart = mPrefs->mPassiveSyncAutoStart;
398 if ( autoStart != mPrefs->mPassiveSyncAutoStart ) 398 if ( autoStart != mPrefs->mPassiveSyncAutoStart )
399 changed = true; 399 changed = true;
400 bool ok; 400 bool ok;
401 mPrefs->mPassiveSyncAutoStart = false; 401 mPrefs->mPassiveSyncAutoStart = false;
402 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 402 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
403 if ( ! ok ) { 403 if ( ! ok ) {
404 KMessageBox::information( 0, i18n("No valid port")); 404 KMessageBox::information( 0, i18n("No valid port"));
405 return; 405 return;
406 } 406 }
407 //qDebug("port %d ", port); 407 //qDebug("port %d ", port);
408 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 408 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
409 mServerSocket->setFileName( defaultFileName() );//bbb 409 mServerSocket->setFileName( defaultFileName() );//bbb
410 //qDebug("connected "); 410 //qDebug("connected ");
411 if ( !mServerSocket->ok() ) { 411 if ( !mServerSocket->ok() ) {
412 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 412 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
413 delete mServerSocket; 413 delete mServerSocket;
414 mServerSocket = 0; 414 mServerSocket = 0;
415 return; 415 return;
416 } 416 }
417 mPrefs->mPassiveSyncAutoStart = autoStart; 417 mPrefs->mPassiveSyncAutoStart = autoStart;
418 if ( changed ) { 418 if ( changed ) {
419 mPrefs->writeConfig(); 419 mPrefs->writeConfig();
420 } 420 }
421 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 421 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
422 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 422 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
423} 423}
424 424
425void KSyncManager::syncLocalFile() 425void KSyncManager::syncLocalFile()
426{ 426{
427 427
428 QString fn =mPrefs->mLastSyncedLocalFile; 428 QString fn =mPrefs->mLastSyncedLocalFile;
429 QString ext; 429 QString ext;
430 430
431 switch(mTargetApp) 431 switch(mTargetApp)
432 { 432 {
433 case (KAPI): 433 case (KAPI):
434 ext = "(*.vcf)"; 434 ext = "(*.vcf)";
435 break; 435 break;
436 case (KOPI): 436 case (KOPI):
437 ext = "(*.ics/*.vcs)"; 437 ext = "(*.ics/*.vcs)";
438 break; 438 break;
439 case (PWMPI): 439 case (PWMPI):
440 ext = "(*.pwm)"; 440 ext = "(*.pwm)";
441 break; 441 break;
442 default: 442 default:
443 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 443 qDebug("KSM::syncLocalFile: invalid apptype selected");
444 break; 444 break;
445 445
446 } 446 }
447 447
448 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 448 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
449 if ( fn == "" ) 449 if ( fn == "" )
450 return; 450 return;
451 if ( syncWithFile( fn, false ) ) { 451 if ( syncWithFile( fn, false ) ) {
452 qDebug("syncLocalFile() successful "); 452 qDebug("KSM::syncLocalFile() successful ");
453 } 453 }
454 454
455} 455}
456 456
457bool KSyncManager::syncWithFile( QString fn , bool quick ) 457bool KSyncManager::syncWithFile( QString fn , bool quick )
458{ 458{
459 bool ret = false; 459 bool ret = false;
460 QFileInfo info; 460 QFileInfo info;
461 info.setFile( fn ); 461 info.setFile( fn );
462 QString mess; 462 QString mess;
463 bool loadbup = true; 463 bool loadbup = true;
464 if ( !info. exists() ) { 464 if ( !info. exists() ) {
465 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 465 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
466 int result = QMessageBox::warning( mParent, i18n("Warning!"), 466 int result = QMessageBox::warning( mParent, i18n("Warning!"),
467 mess ); 467 mess );
468 return ret; 468 return ret;
469 } 469 }
470 int result = 0; 470 int result = 0;
471 if ( !quick ) { 471 if ( !quick ) {
472 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 472 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
473 result = QMessageBox::warning( mParent, i18n("Warning!"), 473 result = QMessageBox::warning( mParent, i18n("Warning!"),
474 mess, 474 mess,
475 i18n("Sync"), i18n("Cancel"), 0, 475 i18n("Sync"), i18n("Cancel"), 0,
476 0, 1 ); 476 0, 1 );
477 if ( result ) 477 if ( result )
478 return false; 478 return false;
479 } 479 }
480 if ( mAskForPreferences ) 480 if ( mAskForPreferences )
481 if ( !edit_sync_options()) { 481 if ( !edit_sync_options()) {
482 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 482 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
483 return false; 483 return false;
484 } 484 }
485 if ( result == 0 ) { 485 if ( result == 0 ) {
486 //qDebug("Now sycing ... "); 486 //qDebug("Now sycing ... ");
487 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 487 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
488 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 488 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
489 else 489 else
490 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 490 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
491 if ( ! quick ) 491 if ( ! quick )
492 mPrefs->mLastSyncedLocalFile = fn; 492 mPrefs->mLastSyncedLocalFile = fn;
493 } 493 }
494 return ret; 494 return ret;
495} 495}
496 496
497void KSyncManager::quickSyncLocalFile() 497void KSyncManager::quickSyncLocalFile()
498{ 498{
499 499
500 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { 500 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
501 qDebug("quick syncLocalFile() successful "); 501 qDebug("KSM::quick syncLocalFile() successful ");
502 502
503 } 503 }
504} 504}
505 505
506void KSyncManager::multiSync( bool askforPrefs ) 506void KSyncManager::multiSync( bool askforPrefs )
507{ 507{
508 if (blockSave()) 508 if (blockSave())
509 return; 509 return;
510 setBlockSave(true); 510 setBlockSave(true);
511 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 511 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
512 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 512 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
513 question, 513 question,
514 i18n("Yes"), i18n("No"), 514 i18n("Yes"), i18n("No"),
515 0, 0 ) != 0 ) { 515 0, 0 ) != 0 ) {
516 setBlockSave(false); 516 setBlockSave(false);
517 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 517 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
518 return; 518 return;
519 } 519 }
520 mCurrentSyncDevice = i18n("Multiple profiles") ; 520 mCurrentSyncDevice = i18n("Multiple profiles") ;
521 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 521 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
522 if ( askforPrefs ) { 522 if ( askforPrefs ) {
523 if ( !edit_sync_options()) { 523 if ( !edit_sync_options()) {
524 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); 524 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") );
525 return; 525 return;
526 } 526 }
527 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; 527 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
528 } 528 }
529 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 529 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
530 qApp->processEvents(); 530 qApp->processEvents();
531 int num = ringSync() ; 531 int num = ringSync() ;
532 if ( num > 1 ) 532 if ( num > 1 )
533 ringSync(); 533 ringSync();
534 setBlockSave(false); 534 setBlockSave(false);
535 if ( num ) 535 if ( num )
536 emit save(); 536 emit save();
537 if ( num ) 537 if ( num )
538 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); 538 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
539 else 539 else
540 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 540 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
541 return; 541 return;
542} 542}
543 543
544int KSyncManager::ringSync() 544int KSyncManager::ringSync()
545{ 545{
546 546
547 int syncedProfiles = 0; 547 int syncedProfiles = 0;
548 unsigned int i; 548 unsigned int i;
549 QTime timer; 549 QTime timer;
550 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 550 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
551 QStringList syncProfileNames = mSyncProfileNames; 551 QStringList syncProfileNames = mSyncProfileNames;
552 KSyncProfile* temp = new KSyncProfile (); 552 KSyncProfile* temp = new KSyncProfile ();
553 mAskForPreferences = false; 553 mAskForPreferences = false;
554 for ( i = 0; i < syncProfileNames.count(); ++i ) { 554 for ( i = 0; i < syncProfileNames.count(); ++i ) {
555 mCurrentSyncProfile = i; 555 mCurrentSyncProfile = i;
556 temp->setName(syncProfileNames[mCurrentSyncProfile]); 556 temp->setName(syncProfileNames[mCurrentSyncProfile]);
557 temp->readConfig(&config); 557 temp->readConfig(&config);
558 558
559 bool includeInRingSync; 559 bool includeInRingSync;
560 switch(mTargetApp) 560 switch(mTargetApp)
561 { 561 {
562 case (KAPI): 562 case (KAPI):
563 includeInRingSync = temp->getIncludeInRingSyncAB(); 563 includeInRingSync = temp->getIncludeInRingSyncAB();
564 break; 564 break;
565 case (KOPI): 565 case (KOPI):
566 includeInRingSync = temp->getIncludeInRingSync(); 566 includeInRingSync = temp->getIncludeInRingSync();
567 break; 567 break;
568 case (PWMPI): 568 case (PWMPI):
569 includeInRingSync = temp->getIncludeInRingSyncPWM(); 569 includeInRingSync = temp->getIncludeInRingSyncPWM();
570 break; 570 break;
571 default: 571 default:
572 qDebug("KSyncManager::ringSync: invalid apptype selected"); 572 qDebug("KSM::ringSync: invalid apptype selected");
573 break; 573 break;
574 574
575 } 575 }
576 576
577 577
578 if ( includeInRingSync && ( i < 1 || i > 2 )) { 578 if ( includeInRingSync && ( i < 1 || i > 2 )) {
579 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 579 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
580 ++syncedProfiles; 580 ++syncedProfiles;
581 mSyncWithDesktop = false; 581 mSyncWithDesktop = false;
582 // mAskForPreferences = temp->getAskForPreferences(); 582 // mAskForPreferences = temp->getAskForPreferences();
583 mWriteBackFile = temp->getWriteBackFile(); 583 mWriteBackFile = temp->getWriteBackFile();
584 mWriteBackExistingOnly = temp->getWriteBackExisting(); 584 mWriteBackExistingOnly = temp->getWriteBackExisting();
585 mIsKapiFile = temp->getIsKapiFile(); 585 mIsKapiFile = temp->getIsKapiFile();
586 mWriteBackInFuture = 0; 586 mWriteBackInFuture = 0;
587 if ( temp->getWriteBackFuture() ) { 587 if ( temp->getWriteBackFuture() ) {
588 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 588 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
589 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 589 mWriteBackInPast = temp->getWriteBackPastWeeks( );
590 } 590 }
591 mFilterInCal = temp->getFilterInCal(); 591 mFilterInCal = temp->getFilterInCal();
592 mFilterOutCal = temp->getFilterOutCal(); 592 mFilterOutCal = temp->getFilterOutCal();
593 mFilterInAB = temp->getFilterInAB(); 593 mFilterInAB = temp->getFilterInAB();
594 mFilterOutAB = temp->getFilterOutAB(); 594 mFilterOutAB = temp->getFilterOutAB();
595 mShowSyncSummary = false; 595 mShowSyncSummary = false;
596 mCurrentSyncDevice = syncProfileNames[i] ; 596 mCurrentSyncDevice = syncProfileNames[i] ;
597 mCurrentSyncName = mLocalMachineName; 597 mCurrentSyncName = mLocalMachineName;
598 if ( i == 0 ) { 598 if ( i == 0 ) {
599 mIsKapiFile = false; 599 mIsKapiFile = false;
600#ifdef DESKTOP_VERSION 600#ifdef DESKTOP_VERSION
601 syncKDE(); 601 syncKDE();
602#else 602#else
603 syncSharp(); 603 syncSharp();
604#endif 604#endif
605 } else { 605 } else {
606 if ( temp->getIsLocalFileSync() ) { 606 if ( temp->getIsLocalFileSync() ) {
607 switch(mTargetApp) 607 switch(mTargetApp)
608 { 608 {
609 case (KAPI): 609 case (KAPI):
610 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 610 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
611 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 611 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
612 break; 612 break;
613 case (KOPI): 613 case (KOPI):
614 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 614 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
615 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 615 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
616 break; 616 break;
617 case (PWMPI): 617 case (PWMPI):
618 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 618 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
619 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 619 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
620 break; 620 break;
621 default: 621 default:
622 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 622 qDebug("KSM: invalid apptype selected");
623 break; 623 break;
624 } 624 }
625 } else { 625 } else {
626 if ( temp->getIsPhoneSync() ) { 626 if ( temp->getIsPhoneSync() ) {
627 mPhoneDevice = temp->getPhoneDevice( ) ; 627 mPhoneDevice = temp->getPhoneDevice( ) ;
628 mPhoneConnection = temp->getPhoneConnection( ); 628 mPhoneConnection = temp->getPhoneConnection( );
629 mPhoneModel = temp->getPhoneModel( ); 629 mPhoneModel = temp->getPhoneModel( );
630 syncPhone(); 630 syncPhone();
631 } else if ( temp->getIsPiSync() ) { 631 } else if ( temp->getIsPiSync() ) {
632 if ( mTargetApp == KAPI ) { 632 if ( mTargetApp == KAPI ) {
633 mPassWordPiSync = temp->getRemotePwAB(); 633 mPassWordPiSync = temp->getRemotePwAB();
634 mActiveSyncPort = temp->getRemotePortAB(); 634 mActiveSyncPort = temp->getRemotePortAB();
635 mActiveSyncIP = temp->getRemoteIPAB(); 635 mActiveSyncIP = temp->getRemoteIPAB();
636 } else if ( mTargetApp == KOPI ) { 636 } else if ( mTargetApp == KOPI ) {
637 mPassWordPiSync = temp->getRemotePw(); 637 mPassWordPiSync = temp->getRemotePw();
638 mActiveSyncPort = temp->getRemotePort(); 638 mActiveSyncPort = temp->getRemotePort();
639 mActiveSyncIP = temp->getRemoteIP(); 639 mActiveSyncIP = temp->getRemoteIP();
640 } else { 640 } else {
641 mPassWordPiSync = temp->getRemotePwPWM(); 641 mPassWordPiSync = temp->getRemotePwPWM();
642 mActiveSyncPort = temp->getRemotePortPWM(); 642 mActiveSyncPort = temp->getRemotePortPWM();
643 mActiveSyncIP = temp->getRemoteIPPWM(); 643 mActiveSyncIP = temp->getRemoteIPPWM();
644 } 644 }
645 syncPi(); 645 syncPi();
646 while ( !mPisyncFinished ) { 646 while ( !mPisyncFinished ) {
647 //qDebug("waiting "); 647 //qDebug("waiting ");
648 qApp->processEvents(); 648 qApp->processEvents();
649 } 649 }
650 timer.start(); 650 timer.start();
651 while ( timer.elapsed () < 2000 ) { 651 while ( timer.elapsed () < 2000 ) {
652 qApp->processEvents(); 652 qApp->processEvents();
653 } 653 }
654 } else 654 } else
655 syncRemote( temp, false ); 655 syncRemote( temp, false );
656 656
657 } 657 }
658 } 658 }
659 timer.start(); 659 timer.start();
660 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 660 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
661 while ( timer.elapsed () < 2000 ) { 661 while ( timer.elapsed () < 2000 ) {
662 qApp->processEvents(); 662 qApp->processEvents();
663#ifndef _WIN32_ 663#ifndef _WIN32_
664 sleep (1); 664 sleep (1);
665#endif 665#endif
666 } 666 }
667 667
668 } 668 }
669 669
670 } 670 }
671 delete temp; 671 delete temp;
672 return syncedProfiles; 672 return syncedProfiles;
673} 673}
674 674
675void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 675void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
676{ 676{
677 QString question; 677 QString question;
678 if ( ask ) { 678 if ( ask ) {
679 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 679 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
680 if ( QMessageBox::information( mParent, i18n("Sync"), 680 if ( QMessageBox::information( mParent, i18n("Sync"),
681 question, 681 question,
682 i18n("Yes"), i18n("No"), 682 i18n("Yes"), i18n("No"),
683 0, 0 ) != 0 ) 683 0, 0 ) != 0 )
684 return; 684 return;
685 } 685 }
686 686
687 QString preCommand; 687 QString preCommand;
688 QString localTempFile; 688 QString localTempFile;
689 QString postCommand; 689 QString postCommand;
690 690
691 switch(mTargetApp) 691 switch(mTargetApp)
692 { 692 {
693 case (KAPI): 693 case (KAPI):
694 preCommand = prof->getPreSyncCommandAB(); 694 preCommand = prof->getPreSyncCommandAB();
695 postCommand = prof->getPostSyncCommandAB(); 695 postCommand = prof->getPostSyncCommandAB();
696 localTempFile = prof->getLocalTempFileAB(); 696 localTempFile = prof->getLocalTempFileAB();
697 break; 697 break;
698 case (KOPI): 698 case (KOPI):
699 preCommand = prof->getPreSyncCommand(); 699 preCommand = prof->getPreSyncCommand();
700 postCommand = prof->getPostSyncCommand(); 700 postCommand = prof->getPostSyncCommand();
701 localTempFile = prof->getLocalTempFile(); 701 localTempFile = prof->getLocalTempFile();
702 break; 702 break;
703 case (PWMPI): 703 case (PWMPI):
704 preCommand = prof->getPreSyncCommandPWM(); 704 preCommand = prof->getPreSyncCommandPWM();
705 postCommand = prof->getPostSyncCommandPWM(); 705 postCommand = prof->getPostSyncCommandPWM();
706 localTempFile = prof->getLocalTempFilePWM(); 706 localTempFile = prof->getLocalTempFilePWM();
707 break; 707 break;
708 default: 708 default:
709 qDebug("KSyncManager::syncRemote: invalid apptype selected"); 709 qDebug("KSM::syncRemote: invalid apptype selected");
710 break; 710 break;
711 } 711 }
712 712
713 713
714 int fi; 714 int fi;
715 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 715 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
716 QString pwd = getPassword(); 716 QString pwd = getPassword();
717 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 717 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
718 718
719 } 719 }
720 int maxlen = 30; 720 int maxlen = 30;
721 if ( QApplication::desktop()->width() > 320 ) 721 if ( QApplication::desktop()->width() > 320 )
722 maxlen += 25; 722 maxlen += 25;
723 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 723 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
724 int fileSize = 0; 724 int fileSize = 0;
725 int result = system ( preCommand ); 725 int result = system ( preCommand );
726 // 0 : okay 726 // 0 : okay
727 // 256: no such file or dir 727 // 256: no such file or dir
728 // 728 //
729 qDebug("Sync: Remote copy result(0 = okay): %d ",result ); 729 qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result );
730 if ( result != 0 ) { 730 if ( result != 0 ) {
731 unsigned int len = maxlen; 731 unsigned int len = maxlen;
732 while ( len < preCommand.length() ) { 732 while ( len < preCommand.length() ) {
733 preCommand.insert( len , "\n" ); 733 preCommand.insert( len , "\n" );
734 len += maxlen +2; 734 len += maxlen +2;
735 } 735 }
736 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; 736 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ;
737 QMessageBox::information( mParent, i18n("Sync - ERROR"), 737 QMessageBox::information( mParent, i18n("Sync - ERROR"),
738 question, 738 question,
739 i18n("Okay!")) ; 739 i18n("Okay!")) ;
740 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 740 mParent->topLevelWidget()->setCaption ("KDE-Pim");
741 return; 741 return;
742 } 742 }
743 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 743 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
744 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 744 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
745 745
746 if ( syncWithFile( localTempFile, true ) ) { 746 if ( syncWithFile( localTempFile, true ) ) {
747 747
748 if ( mWriteBackFile ) { 748 if ( mWriteBackFile ) {
749 int fi; 749 int fi;
750 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 750 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
751 QString pwd = getPassword(); 751 QString pwd = getPassword();
752 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 752 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
753 753
754 } 754 }
755 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 755 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
756 result = system ( postCommand ); 756 result = system ( postCommand );
757 qDebug("Sync:Writing back file result: %d ", result); 757 qDebug("KSM::Sync:Writing back file result: %d ", result);
758 if ( result != 0 ) { 758 if ( result != 0 ) {
759 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 759 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
760 return; 760 return;
761 } else { 761 } else {
762 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 762 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
763 } 763 }
764 } 764 }
765 } 765 }
766 return; 766 return;
767} 767}
768bool KSyncManager::edit_pisync_options() 768bool KSyncManager::edit_pisync_options()
769{ 769{
770 QDialog dia( mParent, "dia", true ); 770 QDialog dia( mParent, "dia", true );
771 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 771 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
772 QVBoxLayout lay ( &dia ); 772 QVBoxLayout lay ( &dia );
773 lay.setSpacing( 5 ); 773 lay.setSpacing( 5 );
774 lay.setMargin( 3 ); 774 lay.setMargin( 3 );
775 QLabel lab1 ( i18n("Password for remote access:"), &dia); 775 QLabel lab1 ( i18n("Password for remote access:"), &dia);
776 lay.addWidget( &lab1 ); 776 lay.addWidget( &lab1 );
777 QLineEdit le1 (&dia ); 777 QLineEdit le1 (&dia );
778 lay.addWidget( &le1 ); 778 lay.addWidget( &le1 );
779 QLabel lab2 ( i18n("Remote IP address:"), &dia); 779 QLabel lab2 ( i18n("Remote IP address:"), &dia);
780 lay.addWidget( &lab2 ); 780 lay.addWidget( &lab2 );
781 QLineEdit le2 (&dia ); 781 QLineEdit le2 (&dia );
782 lay.addWidget( &le2 ); 782 lay.addWidget( &le2 );
783 QLabel lab3 ( i18n("Remote port number:"), &dia); 783 QLabel lab3 ( i18n("Remote port number:"), &dia);
784 lay.addWidget( &lab3 ); 784 lay.addWidget( &lab3 );
785 QLineEdit le3 (&dia ); 785 QLineEdit le3 (&dia );
786 lay.addWidget( &le3 ); 786 lay.addWidget( &le3 );
787 QPushButton pb ( "OK", &dia); 787 QPushButton pb ( "OK", &dia);
788 lay.addWidget( &pb ); 788 lay.addWidget( &pb );
789 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 789 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
790 le1.setText( mPassWordPiSync ); 790 le1.setText( mPassWordPiSync );
791 le2.setText( mActiveSyncIP ); 791 le2.setText( mActiveSyncIP );
792 le3.setText( mActiveSyncPort ); 792 le3.setText( mActiveSyncPort );
793 if ( dia.exec() ) { 793 if ( dia.exec() ) {
794 mPassWordPiSync = le1.text(); 794 mPassWordPiSync = le1.text();
795 mActiveSyncPort = le3.text(); 795 mActiveSyncPort = le3.text();
796 mActiveSyncIP = le2.text(); 796 mActiveSyncIP = le2.text();
797 return true; 797 return true;
798 } 798 }
799 return false; 799 return false;
800} 800}
801bool KSyncManager::edit_sync_options() 801bool KSyncManager::edit_sync_options()
802{ 802{
803 803
804 QDialog dia( mParent, "dia", true ); 804 QDialog dia( mParent, "dia", true );
805 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 805 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
806 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 806 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
807 QVBoxLayout lay ( &dia ); 807 QVBoxLayout lay ( &dia );
808 lay.setSpacing( 2 ); 808 lay.setSpacing( 2 );
809 lay.setMargin( 3 ); 809 lay.setMargin( 3 );
810 lay.addWidget(&gr); 810 lay.addWidget(&gr);
811 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 811 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
812 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 812 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
813 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 813 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
814 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 814 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
815 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 815 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
816 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 816 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
817 //QRadioButton both( i18n("Take both on conflict"), &gr ); 817 //QRadioButton both( i18n("Take both on conflict"), &gr );
818 QPushButton pb ( "OK", &dia); 818 QPushButton pb ( "OK", &dia);
819 lay.addWidget( &pb ); 819 lay.addWidget( &pb );
820 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 820 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
821 switch ( mSyncAlgoPrefs ) { 821 switch ( mSyncAlgoPrefs ) {
822 case 0: 822 case 0:
823 loc.setChecked( true); 823 loc.setChecked( true);
824 break; 824 break;
825 case 1: 825 case 1:
826 rem.setChecked( true ); 826 rem.setChecked( true );
827 break; 827 break;
828 case 2: 828 case 2:
829 newest.setChecked( true); 829 newest.setChecked( true);
830 break; 830 break;
831 case 3: 831 case 3:
832 ask.setChecked( true); 832 ask.setChecked( true);
833 break; 833 break;
834 case 4: 834 case 4:
835 f_loc.setChecked( true); 835 f_loc.setChecked( true);
836 break; 836 break;
837 case 5: 837 case 5:
838 f_rem.setChecked( true); 838 f_rem.setChecked( true);
839 break; 839 break;
840 case 6: 840 case 6:
841 // both.setChecked( true); 841 // both.setChecked( true);
842 break; 842 break;
843 default: 843 default:
844 break; 844 break;
845 } 845 }
846 if ( dia.exec() ) { 846 if ( dia.exec() ) {
847 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 847 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
848 return true; 848 return true;
849 } 849 }
850 return false; 850 return false;
851} 851}
852 852
853QString KSyncManager::getPassword( ) 853QString KSyncManager::getPassword( )
854{ 854{
855 QString retfile = ""; 855 QString retfile = "";
856 QDialog dia ( mParent, "input-dialog", true ); 856 QDialog dia ( mParent, "input-dialog", true );
857 QLineEdit lab ( &dia ); 857 QLineEdit lab ( &dia );
858 lab.setEchoMode( QLineEdit::Password ); 858 lab.setEchoMode( QLineEdit::Password );
859 QVBoxLayout lay( &dia ); 859 QVBoxLayout lay( &dia );
860 lay.setMargin(7); 860 lay.setMargin(7);
861 lay.setSpacing(7); 861 lay.setSpacing(7);
862 lay.addWidget( &lab); 862 lay.addWidget( &lab);
863 dia.setFixedSize( 230,50 ); 863 dia.setFixedSize( 230,50 );
864 dia.setCaption( i18n("Enter password") ); 864 dia.setCaption( i18n("Enter password") );
865 QPushButton pb ( "OK", &dia); 865 QPushButton pb ( "OK", &dia);
866 lay.addWidget( &pb ); 866 lay.addWidget( &pb );
867 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 867 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
868 dia.show(); 868 dia.show();
869 int res = dia.exec(); 869 int res = dia.exec();
870 if ( res ) 870 if ( res )
871 retfile = lab.text(); 871 retfile = lab.text();
872 dia.hide(); 872 dia.hide();
873 qApp->processEvents(); 873 qApp->processEvents();
874 return retfile; 874 return retfile;
875 875
876} 876}
877 877
878 878
879void KSyncManager::confSync() 879void KSyncManager::confSync()
880{ 880{
881 static KSyncPrefsDialog* sp = 0; 881 static KSyncPrefsDialog* sp = 0;
882 if ( ! sp ) { 882 if ( ! sp ) {
883 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 883 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
884 } 884 }
885 sp->usrReadConfig(); 885 sp->usrReadConfig();
886#ifndef DESKTOP_VERSION 886#ifndef DESKTOP_VERSION
887 sp->showMaximized(); 887 sp->showMaximized();
888#else 888#else
889 sp->show(); 889 sp->show();
890#endif 890#endif
891 sp->exec(); 891 sp->exec();
892 QStringList oldSyncProfileNames = mSyncProfileNames; 892 QStringList oldSyncProfileNames = mSyncProfileNames;
893 mSyncProfileNames = sp->getSyncProfileNames(); 893 mSyncProfileNames = sp->getSyncProfileNames();
894 mLocalMachineName = sp->getLocalMachineName (); 894 mLocalMachineName = sp->getLocalMachineName ();
895 int ii; 895 int ii;
896 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { 896 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) {
897 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) 897 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) )
898 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); 898 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] );
899 } 899 }
900 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 900 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
901} 901}
902void KSyncManager::syncKDE() 902void KSyncManager::syncKDE()
903{ 903{
904 mSyncWithDesktop = true; 904 mSyncWithDesktop = true;
905 emit save(); 905 emit save();
906 switch(mTargetApp) 906 switch(mTargetApp)
907 { 907 {
908 case (KAPI): 908 case (KAPI):
909 { 909 {
910#ifdef DESKTOP_VERSION 910#ifdef DESKTOP_VERSION
911 QString command = qApp->applicationDirPath () + "/kdeabdump"; 911 QString command = qApp->applicationDirPath () + "/kdeabdump";
912#else 912#else
913 QString command = "kdeabdump"; 913 QString command = "kdeabdump";
914#endif 914#endif
915 if ( ! QFile::exists ( command ) ) 915 if ( ! QFile::exists ( command ) )
916 command = "kdeabdump"; 916 command = "kdeabdump";
917 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; 917 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf";
918 system ( command.latin1()); 918 system ( command.latin1());
919 if ( syncWithFile( fileName,true ) ) { 919 if ( syncWithFile( fileName,true ) ) {
920 if ( mWriteBackFile ) { 920 if ( mWriteBackFile ) {
921 command += " --read"; 921 command += " --read";
922 system ( command.latin1()); 922 system ( command.latin1());
923 } 923 }
924 } 924 }
925 925
926 } 926 }
927 break; 927 break;
928 case (KOPI): 928 case (KOPI):
929 { 929 {
930#ifdef DESKTOP_VERSION 930#ifdef DESKTOP_VERSION
931 QString command = qApp->applicationDirPath () + "/kdecaldump"; 931 QString command = qApp->applicationDirPath () + "/kdecaldump";
932#else 932#else
933 QString command = "kdecaldump"; 933 QString command = "kdecaldump";
934#endif 934#endif
935 if ( ! QFile::exists ( command ) ) 935 if ( ! QFile::exists ( command ) )
936 command = "kdecaldump"; 936 command = "kdecaldump";
937 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; 937 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
938 system ( command.latin1()); 938 system ( command.latin1());
939 if ( syncWithFile( fileName,true ) ) { 939 if ( syncWithFile( fileName,true ) ) {
940 if ( mWriteBackFile ) { 940 if ( mWriteBackFile ) {
941 command += " --read"; 941 command += " --read";
942 system ( command.latin1()); 942 system ( command.latin1());
943 } 943 }
944 } 944 }
945 945
946 } 946 }
947 break; 947 break;
948 case (PWMPI): 948 case (PWMPI):
949 949
950 break; 950 break;
951 default: 951 default:
952 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 952 qDebug("KSM::slotSyncMenu: invalid apptype selected");
953 break; 953 break;
954 954
955 } 955 }
956} 956}
957 957
958void KSyncManager::syncSharp() 958void KSyncManager::syncSharp()
959{ 959{
960 960
961 if ( ! syncExternalApplication("sharp") ) 961 if ( ! syncExternalApplication("sharp") )
962 qDebug("ERROR sync sharp "); 962 qDebug("KSM::ERROR sync sharp ");
963} 963}
964 964
965bool KSyncManager::syncExternalApplication(QString resource) 965bool KSyncManager::syncExternalApplication(QString resource)
966{ 966{
967 967
968 emit save(); 968 emit save();
969 969
970 if ( mAskForPreferences ) 970 if ( mAskForPreferences )
971 if ( !edit_sync_options()) { 971 if ( !edit_sync_options()) {
972 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 972 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
973 return false; 973 return false;
974 } 974 }
975 975
976 qDebug("Sync extern %s", resource.latin1()); 976 qDebug("KSM::Sync extern %s", resource.latin1());
977 977
978 bool syncOK = mImplementation->syncExternal(this, resource); 978 bool syncOK = mImplementation->syncExternal(this, resource);
979 979
980 return syncOK; 980 return syncOK;
981 981
982} 982}
983 983
984void KSyncManager::syncPhone() 984void KSyncManager::syncPhone()
985{ 985{
986 986
987 syncExternalApplication("phone"); 987 syncExternalApplication("phone");
988 988
989} 989}
990 990
991void KSyncManager::showProgressBar(int percentage, QString caption, int total) 991void KSyncManager::showProgressBar(int percentage, QString caption, int total)
992{ 992{
993 if (!bar->isVisible()) 993 if (!bar->isVisible())
994 { 994 {
995 bar->setCaption (caption); 995 bar->setCaption (caption);
996 bar->setTotalSteps ( total ) ; 996 bar->setTotalSteps ( total ) ;
997 bar->show(); 997 bar->show();
998 } 998 }
999 bar->raise(); 999 bar->raise();
1000 bar->setProgress( percentage ); 1000 bar->setProgress( percentage );
1001 qApp->processEvents(); 1001 qApp->processEvents();
1002} 1002}
1003 1003
1004void KSyncManager::hideProgressBar() 1004void KSyncManager::hideProgressBar()
1005{ 1005{
1006 bar->hide(); 1006 bar->hide();
1007 qApp->processEvents(); 1007 qApp->processEvents();
1008} 1008}
1009 1009
1010bool KSyncManager::isProgressBarCanceled() 1010bool KSyncManager::isProgressBarCanceled()
1011{ 1011{
1012 return !bar->isVisible(); 1012 return !bar->isVisible();
1013} 1013}
1014 1014
1015QString KSyncManager::syncFileName() 1015QString KSyncManager::syncFileName()
1016{ 1016{
1017 1017
1018 QString fn = "tempfile"; 1018 QString fn = "tempfile";
1019 switch(mTargetApp) 1019 switch(mTargetApp)
1020 { 1020 {
1021 case (KAPI): 1021 case (KAPI):
1022 fn = "tempsyncab.vcf"; 1022 fn = "tempsyncab.vcf";
1023 break; 1023 break;
1024 case (KOPI): 1024 case (KOPI):
1025 fn = "tempsynccal.ics"; 1025 fn = "tempsynccal.ics";
1026 break; 1026 break;
1027 case (PWMPI): 1027 case (PWMPI):
1028 fn = "tempsyncpw.pwm"; 1028 fn = "tempsyncpw.pwm";
1029 break; 1029 break;
1030 default: 1030 default:
1031 break; 1031 break;
1032 } 1032 }
1033#ifdef _WIN32_ 1033#ifdef _WIN32_
1034 return locateLocal( "tmp", fn ); 1034 return locateLocal( "tmp", fn );
1035#else 1035#else
1036 return (QString( "/tmp/" )+ fn ); 1036 return (QString( "/tmp/" )+ fn );
1037#endif 1037#endif
1038} 1038}
1039 1039
1040void KSyncManager::syncPi() 1040void KSyncManager::syncPi()
1041{ 1041{
1042 mIsKapiFile = true; 1042 mIsKapiFile = true;
1043 mPisyncFinished = false; 1043 mPisyncFinished = false;
1044 qApp->processEvents(); 1044 qApp->processEvents();
1045 if ( mAskForPreferences ) 1045 if ( mAskForPreferences )
1046 if ( !edit_pisync_options()) { 1046 if ( !edit_pisync_options()) {
1047 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1047 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1048 return; 1048 return;
1049 } 1049 }
1050 bool ok; 1050 bool ok;
1051 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 1051 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
1052 if ( ! ok ) { 1052 if ( ! ok ) {
1053 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1053 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
1054 return; 1054 return;
1055 } 1055 }
1056 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); 1056 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this );
1057 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1057 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1058 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); 1058 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") );
1059 commandSocket->readFile( syncFileName() ); 1059 commandSocket->readFile( syncFileName() );
1060} 1060}
1061 1061
1062void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 1062void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1063{ 1063{
1064 //enum { success, errorW, errorR, quiet }; 1064 //enum { success, errorW, errorR, quiet };
1065 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { 1065 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) {
1066 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 1066 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
1067 delete s; 1067 delete s;
1068 if ( state == KCommandSocket::errorR ) { 1068 if ( state == KCommandSocket::errorR ) {
1069 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 1069 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
1070 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1070 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1071 commandSocket->sendStop(); 1071 commandSocket->sendStop();
1072 } 1072 }
1073 mPisyncFinished = true; 1073 mPisyncFinished = true;
1074 return; 1074 return;
1075 1075
1076 } else if ( state == KCommandSocket::errorW ) { 1076 } else if ( state == KCommandSocket::errorW ) {
1077 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 1077 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
1078 mPisyncFinished = true; 1078 mPisyncFinished = true;
1079 1079
1080 } else if ( state == KCommandSocket::successR ) { 1080 } else if ( state == KCommandSocket::successR ) {
1081 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1081 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
1082 1082
1083 } else if ( state == KCommandSocket::successW ) { 1083 } else if ( state == KCommandSocket::successW ) {
1084 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1084 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1085 mPisyncFinished = true; 1085 mPisyncFinished = true;
1086 } 1086 }
1087 1087
1088 delete s; 1088 delete s;
1089} 1089}
1090 1090
1091void KSyncManager::readFileFromSocket() 1091void KSyncManager::readFileFromSocket()
1092{ 1092{
1093 QString fileName = syncFileName(); 1093 QString fileName = syncFileName();
1094 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 1094 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
1095 if ( ! syncWithFile( fileName , true ) ) { 1095 if ( ! syncWithFile( fileName , true ) ) {
1096 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 1096 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
1097 mPisyncFinished = true; 1097 mPisyncFinished = true;
1098 return; 1098 return;
1099 } 1099 }
1100 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 1100 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
1101 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1101 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1102 if ( mWriteBackFile ) 1102 if ( mWriteBackFile )
1103 commandSocket->writeFile( fileName ); 1103 commandSocket->writeFile( fileName );
1104 else { 1104 else {
1105 commandSocket->sendStop(); 1105 commandSocket->sendStop();
1106 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1106 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1107 mPisyncFinished = true; 1107 mPisyncFinished = true;
1108 } 1108 }
1109} 1109}
1110 1110
1111KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 1111KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
1112{ 1112{
1113 mPassWord = pw; 1113 mPassWord = pw;
1114 mSocket = 0; 1114 mSocket = 0;
1115 mSyncActionDialog = 0; 1115 mSyncActionDialog = 0;
1116 blockRC = false; 1116 blockRC = false;
1117}; 1117};
1118 1118
1119void KServerSocket::newConnection ( int socket ) 1119void KServerSocket::newConnection ( int socket )
1120{ 1120{
1121 // qDebug("KServerSocket:New connection %d ", socket); 1121 // qDebug("KServerSocket:New connection %d ", socket);
1122 if ( mSocket ) { 1122 if ( mSocket ) {
1123 qDebug("KServerSocket::newConnection Socket deleted! "); 1123 qDebug("KSS::newConnection Socket deleted! ");
1124 delete mSocket; 1124 delete mSocket;
1125 mSocket = 0; 1125 mSocket = 0;
1126 } 1126 }
1127 mSocket = new QSocket( this ); 1127 mSocket = new QSocket( this );
1128 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1128 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1129 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1129 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1130 mSocket->setSocket( socket ); 1130 mSocket->setSocket( socket );
1131} 1131}
1132 1132
1133void KServerSocket::discardClient() 1133void KServerSocket::discardClient()
1134{ 1134{
1135 //qDebug(" KServerSocket::discardClient()"); 1135 //qDebug(" KServerSocket::discardClient()");
1136 if ( mSocket ) { 1136 if ( mSocket ) {
1137 delete mSocket; 1137 delete mSocket;
1138 mSocket = 0; 1138 mSocket = 0;
1139 } 1139 }
1140 //emit endConnect(); 1140 //emit endConnect();
1141} 1141}
1142void KServerSocket::readClient() 1142void KServerSocket::readClient()
1143{ 1143{
1144 if ( blockRC ) 1144 if ( blockRC )
1145 return; 1145 return;
1146 if ( mSocket == 0 ) { 1146 if ( mSocket == 0 ) {
1147 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 1147 qDebug("ERROR::KSS::readClient(): mSocket == 0 ");
1148 return; 1148 return;
1149 } 1149 }
1150 //qDebug("KServerSocket::readClient()"); 1150 //qDebug("KServerSocket::readClient()");
1151 if ( mSocket->canReadLine() ) { 1151 if ( mSocket->canReadLine() ) {
1152 QString line = mSocket->readLine(); 1152 QString line = mSocket->readLine();
1153 //qDebug("KServerSocket readline: %s ", line.latin1()); 1153 //qDebug("KServerSocket readline: %s ", line.latin1());
1154 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 1154 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
1155 if ( tokens[0] == "GET" ) { 1155 if ( tokens[0] == "GET" ) {
1156 if ( tokens[1] == mPassWord ) { 1156 if ( tokens[1] == mPassWord ) {
1157 //emit sendFile( mSocket ); 1157 //emit sendFile( mSocket );
1158 bool ok = false; 1158 bool ok = false;
1159 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); 1159 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok);
1160 if ( ok ) { 1160 if ( ok ) {
1161 KSyncManager::mRequestedSyncEvent = dt; 1161 KSyncManager::mRequestedSyncEvent = dt;
1162 } 1162 }
1163 else 1163 else
1164 KSyncManager::mRequestedSyncEvent = QDateTime(); 1164 KSyncManager::mRequestedSyncEvent = QDateTime();
1165 send_file(); 1165 send_file();
1166 } 1166 }
1167 else { 1167 else {
1168 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); 1168 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"));
1169 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 1169 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
1170 } 1170 }
1171 } 1171 }
1172 if ( tokens[0] == "PUT" ) { 1172 if ( tokens[0] == "PUT" ) {
1173 if ( tokens[1] == mPassWord ) { 1173 if ( tokens[1] == mPassWord ) {
1174 //emit getFile( mSocket ); 1174 //emit getFile( mSocket );
1175 blockRC = true; 1175 blockRC = true;
1176 get_file(); 1176 get_file();
1177 } 1177 }
1178 else { 1178 else {
1179 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); 1179 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"));
1180 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 1180 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
1181 } 1181 }
1182 } 1182 }
1183 if ( tokens[0] == "STOP" ) { 1183 if ( tokens[0] == "STOP" ) {
1184 //emit endConnect(); 1184 //emit endConnect();
1185 end_connect(); 1185 end_connect();
1186 } 1186 }
1187 } 1187 }
1188} 1188}
1189void KServerSocket::end_connect() 1189void KServerSocket::end_connect()
1190{ 1190{
1191 delete mSyncActionDialog; 1191 delete mSyncActionDialog;
1192 mSyncActionDialog = 0; 1192 mSyncActionDialog = 0;
1193} 1193}
1194void KServerSocket::send_file() 1194void KServerSocket::send_file()
1195{ 1195{
1196 //qDebug("MainWindow::sendFile(QSocket* s) "); 1196 //qDebug("MainWindow::sendFile(QSocket* s) ");
1197 if ( mSyncActionDialog ) 1197 if ( mSyncActionDialog )
1198 delete mSyncActionDialog; 1198 delete mSyncActionDialog;
1199 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 1199 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
1200 mSyncActionDialog->setCaption(i18n("Received sync request")); 1200 mSyncActionDialog->setCaption(i18n("Received sync request"));
1201 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 1201 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
1202 label->setAlignment ( Qt::AlignHCenter ); 1202 label->setAlignment ( Qt::AlignHCenter );
1203 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1203 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
1204 lay->addWidget( label); 1204 lay->addWidget( label);
1205 lay->setMargin(7); 1205 lay->setMargin(7);
1206 lay->setSpacing(7); 1206 lay->setSpacing(7);
1207 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1207 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1208 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); 1208 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent );
1209 if ( secs < 0 ) 1209 if ( secs < 0 )
1210 secs = secs * (-1); 1210 secs = secs * (-1);
1211 if ( secs > 30 ) 1211 if ( secs > 30 )
1212 //if ( true ) 1212 //if ( true )
1213 { 1213 {
1214 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); 1214 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs );
1215 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1215 QLabel* label = new QLabel( warning, mSyncActionDialog );
1216 label->setAlignment ( Qt::AlignHCenter ); 1216 label->setAlignment ( Qt::AlignHCenter );
1217 lay->addWidget( label); 1217 lay->addWidget( label);
1218 if ( secs > 180 ) 1218 if ( secs > 180 )
1219 { 1219 {
1220 if ( secs > 300 ) { 1220 if ( secs > 300 ) {
1221 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\n of more than 5 minutes.\nPlease adjust your clocks.\n<b>You may get wrong syncing results!<\b>\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { 1221 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\n of more than 5 minutes.\nPlease adjust your clocks.\n<b>You may get wrong syncing results!<\b>\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) {
1222 qDebug("cancelled "); 1222 qDebug("KSS::Sync cancelled ,cs");
1223 return ; 1223 return ;
1224 } 1224 }
1225 } 1225 }
1226 QFont f = label->font(); 1226 QFont f = label->font();
1227 f.setPointSize ( f.pointSize() *2 ); 1227 f.setPointSize ( f.pointSize() *2 );
1228 f. setBold (true ); 1228 f. setBold (true );
1229 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1229 QLabel* label = new QLabel( warning, mSyncActionDialog );
1230 label->setFont( f ); 1230 label->setFont( f );
1231 warning = i18n("ADJUST\nYOUR\nCLOCKS!"); 1231 warning = i18n("ADJUST\nYOUR\nCLOCKS!");
1232 label->setText( warning ); 1232 label->setText( warning );
1233 label->setAlignment ( Qt::AlignHCenter ); 1233 label->setAlignment ( Qt::AlignHCenter );
1234 lay->addWidget( label); 1234 lay->addWidget( label);
1235 mSyncActionDialog->setFixedSize( 230, 300); 1235 mSyncActionDialog->setFixedSize( 230, 300);
1236 } else { 1236 } else {
1237 mSyncActionDialog->setFixedSize( 230, 200); 1237 mSyncActionDialog->setFixedSize( 230, 200);
1238 } 1238 }
1239 } else { 1239 } else {
1240 mSyncActionDialog->setFixedSize( 230, 120); 1240 mSyncActionDialog->setFixedSize( 230, 120);
1241 } 1241 }
1242 } else 1242 } else
1243 mSyncActionDialog->setFixedSize( 230, 120); 1243 mSyncActionDialog->setFixedSize( 230, 120);
1244 mSyncActionDialog->show(); 1244 mSyncActionDialog->show();
1245 mSyncActionDialog->raise(); 1245 mSyncActionDialog->raise();
1246 emit request_file(); 1246 emit request_file();
1247 qApp->processEvents(); 1247 qApp->processEvents();
1248 QString fileName = mFileName; 1248 QString fileName = mFileName;
1249 QFile file( fileName ); 1249 QFile file( fileName );
1250 if (!file.open( IO_ReadOnly ) ) { 1250 if (!file.open( IO_ReadOnly ) ) {
1251 delete mSyncActionDialog; 1251 delete mSyncActionDialog;
1252 mSyncActionDialog = 0; 1252 mSyncActionDialog = 0;
1253 qDebug("KSS::error open sync file: %s ", fileName.latin1()); 1253 qDebug("KSS::error open sync file: %s ", fileName.latin1());
1254 mSocket->close(); 1254 mSocket->close();
1255 if ( mSocket->state() == QSocket::Idle ) 1255 if ( mSocket->state() == QSocket::Idle )
1256 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1256 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1257 return ; 1257 return ;
1258 1258
1259 } 1259 }
1260 mSyncActionDialog->setCaption( i18n("Sending file...") ); 1260 mSyncActionDialog->setCaption( i18n("Sending file...") );
1261 QTextStream ts( &file ); 1261 QTextStream ts( &file );
1262 ts.setEncoding( QTextStream::Latin1 ); 1262 ts.setEncoding( QTextStream::Latin1 );
1263 1263
1264 QTextStream os( mSocket ); 1264 QTextStream os( mSocket );
1265 os.setEncoding( QTextStream::Latin1 ); 1265 os.setEncoding( QTextStream::Latin1 );
1266 while ( ! ts.atEnd() ) { 1266 while ( ! ts.atEnd() ) {
1267 os << ts.readLine() << "\r\n"; 1267 os << ts.readLine() << "\r\n";
1268 } 1268 }
1269 //os << ts.read(); 1269 //os << ts.read();
1270 file.close(); 1270 file.close();
1271 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 1271 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
1272 mSocket->close(); 1272 mSocket->close();
1273 if ( mSocket->state() == QSocket::Idle ) 1273 if ( mSocket->state() == QSocket::Idle )
1274 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1274 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1275} 1275}
1276void KServerSocket::get_file() 1276void KServerSocket::get_file()
1277{ 1277{
1278 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 1278 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
1279 1279
1280 piTime.start(); 1280 piTime.start();
1281 piFileString = ""; 1281 piFileString = "";
1282 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 1282 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
1283} 1283}
1284 1284
1285 1285
1286void KServerSocket::readBackFileFromSocket() 1286void KServerSocket::readBackFileFromSocket()
1287{ 1287{
1288 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 1288 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
1289 while ( mSocket->canReadLine () ) { 1289 while ( mSocket->canReadLine () ) {
1290 piTime.restart(); 1290 piTime.restart();
1291 QString line = mSocket->readLine (); 1291 QString line = mSocket->readLine ();
1292 piFileString += line; 1292 piFileString += line;
1293 //qDebug("readline: %s ", line.latin1()); 1293 //qDebug("readline: %s ", line.latin1());
1294 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 1294 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
1295 1295
1296 } 1296 }
1297 if ( piTime.elapsed () < 3000 ) { 1297 if ( piTime.elapsed () < 3000 ) {
1298 // wait for more 1298 // wait for more
1299 //qDebug("waitformore "); 1299 //qDebug("waitformore ");
1300 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 1300 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
1301 return; 1301 return;
1302 } 1302 }
1303 QString fileName = mFileName; 1303 QString fileName = mFileName;
1304 QFile file ( fileName ); 1304 QFile file ( fileName );
1305 if (!file.open( IO_WriteOnly ) ) { 1305 if (!file.open( IO_WriteOnly ) ) {
1306 delete mSyncActionDialog; 1306 delete mSyncActionDialog;
1307 mSyncActionDialog = 0; 1307 mSyncActionDialog = 0;
1308 qDebug("KSS:Error open read back file "); 1308 qDebug("KSS:Error open read back file ");
1309 piFileString = ""; 1309 piFileString = "";
1310 emit file_received( false ); 1310 emit file_received( false );
1311 blockRC = false; 1311 blockRC = false;
1312 return ; 1312 return ;
1313 1313
1314 } 1314 }
1315 1315
1316 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1316 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1317 QTextStream ts ( &file ); 1317 QTextStream ts ( &file );
1318 ts.setEncoding( QTextStream::Latin1 ); 1318 ts.setEncoding( QTextStream::Latin1 );
1319 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 1319 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1320 ts << piFileString; 1320 ts << piFileString;
1321 mSocket->close(); 1321 mSocket->close();
1322 if ( mSocket->state() == QSocket::Idle ) 1322 if ( mSocket->state() == QSocket::Idle )
1323 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1323 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1324 file.close(); 1324 file.close();
1325 piFileString = ""; 1325 piFileString = "";
1326 emit file_received( true ); 1326 emit file_received( true );
1327 delete mSyncActionDialog; 1327 delete mSyncActionDialog;
1328 mSyncActionDialog = 0; 1328 mSyncActionDialog = 0;
1329 blockRC = false; 1329 blockRC = false;
1330 1330
1331} 1331}
1332 1332
1333KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) 1333KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
1334{ 1334{
1335 mPassWord = password; 1335 mPassWord = password;
1336 mSocket = 0; 1336 mSocket = 0;
1337 mPort = port; 1337 mPort = port;
1338 mHost = host; 1338 mHost = host;
1339 1339
1340 mRetVal = quiet; 1340 mRetVal = quiet;
1341 mTimerSocket = new QTimer ( this ); 1341 mTimerSocket = new QTimer ( this );
1342 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); 1342 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
1343} 1343}
1344void KCommandSocket::readFile( QString fn ) 1344void KCommandSocket::readFile( QString fn )
1345{ 1345{
1346 if ( !mSocket ) { 1346 if ( !mSocket ) {
1347 mSocket = new QSocket( this ); 1347 mSocket = new QSocket( this );
1348 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1348 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1349 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1349 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1350 } 1350 }
1351 mFileString = ""; 1351 mFileString = "";
1352 mFileName = fn; 1352 mFileName = fn;
1353 mFirst = true; 1353 mFirst = true;
1354 mSocket->connectToHost( mHost, mPort ); 1354 mSocket->connectToHost( mHost, mPort );
1355 QTextStream os( mSocket ); 1355 QTextStream os( mSocket );
1356 os.setEncoding( QTextStream::Latin1 ); 1356 os.setEncoding( QTextStream::Latin1 );
1357 1357
1358 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); 1358 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate );
1359 os << "GET " << mPassWord << curDt <<"\r\n"; 1359 os << "GET " << mPassWord << curDt <<"\r\n";
1360 mTimerSocket->start( 300000 ); 1360 mTimerSocket->start( 300000 );
1361} 1361}
1362 1362
1363void KCommandSocket::writeFile( QString fileName ) 1363void KCommandSocket::writeFile( QString fileName )
1364{ 1364{
1365 if ( !mSocket ) { 1365 if ( !mSocket ) {
1366 mSocket = new QSocket( this ); 1366 mSocket = new QSocket( this );
1367 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1367 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1368 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 1368 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1369 } 1369 }
1370 mFileName = fileName ; 1370 mFileName = fileName ;
1371 mSocket->connectToHost( mHost, mPort ); 1371 mSocket->connectToHost( mHost, mPort );
1372} 1372}
1373void KCommandSocket::writeFileToSocket() 1373void KCommandSocket::writeFileToSocket()
1374{ 1374{
1375 QFile file2( mFileName ); 1375 QFile file2( mFileName );
1376 if (!file2.open( IO_ReadOnly ) ) { 1376 if (!file2.open( IO_ReadOnly ) ) {
1377 mRetVal= errorW; 1377 mRetVal= errorW;
1378 mSocket->close(); 1378 mSocket->close();
1379 if ( mSocket->state() == QSocket::Idle ) 1379 if ( mSocket->state() == QSocket::Idle )
1380 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1380 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1381 return ; 1381 return ;
1382 } 1382 }
1383 QTextStream ts2( &file2 ); 1383 QTextStream ts2( &file2 );
1384 ts2.setEncoding( QTextStream::Latin1 ); 1384 ts2.setEncoding( QTextStream::Latin1 );
1385 QTextStream os2( mSocket ); 1385 QTextStream os2( mSocket );
1386 os2.setEncoding( QTextStream::Latin1 ); 1386 os2.setEncoding( QTextStream::Latin1 );
1387 os2 << "PUT " << mPassWord << "\r\n";; 1387 os2 << "PUT " << mPassWord << "\r\n";;
1388 while ( ! ts2.atEnd() ) { 1388 while ( ! ts2.atEnd() ) {
1389 os2 << ts2.readLine() << "\r\n"; 1389 os2 << ts2.readLine() << "\r\n";
1390 } 1390 }
1391 mRetVal= successW; 1391 mRetVal= successW;
1392 file2.close(); 1392 file2.close();
1393 mSocket->close(); 1393 mSocket->close();
1394 if ( mSocket->state() == QSocket::Idle ) 1394 if ( mSocket->state() == QSocket::Idle )
1395 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1395 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1396} 1396}
1397void KCommandSocket::sendStop() 1397void KCommandSocket::sendStop()
1398{ 1398{
1399 if ( !mSocket ) { 1399 if ( !mSocket ) {
1400 mSocket = new QSocket( this ); 1400 mSocket = new QSocket( this );
1401 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1401 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1402 } 1402 }
1403 mSocket->connectToHost( mHost, mPort ); 1403 mSocket->connectToHost( mHost, mPort );
1404 QTextStream os2( mSocket ); 1404 QTextStream os2( mSocket );
1405 os2.setEncoding( QTextStream::Latin1 ); 1405 os2.setEncoding( QTextStream::Latin1 );
1406 os2 << "STOP\r\n"; 1406 os2 << "STOP\r\n";
1407 mSocket->close(); 1407 mSocket->close();
1408 if ( mSocket->state() == QSocket::Idle ) 1408 if ( mSocket->state() == QSocket::Idle )
1409 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1409 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1410} 1410}
1411 1411
1412void KCommandSocket::startReadFileFromSocket() 1412void KCommandSocket::startReadFileFromSocket()
1413{ 1413{
1414 if ( ! mFirst ) 1414 if ( ! mFirst )
1415 return; 1415 return;
1416 mFirst = false; 1416 mFirst = false;
1417 mTimerSocket->stop(); 1417 mTimerSocket->stop();
1418 mFileString = ""; 1418 mFileString = "";
1419 mTime.start(); 1419 mTime.start();
1420 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 1420 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
1421 1421
1422} 1422}
1423void KCommandSocket::readFileFromSocket() 1423void KCommandSocket::readFileFromSocket()
1424{ 1424{
1425 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 1425 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
1426 while ( mSocket->canReadLine () ) { 1426 while ( mSocket->canReadLine () ) {
1427 mTime.restart(); 1427 mTime.restart();
1428 QString line = mSocket->readLine (); 1428 QString line = mSocket->readLine ();
1429 mFileString += line; 1429 mFileString += line;
1430 //qDebug("readline: %s ", line.latin1()); 1430 //qDebug("readline: %s ", line.latin1());
1431 } 1431 }
1432 if ( mTime.elapsed () < 3000 ) { 1432 if ( mTime.elapsed () < 3000 ) {
1433 // wait for more 1433 // wait for more
1434 //qDebug("waitformore "); 1434 //qDebug("waitformore ");
1435 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 1435 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
1436 return; 1436 return;
1437 } 1437 }
1438 QString fileName = mFileName; 1438 QString fileName = mFileName;
1439 QFile file ( fileName ); 1439 QFile file ( fileName );
1440 if (!file.open( IO_WriteOnly ) ) { 1440 if (!file.open( IO_WriteOnly ) ) {
1441 mFileString = ""; 1441 mFileString = "";
1442 mRetVal = errorR; 1442 mRetVal = errorR;
1443 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); 1443 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() );
1444 deleteSocket(); 1444 deleteSocket();
1445 return ; 1445 return ;
1446 1446
1447 } 1447 }
1448 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1448 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1449 QTextStream ts ( &file ); 1449 QTextStream ts ( &file );
1450 ts.setEncoding( QTextStream::Latin1 ); 1450 ts.setEncoding( QTextStream::Latin1 );
1451 ts << mFileString; 1451 ts << mFileString;
1452 file.close(); 1452 file.close();
1453 mFileString = ""; 1453 mFileString = "";
1454 mRetVal = successR; 1454 mRetVal = successR;
1455 mSocket->close(); 1455 mSocket->close();
1456 // if state is not idle, deleteSocket(); is called via 1456 // if state is not idle, deleteSocket(); is called via
1457 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1457 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1458 if ( mSocket->state() == QSocket::Idle ) 1458 if ( mSocket->state() == QSocket::Idle )
1459 deleteSocket(); 1459 deleteSocket();
1460} 1460}
1461 1461
1462void KCommandSocket::deleteSocket() 1462void KCommandSocket::deleteSocket()
1463{ 1463{
1464 //qDebug("KCommandSocket::deleteSocket() "); 1464 //qDebug("KCommandSocket::deleteSocket() ");
1465 if ( mTimerSocket->isActive () ) { 1465 if ( mTimerSocket->isActive () ) {
1466 mTimerSocket->stop(); 1466 mTimerSocket->stop();
1467 mRetVal = errorTO; 1467 mRetVal = errorTO;
1468 qDebug("Connection to remote host timed out"); 1468 qDebug("KCS::Connection to remote host timed out");
1469 if ( mSocket ) { 1469 if ( mSocket ) {
1470 mSocket->close(); 1470 mSocket->close();
1471 //if ( mSocket->state() == QSocket::Idle ) 1471 //if ( mSocket->state() == QSocket::Idle )
1472 // deleteSocket(); 1472 // deleteSocket();
1473 delete mSocket; 1473 delete mSocket;
1474 mSocket = 0; 1474 mSocket = 0;
1475 } 1475 }
1476 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); 1476 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? "));
1477 emit commandFinished( this, mRetVal ); 1477 emit commandFinished( this, mRetVal );
1478 return; 1478 return;
1479 } 1479 }
1480 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 1480 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
1481 if ( mSocket) 1481 if ( mSocket)
1482 delete mSocket; 1482 delete mSocket;
1483 mSocket = 0; 1483 mSocket = 0;
1484 emit commandFinished( this, mRetVal ); 1484 emit commandFinished( this, mRetVal );
1485} 1485}