summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.cpp
authorzautrix <zautrix>2005-07-02 19:38:48 (UTC)
committer zautrix <zautrix>2005-07-02 19:38:48 (UTC)
commit1de3670209f954b71e679c6b3a83a1334b43f895 (patch) (unidiff)
tree900f1607ecdf254147c97eff4ecd3b5ef97c1d4f /libkdepim/ksyncmanager.cpp
parent8cde05e63c63af0f3ad8048d7160798439125d43 (diff)
downloadkdepimpi-1de3670209f954b71e679c6b3a83a1334b43f895.zip
kdepimpi-1de3670209f954b71e679c6b3a83a1334b43f895.tar.gz
kdepimpi-1de3670209f954b71e679c6b3a83a1334b43f895.tar.bz2
compile fix
Diffstat (limited to 'libkdepim/ksyncmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 038e032..fc0ac6b 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,435 +1,436 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21// $Id$ 21// $Id$
22 22
23#include "ksyncmanager.h" 23#include "ksyncmanager.h"
24 24
25#include <stdlib.h> 25#include <stdlib.h>
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#include <unistd.h> 28#include <unistd.h>
29#endif 29#endif
30 30
31 31
32#include "ksyncprofile.h" 32#include "ksyncprofile.h"
33#include "ksyncprefsdialog.h" 33#include "ksyncprefsdialog.h"
34#include "kpimprefs.h" 34#include "kpimprefs.h"
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <qdir.h> 37#include <qdir.h>
38#include <qprogressbar.h> 38#include <qprogressbar.h>
39#include <qpopupmenu.h> 39#include <qpopupmenu.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qradiobutton.h> 41#include <qradiobutton.h>
42#include <qbuttongroup.h> 42#include <qbuttongroup.h>
43#include <qtimer.h> 43#include <qtimer.h>
44#include <qmessagebox.h> 44#include <qmessagebox.h>
45#include <qapplication.h> 45#include <qapplication.h>
46#include <qlineedit.h> 46#include <qlineedit.h>
47#include <qdialog.h> 47#include <qdialog.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qtextcodec.h> 49#include <qtextcodec.h>
50#include <qlabel.h> 50#include <qlabel.h>
51#include <qcheckbox.h> 51#include <qcheckbox.h>
52#include <qapplication.h>
52 53
53#include <klocale.h> 54#include <klocale.h>
54#include <kglobal.h> 55#include <kglobal.h>
55#include <kconfig.h> 56#include <kconfig.h>
56#include <kfiledialog.h> 57#include <kfiledialog.h>
57 58
58QDateTime KSyncManager::mRequestedSyncEvent; 59QDateTime KSyncManager::mRequestedSyncEvent;
59 60
60 61
61KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 62KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
62 : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) 63 : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu)
63{ 64{
64 mServerSocket = 0; 65 mServerSocket = 0;
65 bar = new QProgressBar ( 1, 0 ); 66 bar = new QProgressBar ( 1, 0 );
66 bar->setCaption (""); 67 bar->setCaption ("");
67 mWriteBackInPast = 2; 68 mWriteBackInPast = 2;
68 69
69 70
70} 71}
71 72
72KSyncManager::~KSyncManager() 73KSyncManager::~KSyncManager()
73{ 74{
74 delete bar; 75 delete bar;
75} 76}
76 77
77void KSyncManager::setDefaultFileName( QString s) 78void KSyncManager::setDefaultFileName( QString s)
78{ 79{
79 mDefFileName = s ; 80 mDefFileName = s ;
80 if ( mPrefs->mPassiveSyncAutoStart ) 81 if ( mPrefs->mPassiveSyncAutoStart )
81 enableQuick( false ); 82 enableQuick( false );
82} 83}
83 84
84void KSyncManager::fillSyncMenu() 85void KSyncManager::fillSyncMenu()
85{ 86{
86 if ( mSyncMenu->count() ) 87 if ( mSyncMenu->count() )
87 mSyncMenu->clear(); 88 mSyncMenu->clear();
88 89
89 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 90 mSyncMenu->insertItem( i18n("Configure..."), 0 );
90 mSyncMenu->insertSeparator(); 91 mSyncMenu->insertSeparator();
91 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); 92 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu );
92 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); 93 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 );
93 clearMenu->insertItem( i18n("For all profiles"), 1 ); 94 clearMenu->insertItem( i18n("For all profiles"), 1 );
94 clearMenu->insertSeparator(); 95 clearMenu->insertSeparator();
95 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); 96 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) );
96 mSyncMenu->insertSeparator(); 97 mSyncMenu->insertSeparator();
97 if ( mServerSocket == 0 ) { 98 if ( mServerSocket == 0 ) {
98 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 99 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
99 } else { 100 } else {
100 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 101 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
101 } 102 }
102 mSyncMenu->insertSeparator(); 103 mSyncMenu->insertSeparator();
103 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 104 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
104 mSyncMenu->insertSeparator(); 105 mSyncMenu->insertSeparator();
105 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 106 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
106 config.setGroup("General"); 107 config.setGroup("General");
107 QStringList prof = config.readListEntry("SyncProfileNames"); 108 QStringList prof = config.readListEntry("SyncProfileNames");
108 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 109 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
109 if ( prof.count() < 2 ) { 110 if ( prof.count() < 2 ) {
110 prof.clear(); 111 prof.clear();
111 QString externalName; 112 QString externalName;
112#ifdef DESKTOP_VERSION 113#ifdef DESKTOP_VERSION
113#ifdef _WIN32_ 114#ifdef _WIN32_
114 externalName = "OutLook(not_implemented)"; 115 externalName = "OutLook(not_implemented)";
115#else 116#else
116 externalName = "KDE_Desktop"; 117 externalName = "KDE_Desktop";
117#endif 118#endif
118#else 119#else
119 externalName = "Sharp_DTM"; 120 externalName = "Sharp_DTM";
120#endif 121#endif
121 prof << externalName; 122 prof << externalName;
122 prof << i18n("Local_file"); 123 prof << i18n("Local_file");
123 prof << i18n("Last_file"); 124 prof << i18n("Last_file");
124 KSyncProfile* temp = new KSyncProfile (); 125 KSyncProfile* temp = new KSyncProfile ();
125 temp->setName( prof[0] ); 126 temp->setName( prof[0] );
126 temp->writeConfig(&config); 127 temp->writeConfig(&config);
127 temp->setName( prof[1] ); 128 temp->setName( prof[1] );
128 temp->writeConfig(&config); 129 temp->writeConfig(&config);
129 temp->setName( prof[2] ); 130 temp->setName( prof[2] );
130 temp->writeConfig(&config); 131 temp->writeConfig(&config);
131 config.setGroup("General"); 132 config.setGroup("General");
132 config.writeEntry("SyncProfileNames",prof); 133 config.writeEntry("SyncProfileNames",prof);
133 config.writeEntry("ExternSyncProfiles",externalName); 134 config.writeEntry("ExternSyncProfiles",externalName);
134 config.sync(); 135 config.sync();
135 delete temp; 136 delete temp;
136 } 137 }
137 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 138 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
138 mSyncProfileNames = prof; 139 mSyncProfileNames = prof;
139 unsigned int i; 140 unsigned int i;
140 for ( i = 0; i < prof.count(); ++i ) { 141 for ( i = 0; i < prof.count(); ++i ) {
141 QString insertText = prof[i]; 142 QString insertText = prof[i];
142 if ( i == 0 ) { 143 if ( i == 0 ) {
143#ifdef DESKTOP_VERSION 144#ifdef DESKTOP_VERSION
144#ifdef _WIN32_ 145#ifdef _WIN32_
145 insertText = "OutLook(not_implemented)"; 146 insertText = "OutLook(not_implemented)";
146#else 147#else
147 insertText = "KDE_Desktop"; 148 insertText = "KDE_Desktop";
148#endif 149#endif
149#else 150#else
150 insertText = "Sharp_DTM"; 151 insertText = "Sharp_DTM";
151#endif 152#endif
152 } 153 }
153 mSyncMenu->insertItem( insertText, 1000+i ); 154 mSyncMenu->insertItem( insertText, 1000+i );
154 clearMenu->insertItem( insertText, 1000+i ); 155 clearMenu->insertItem( insertText, 1000+i );
155 if ( i == 2 ) 156 if ( i == 2 )
156 mSyncMenu->insertSeparator(); 157 mSyncMenu->insertSeparator();
157 } 158 }
158 QDir app_dir; 159 QDir app_dir;
159 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 160 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
160 if ( mTargetApp == PWMPI) { 161 if ( mTargetApp == PWMPI) {
161 mSyncMenu->removeItem( 1000 ); 162 mSyncMenu->removeItem( 1000 );
162 clearMenu->removeItem( 1000 ); 163 clearMenu->removeItem( 1000 );
163 } 164 }
164#ifndef DESKTOP_VERSION 165#ifndef DESKTOP_VERSION
165 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 166 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
166 mSyncMenu->removeItem( 1000 ); 167 mSyncMenu->removeItem( 1000 );
167 clearMenu->removeItem( 1000 ); 168 clearMenu->removeItem( 1000 );
168 } 169 }
169#endif 170#endif
170 mSyncMenu->removeItem( 1002 ); 171 mSyncMenu->removeItem( 1002 );
171 clearMenu->removeItem( 1002 ); 172 clearMenu->removeItem( 1002 );
172} 173}
173void KSyncManager::slotClearMenu( int action ) 174void KSyncManager::slotClearMenu( int action )
174{ 175{
175 QString syncDevice; 176 QString syncDevice;
176 if ( action > 999 ) { 177 if ( action > 999 ) {
177 syncDevice = mSyncProfileNames[action - 1000] ; 178 syncDevice = mSyncProfileNames[action - 1000] ;
178 } 179 }
179 180
180 181
181 182
182 int result = 0; 183 int result = 0;
183 QString sd; 184 QString sd;
184 if ( syncDevice.isEmpty() ) 185 if ( syncDevice.isEmpty() )
185 sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); 186 sd = i18n("Do you want to\nclear all sync info\nof all profiles?");
186 else 187 else
187 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); 188 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice );
188 189
189 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, 190 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0,
190 0, 1 ); 191 0, 1 );
191 if ( result ) 192 if ( result )
192 return; 193 return;
193 mImplementation->removeSyncInfo( syncDevice ); 194 mImplementation->removeSyncInfo( syncDevice );
194} 195}
195void KSyncManager::slotSyncMenu( int action ) 196void KSyncManager::slotSyncMenu( int action )
196{ 197{
197 qDebug("KSM::syncaction %d ", action); 198 qDebug("KSM::syncaction %d ", action);
198 if ( action == 5000 ) 199 if ( action == 5000 )
199 return; 200 return;
200 mSyncWithDesktop = false; 201 mSyncWithDesktop = false;
201 if ( action == 0 ) { 202 if ( action == 0 ) {
202 203
203 // seems to be a Qt2 event handling bug 204 // seems to be a Qt2 event handling bug
204 // syncmenu.clear causes a segfault at first time 205 // syncmenu.clear causes a segfault at first time
205 // when we call it after the main event loop, it is ok 206 // when we call it after the main event loop, it is ok
206 // same behaviour when calling OM/Pi via QCOP for the first time 207 // same behaviour when calling OM/Pi via QCOP for the first time
207 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 208 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
208 //confSync(); 209 //confSync();
209 210
210 return; 211 return;
211 } 212 }
212 if ( action == 1 ) { 213 if ( action == 1 ) {
213 multiSync( true ); 214 multiSync( true );
214 return; 215 return;
215 } 216 }
216 if ( action == 2 ) { 217 if ( action == 2 ) {
217 enableQuick(); 218 enableQuick();
218 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 219 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
219 return; 220 return;
220 } 221 }
221 if ( action == 3 ) { 222 if ( action == 3 ) {
222 delete mServerSocket; 223 delete mServerSocket;
223 mServerSocket = 0; 224 mServerSocket = 0;
224 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 225 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
225 return; 226 return;
226 } 227 }
227 228
228 if (blockSave()) 229 if (blockSave())
229 return; 230 return;
230 231
231 setBlockSave(true); 232 setBlockSave(true);
232 bool silent = false; 233 bool silent = false;
233 if ( action == 999 ) { 234 if ( action == 999 ) {
234 //special mode for silent syncing 235 //special mode for silent syncing
235 action = 1000; 236 action = 1000;
236 silent = true; 237 silent = true;
237 } 238 }
238 239
239 mCurrentSyncProfile = action - 1000 ; 240 mCurrentSyncProfile = action - 1000 ;
240 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 241 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
241 mCurrentSyncName = mLocalMachineName ; 242 mCurrentSyncName = mLocalMachineName ;
242 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 243 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
243 KSyncProfile* temp = new KSyncProfile (); 244 KSyncProfile* temp = new KSyncProfile ();
244 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 245 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
245 temp->readConfig(&config); 246 temp->readConfig(&config);
246 if (silent) { 247 if (silent) {
247 mAskForPreferences = false; 248 mAskForPreferences = false;
248 mShowSyncSummary = false; 249 mShowSyncSummary = false;
249 mWriteBackFile = true; 250 mWriteBackFile = true;
250 mSyncAlgoPrefs = 2;// take newest 251 mSyncAlgoPrefs = 2;// take newest
251 } 252 }
252 else { 253 else {
253 mAskForPreferences = temp->getAskForPreferences(); 254 mAskForPreferences = temp->getAskForPreferences();
254 mShowSyncSummary = temp->getShowSummaryAfterSync(); 255 mShowSyncSummary = temp->getShowSummaryAfterSync();
255 mWriteBackFile = temp->getWriteBackFile(); 256 mWriteBackFile = temp->getWriteBackFile();
256 mSyncAlgoPrefs = temp->getSyncPrefs(); 257 mSyncAlgoPrefs = temp->getSyncPrefs();
257 } 258 }
258 mWriteBackExistingOnly = temp->getWriteBackExisting(); 259 mWriteBackExistingOnly = temp->getWriteBackExisting();
259 mIsKapiFile = temp->getIsKapiFile(); 260 mIsKapiFile = temp->getIsKapiFile();
260 mWriteBackInFuture = 0; 261 mWriteBackInFuture = 0;
261 if ( temp->getWriteBackFuture() ) { 262 if ( temp->getWriteBackFuture() ) {
262 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 263 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
263 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 264 mWriteBackInPast = temp->getWriteBackPastWeeks( );
264 } 265 }
265 mFilterInCal = temp->getFilterInCal(); 266 mFilterInCal = temp->getFilterInCal();
266 mFilterOutCal = temp->getFilterOutCal(); 267 mFilterOutCal = temp->getFilterOutCal();
267 mFilterInAB = temp->getFilterInAB(); 268 mFilterInAB = temp->getFilterInAB();
268 mFilterOutAB = temp->getFilterOutAB(); 269 mFilterOutAB = temp->getFilterOutAB();
269 270
270 if ( action == 1000 ) { 271 if ( action == 1000 ) {
271 mIsKapiFile = false; 272 mIsKapiFile = false;
272#ifdef DESKTOP_VERSION 273#ifdef DESKTOP_VERSION
273 syncKDE(); 274 syncKDE();
274#else 275#else
275 syncSharp(); 276 syncSharp();
276#endif 277#endif
277 278
278 } else if ( action == 1001 ) { 279 } else if ( action == 1001 ) {
279 syncLocalFile(); 280 syncLocalFile();
280 281
281 } else if ( action == 1002 ) { 282 } else if ( action == 1002 ) {
282 mWriteBackFile = false; 283 mWriteBackFile = false;
283 mAskForPreferences = false; 284 mAskForPreferences = false;
284 mShowSyncSummary = false; 285 mShowSyncSummary = false;
285 mSyncAlgoPrefs = 3; 286 mSyncAlgoPrefs = 3;
286 quickSyncLocalFile(); 287 quickSyncLocalFile();
287 288
288 } else if ( action >= 1003 ) { 289 } else if ( action >= 1003 ) {
289 if ( temp->getIsLocalFileSync() ) { 290 if ( temp->getIsLocalFileSync() ) {
290 switch(mTargetApp) 291 switch(mTargetApp)
291 { 292 {
292 case (KAPI): 293 case (KAPI):
293 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 294 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
294 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 295 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
295 break; 296 break;
296 case (KOPI): 297 case (KOPI):
297 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 298 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
298 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 299 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
299 break; 300 break;
300 case (PWMPI): 301 case (PWMPI):
301 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 302 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
302 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 303 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
303 break; 304 break;
304 default: 305 default:
305 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 306 qDebug("KSM::slotSyncMenu: invalid apptype selected");
306 break; 307 break;
307 308
308 } 309 }
309 } else { 310 } else {
310 if ( temp->getIsPhoneSync() ) { 311 if ( temp->getIsPhoneSync() ) {
311 mPhoneDevice = temp->getPhoneDevice( ) ; 312 mPhoneDevice = temp->getPhoneDevice( ) ;
312 mPhoneConnection = temp->getPhoneConnection( ); 313 mPhoneConnection = temp->getPhoneConnection( );
313 mPhoneModel = temp->getPhoneModel( ); 314 mPhoneModel = temp->getPhoneModel( );
314 syncPhone(); 315 syncPhone();
315 } else if ( temp->getIsPiSync() ) { 316 } else if ( temp->getIsPiSync() ) {
316 if ( mTargetApp == KAPI ) { 317 if ( mTargetApp == KAPI ) {
317 mPassWordPiSync = temp->getRemotePwAB(); 318 mPassWordPiSync = temp->getRemotePwAB();
318 mActiveSyncPort = temp->getRemotePortAB(); 319 mActiveSyncPort = temp->getRemotePortAB();
319 mActiveSyncIP = temp->getRemoteIPAB(); 320 mActiveSyncIP = temp->getRemoteIPAB();
320 } else if ( mTargetApp == KOPI ) { 321 } else if ( mTargetApp == KOPI ) {
321 mPassWordPiSync = temp->getRemotePw(); 322 mPassWordPiSync = temp->getRemotePw();
322 mActiveSyncPort = temp->getRemotePort(); 323 mActiveSyncPort = temp->getRemotePort();
323 mActiveSyncIP = temp->getRemoteIP(); 324 mActiveSyncIP = temp->getRemoteIP();
324 } else { 325 } else {
325 mPassWordPiSync = temp->getRemotePwPWM(); 326 mPassWordPiSync = temp->getRemotePwPWM();
326 mActiveSyncPort = temp->getRemotePortPWM(); 327 mActiveSyncPort = temp->getRemotePortPWM();
327 mActiveSyncIP = temp->getRemoteIPPWM(); 328 mActiveSyncIP = temp->getRemoteIPPWM();
328 } 329 }
329 syncPi(); 330 syncPi();
330 while ( !mPisyncFinished ) { 331 while ( !mPisyncFinished ) {
331 //qDebug("waiting "); 332 //qDebug("waiting ");
332 qApp->processEvents(); 333 qApp->processEvents();
333 } 334 }
334 } else 335 } else
335 syncRemote( temp ); 336 syncRemote( temp );
336 337
337 } 338 }
338 } 339 }
339 delete temp; 340 delete temp;
340 setBlockSave(false); 341 setBlockSave(false);
341} 342}
342 343
343void KSyncManager::enableQuick( bool ask ) 344void KSyncManager::enableQuick( bool ask )
344{ 345{
345 bool autoStart; 346 bool autoStart;
346 bool changed = false; 347 bool changed = false;
347 if ( ask ) { 348 if ( ask ) {
348 QDialog dia ( 0, "input-dialog", true ); 349 QDialog dia ( 0, "input-dialog", true );
349 QLineEdit lab ( &dia ); 350 QLineEdit lab ( &dia );
350 QVBoxLayout lay( &dia ); 351 QVBoxLayout lay( &dia );
351 lab.setText( mPrefs->mPassiveSyncPort ); 352 lab.setText( mPrefs->mPassiveSyncPort );
352 lay.setMargin(7); 353 lay.setMargin(7);
353 lay.setSpacing(7); 354 lay.setSpacing(7);
354 int po = 9197+mTargetApp; 355 int po = 9197+mTargetApp;
355 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 356 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
356 lay.addWidget( &label); 357 lay.addWidget( &label);
357 lay.addWidget( &lab); 358 lay.addWidget( &lab);
358 359
359 QLineEdit lepw ( &dia ); 360 QLineEdit lepw ( &dia );
360 lepw.setText( mPrefs->mPassiveSyncPw ); 361 lepw.setText( mPrefs->mPassiveSyncPw );
361 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 362 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
362 lay.addWidget( &label2); 363 lay.addWidget( &label2);
363 lay.addWidget( &lepw); 364 lay.addWidget( &lepw);
364 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); 365 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia );
365 lay.addWidget( &autostart); 366 lay.addWidget( &autostart);
366 autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); 367 autostart.setChecked( mPrefs->mPassiveSyncAutoStart );
367#ifdef DESKTOP_VERSION 368#ifdef DESKTOP_VERSION
368#ifdef _WIN32_ 369#ifdef _WIN32_
369 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); 370 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia );
370 syncdesktop.hide();// not implemented! 371 syncdesktop.hide();// not implemented!
371#else 372#else
372 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); 373 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia );
373#endif 374#endif
374 lay.addWidget( &syncdesktop); 375 lay.addWidget( &syncdesktop);
375#else 376#else
376 mPrefs->mPassiveSyncWithDesktop = false; 377 mPrefs->mPassiveSyncWithDesktop = false;
377 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); 378 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
378 syncdesktop.hide(); 379 syncdesktop.hide();
379#endif 380#endif
380 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); 381 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
381 382
382 QPushButton pb ( "OK", &dia); 383 QPushButton pb ( "OK", &dia);
383 lay.addWidget( &pb ); 384 lay.addWidget( &pb );
384 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 385 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
385 dia.resize( 230,120 ); 386 dia.resize( 230,120 );
386 dia.setCaption( i18n("Enter port for Pi-Sync") ); 387 dia.setCaption( i18n("Enter port for Pi-Sync") );
387 dia.show(); 388 dia.show();
388#ifndef DESKTOP_VERSION 389#ifndef DESKTOP_VERSION
389 int dw = QApplication::desktop()->width(); 390 int dw = QApplication::desktop()->width();
390 int dh = QApplication::desktop()->height(); 391 int dh = QApplication::desktop()->height();
391 dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); 392 dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 );
392#endif 393#endif
393 if ( ! dia.exec() ) 394 if ( ! dia.exec() )
394 return; 395 return;
395 dia.hide(); 396 dia.hide();
396 qApp->processEvents(); 397 qApp->processEvents();
397 if ( mPrefs->mPassiveSyncPw != lepw.text() ) { 398 if ( mPrefs->mPassiveSyncPw != lepw.text() ) {
398 changed = true; 399 changed = true;
399 mPrefs->mPassiveSyncPw = lepw.text(); 400 mPrefs->mPassiveSyncPw = lepw.text();
400 } 401 }
401 if ( mPrefs->mPassiveSyncPort != lab.text() ) { 402 if ( mPrefs->mPassiveSyncPort != lab.text() ) {
402 mPrefs->mPassiveSyncPort = lab.text(); 403 mPrefs->mPassiveSyncPort = lab.text();
403 changed = true; 404 changed = true;
404 } 405 }
405 autoStart = autostart.isChecked(); 406 autoStart = autostart.isChecked();
406 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { 407 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) {
407 changed = true; 408 changed = true;
408 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); 409 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked();
409 } 410 }
410 } 411 }
411 else 412 else
412 autoStart = mPrefs->mPassiveSyncAutoStart; 413 autoStart = mPrefs->mPassiveSyncAutoStart;
413 if ( autoStart != mPrefs->mPassiveSyncAutoStart ) 414 if ( autoStart != mPrefs->mPassiveSyncAutoStart )
414 changed = true; 415 changed = true;
415 bool ok; 416 bool ok;
416 mPrefs->mPassiveSyncAutoStart = false; 417 mPrefs->mPassiveSyncAutoStart = false;
417 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 418 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
418 if ( ! ok ) { 419 if ( ! ok ) {
419 KMessageBox::information( 0, i18n("No valid port")); 420 KMessageBox::information( 0, i18n("No valid port"));
420 return; 421 return;
421 } 422 }
422 //qDebug("port %d ", port); 423 //qDebug("port %d ", port);
423 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 424 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
424 mServerSocket->setFileName( defaultFileName() );//bbb 425 mServerSocket->setFileName( defaultFileName() );//bbb
425 if ( !mServerSocket->ok() ) { 426 if ( !mServerSocket->ok() ) {
426 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 427 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
427 delete mServerSocket; 428 delete mServerSocket;
428 mServerSocket = 0; 429 mServerSocket = 0;
429 return; 430 return;
430 } 431 }
431 mPrefs->mPassiveSyncAutoStart = autoStart; 432 mPrefs->mPassiveSyncAutoStart = autoStart;
432 if ( changed ) { 433 if ( changed ) {
433 mPrefs->writeConfig(); 434 mPrefs->writeConfig();
434 } 435 }
435 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 436 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );