summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.cpp
authorzautrix <zautrix>2005-04-04 09:34:08 (UTC)
committer zautrix <zautrix>2005-04-04 09:34:08 (UTC)
commit69a388bdef8d4a31063f983735d2b7d25775f3cf (patch) (unidiff)
treea7b9bfe175a9f396c44b5eee4b9321a1061d3b76 /libkdepim/ksyncmanager.cpp
parent98db9169fcd69b1d20e6785278312e0d88722435 (diff)
downloadkdepimpi-69a388bdef8d4a31063f983735d2b7d25775f3cf.zip
kdepimpi-69a388bdef8d4a31063f983735d2b7d25775f3cf.tar.gz
kdepimpi-69a388bdef8d4a31063f983735d2b7d25775f3cf.tar.bz2
fixes
Diffstat (limited to 'libkdepim/ksyncmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 85a2aeb..db815d6 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,526 +1,538 @@
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(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) 62 : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), 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 68
69 69
70} 70}
71 71
72KSyncManager::~KSyncManager() 72KSyncManager::~KSyncManager()
73{ 73{
74 delete bar; 74 delete bar;
75} 75}
76 76
77void KSyncManager::setDefaultFileName( QString s) 77void KSyncManager::setDefaultFileName( QString s)
78{ 78{
79 mDefFileName = s ; 79 mDefFileName = s ;
80 if ( mPrefs->mPassiveSyncAutoStart ) 80 if ( mPrefs->mPassiveSyncAutoStart )
81 enableQuick( false ); 81 enableQuick( false );
82} 82}
83 83
84void KSyncManager::fillSyncMenu() 84void KSyncManager::fillSyncMenu()
85{ 85{
86 if ( mSyncMenu->count() ) 86 if ( mSyncMenu->count() )
87 mSyncMenu->clear(); 87 mSyncMenu->clear();
88 88
89 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 89 mSyncMenu->insertItem( i18n("Configure..."), 0 );
90 mSyncMenu->insertSeparator(); 90 mSyncMenu->insertSeparator();
91 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); 91 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu );
92 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); 92 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 );
93 clearMenu->insertItem( i18n("For all profiles"), 1 ); 93 clearMenu->insertItem( i18n("For all profiles"), 1 );
94 clearMenu->insertSeparator(); 94 clearMenu->insertSeparator();
95 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); 95 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) );
96 mSyncMenu->insertSeparator(); 96 mSyncMenu->insertSeparator();
97 if ( mServerSocket == 0 ) { 97 if ( mServerSocket == 0 ) {
98 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 98 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
99 } else { 99 } else {
100 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 100 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
101 } 101 }
102 mSyncMenu->insertSeparator(); 102 mSyncMenu->insertSeparator();
103 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 103 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
104 mSyncMenu->insertSeparator(); 104 mSyncMenu->insertSeparator();
105 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 105 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
106 config.setGroup("General"); 106 config.setGroup("General");
107 QStringList prof = config.readListEntry("SyncProfileNames"); 107 QStringList prof = config.readListEntry("SyncProfileNames");
108 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 108 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
109 if ( prof.count() < 2 ) { 109 if ( prof.count() < 2 ) {
110 prof.clear(); 110 prof.clear();
111 QString externalName; 111 QString externalName;
112#ifdef DESKTOP_VERSION 112#ifdef DESKTOP_VERSION
113#ifdef _WIN32_ 113#ifdef _WIN32_
114 externalName = "OutLook(not_implemented)"; 114 externalName = "OutLook(not_implemented)";
115#else 115#else
116 externalName = "KDE_Desktop"; 116 externalName = "KDE_Desktop";
117#endif 117#endif
118#else 118#else
119 externalName = "Sharp_DTM"; 119 externalName = "Sharp_DTM";
120#endif 120#endif
121 prof << externalName; 121 prof << externalName;
122 prof << i18n("Local_file"); 122 prof << i18n("Local_file");
123 prof << i18n("Last_file"); 123 prof << i18n("Last_file");
124 KSyncProfile* temp = new KSyncProfile (); 124 KSyncProfile* temp = new KSyncProfile ();
125 temp->setName( prof[0] ); 125 temp->setName( prof[0] );
126 temp->writeConfig(&config); 126 temp->writeConfig(&config);
127 temp->setName( prof[1] ); 127 temp->setName( prof[1] );
128 temp->writeConfig(&config); 128 temp->writeConfig(&config);
129 temp->setName( prof[2] ); 129 temp->setName( prof[2] );
130 temp->writeConfig(&config); 130 temp->writeConfig(&config);
131 config.setGroup("General"); 131 config.setGroup("General");
132 config.writeEntry("SyncProfileNames",prof); 132 config.writeEntry("SyncProfileNames",prof);
133 config.writeEntry("ExternSyncProfiles",externalName); 133 config.writeEntry("ExternSyncProfiles",externalName);
134 config.sync(); 134 config.sync();
135 delete temp; 135 delete temp;
136 } 136 }
137 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 137 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
138 mSyncProfileNames = prof; 138 mSyncProfileNames = prof;
139 unsigned int i; 139 unsigned int i;
140 for ( i = 0; i < prof.count(); ++i ) { 140 for ( i = 0; i < prof.count(); ++i ) {
141 mSyncMenu->insertItem( prof[i], 1000+i ); 141 QString insertText = prof[i];
142 clearMenu->insertItem( prof[i], 1000+i ); 142 if ( i == 0 ) {
143#ifdef DESKTOP_VERSION
144#ifdef _WIN32_
145 insertText = "OutLook(not_implemented)";
146#else
147 insertText = "KDE_Desktop";
148#endif
149#else
150 insertText = "Sharp_DTM";
151#endif
152 }
153 mSyncMenu->insertItem( insertText, 1000+i );
154 clearMenu->insertItem( insertText, 1000+i );
143 if ( i == 2 ) 155 if ( i == 2 )
144 mSyncMenu->insertSeparator(); 156 mSyncMenu->insertSeparator();
145 } 157 }
146 QDir app_dir; 158 QDir app_dir;
147 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 159 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
148 if ( mTargetApp == PWMPI) { 160 if ( mTargetApp == PWMPI) {
149 mSyncMenu->removeItem( 1000 ); 161 mSyncMenu->removeItem( 1000 );
150 clearMenu->removeItem( 1000 ); 162 clearMenu->removeItem( 1000 );
151 } 163 }
152#ifndef DESKTOP_VERSION 164#ifndef DESKTOP_VERSION
153 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 165 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
154 mSyncMenu->removeItem( 1000 ); 166 mSyncMenu->removeItem( 1000 );
155 clearMenu->removeItem( 1000 ); 167 clearMenu->removeItem( 1000 );
156 } 168 }
157#endif 169#endif
158 mSyncMenu->removeItem( 1002 ); 170 mSyncMenu->removeItem( 1002 );
159 clearMenu->removeItem( 1002 ); 171 clearMenu->removeItem( 1002 );
160} 172}
161void KSyncManager::slotClearMenu( int action ) 173void KSyncManager::slotClearMenu( int action )
162{ 174{
163 QString syncDevice; 175 QString syncDevice;
164 if ( action > 999 ) { 176 if ( action > 999 ) {
165 syncDevice = mSyncProfileNames[action - 1000] ; 177 syncDevice = mSyncProfileNames[action - 1000] ;
166 } 178 }
167 179
168 180
169 181
170 int result = 0; 182 int result = 0;
171 QString sd; 183 QString sd;
172 if ( syncDevice.isEmpty() ) 184 if ( syncDevice.isEmpty() )
173 sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); 185 sd = i18n("Do you want to\nclear all sync info\nof all profiles?");
174 else 186 else
175 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); 187 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice );
176 188
177 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, 189 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0,
178 0, 1 ); 190 0, 1 );
179 if ( result ) 191 if ( result )
180 return; 192 return;
181 mImplementation->removeSyncInfo( syncDevice ); 193 mImplementation->removeSyncInfo( syncDevice );
182} 194}
183void KSyncManager::slotSyncMenu( int action ) 195void KSyncManager::slotSyncMenu( int action )
184{ 196{
185 qDebug("KSM::syncaction %d ", action); 197 qDebug("KSM::syncaction %d ", action);
186 if ( action == 5000 ) 198 if ( action == 5000 )
187 return; 199 return;
188 mSyncWithDesktop = false; 200 mSyncWithDesktop = false;
189 if ( action == 0 ) { 201 if ( action == 0 ) {
190 202
191 // seems to be a Qt2 event handling bug 203 // seems to be a Qt2 event handling bug
192 // syncmenu.clear causes a segfault at first time 204 // syncmenu.clear causes a segfault at first time
193 // when we call it after the main event loop, it is ok 205 // when we call it after the main event loop, it is ok
194 // same behaviour when calling OM/Pi via QCOP for the first time 206 // same behaviour when calling OM/Pi via QCOP for the first time
195 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 207 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
196 //confSync(); 208 //confSync();
197 209
198 return; 210 return;
199 } 211 }
200 if ( action == 1 ) { 212 if ( action == 1 ) {
201 multiSync( true ); 213 multiSync( true );
202 return; 214 return;
203 } 215 }
204 if ( action == 2 ) { 216 if ( action == 2 ) {
205 enableQuick(); 217 enableQuick();
206 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 218 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
207 return; 219 return;
208 } 220 }
209 if ( action == 3 ) { 221 if ( action == 3 ) {
210 delete mServerSocket; 222 delete mServerSocket;
211 mServerSocket = 0; 223 mServerSocket = 0;
212 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 224 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
213 return; 225 return;
214 } 226 }
215 227
216 if (blockSave()) 228 if (blockSave())
217 return; 229 return;
218 230
219 setBlockSave(true); 231 setBlockSave(true);
220 bool silent = false; 232 bool silent = false;
221 if ( action == 999 ) { 233 if ( action == 999 ) {
222 //special mode for silent syncing 234 //special mode for silent syncing
223 action = 1000; 235 action = 1000;
224 silent = true; 236 silent = true;
225 } 237 }
226 238
227 mCurrentSyncProfile = action - 1000 ; 239 mCurrentSyncProfile = action - 1000 ;
228 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 240 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
229 mCurrentSyncName = mLocalMachineName ; 241 mCurrentSyncName = mLocalMachineName ;
230 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 242 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
231 KSyncProfile* temp = new KSyncProfile (); 243 KSyncProfile* temp = new KSyncProfile ();
232 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 244 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
233 temp->readConfig(&config); 245 temp->readConfig(&config);
234 if (silent) { 246 if (silent) {
235 mAskForPreferences = false; 247 mAskForPreferences = false;
236 mShowSyncSummary = false; 248 mShowSyncSummary = false;
237 mWriteBackFile = true; 249 mWriteBackFile = true;
238 mSyncAlgoPrefs = 2;// take newest 250 mSyncAlgoPrefs = 2;// take newest
239 } 251 }
240 else { 252 else {
241 mAskForPreferences = temp->getAskForPreferences(); 253 mAskForPreferences = temp->getAskForPreferences();
242 mShowSyncSummary = temp->getShowSummaryAfterSync(); 254 mShowSyncSummary = temp->getShowSummaryAfterSync();
243 mWriteBackFile = temp->getWriteBackFile(); 255 mWriteBackFile = temp->getWriteBackFile();
244 mSyncAlgoPrefs = temp->getSyncPrefs(); 256 mSyncAlgoPrefs = temp->getSyncPrefs();
245 } 257 }
246 mWriteBackExistingOnly = temp->getWriteBackExisting(); 258 mWriteBackExistingOnly = temp->getWriteBackExisting();
247 mIsKapiFile = temp->getIsKapiFile(); 259 mIsKapiFile = temp->getIsKapiFile();
248 mWriteBackInFuture = 0; 260 mWriteBackInFuture = 0;
249 if ( temp->getWriteBackFuture() ) { 261 if ( temp->getWriteBackFuture() ) {
250 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 262 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
251 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 263 mWriteBackInPast = temp->getWriteBackPastWeeks( );
252 } 264 }
253 mFilterInCal = temp->getFilterInCal(); 265 mFilterInCal = temp->getFilterInCal();
254 mFilterOutCal = temp->getFilterOutCal(); 266 mFilterOutCal = temp->getFilterOutCal();
255 mFilterInAB = temp->getFilterInAB(); 267 mFilterInAB = temp->getFilterInAB();
256 mFilterOutAB = temp->getFilterOutAB(); 268 mFilterOutAB = temp->getFilterOutAB();
257 269
258 if ( action == 1000 ) { 270 if ( action == 1000 ) {
259 mIsKapiFile = false; 271 mIsKapiFile = false;
260#ifdef DESKTOP_VERSION 272#ifdef DESKTOP_VERSION
261 syncKDE(); 273 syncKDE();
262#else 274#else
263 syncSharp(); 275 syncSharp();
264#endif 276#endif
265 277
266 } else if ( action == 1001 ) { 278 } else if ( action == 1001 ) {
267 syncLocalFile(); 279 syncLocalFile();
268 280
269 } else if ( action == 1002 ) { 281 } else if ( action == 1002 ) {
270 mWriteBackFile = false; 282 mWriteBackFile = false;
271 mAskForPreferences = false; 283 mAskForPreferences = false;
272 mShowSyncSummary = false; 284 mShowSyncSummary = false;
273 mSyncAlgoPrefs = 3; 285 mSyncAlgoPrefs = 3;
274 quickSyncLocalFile(); 286 quickSyncLocalFile();
275 287
276 } else if ( action >= 1003 ) { 288 } else if ( action >= 1003 ) {
277 if ( temp->getIsLocalFileSync() ) { 289 if ( temp->getIsLocalFileSync() ) {
278 switch(mTargetApp) 290 switch(mTargetApp)
279 { 291 {
280 case (KAPI): 292 case (KAPI):
281 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 293 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
282 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 294 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
283 break; 295 break;
284 case (KOPI): 296 case (KOPI):
285 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 297 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
286 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 298 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
287 break; 299 break;
288 case (PWMPI): 300 case (PWMPI):
289 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 301 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
290 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 302 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
291 break; 303 break;
292 default: 304 default:
293 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 305 qDebug("KSM::slotSyncMenu: invalid apptype selected");
294 break; 306 break;
295 307
296 } 308 }
297 } else { 309 } else {
298 if ( temp->getIsPhoneSync() ) { 310 if ( temp->getIsPhoneSync() ) {
299 mPhoneDevice = temp->getPhoneDevice( ) ; 311 mPhoneDevice = temp->getPhoneDevice( ) ;
300 mPhoneConnection = temp->getPhoneConnection( ); 312 mPhoneConnection = temp->getPhoneConnection( );
301 mPhoneModel = temp->getPhoneModel( ); 313 mPhoneModel = temp->getPhoneModel( );
302 syncPhone(); 314 syncPhone();
303 } else if ( temp->getIsPiSync() ) { 315 } else if ( temp->getIsPiSync() ) {
304 if ( mTargetApp == KAPI ) { 316 if ( mTargetApp == KAPI ) {
305 mPassWordPiSync = temp->getRemotePwAB(); 317 mPassWordPiSync = temp->getRemotePwAB();
306 mActiveSyncPort = temp->getRemotePortAB(); 318 mActiveSyncPort = temp->getRemotePortAB();
307 mActiveSyncIP = temp->getRemoteIPAB(); 319 mActiveSyncIP = temp->getRemoteIPAB();
308 } else if ( mTargetApp == KOPI ) { 320 } else if ( mTargetApp == KOPI ) {
309 mPassWordPiSync = temp->getRemotePw(); 321 mPassWordPiSync = temp->getRemotePw();
310 mActiveSyncPort = temp->getRemotePort(); 322 mActiveSyncPort = temp->getRemotePort();
311 mActiveSyncIP = temp->getRemoteIP(); 323 mActiveSyncIP = temp->getRemoteIP();
312 } else { 324 } else {
313 mPassWordPiSync = temp->getRemotePwPWM(); 325 mPassWordPiSync = temp->getRemotePwPWM();
314 mActiveSyncPort = temp->getRemotePortPWM(); 326 mActiveSyncPort = temp->getRemotePortPWM();
315 mActiveSyncIP = temp->getRemoteIPPWM(); 327 mActiveSyncIP = temp->getRemoteIPPWM();
316 } 328 }
317 syncPi(); 329 syncPi();
318 while ( !mPisyncFinished ) { 330 while ( !mPisyncFinished ) {
319 //qDebug("waiting "); 331 //qDebug("waiting ");
320 qApp->processEvents(); 332 qApp->processEvents();
321 } 333 }
322 } else 334 } else
323 syncRemote( temp ); 335 syncRemote( temp );
324 336
325 } 337 }
326 } 338 }
327 delete temp; 339 delete temp;
328 setBlockSave(false); 340 setBlockSave(false);
329} 341}
330 342
331void KSyncManager::enableQuick( bool ask ) 343void KSyncManager::enableQuick( bool ask )
332{ 344{
333 bool autoStart; 345 bool autoStart;
334 bool changed = false; 346 bool changed = false;
335 if ( ask ) { 347 if ( ask ) {
336 QDialog dia ( 0, "input-dialog", true ); 348 QDialog dia ( 0, "input-dialog", true );
337 QLineEdit lab ( &dia ); 349 QLineEdit lab ( &dia );
338 QVBoxLayout lay( &dia ); 350 QVBoxLayout lay( &dia );
339 lab.setText( mPrefs->mPassiveSyncPort ); 351 lab.setText( mPrefs->mPassiveSyncPort );
340 lay.setMargin(7); 352 lay.setMargin(7);
341 lay.setSpacing(7); 353 lay.setSpacing(7);
342 int po = 9197+mTargetApp; 354 int po = 9197+mTargetApp;
343 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 355 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
344 lay.addWidget( &label); 356 lay.addWidget( &label);
345 lay.addWidget( &lab); 357 lay.addWidget( &lab);
346 358
347 QLineEdit lepw ( &dia ); 359 QLineEdit lepw ( &dia );
348 lepw.setText( mPrefs->mPassiveSyncPw ); 360 lepw.setText( mPrefs->mPassiveSyncPw );
349 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 361 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
350 lay.addWidget( &label2); 362 lay.addWidget( &label2);
351 lay.addWidget( &lepw); 363 lay.addWidget( &lepw);
352 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); 364 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia );
353 lay.addWidget( &autostart); 365 lay.addWidget( &autostart);
354 autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); 366 autostart.setChecked( mPrefs->mPassiveSyncAutoStart );
355#ifdef DESKTOP_VERSION 367#ifdef DESKTOP_VERSION
356#ifdef _WIN32_ 368#ifdef _WIN32_
357 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); 369 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia );
358 syncdesktop.hide();// not implemented! 370 syncdesktop.hide();// not implemented!
359#else 371#else
360 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); 372 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia );
361#endif 373#endif
362 lay.addWidget( &syncdesktop); 374 lay.addWidget( &syncdesktop);
363#else 375#else
364 mPrefs->mPassiveSyncWithDesktop = false; 376 mPrefs->mPassiveSyncWithDesktop = false;
365 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); 377 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
366 syncdesktop.hide(); 378 syncdesktop.hide();
367#endif 379#endif
368 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); 380 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
369 381
370 QPushButton pb ( "OK", &dia); 382 QPushButton pb ( "OK", &dia);
371 lay.addWidget( &pb ); 383 lay.addWidget( &pb );
372 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 384 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
373 dia.resize( 230,120 ); 385 dia.resize( 230,120 );
374 dia.setCaption( i18n("Enter port for Pi-Sync") ); 386 dia.setCaption( i18n("Enter port for Pi-Sync") );
375 dia.show(); 387 dia.show();
376#ifndef DESKTOP_VERSION 388#ifndef DESKTOP_VERSION
377 int dw = QApplication::desktop()->width(); 389 int dw = QApplication::desktop()->width();
378 int dh = QApplication::desktop()->height(); 390 int dh = QApplication::desktop()->height();
379 dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); 391 dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 );
380#endif 392#endif
381 if ( ! dia.exec() ) 393 if ( ! dia.exec() )
382 return; 394 return;
383 dia.hide(); 395 dia.hide();
384 qApp->processEvents(); 396 qApp->processEvents();
385 if ( mPrefs->mPassiveSyncPw != lepw.text() ) { 397 if ( mPrefs->mPassiveSyncPw != lepw.text() ) {
386 changed = true; 398 changed = true;
387 mPrefs->mPassiveSyncPw = lepw.text(); 399 mPrefs->mPassiveSyncPw = lepw.text();
388 } 400 }
389 if ( mPrefs->mPassiveSyncPort != lab.text() ) { 401 if ( mPrefs->mPassiveSyncPort != lab.text() ) {
390 mPrefs->mPassiveSyncPort = lab.text(); 402 mPrefs->mPassiveSyncPort = lab.text();
391 changed = true; 403 changed = true;
392 } 404 }
393 autoStart = autostart.isChecked(); 405 autoStart = autostart.isChecked();
394 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { 406 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) {
395 changed = true; 407 changed = true;
396 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); 408 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked();
397 } 409 }
398 } 410 }
399 else 411 else
400 autoStart = mPrefs->mPassiveSyncAutoStart; 412 autoStart = mPrefs->mPassiveSyncAutoStart;
401 if ( autoStart != mPrefs->mPassiveSyncAutoStart ) 413 if ( autoStart != mPrefs->mPassiveSyncAutoStart )
402 changed = true; 414 changed = true;
403 bool ok; 415 bool ok;
404 mPrefs->mPassiveSyncAutoStart = false; 416 mPrefs->mPassiveSyncAutoStart = false;
405 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 417 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
406 if ( ! ok ) { 418 if ( ! ok ) {
407 KMessageBox::information( 0, i18n("No valid port")); 419 KMessageBox::information( 0, i18n("No valid port"));
408 return; 420 return;
409 } 421 }
410 //qDebug("port %d ", port); 422 //qDebug("port %d ", port);
411 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 423 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
412 mServerSocket->setFileName( defaultFileName() );//bbb 424 mServerSocket->setFileName( defaultFileName() );//bbb
413 if ( !mServerSocket->ok() ) { 425 if ( !mServerSocket->ok() ) {
414 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 426 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
415 delete mServerSocket; 427 delete mServerSocket;
416 mServerSocket = 0; 428 mServerSocket = 0;
417 return; 429 return;
418 } 430 }
419 mPrefs->mPassiveSyncAutoStart = autoStart; 431 mPrefs->mPassiveSyncAutoStart = autoStart;
420 if ( changed ) { 432 if ( changed ) {
421 mPrefs->writeConfig(); 433 mPrefs->writeConfig();
422 } 434 }
423 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 435 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
424 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 436 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
425} 437}
426 438
427void KSyncManager::syncLocalFile() 439void KSyncManager::syncLocalFile()
428{ 440{
429 441
430 QString fn =mPrefs->mLastSyncedLocalFile; 442 QString fn =mPrefs->mLastSyncedLocalFile;
431 QString ext; 443 QString ext;
432 444
433 switch(mTargetApp) 445 switch(mTargetApp)
434 { 446 {
435 case (KAPI): 447 case (KAPI):
436 ext = "(*.vcf)"; 448 ext = "(*.vcf)";
437 break; 449 break;
438 case (KOPI): 450 case (KOPI):
439 ext = "(*.ics/*.vcs)"; 451 ext = "(*.ics/*.vcs)";
440 break; 452 break;
441 case (PWMPI): 453 case (PWMPI):
442 ext = "(*.pwm)"; 454 ext = "(*.pwm)";
443 break; 455 break;
444 default: 456 default:
445 qDebug("KSM::syncLocalFile: invalid apptype selected"); 457 qDebug("KSM::syncLocalFile: invalid apptype selected");
446 break; 458 break;
447 459
448 } 460 }
449 461
450 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 462 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
451 if ( fn == "" ) 463 if ( fn == "" )
452 return; 464 return;
453 if ( syncWithFile( fn, false ) ) { 465 if ( syncWithFile( fn, false ) ) {
454 qDebug("KSM::syncLocalFile() successful "); 466 qDebug("KSM::syncLocalFile() successful ");
455 } 467 }
456 468
457} 469}
458 470
459bool KSyncManager::syncWithFile( QString fn , bool quick ) 471bool KSyncManager::syncWithFile( QString fn , bool quick )
460{ 472{
461 bool ret = false; 473 bool ret = false;
462 QFileInfo info; 474 QFileInfo info;
463 info.setFile( fn ); 475 info.setFile( fn );
464 QString mess; 476 QString mess;
465 if ( !info. exists() ) { 477 if ( !info. exists() ) {
466 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 478 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
467 QMessageBox::warning( mParent, i18n("Warning!"), 479 QMessageBox::warning( mParent, i18n("Warning!"),
468 mess ); 480 mess );
469 return ret; 481 return ret;
470 } 482 }
471 int result = 0; 483 int result = 0;
472 if ( !quick ) { 484 if ( !quick ) {
473 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 485 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
474 result = QMessageBox::warning( mParent, i18n("Warning!"), 486 result = QMessageBox::warning( mParent, i18n("Warning!"),
475 mess, 487 mess,
476 i18n("Sync"), i18n("Cancel"), 0, 488 i18n("Sync"), i18n("Cancel"), 0,
477 0, 1 ); 489 0, 1 );
478 if ( result ) 490 if ( result )
479 return false; 491 return false;
480 } 492 }
481 if ( mAskForPreferences ) 493 if ( mAskForPreferences )
482 if ( !edit_sync_options()) { 494 if ( !edit_sync_options()) {
483 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 495 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
484 return false; 496 return false;
485 } 497 }
486 if ( result == 0 ) { 498 if ( result == 0 ) {
487 //qDebug("Now sycing ... "); 499 //qDebug("Now sycing ... ");
488 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 500 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
489 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 501 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
490 else 502 else
491 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 503 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
492 if ( ! quick ) 504 if ( ! quick )
493 mPrefs->mLastSyncedLocalFile = fn; 505 mPrefs->mLastSyncedLocalFile = fn;
494 } 506 }
495 return ret; 507 return ret;
496} 508}
497 509
498void KSyncManager::quickSyncLocalFile() 510void KSyncManager::quickSyncLocalFile()
499{ 511{
500 512
501 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { 513 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
502 qDebug("KSM::quick syncLocalFile() successful "); 514 qDebug("KSM::quick syncLocalFile() successful ");
503 515
504 } 516 }
505} 517}
506 518
507void KSyncManager::multiSync( bool askforPrefs ) 519void KSyncManager::multiSync( bool askforPrefs )
508{ 520{
509 if (blockSave()) 521 if (blockSave())
510 return; 522 return;
511 setBlockSave(true); 523 setBlockSave(true);
512 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 524 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
513 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 525 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
514 question, 526 question,
515 i18n("Yes"), i18n("No"), 527 i18n("Yes"), i18n("No"),
516 0, 0 ) != 0 ) { 528 0, 0 ) != 0 ) {
517 setBlockSave(false); 529 setBlockSave(false);
518 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 530 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
519 return; 531 return;
520 } 532 }
521 mCurrentSyncDevice = i18n("Multiple profiles") ; 533 mCurrentSyncDevice = i18n("Multiple profiles") ;
522 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 534 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
523 if ( askforPrefs ) { 535 if ( askforPrefs ) {
524 if ( !edit_sync_options()) { 536 if ( !edit_sync_options()) {
525 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); 537 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") );
526 return; 538 return;