summaryrefslogtreecommitdiffabout
path: root/libkdepim
Unidiff
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp5
-rw-r--r--libkdepim/ksyncprefsdialog.cpp2
2 files changed, 4 insertions, 3 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 6c1f444..f488a07 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,1484 +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("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("KSyncManager::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("KSyncManager::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("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("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("KSyncManager::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("KSyncManager::slotSyncMenu: 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("KSyncManager::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("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("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("KSyncManager::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("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("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
998 bar->show(); 997 bar->show();
999 } 998 }
1000 999 bar->raise();
1001 bar->setProgress( percentage ); 1000 bar->setProgress( percentage );
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} 1008}
1008 1009
1009bool KSyncManager::isProgressBarCanceled() 1010bool KSyncManager::isProgressBarCanceled()
1010{ 1011{
1011 return !bar->isVisible(); 1012 return !bar->isVisible();
1012} 1013}
1013 1014
1014QString KSyncManager::syncFileName() 1015QString KSyncManager::syncFileName()
1015{ 1016{
1016 1017
1017 QString fn = "tempfile"; 1018 QString fn = "tempfile";
1018 switch(mTargetApp) 1019 switch(mTargetApp)
1019 { 1020 {
1020 case (KAPI): 1021 case (KAPI):
1021 fn = "tempsyncab.vcf"; 1022 fn = "tempsyncab.vcf";
1022 break; 1023 break;
1023 case (KOPI): 1024 case (KOPI):
1024 fn = "tempsynccal.ics"; 1025 fn = "tempsynccal.ics";
1025 break; 1026 break;
1026 case (PWMPI): 1027 case (PWMPI):
1027 fn = "tempsyncpw.pwm"; 1028 fn = "tempsyncpw.pwm";
1028 break; 1029 break;
1029 default: 1030 default:
1030 break; 1031 break;
1031 } 1032 }
1032#ifdef _WIN32_ 1033#ifdef _WIN32_
1033 return locateLocal( "tmp", fn ); 1034 return locateLocal( "tmp", fn );
1034#else 1035#else
1035 return (QString( "/tmp/" )+ fn ); 1036 return (QString( "/tmp/" )+ fn );
1036#endif 1037#endif
1037} 1038}
1038 1039
1039void KSyncManager::syncPi() 1040void KSyncManager::syncPi()
1040{ 1041{
1041 mIsKapiFile = true; 1042 mIsKapiFile = true;
1042 mPisyncFinished = false; 1043 mPisyncFinished = false;
1043 qApp->processEvents(); 1044 qApp->processEvents();
1044 if ( mAskForPreferences ) 1045 if ( mAskForPreferences )
1045 if ( !edit_pisync_options()) { 1046 if ( !edit_pisync_options()) {
1046 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1047 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1047 return; 1048 return;
1048 } 1049 }
1049 bool ok; 1050 bool ok;
1050 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 1051 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
1051 if ( ! ok ) { 1052 if ( ! ok ) {
1052 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1053 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
1053 return; 1054 return;
1054 } 1055 }
1055 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); 1056 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this );
1056 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1057 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1057 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); 1058 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") );
1058 commandSocket->readFile( syncFileName() ); 1059 commandSocket->readFile( syncFileName() );
1059} 1060}
1060 1061
1061void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 1062void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1062{ 1063{
1063 //enum { success, errorW, errorR, quiet }; 1064 //enum { success, errorW, errorR, quiet };
1064 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { 1065 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) {
1065 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 1066 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
1066 delete s; 1067 delete s;
1067 if ( state == KCommandSocket::errorR ) { 1068 if ( state == KCommandSocket::errorR ) {
1068 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 1069 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
1069 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1070 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1070 commandSocket->sendStop(); 1071 commandSocket->sendStop();
1071 } 1072 }
1072 mPisyncFinished = true; 1073 mPisyncFinished = true;
1073 return; 1074 return;
1074 1075
1075 } else if ( state == KCommandSocket::errorW ) { 1076 } else if ( state == KCommandSocket::errorW ) {
1076 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 1077 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
1077 mPisyncFinished = true; 1078 mPisyncFinished = true;
1078 1079
1079 } else if ( state == KCommandSocket::successR ) { 1080 } else if ( state == KCommandSocket::successR ) {
1080 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1081 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
1081 1082
1082 } else if ( state == KCommandSocket::successW ) { 1083 } else if ( state == KCommandSocket::successW ) {
1083 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1084 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1084 mPisyncFinished = true; 1085 mPisyncFinished = true;
1085 } 1086 }
1086 1087
1087 delete s; 1088 delete s;
1088} 1089}
1089 1090
1090void KSyncManager::readFileFromSocket() 1091void KSyncManager::readFileFromSocket()
1091{ 1092{
1092 QString fileName = syncFileName(); 1093 QString fileName = syncFileName();
1093 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 1094 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
1094 if ( ! syncWithFile( fileName , true ) ) { 1095 if ( ! syncWithFile( fileName , true ) ) {
1095 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 1096 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
1096 mPisyncFinished = true; 1097 mPisyncFinished = true;
1097 return; 1098 return;
1098 } 1099 }
1099 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 1100 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
1100 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1101 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1101 if ( mWriteBackFile ) 1102 if ( mWriteBackFile )
1102 commandSocket->writeFile( fileName ); 1103 commandSocket->writeFile( fileName );
1103 else { 1104 else {
1104 commandSocket->sendStop(); 1105 commandSocket->sendStop();
1105 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1106 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1106 mPisyncFinished = true; 1107 mPisyncFinished = true;
1107 } 1108 }
1108} 1109}
1109 1110
1110KServerSocket:: 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 )
1111{ 1112{
1112 mPassWord = pw; 1113 mPassWord = pw;
1113 mSocket = 0; 1114 mSocket = 0;
1114 mSyncActionDialog = 0; 1115 mSyncActionDialog = 0;
1115 blockRC = false; 1116 blockRC = false;
1116}; 1117};
1117 1118
1118void KServerSocket::newConnection ( int socket ) 1119void KServerSocket::newConnection ( int socket )
1119{ 1120{
1120 // qDebug("KServerSocket:New connection %d ", socket); 1121 // qDebug("KServerSocket:New connection %d ", socket);
1121 if ( mSocket ) { 1122 if ( mSocket ) {
1122 qDebug("KServerSocket::newConnection Socket deleted! "); 1123 qDebug("KServerSocket::newConnection Socket deleted! ");
1123 delete mSocket; 1124 delete mSocket;
1124 mSocket = 0; 1125 mSocket = 0;
1125 } 1126 }
1126 mSocket = new QSocket( this ); 1127 mSocket = new QSocket( this );
1127 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1128 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1128 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1129 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1129 mSocket->setSocket( socket ); 1130 mSocket->setSocket( socket );
1130} 1131}
1131 1132
1132void KServerSocket::discardClient() 1133void KServerSocket::discardClient()
1133{ 1134{
1134 //qDebug(" KServerSocket::discardClient()"); 1135 //qDebug(" KServerSocket::discardClient()");
1135 if ( mSocket ) { 1136 if ( mSocket ) {
1136 delete mSocket; 1137 delete mSocket;
1137 mSocket = 0; 1138 mSocket = 0;
1138 } 1139 }
1139 //emit endConnect(); 1140 //emit endConnect();
1140} 1141}
1141void KServerSocket::readClient() 1142void KServerSocket::readClient()
1142{ 1143{
1143 if ( blockRC ) 1144 if ( blockRC )
1144 return; 1145 return;
1145 if ( mSocket == 0 ) { 1146 if ( mSocket == 0 ) {
1146 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 1147 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
1147 return; 1148 return;
1148 } 1149 }
1149 //qDebug("KServerSocket::readClient()"); 1150 //qDebug("KServerSocket::readClient()");
1150 if ( mSocket->canReadLine() ) { 1151 if ( mSocket->canReadLine() ) {
1151 QString line = mSocket->readLine(); 1152 QString line = mSocket->readLine();
1152 //qDebug("KServerSocket readline: %s ", line.latin1()); 1153 //qDebug("KServerSocket readline: %s ", line.latin1());
1153 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 1154 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
1154 if ( tokens[0] == "GET" ) { 1155 if ( tokens[0] == "GET" ) {
1155 if ( tokens[1] == mPassWord ) { 1156 if ( tokens[1] == mPassWord ) {
1156 //emit sendFile( mSocket ); 1157 //emit sendFile( mSocket );
1157 bool ok = false; 1158 bool ok = false;
1158 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); 1159 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok);
1159 if ( ok ) { 1160 if ( ok ) {
1160 KSyncManager::mRequestedSyncEvent = dt; 1161 KSyncManager::mRequestedSyncEvent = dt;
1161 } 1162 }
1162 else 1163 else
1163 KSyncManager::mRequestedSyncEvent = QDateTime(); 1164 KSyncManager::mRequestedSyncEvent = QDateTime();
1164 send_file(); 1165 send_file();
1165 } 1166 }
1166 else { 1167 else {
1167 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); 1168 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"));
1168 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 1169 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
1169 } 1170 }
1170 } 1171 }
1171 if ( tokens[0] == "PUT" ) { 1172 if ( tokens[0] == "PUT" ) {
1172 if ( tokens[1] == mPassWord ) { 1173 if ( tokens[1] == mPassWord ) {
1173 //emit getFile( mSocket ); 1174 //emit getFile( mSocket );
1174 blockRC = true; 1175 blockRC = true;
1175 get_file(); 1176 get_file();
1176 } 1177 }
1177 else { 1178 else {
1178 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); 1179 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"));
1179 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 1180 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
1180 } 1181 }
1181 } 1182 }
1182 if ( tokens[0] == "STOP" ) { 1183 if ( tokens[0] == "STOP" ) {
1183 //emit endConnect(); 1184 //emit endConnect();
1184 end_connect(); 1185 end_connect();
1185 } 1186 }
1186 } 1187 }
1187} 1188}
1188void KServerSocket::end_connect() 1189void KServerSocket::end_connect()
1189{ 1190{
1190 delete mSyncActionDialog; 1191 delete mSyncActionDialog;
1191 mSyncActionDialog = 0; 1192 mSyncActionDialog = 0;
1192} 1193}
1193void KServerSocket::send_file() 1194void KServerSocket::send_file()
1194{ 1195{
1195 //qDebug("MainWindow::sendFile(QSocket* s) "); 1196 //qDebug("MainWindow::sendFile(QSocket* s) ");
1196 if ( mSyncActionDialog ) 1197 if ( mSyncActionDialog )
1197 delete mSyncActionDialog; 1198 delete mSyncActionDialog;
1198 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 1199 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
1199 mSyncActionDialog->setCaption(i18n("Received sync request")); 1200 mSyncActionDialog->setCaption(i18n("Received sync request"));
1200 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 );
1201 label->setAlignment ( Qt::AlignHCenter ); 1202 label->setAlignment ( Qt::AlignHCenter );
1202 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1203 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
1203 lay->addWidget( label); 1204 lay->addWidget( label);
1204 lay->setMargin(7); 1205 lay->setMargin(7);
1205 lay->setSpacing(7); 1206 lay->setSpacing(7);
1206 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1207 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1207 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); 1208 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent );
1208 if ( secs < 0 ) 1209 if ( secs < 0 )
1209 secs = secs * (-1); 1210 secs = secs * (-1);
1210 if ( secs > 30 ) 1211 if ( secs > 30 )
1211 //if ( true ) 1212 //if ( true )
1212 { 1213 {
1213 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 );
1214 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1215 QLabel* label = new QLabel( warning, mSyncActionDialog );
1215 label->setAlignment ( Qt::AlignHCenter ); 1216 label->setAlignment ( Qt::AlignHCenter );
1216 lay->addWidget( label); 1217 lay->addWidget( label);
1217 if ( secs > 180 ) 1218 if ( secs > 180 )
1218 { 1219 {
1219 if ( secs > 300 ) { 1220 if ( secs > 300 ) {
1220 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!"))) {
1221 qDebug("cancelled "); 1222 qDebug("cancelled ");
1222 return ; 1223 return ;
1223 } 1224 }
1224 } 1225 }
1225 QFont f = label->font(); 1226 QFont f = label->font();
1226 f.setPointSize ( f.pointSize() *2 ); 1227 f.setPointSize ( f.pointSize() *2 );
1227 f. setBold (true ); 1228 f. setBold (true );
1228 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1229 QLabel* label = new QLabel( warning, mSyncActionDialog );
1229 label->setFont( f ); 1230 label->setFont( f );
1230 warning = i18n("ADJUST\nYOUR\nCLOCKS!"); 1231 warning = i18n("ADJUST\nYOUR\nCLOCKS!");
1231 label->setText( warning ); 1232 label->setText( warning );
1232 label->setAlignment ( Qt::AlignHCenter ); 1233 label->setAlignment ( Qt::AlignHCenter );
1233 lay->addWidget( label); 1234 lay->addWidget( label);
1234 mSyncActionDialog->setFixedSize( 230, 300); 1235 mSyncActionDialog->setFixedSize( 230, 300);
1235 } else { 1236 } else {
1236 mSyncActionDialog->setFixedSize( 230, 200); 1237 mSyncActionDialog->setFixedSize( 230, 200);
1237 } 1238 }
1238 } else { 1239 } else {
1239 mSyncActionDialog->setFixedSize( 230, 120); 1240 mSyncActionDialog->setFixedSize( 230, 120);
1240 } 1241 }
1241 } else 1242 } else
1242 mSyncActionDialog->setFixedSize( 230, 120); 1243 mSyncActionDialog->setFixedSize( 230, 120);
1243 mSyncActionDialog->show(); 1244 mSyncActionDialog->show();
1244 mSyncActionDialog->raise(); 1245 mSyncActionDialog->raise();
1245 emit request_file(); 1246 emit request_file();
1246 qApp->processEvents(); 1247 qApp->processEvents();
1247 QString fileName = mFileName; 1248 QString fileName = mFileName;
1248 QFile file( fileName ); 1249 QFile file( fileName );
1249 if (!file.open( IO_ReadOnly ) ) { 1250 if (!file.open( IO_ReadOnly ) ) {
1250 delete mSyncActionDialog; 1251 delete mSyncActionDialog;
1251 mSyncActionDialog = 0; 1252 mSyncActionDialog = 0;
1252 qDebug("KSS::error open sync file: %s ", fileName.latin1()); 1253 qDebug("KSS::error open sync file: %s ", fileName.latin1());
1253 mSocket->close(); 1254 mSocket->close();
1254 if ( mSocket->state() == QSocket::Idle ) 1255 if ( mSocket->state() == QSocket::Idle )
1255 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1256 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1256 return ; 1257 return ;
1257 1258
1258 } 1259 }
1259 mSyncActionDialog->setCaption( i18n("Sending file...") ); 1260 mSyncActionDialog->setCaption( i18n("Sending file...") );
1260 QTextStream ts( &file ); 1261 QTextStream ts( &file );
1261 ts.setEncoding( QTextStream::Latin1 ); 1262 ts.setEncoding( QTextStream::Latin1 );
1262 1263
1263 QTextStream os( mSocket ); 1264 QTextStream os( mSocket );
1264 os.setEncoding( QTextStream::Latin1 ); 1265 os.setEncoding( QTextStream::Latin1 );
1265 while ( ! ts.atEnd() ) { 1266 while ( ! ts.atEnd() ) {
1266 os << ts.readLine() << "\r\n"; 1267 os << ts.readLine() << "\r\n";
1267 } 1268 }
1268 //os << ts.read(); 1269 //os << ts.read();
1269 file.close(); 1270 file.close();
1270 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 1271 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
1271 mSocket->close(); 1272 mSocket->close();
1272 if ( mSocket->state() == QSocket::Idle ) 1273 if ( mSocket->state() == QSocket::Idle )
1273 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1274 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1274} 1275}
1275void KServerSocket::get_file() 1276void KServerSocket::get_file()
1276{ 1277{
1277 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 1278 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
1278 1279
1279 piTime.start(); 1280 piTime.start();
1280 piFileString = ""; 1281 piFileString = "";
1281 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 1282 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
1282} 1283}
1283 1284
1284 1285
1285void KServerSocket::readBackFileFromSocket() 1286void KServerSocket::readBackFileFromSocket()
1286{ 1287{
1287 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 1288 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
1288 while ( mSocket->canReadLine () ) { 1289 while ( mSocket->canReadLine () ) {
1289 piTime.restart(); 1290 piTime.restart();
1290 QString line = mSocket->readLine (); 1291 QString line = mSocket->readLine ();
1291 piFileString += line; 1292 piFileString += line;
1292 //qDebug("readline: %s ", line.latin1()); 1293 //qDebug("readline: %s ", line.latin1());
1293 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 1294 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
1294 1295
1295 } 1296 }
1296 if ( piTime.elapsed () < 3000 ) { 1297 if ( piTime.elapsed () < 3000 ) {
1297 // wait for more 1298 // wait for more
1298 //qDebug("waitformore "); 1299 //qDebug("waitformore ");
1299 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 1300 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
1300 return; 1301 return;
1301 } 1302 }
1302 QString fileName = mFileName; 1303 QString fileName = mFileName;
1303 QFile file ( fileName ); 1304 QFile file ( fileName );
1304 if (!file.open( IO_WriteOnly ) ) { 1305 if (!file.open( IO_WriteOnly ) ) {
1305 delete mSyncActionDialog; 1306 delete mSyncActionDialog;
1306 mSyncActionDialog = 0; 1307 mSyncActionDialog = 0;
1307 qDebug("KSS:Error open read back file "); 1308 qDebug("KSS:Error open read back file ");
1308 piFileString = ""; 1309 piFileString = "";
1309 emit file_received( false ); 1310 emit file_received( false );
1310 blockRC = false; 1311 blockRC = false;
1311 return ; 1312 return ;
1312 1313
1313 } 1314 }
1314 1315
1315 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1316 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1316 QTextStream ts ( &file ); 1317 QTextStream ts ( &file );
1317 ts.setEncoding( QTextStream::Latin1 ); 1318 ts.setEncoding( QTextStream::Latin1 );
1318 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 1319 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1319 ts << piFileString; 1320 ts << piFileString;
1320 mSocket->close(); 1321 mSocket->close();
1321 if ( mSocket->state() == QSocket::Idle ) 1322 if ( mSocket->state() == QSocket::Idle )
1322 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1323 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1323 file.close(); 1324 file.close();
1324 piFileString = ""; 1325 piFileString = "";
1325 emit file_received( true ); 1326 emit file_received( true );
1326 delete mSyncActionDialog; 1327 delete mSyncActionDialog;
1327 mSyncActionDialog = 0; 1328 mSyncActionDialog = 0;
1328 blockRC = false; 1329 blockRC = false;
1329 1330
1330} 1331}
1331 1332
1332KCommandSocket::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 )
1333{ 1334{
1334 mPassWord = password; 1335 mPassWord = password;
1335 mSocket = 0; 1336 mSocket = 0;
1336 mPort = port; 1337 mPort = port;
1337 mHost = host; 1338 mHost = host;
1338 1339
1339 mRetVal = quiet; 1340 mRetVal = quiet;
1340 mTimerSocket = new QTimer ( this ); 1341 mTimerSocket = new QTimer ( this );
1341 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); 1342 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
1342} 1343}
1343void KCommandSocket::readFile( QString fn ) 1344void KCommandSocket::readFile( QString fn )
1344{ 1345{
1345 if ( !mSocket ) { 1346 if ( !mSocket ) {
1346 mSocket = new QSocket( this ); 1347 mSocket = new QSocket( this );
1347 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1348 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1348 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1349 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1349 } 1350 }
1350 mFileString = ""; 1351 mFileString = "";
1351 mFileName = fn; 1352 mFileName = fn;
1352 mFirst = true; 1353 mFirst = true;
1353 mSocket->connectToHost( mHost, mPort ); 1354 mSocket->connectToHost( mHost, mPort );
1354 QTextStream os( mSocket ); 1355 QTextStream os( mSocket );
1355 os.setEncoding( QTextStream::Latin1 ); 1356 os.setEncoding( QTextStream::Latin1 );
1356 1357
1357 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 );
1358 os << "GET " << mPassWord << curDt <<"\r\n"; 1359 os << "GET " << mPassWord << curDt <<"\r\n";
1359 mTimerSocket->start( 300000 ); 1360 mTimerSocket->start( 300000 );
1360} 1361}
1361 1362
1362void KCommandSocket::writeFile( QString fileName ) 1363void KCommandSocket::writeFile( QString fileName )
1363{ 1364{
1364 if ( !mSocket ) { 1365 if ( !mSocket ) {
1365 mSocket = new QSocket( this ); 1366 mSocket = new QSocket( this );
1366 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1367 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1367 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 1368 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1368 } 1369 }
1369 mFileName = fileName ; 1370 mFileName = fileName ;
1370 mSocket->connectToHost( mHost, mPort ); 1371 mSocket->connectToHost( mHost, mPort );
1371} 1372}
1372void KCommandSocket::writeFileToSocket() 1373void KCommandSocket::writeFileToSocket()
1373{ 1374{
1374 QFile file2( mFileName ); 1375 QFile file2( mFileName );
1375 if (!file2.open( IO_ReadOnly ) ) { 1376 if (!file2.open( IO_ReadOnly ) ) {
1376 mRetVal= errorW; 1377 mRetVal= errorW;
1377 mSocket->close(); 1378 mSocket->close();
1378 if ( mSocket->state() == QSocket::Idle ) 1379 if ( mSocket->state() == QSocket::Idle )
1379 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1380 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1380 return ; 1381 return ;
1381 } 1382 }
1382 QTextStream ts2( &file2 ); 1383 QTextStream ts2( &file2 );
1383 ts2.setEncoding( QTextStream::Latin1 ); 1384 ts2.setEncoding( QTextStream::Latin1 );
1384 QTextStream os2( mSocket ); 1385 QTextStream os2( mSocket );
1385 os2.setEncoding( QTextStream::Latin1 ); 1386 os2.setEncoding( QTextStream::Latin1 );
1386 os2 << "PUT " << mPassWord << "\r\n";; 1387 os2 << "PUT " << mPassWord << "\r\n";;
1387 while ( ! ts2.atEnd() ) { 1388 while ( ! ts2.atEnd() ) {
1388 os2 << ts2.readLine() << "\r\n"; 1389 os2 << ts2.readLine() << "\r\n";
1389 } 1390 }
1390 mRetVal= successW; 1391 mRetVal= successW;
1391 file2.close(); 1392 file2.close();
1392 mSocket->close(); 1393 mSocket->close();
1393 if ( mSocket->state() == QSocket::Idle ) 1394 if ( mSocket->state() == QSocket::Idle )
1394 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1395 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1395} 1396}
1396void KCommandSocket::sendStop() 1397void KCommandSocket::sendStop()
1397{ 1398{
1398 if ( !mSocket ) { 1399 if ( !mSocket ) {
1399 mSocket = new QSocket( this ); 1400 mSocket = new QSocket( this );
1400 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1401 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1401 } 1402 }
1402 mSocket->connectToHost( mHost, mPort ); 1403 mSocket->connectToHost( mHost, mPort );
1403 QTextStream os2( mSocket ); 1404 QTextStream os2( mSocket );
1404 os2.setEncoding( QTextStream::Latin1 ); 1405 os2.setEncoding( QTextStream::Latin1 );
1405 os2 << "STOP\r\n"; 1406 os2 << "STOP\r\n";
1406 mSocket->close(); 1407 mSocket->close();
1407 if ( mSocket->state() == QSocket::Idle ) 1408 if ( mSocket->state() == QSocket::Idle )
1408 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1409 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1409} 1410}
1410 1411
1411void KCommandSocket::startReadFileFromSocket() 1412void KCommandSocket::startReadFileFromSocket()
1412{ 1413{
1413 if ( ! mFirst ) 1414 if ( ! mFirst )
1414 return; 1415 return;
1415 mFirst = false; 1416 mFirst = false;
1416 mTimerSocket->stop(); 1417 mTimerSocket->stop();
1417 mFileString = ""; 1418 mFileString = "";
1418 mTime.start(); 1419 mTime.start();
1419 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 1420 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
1420 1421
1421} 1422}
1422void KCommandSocket::readFileFromSocket() 1423void KCommandSocket::readFileFromSocket()
1423{ 1424{
1424 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 1425 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
1425 while ( mSocket->canReadLine () ) { 1426 while ( mSocket->canReadLine () ) {
1426 mTime.restart(); 1427 mTime.restart();
1427 QString line = mSocket->readLine (); 1428 QString line = mSocket->readLine ();
1428 mFileString += line; 1429 mFileString += line;
1429 //qDebug("readline: %s ", line.latin1()); 1430 //qDebug("readline: %s ", line.latin1());
1430 } 1431 }
1431 if ( mTime.elapsed () < 3000 ) { 1432 if ( mTime.elapsed () < 3000 ) {
1432 // wait for more 1433 // wait for more
1433 //qDebug("waitformore "); 1434 //qDebug("waitformore ");
1434 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 1435 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
1435 return; 1436 return;
1436 } 1437 }
1437 QString fileName = mFileName; 1438 QString fileName = mFileName;
1438 QFile file ( fileName ); 1439 QFile file ( fileName );
1439 if (!file.open( IO_WriteOnly ) ) { 1440 if (!file.open( IO_WriteOnly ) ) {
1440 mFileString = ""; 1441 mFileString = "";
1441 mRetVal = errorR; 1442 mRetVal = errorR;
1442 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() );
1443 deleteSocket(); 1444 deleteSocket();
1444 return ; 1445 return ;
1445 1446
1446 } 1447 }
1447 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1448 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1448 QTextStream ts ( &file ); 1449 QTextStream ts ( &file );
1449 ts.setEncoding( QTextStream::Latin1 ); 1450 ts.setEncoding( QTextStream::Latin1 );
1450 ts << mFileString; 1451 ts << mFileString;
1451 file.close(); 1452 file.close();
1452 mFileString = ""; 1453 mFileString = "";
1453 mRetVal = successR; 1454 mRetVal = successR;
1454 mSocket->close(); 1455 mSocket->close();
1455 // if state is not idle, deleteSocket(); is called via 1456 // if state is not idle, deleteSocket(); is called via
1456 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1457 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1457 if ( mSocket->state() == QSocket::Idle ) 1458 if ( mSocket->state() == QSocket::Idle )
1458 deleteSocket(); 1459 deleteSocket();
1459} 1460}
1460 1461
1461void KCommandSocket::deleteSocket() 1462void KCommandSocket::deleteSocket()
1462{ 1463{
1463 //qDebug("KCommandSocket::deleteSocket() "); 1464 //qDebug("KCommandSocket::deleteSocket() ");
1464 if ( mTimerSocket->isActive () ) { 1465 if ( mTimerSocket->isActive () ) {
1465 mTimerSocket->stop(); 1466 mTimerSocket->stop();
1466 mRetVal = errorTO; 1467 mRetVal = errorTO;
1467 qDebug("Connection to remote host timed out"); 1468 qDebug("Connection to remote host timed out");
1468 if ( mSocket ) { 1469 if ( mSocket ) {
1469 mSocket->close(); 1470 mSocket->close();
1470 //if ( mSocket->state() == QSocket::Idle ) 1471 //if ( mSocket->state() == QSocket::Idle )
1471 // deleteSocket(); 1472 // deleteSocket();
1472 delete mSocket; 1473 delete mSocket;
1473 mSocket = 0; 1474 mSocket = 0;
1474 } 1475 }
1475 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? "));
1476 emit commandFinished( this, mRetVal ); 1477 emit commandFinished( this, mRetVal );
1477 return; 1478 return;
1478 } 1479 }
1479 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 1480 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
1480 if ( mSocket) 1481 if ( mSocket)
1481 delete mSocket; 1482 delete mSocket;
1482 mSocket = 0; 1483 mSocket = 0;
1483 emit commandFinished( this, mRetVal ); 1484 emit commandFinished( this, mRetVal );
1484} 1485}
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp
index 2101bbb..3db58ec 100644
--- a/libkdepim/ksyncprefsdialog.cpp
+++ b/libkdepim/ksyncprefsdialog.cpp
@@ -1,830 +1,830 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qgroupbox.h> 26#include <qgroupbox.h>
27#include <qbuttongroup.h> 27#include <qbuttongroup.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qfont.h> 29#include <qfont.h>
30#include <qslider.h> 30#include <qslider.h>
31#include <qfile.h> 31#include <qfile.h>
32#include <qdir.h> 32#include <qdir.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qvbox.h> 35#include <qvbox.h>
36#include <qhbox.h> 36#include <qhbox.h>
37#include <qspinbox.h> 37#include <qspinbox.h>
38#include <qdatetime.h> 38#include <qdatetime.h>
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qradiobutton.h> 40#include <qradiobutton.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qstrlist.h> 42#include <qstrlist.h>
43#include <qapplication.h> 43#include <qapplication.h>
44#include <qlayout.h> 44#include <qlayout.h>
45#include <qscrollview.h> 45#include <qscrollview.h>
46#include <qvgroupbox.h> 46#include <qvgroupbox.h>
47#include <qhgroupbox.h> 47#include <qhgroupbox.h>
48 48
49#include <kcolorbutton.h> 49#include <kcolorbutton.h>
50#include <kdebug.h> 50#include <kdebug.h>
51#include <klocale.h> 51#include <klocale.h>
52#include <kglobal.h> 52#include <kglobal.h>
53#include <kfontdialog.h> 53#include <kfontdialog.h>
54#include <kmessagebox.h> 54#include <kmessagebox.h>
55#include <kcolordialog.h> 55#include <kcolordialog.h>
56#include <kiconloader.h> 56#include <kiconloader.h>
57#include <kemailsettings.h> 57#include <kemailsettings.h>
58#include <kstandarddirs.h> 58#include <kstandarddirs.h>
59#include <kfiledialog.h> 59#include <kfiledialog.h>
60#include <kmessagebox.h> 60#include <kmessagebox.h>
61 61
62//#include <kurlrequester.h> 62//#include <kurlrequester.h>
63#include <klineedit.h> 63#include <klineedit.h>
64#include "ksyncprofile.h" 64#include "ksyncprofile.h"
65 65
66 66
67//#include "koprefs.h" 67//#include "koprefs.h"
68 68
69#include "ksyncprefsdialog.h" 69#include "ksyncprefsdialog.h"
70//#include "koglobals.h" 70//#include "koglobals.h"
71 71
72 72
73KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) : 73KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) :
74 KDialog(parent,name,true) 74 KDialog(parent,name,true)
75{ 75{
76 76
77 setCaption( i18n("Synchronization Preferences")); 77 setCaption( i18n("Synchronization Preferences"));
78 78
79 mSyncProfiles.setAutoDelete( true ); 79 mSyncProfiles.setAutoDelete( true );
80 setupSyncAlgTab(); 80 setupSyncAlgTab();
81} 81}
82 82
83 83
84KSyncPrefsDialog::~KSyncPrefsDialog() 84KSyncPrefsDialog::~KSyncPrefsDialog()
85{ 85{
86} 86}
87 87
88void KSyncPrefsDialog::setupSyncAlgTab() 88void KSyncPrefsDialog::setupSyncAlgTab()
89{ 89{
90 QLabel * lab; 90 QLabel * lab;
91 //QFrame *page = addPage(i18n("Sync Prefs"),0,0); 91 //QFrame *page = addPage(i18n("Sync Prefs"),0,0);
92 QVBox * mainbox = new QVBox( this ); 92 QVBox * mainbox = new QVBox( this );
93 QScrollView* sv = new QScrollView( mainbox ); 93 QScrollView* sv = new QScrollView( mainbox );
94 QHBoxLayout * lay = new QHBoxLayout( this ); 94 QHBoxLayout * lay = new QHBoxLayout( this );
95 lay->addWidget( mainbox ); 95 lay->addWidget( mainbox );
96 QHBox * b_box = new QHBox( mainbox ); 96 QHBox * b_box = new QHBox( mainbox );
97 97
98 QPushButton* button = new QPushButton( i18n("Ok"), b_box ); 98 QPushButton* button = new QPushButton( i18n("Ok"), b_box );
99 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); 99 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) );
100 button = new QPushButton( i18n("Cancel"), b_box ); 100 button = new QPushButton( i18n("Cancel"), b_box );
101 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); 101 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) );
102 //QBoxLayout * sl = new QVBoxLayout(this ); 102 //QBoxLayout * sl = new QVBoxLayout(this );
103 //sl->addWidget ( sv ); 103 //sl->addWidget ( sv );
104 sv->setResizePolicy ( QScrollView::AutoOneFit ); 104 sv->setResizePolicy ( QScrollView::AutoOneFit );
105 QFrame *topFrame = new QFrame ( sv ); 105 QFrame *topFrame = new QFrame ( sv );
106 sv->addChild( topFrame ); 106 sv->addChild( topFrame );
107 mSetupSyncAlgTab = topFrame; 107 mSetupSyncAlgTab = topFrame;
108 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 108 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
109 topLayout->setSpacing(spacingHint()); 109 topLayout->setSpacing(spacingHint());
110 topLayout->setMargin(marginHint()); 110 topLayout->setMargin(marginHint());
111 111
112 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); 112 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame);
113 int iii = 0; 113 int iii = 0;
114 //topLayout->addMultiCellWidget(lab , iii,iii,0,1); 114 //topLayout->addMultiCellWidget(lab , iii,iii,0,1);
115 //++iii; 115 //++iii;
116 116
117 mMyMachineName = new QLineEdit(topFrame); 117 mMyMachineName = new QLineEdit(topFrame);
118 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); 118 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame);
119 topLayout->addWidget(lab ,iii,0); 119 topLayout->addWidget(lab ,iii,0);
120 topLayout->addWidget(mMyMachineName,iii,1); 120 topLayout->addWidget(mMyMachineName,iii,1);
121 ++iii; 121 ++iii;
122 122
123 QHBox* buttonbox = new QHBox( topFrame); 123 QHBox* buttonbox = new QHBox( topFrame);
124 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); 124 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1);
125 ++iii; 125 ++iii;
126 button = new QPushButton( i18n("New profile"), buttonbox ); 126 button = new QPushButton( i18n("New profile"), buttonbox );
127 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); 127 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) );
128 128
129 button = new QPushButton( i18n("Clone profile"), buttonbox ); 129 button = new QPushButton( i18n("Clone profile"), buttonbox );
130 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); 130 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) );
131 131
132 button = new QPushButton( i18n("Delete profile"), buttonbox ); 132 button = new QPushButton( i18n("Delete profile"), buttonbox );
133 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); 133 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) );
134 134
135 mProfileBox = new QComboBox(topFrame); 135 mProfileBox = new QComboBox(topFrame);
136 mProfileBox->setEditable ( true ); 136 mProfileBox->setEditable ( true );
137 mProfileBox->setInsertionPolicy(QComboBox::NoInsertion); 137 mProfileBox->setInsertionPolicy(QComboBox::NoInsertion);
138 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); 138 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) );
139 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); 139 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) );
140 140
141 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); 141 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame);
142 topLayout->addWidget(lab ,iii,0); 142 topLayout->addWidget(lab ,iii,0);
143 topLayout->addWidget(mProfileBox, iii,1); 143 topLayout->addWidget(mProfileBox, iii,1);
144 ++iii; 144 ++iii;
145 145
146 146
147 147
148 QHGroupBox *iims = new QHGroupBox( i18n("Multiple Sync options"), topFrame); 148 QHGroupBox *iims = new QHGroupBox( i18n("Multiple Sync options"), topFrame);
149 new QLabel( i18n("Include in multiple "), iims ); 149 new QLabel( i18n("Include in multiple "), iims );
150 mIncludeInRing = new QCheckBox( i18n("calendar "), iims ); 150 mIncludeInRing = new QCheckBox( i18n("calendar "), iims );
151 mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims ); 151 mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims );
152 mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims ); 152 mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims );
153 new QLabel( i18n(" sync"), iims ); 153 new QLabel( i18n(" sync"), iims );
154 topLayout->addMultiCellWidget(iims, iii,iii,0,1); 154 topLayout->addMultiCellWidget(iims, iii,iii,0,1);
155 ++iii; 155 ++iii;
156 QVGroupBox* gb0 = new QVGroupBox( i18n("Sync algo options"), topFrame); 156 QVGroupBox* gb0 = new QVGroupBox( i18n("Sync algo options"), topFrame);
157 topLayout->addMultiCellWidget(gb0, iii,iii,0,1); 157 topLayout->addMultiCellWidget(gb0, iii,iii,0,1);
158 ++iii; 158 ++iii;
159 QButtonGroup* gr; 159 QButtonGroup* gr;
160 { 160 {
161 QVGroupBox* topFrame = gb0; 161 QVGroupBox* topFrame = gb0;
162 162
163 163
164 164
165 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); 165 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame );
166 //topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); 166 //topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1);
167 //++iii; 167 //++iii;
168 gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); 168 gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame);
169 //topLayout->addMultiCellWidget(gr, iii,iii,0,1); 169 //topLayout->addMultiCellWidget(gr, iii,iii,0,1);
170 //++iii; 170 //++iii;
171 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); 171 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr );
172 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); 172 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr );
173 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); 173 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr );
174 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); 174 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr );
175 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); 175 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr );
176 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); 176 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr );
177 // both = new QRadioButton ( i18n("Take both on conflict"), gr ); 177 // both = new QRadioButton ( i18n("Take both on conflict"), gr );
178 178
179 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); 179 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame );
180 //topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); 180 //topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1);
181 //++iii; 181 //++iii;
182 182
183 QHGroupBox* gb5 = new QHGroupBox( i18n("Apply filter when adding data to local:"), topFrame); 183 QHGroupBox* gb5 = new QHGroupBox( i18n("Apply filter when adding data to local:"), topFrame);
184 QVBox * fibo2 = new QVBox ( gb5 ); 184 QVBox * fibo2 = new QVBox ( gb5 );
185 new QLabel ( i18n("Incoming calendar filter:"), fibo2 ); 185 new QLabel ( i18n("Incoming calendar filter:"), fibo2 );
186 mFilterInCal = new QComboBox( fibo2 ); 186 mFilterInCal = new QComboBox( fibo2 );
187 fibo2 = new QVBox ( gb5 ); 187 fibo2 = new QVBox ( gb5 );
188 new QLabel ( i18n("Incoming adressbook filter:"), fibo2 ); 188 new QLabel ( i18n("Incoming addressbook filter:"), fibo2 );
189 mFilterInAB = new QComboBox( fibo2 ); 189 mFilterInAB = new QComboBox( fibo2 );
190 190
191 mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame ); 191 mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame );
192 // topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); 192 // topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1);
193 // ++iii; 193 // ++iii;
194 194
195 QVGroupBox* gb2 = new QVGroupBox( i18n("Write back options"), topFrame); 195 QVGroupBox* gb2 = new QVGroupBox( i18n("Write back options"), topFrame);
196 //topLayout->addMultiCellWidget(gb2, iii,iii,0,1); 196 //topLayout->addMultiCellWidget(gb2, iii,iii,0,1);
197 //++iii; 197 //++iii;
198 { 198 {
199 QVGroupBox*topFrame = gb2; 199 QVGroupBox*topFrame = gb2;
200 mWriteBackExisting= new QCheckBox( i18n("Write back (on remote) existing entries only"), topFrame ); 200 mWriteBackExisting= new QCheckBox( i18n("Write back (on remote) existing entries only"), topFrame );
201 QHGroupBox* gb4 = new QHGroupBox( i18n("Apply filter when adding data to remote:"), topFrame); 201 QHGroupBox* gb4 = new QHGroupBox( i18n("Apply filter when adding data to remote:"), topFrame);
202 QVBox * fibo = new QVBox ( gb4 ); 202 QVBox * fibo = new QVBox ( gb4 );
203 new QLabel ( i18n("Outgoing calendar filter:"), fibo ); 203 new QLabel ( i18n("Outgoing calendar filter:"), fibo );
204 mFilterOutCal = new QComboBox( fibo ); 204 mFilterOutCal = new QComboBox( fibo );
205 fibo = new QVBox ( gb4 ); 205 fibo = new QVBox ( gb4 );
206 new QLabel ( i18n("Outgoing addressbook filter:"), fibo ); 206 new QLabel ( i18n("Outgoing addressbook filter:"), fibo );
207 mFilterOutAB = new QComboBox( fibo ); 207 mFilterOutAB = new QComboBox( fibo );
208 //topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); 208 //topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1);
209 //++iii; 209 //++iii;
210 mWriteBackFuture= new QCheckBox( i18n("Write back (calendar) entries for time period only"), topFrame ); 210 mWriteBackFuture= new QCheckBox( i18n("Write back (calendar) entries for time period only"), topFrame );
211 //topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1); 211 //topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1);
212 //++iii; 212 //++iii;
213 QHGroupBox* gb3 = new QHGroupBox( i18n("Time period"), topFrame); 213 QHGroupBox* gb3 = new QHGroupBox( i18n("Time period"), topFrame);
214 connect ( mWriteBackFuture, SIGNAL( toggled ( bool ) ), gb3, SLOT ( setEnabled ( bool ) ) ); 214 connect ( mWriteBackFuture, SIGNAL( toggled ( bool ) ), gb3, SLOT ( setEnabled ( bool ) ) );
215 new QLabel( i18n("From ") , gb3 ); 215 new QLabel( i18n("From ") , gb3 );
216 mWriteBackPastWeeks= new QSpinBox(1,104, 1, gb3); 216 mWriteBackPastWeeks= new QSpinBox(1,104, 1, gb3);
217 new QLabel( i18n(" weeks in the past to ") , gb3 ); 217 new QLabel( i18n(" weeks in the past to ") , gb3 );
218 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, gb3); 218 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, gb3);
219 new QLabel( i18n(" weeks in the future ") , gb3 ); 219 new QLabel( i18n(" weeks in the future ") , gb3 );
220 //topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1); 220 //topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1);
221 //++iii; 221 //++iii;
222 gb3->setEnabled( false ); 222 gb3->setEnabled( false );
223 connect ( mWriteBackExisting, SIGNAL( toggled ( bool ) ), gb4, SLOT ( setDisabled ( bool ) ) ); 223 connect ( mWriteBackExisting, SIGNAL( toggled ( bool ) ), gb4, SLOT ( setDisabled ( bool ) ) );
224 } 224 }
225 connect ( mWriteBackFile, SIGNAL( toggled ( bool ) ), gb2, SLOT ( setEnabled ( bool ) ) ); 225 connect ( mWriteBackFile, SIGNAL( toggled ( bool ) ), gb2, SLOT ( setEnabled ( bool ) ) );
226 226
227 } 227 }
228 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); 228 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame);
229 gr = proGr; 229 gr = proGr;
230 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 230 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
231 ++iii; 231 ++iii;
232 mIsLocal = new QRadioButton ( i18n("Local file"), gr ); 232 mIsLocal = new QRadioButton ( i18n("Local file"), gr );
233 mIsPi = new QRadioButton ( i18n("Pi-Sync ( direct Kx/Pi to Kx/Pi sync )"), gr ); 233 mIsPi = new QRadioButton ( i18n("Pi-Sync ( direct Kx/Pi to Kx/Pi sync )"), gr );
234 connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 234 connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
235 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); 235 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr );
236 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 236 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
237 mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr ); 237 mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr );
238 connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 238 connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
239 239
240 QVGroupBox* gb1 = new QVGroupBox( i18n("Profile kind specific settings"), topFrame); 240 QVGroupBox* gb1 = new QVGroupBox( i18n("Profile kind specific settings"), topFrame);
241 topLayout->addMultiCellWidget(gb1, iii,iii,0,1); 241 topLayout->addMultiCellWidget(gb1, iii,iii,0,1);
242 ++iii; 242 ++iii;
243 243
244 // ****************************************** 244 // ******************************************
245 // Profile kind specific settings 245 // Profile kind specific settings
246 { 246 {
247 // *** phone ******************************* 247 // *** phone *******************************
248 QVGroupBox* topFrame = gb1; 248 QVGroupBox* topFrame = gb1;
249 phoneWidget = new QVBox( topFrame); 249 phoneWidget = new QVBox( topFrame);
250 //topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1); 250 //topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1);
251 //++iii; 251 //++iii;
252 mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget ); 252 mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget );
253 QHBox* temphb = new QHBox( phoneWidget ); 253 QHBox* temphb = new QHBox( phoneWidget );
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 button = new QPushButton( i18n("Help..."), temphb ); 256 button = new QPushButton( i18n("Help..."), temphb );
257 connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) ); 257 connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) );
258 258
259 259
260 temphb = new QHBox( phoneWidget ); 260 temphb = new QHBox( phoneWidget );
261 new QLabel( i18n("Connection: "), temphb ); 261 new QLabel( i18n("Connection: "), temphb );
262 mPhoneConnection = new QLineEdit( temphb); 262 mPhoneConnection = new QLineEdit( temphb);
263 button = new QPushButton( i18n("Help..."), temphb ); 263 button = new QPushButton( i18n("Help..."), temphb );
264 connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) ); 264 connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) );
265 265
266 266
267 temphb = new QHBox( phoneWidget ); 267 temphb = new QHBox( phoneWidget );
268 new QLabel( i18n("Model(opt.): "), temphb ); 268 new QLabel( i18n("Model(opt.): "), temphb );
269 mPhoneModel = new QLineEdit( temphb); 269 mPhoneModel = new QLineEdit( temphb);
270 button = new QPushButton( i18n("Help..."), temphb ); 270 button = new QPushButton( i18n("Help..."), temphb );
271 connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) ); 271 connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) );
272 272
273 // *** local******************************* 273 // *** local*******************************
274 localFileWidget = new QVBox( topFrame); 274 localFileWidget = new QVBox( topFrame);
275 //topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); 275 //topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1);
276 //++iii; 276 //++iii;
277 temphb = new QHBox( localFileWidget ); 277 temphb = new QHBox( localFileWidget );
278 278
279 lab = new QLabel( i18n("Local file Cal:"), temphb ); 279 lab = new QLabel( i18n("Local file Cal:"), temphb );
280 lab = new QLabel( i18n("Local file ABook:"), temphb ); 280 lab = new QLabel( i18n("Local file ABook:"), temphb );
281 lab = new QLabel( i18n("Local file PWMgr:"), temphb ); 281 lab = new QLabel( i18n("Local file PWMgr:"), temphb );
282 temphb = new QHBox( localFileWidget ); 282 temphb = new QHBox( localFileWidget );
283 button = new QPushButton( i18n("Choose..."), temphb ); 283 button = new QPushButton( i18n("Choose..."), temphb );
284 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); 284 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) );
285 button = new QPushButton( i18n("Choose..."), temphb ); 285 button = new QPushButton( i18n("Choose..."), temphb );
286 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) ); 286 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) );
287 button = new QPushButton( i18n("Choose..."), temphb ); 287 button = new QPushButton( i18n("Choose..."), temphb );
288 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) ); 288 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) );
289 temphb = new QHBox( localFileWidget ); 289 temphb = new QHBox( localFileWidget );
290 290
291 mRemoteFile = new QLineEdit( temphb); 291 mRemoteFile = new QLineEdit( temphb);
292 mRemoteFileAB = new QLineEdit( temphb); 292 mRemoteFileAB = new QLineEdit( temphb);
293 mRemoteFilePWM = new QLineEdit( temphb); 293 mRemoteFilePWM = new QLineEdit( temphb);
294 mIsKapiFileL = new QCheckBox( i18n("Addressbook file (*.vcf) is used by KA/Pi"), localFileWidget ); 294 mIsKapiFileL = new QCheckBox( i18n("Addressbook file (*.vcf) is used by KA/Pi"), localFileWidget );
295 295
296 296
297 // *** remote******************************* 297 // *** remote*******************************
298 remoteFileWidget = new QVBox( topFrame); 298 remoteFileWidget = new QVBox( topFrame);
299 //topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); 299 //topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1);
300 //++iii; 300 //++iii;
301 temphb = new QHBox( remoteFileWidget ); 301 temphb = new QHBox( remoteFileWidget );
302 new QLabel( i18n("Calendar:"), temphb); 302 new QLabel( i18n("Calendar:"), temphb);
303 new QLabel( i18n("AddressBook:"), temphb); 303 new QLabel( i18n("AddressBook:"), temphb);
304 new QLabel( i18n("PWManager:"), temphb); 304 new QLabel( i18n("PWManager:"), temphb);
305 305
306 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); 306 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget);
307 temphb = new QHBox( remoteFileWidget ); 307 temphb = new QHBox( remoteFileWidget );
308 mRemotePrecommand = new QLineEdit(temphb); 308 mRemotePrecommand = new QLineEdit(temphb);
309 mRemotePrecommandAB = new QLineEdit(temphb); 309 mRemotePrecommandAB = new QLineEdit(temphb);
310 mRemotePrecommandPWM = new QLineEdit(temphb); 310 mRemotePrecommandPWM = new QLineEdit(temphb);
311 311
312 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); 312 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget);
313 temphb = new QHBox( remoteFileWidget ); 313 temphb = new QHBox( remoteFileWidget );
314 mLocalTempFile = new QLineEdit(temphb); 314 mLocalTempFile = new QLineEdit(temphb);
315 mLocalTempFileAB = new QLineEdit(temphb); 315 mLocalTempFileAB = new QLineEdit(temphb);
316 mLocalTempFilePWM = new QLineEdit(temphb); 316 mLocalTempFilePWM = new QLineEdit(temphb);
317 317
318 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); 318 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget);
319 temphb = new QHBox( remoteFileWidget ); 319 temphb = new QHBox( remoteFileWidget );
320 mRemotePostcommand = new QLineEdit(temphb ); 320 mRemotePostcommand = new QLineEdit(temphb );
321 mRemotePostcommandAB = new QLineEdit(temphb ); 321 mRemotePostcommandAB = new QLineEdit(temphb );
322 mRemotePostcommandPWM = new QLineEdit(temphb ); 322 mRemotePostcommandPWM = new QLineEdit(temphb );
323 mIsKapiFileR = new QCheckBox( i18n("Addressbook file is used by KA/Pi"), remoteFileWidget ); 323 mIsKapiFileR = new QCheckBox( i18n("Addressbook file is used by KA/Pi"), remoteFileWidget );
324 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); 324 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget);
325 temphb = new QHBox( remoteFileWidget ); 325 temphb = new QHBox( remoteFileWidget );
326 button = new QPushButton( i18n("ssh/scp"), temphb ); 326 button = new QPushButton( i18n("ssh/scp"), temphb );
327 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); 327 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) );
328 button = new QPushButton( i18n("ftp"), temphb ); 328 button = new QPushButton( i18n("ftp"), temphb );
329 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); 329 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) );
330 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); 330 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget);
331 331
332 // *** pi-sync******************************* 332 // *** pi-sync*******************************
333 piWidget = new QVBox( topFrame); 333 piWidget = new QVBox( topFrame);
334 //topLayout->addMultiCellWidget(piWidget, iii,iii,0,1); 334 //topLayout->addMultiCellWidget(piWidget, iii,iii,0,1);
335 //++iii; 335 //++iii;
336 temphb = new QHBox( piWidget ); 336 temphb = new QHBox( piWidget );
337 new QLabel( i18n("Calendar:"), temphb); 337 new QLabel( i18n("Calendar:"), temphb);
338 new QLabel( i18n("AddressBook:"), temphb); 338 new QLabel( i18n("AddressBook:"), temphb);
339 new QLabel( i18n("PWManager:"), temphb); 339 new QLabel( i18n("PWManager:"), temphb);
340 340
341 lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget); 341 lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget);
342 temphb = new QHBox( piWidget ); 342 temphb = new QHBox( piWidget );
343 mRemotePw = new QLineEdit(temphb); 343 mRemotePw = new QLineEdit(temphb);
344 mRemotePwAB = new QLineEdit(temphb); 344 mRemotePwAB = new QLineEdit(temphb);
345 mRemotePwPWM = new QLineEdit(temphb); 345 mRemotePwPWM = new QLineEdit(temphb);
346 346
347 lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget); 347 lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget);
348 temphb = new QHBox( piWidget ); 348 temphb = new QHBox( piWidget );
349 mRemoteIP = new QLineEdit(temphb); 349 mRemoteIP = new QLineEdit(temphb);
350 mRemoteIPAB = new QLineEdit(temphb); 350 mRemoteIPAB = new QLineEdit(temphb);
351 mRemoteIPPWM = new QLineEdit(temphb); 351 mRemoteIPPWM = new QLineEdit(temphb);
352 352
353 lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget); 353 lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget);
354 temphb = new QHBox( piWidget ); 354 temphb = new QHBox( piWidget );
355 mRemotePort = new QLineEdit(temphb); 355 mRemotePort = new QLineEdit(temphb);
356 mRemotePortAB = new QLineEdit(temphb); 356 mRemotePortAB = new QLineEdit(temphb);
357 mRemotePortPWM = new QLineEdit(temphb); 357 mRemotePortPWM = new QLineEdit(temphb);
358 } 358 }
359 // ****************************************** 359 // ******************************************
360 // Profile kind specific settings END 360 // Profile kind specific settings END
361 361
362} 362}
363 363
364void KSyncPrefsDialog::readFilter() 364void KSyncPrefsDialog::readFilter()
365{ 365{
366 mFilterKapi.clear(); 366 mFilterKapi.clear();
367 mFilterKopi.clear(); 367 mFilterKopi.clear();
368 KConfig cfgko(locateLocal("config","korganizerrc")); 368 KConfig cfgko(locateLocal("config","korganizerrc"));
369 KConfig cfgka(locateLocal("config","kaddressbookrc")); 369 KConfig cfgka(locateLocal("config","kaddressbookrc"));
370 cfgko.setGroup("General"); 370 cfgko.setGroup("General");
371 mFilterKopi = cfgko.readListEntry("CalendarFilters"); 371 mFilterKopi = cfgko.readListEntry("CalendarFilters");
372 cfgka.setGroup("Filter"); 372 cfgka.setGroup("Filter");
373 int count = cfgka.readNumEntry( "Count", 0 ); 373 int count = cfgka.readNumEntry( "Count", 0 );
374 for ( int i = 0; i < count; i++ ) { 374 for ( int i = 0; i < count; i++ ) {
375 cfgka.setGroup("Filter_"+QString::number( i ) ); 375 cfgka.setGroup("Filter_"+QString::number( i ) );
376 mFilterKapi.append( cfgka.readEntry("Name", "internal error") ); 376 mFilterKapi.append( cfgka.readEntry("Name", "internal error") );
377 } 377 }
378 mFilterOutCal->clear(); 378 mFilterOutCal->clear();
379 mFilterInCal->clear(); 379 mFilterInCal->clear();
380 mFilterOutAB->clear(); 380 mFilterOutAB->clear();
381 mFilterInAB->clear(); 381 mFilterInAB->clear();
382 QStringList temp = mFilterKopi; 382 QStringList temp = mFilterKopi;
383 temp.prepend(i18n("No Filter") ); 383 temp.prepend(i18n("No Filter") );
384 mFilterOutCal->insertStringList( temp ); 384 mFilterOutCal->insertStringList( temp );
385 mFilterInCal->insertStringList( temp ); 385 mFilterInCal->insertStringList( temp );
386 temp = mFilterKapi; 386 temp = mFilterKapi;
387 temp.prepend(i18n("No Filter") ); 387 temp.prepend(i18n("No Filter") );
388 mFilterOutAB->insertStringList( temp ); 388 mFilterOutAB->insertStringList( temp );
389 mFilterInAB->insertStringList( temp ); 389 mFilterInAB->insertStringList( temp );
390} 390}
391 391
392void KSyncPrefsDialog::slotOK() 392void KSyncPrefsDialog::slotOK()
393{ 393{
394 if ( mMyMachineName->text() == "undefined" ) { 394 if ( mMyMachineName->text() == "undefined" ) {
395 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); 395 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error"));
396 return; 396 return;
397 } 397 }
398 int i; 398 int i;
399 for (i = 0; i < mSyncProfileNames.count(); ++ i) { 399 for (i = 0; i < mSyncProfileNames.count(); ++ i) {
400 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { 400 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) {
401 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); 401 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error"));
402 return; 402 return;
403 } 403 }
404 } 404 }
405 usrWriteConfig(); 405 usrWriteConfig();
406 QDialog::accept(); 406 QDialog::accept();
407} 407}
408void KSyncPrefsDialog::accept() 408void KSyncPrefsDialog::accept()
409{ 409{
410 slotOK(); 410 slotOK();
411} 411}
412void KSyncPrefsDialog::chooseFile() 412void KSyncPrefsDialog::chooseFile()
413{ 413{
414 QString fn = QDir::homeDirPath(); 414 QString fn = QDir::homeDirPath();
415 415
416 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 416 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
417 if ( fn == "" ) 417 if ( fn == "" )
418 return; 418 return;
419 mRemoteFile->setText( fn ); 419 mRemoteFile->setText( fn );
420} 420}
421 421
422void KSyncPrefsDialog::chooseFileAB() 422void KSyncPrefsDialog::chooseFileAB()
423{ 423{
424 QString fn = QDir::homeDirPath(); 424 QString fn = QDir::homeDirPath();
425 425
426 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this ); 426 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this );
427 if ( fn == "" ) 427 if ( fn == "" )
428 return; 428 return;
429 mRemoteFileAB->setText( fn ); 429 mRemoteFileAB->setText( fn );
430} 430}
431 431
432void KSyncPrefsDialog::chooseFilePWM() 432void KSyncPrefsDialog::chooseFilePWM()
433{ 433{
434 QString fn = QDir::homeDirPath(); 434 QString fn = QDir::homeDirPath();
435 435
436 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this ); 436 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this );
437 if ( fn == "" ) 437 if ( fn == "" )
438 return; 438 return;
439 mRemoteFilePWM->setText( fn ); 439 mRemoteFilePWM->setText( fn );
440} 440}
441 441
442void KSyncPrefsDialog::textChanged( const QString & s ) 442void KSyncPrefsDialog::textChanged( const QString & s )
443{ 443{
444 if ( mProfileBox->count() == 0 ) 444 if ( mProfileBox->count() == 0 )
445 return; 445 return;
446 if ( currentSelection < 3 ) { 446 if ( currentSelection < 3 ) {
447 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); 447 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error"));
448 mProfileBox->blockSignals( true ); 448 mProfileBox->blockSignals( true );
449 mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); 449 mProfileBox->setCurrentItem(mProfileBox-> currentItem ());
450 mProfileBox->blockSignals( false ); 450 mProfileBox->blockSignals( false );
451 return; 451 return;
452 } 452 }
453 //qDebug("cur i %d ",mProfileBox-> currentItem () ); 453 //qDebug("cur i %d ",mProfileBox-> currentItem () );
454 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; 454 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ;
455 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; 455 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ;
456 prof->setName( s ); 456 prof->setName( s );
457 mSyncProfileNames[mProfileBox-> currentItem ()] = s; 457 mSyncProfileNames[mProfileBox-> currentItem ()] = s;
458} 458}
459void KSyncPrefsDialog::profileChanged( int item ) 459void KSyncPrefsDialog::profileChanged( int item )
460{ 460{
461 //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() ); 461 //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() );
462 KSyncProfile* prof; 462 KSyncProfile* prof;
463 saveProfile(); 463 saveProfile();
464 readFilter(); 464 readFilter();
465 currentSelection = item; 465 currentSelection = item;
466 prof = mSyncProfiles.at(item) ; 466 prof = mSyncProfiles.at(item) ;
467 467
468 mRemotePw->setText(prof->getRemotePw()); 468 mRemotePw->setText(prof->getRemotePw());
469 mRemoteIP->setText(prof->getRemoteIP()); 469 mRemoteIP->setText(prof->getRemoteIP());
470 mRemotePort->setText(prof->getRemotePort()); 470 mRemotePort->setText(prof->getRemotePort());
471 471
472 mRemotePwAB->setText(prof->getRemotePwAB()); 472 mRemotePwAB->setText(prof->getRemotePwAB());
473 mRemoteIPAB->setText(prof->getRemoteIPAB()); 473 mRemoteIPAB->setText(prof->getRemoteIPAB());
474 mRemotePortAB->setText(prof->getRemotePortAB()); 474 mRemotePortAB->setText(prof->getRemotePortAB());
475 475
476 mRemotePwPWM->setText(prof->getRemotePwPWM()); 476 mRemotePwPWM->setText(prof->getRemotePwPWM());
477 mRemoteIPPWM->setText(prof->getRemoteIPPWM()); 477 mRemoteIPPWM->setText(prof->getRemoteIPPWM());
478 mRemotePortPWM->setText(prof->getRemotePortPWM()); 478 mRemotePortPWM->setText(prof->getRemotePortPWM());
479 479
480 mRemotePrecommand->setText(prof->getPreSyncCommand()); 480 mRemotePrecommand->setText(prof->getPreSyncCommand());
481 mRemotePostcommand->setText(prof->getPostSyncCommand()); 481 mRemotePostcommand->setText(prof->getPostSyncCommand());
482 mLocalTempFile->setText(prof->getLocalTempFile()); 482 mLocalTempFile->setText(prof->getLocalTempFile());
483 mRemoteFile->setText(prof->getRemoteFileName()) ; 483 mRemoteFile->setText(prof->getRemoteFileName()) ;
484 484
485 mRemotePrecommandAB->setText(prof->getPreSyncCommandAB()); 485 mRemotePrecommandAB->setText(prof->getPreSyncCommandAB());
486 mRemotePostcommandAB->setText(prof->getPostSyncCommandAB()); 486 mRemotePostcommandAB->setText(prof->getPostSyncCommandAB());
487 mLocalTempFileAB->setText(prof->getLocalTempFileAB()); 487 mLocalTempFileAB->setText(prof->getLocalTempFileAB());
488 mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ; 488 mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ;
489 489
490 mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM()); 490 mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM());
491 mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM()); 491 mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM());
492 mLocalTempFilePWM->setText(prof->getLocalTempFilePWM()); 492 mLocalTempFilePWM->setText(prof->getLocalTempFilePWM());
493 mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ; 493 mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ;
494 494
495 if ( mWriteContactToSIM ) 495 if ( mWriteContactToSIM )
496 mWriteContactToSIM->setChecked( prof->getWriteContactToSIM()); 496 mWriteContactToSIM->setChecked( prof->getWriteContactToSIM());
497 mPhoneDevice->setText(prof->getPhoneDevice()); 497 mPhoneDevice->setText(prof->getPhoneDevice());
498 mPhoneConnection->setText(prof->getPhoneConnection()); 498 mPhoneConnection->setText(prof->getPhoneConnection());
499 mPhoneModel->setText(prof->getPhoneModel()); 499 mPhoneModel->setText(prof->getPhoneModel());
500 500
501 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); 501 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
502 mAskForPreferences->setChecked( prof->getAskForPreferences()); 502 mAskForPreferences->setChecked( prof->getAskForPreferences());
503 mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); 503 mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
504 mWriteBackFile->setChecked( prof->getWriteBackFile()); 504 mWriteBackFile->setChecked( prof->getWriteBackFile());
505 mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); 505 mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
506 mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() ); 506 mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() );
507 mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() ); 507 mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() );
508 mWriteBackFuture->setChecked( prof->getWriteBackFuture()); 508 mWriteBackFuture->setChecked( prof->getWriteBackFuture());
509 mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() ); 509 mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() );
510 mWriteBackPastWeeks->setValue( prof->getWriteBackPastWeeks() ); 510 mWriteBackPastWeeks->setValue( prof->getWriteBackPastWeeks() );
511 511
512 mFilterInCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterInCal () ) + 1 ); 512 mFilterInCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterInCal () ) + 1 );
513 mFilterOutCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterOutCal () ) + 1 ); 513 mFilterOutCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterOutCal () ) + 1 );
514 mFilterInAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterInAB () ) + 1 ); 514 mFilterInAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterInAB () ) + 1 );
515 mFilterOutAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterOutAB () ) + 1 ); 515 mFilterOutAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterOutAB () ) + 1 );
516 516
517 switch ( prof->getSyncPrefs() ) { 517 switch ( prof->getSyncPrefs() ) {
518 case 0: 518 case 0:
519 loc->setChecked( true); 519 loc->setChecked( true);
520 break; 520 break;
521 case 1: 521 case 1:
522 rem->setChecked( true ); 522 rem->setChecked( true );
523 break; 523 break;
524 case 2: 524 case 2:
525 newest->setChecked( true); 525 newest->setChecked( true);
526 break; 526 break;
527 case 3: 527 case 3:
528 ask->setChecked( true); 528 ask->setChecked( true);
529 break; 529 break;
530 case 4: 530 case 4:
531 f_loc->setChecked( true); 531 f_loc->setChecked( true);
532 break; 532 break;
533 case 5: 533 case 5:
534 f_rem->setChecked( true); 534 f_rem->setChecked( true);
535 break; 535 break;
536 case 6: 536 case 6:
537 //both->setChecked( true); 537 //both->setChecked( true);
538 break; 538 break;
539 default: 539 default:
540 break; 540 break;
541 } 541 }
542 mIsLocal->setChecked(prof->getIsLocalFileSync()) ; 542 mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
543 mIsPhone->setChecked(prof->getIsPhoneSync()) ; 543 mIsPhone->setChecked(prof->getIsPhoneSync()) ;
544 mIsPi->setChecked(prof->getIsPiSync()) ; 544 mIsPi->setChecked(prof->getIsPiSync()) ;
545 mIsKapiFileL->setChecked(prof->getIsKapiFile()) ; 545 mIsKapiFileL->setChecked(prof->getIsKapiFile()) ;
546 mIsKapiFileR->setChecked(prof->getIsKapiFile()) ; 546 mIsKapiFileR->setChecked(prof->getIsKapiFile()) ;
547 547
548 mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() ); 548 mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() );
549 proGr->setEnabled( item > 2 ); 549 proGr->setEnabled( item > 2 );
550 if ( item < 3 ) { 550 if ( item < 3 ) {
551 localFileWidget->hide(); 551 localFileWidget->hide();
552 remoteFileWidget->hide(); 552 remoteFileWidget->hide();
553 phoneWidget->hide(); 553 phoneWidget->hide();
554 piWidget->hide(); 554 piWidget->hide();
555 555
556 } else 556 } else
557 kindChanged( prof->getIsLocalFileSync() ); 557 kindChanged( prof->getIsLocalFileSync() );
558} 558}
559 559
560void KSyncPrefsDialog::fillSSH() 560void KSyncPrefsDialog::fillSSH()
561{ 561{
562 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 562 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
563 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 563 mLocalTempFile->setText("/tmp/mycalendar.ics" );
564 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); 564 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" );
565 mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); 565 mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
566 mLocalTempFileAB->setText("/tmp/std.vcf" ); 566 mLocalTempFileAB->setText("/tmp/std.vcf" );
567 mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" ); 567 mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" );
568 mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); 568 mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
569 mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); 569 mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
570 mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" ); 570 mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" );
571} 571}
572void KSyncPrefsDialog::fillFTP() 572void KSyncPrefsDialog::fillFTP()
573{ 573{
574 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); 574 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" );
575 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 575 mLocalTempFile->setText("/tmp/mycalendar.ics" );
576 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 576 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
577 mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" ); 577 mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" );
578 mLocalTempFileAB->setText("/tmp/std.vcf" ); 578 mLocalTempFileAB->setText("/tmp/std.vcf" );
579 mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); 579 mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
580 580
581 mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" ); 581 mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" );
582 mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); 582 mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
583 mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); 583 mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
584 584
585} 585}
586void KSyncPrefsDialog::kindChanged( bool b ) 586void KSyncPrefsDialog::kindChanged( bool b )
587{ 587{
588 588
589 if ( mIsLocal->isChecked () ) { 589 if ( mIsLocal->isChecked () ) {
590 mIsKapiFileL->setChecked( mIsKapiFileR->isChecked() ); 590 mIsKapiFileL->setChecked( mIsKapiFileR->isChecked() );
591 } else { 591 } else {
592 mIsKapiFileR->setChecked( mIsKapiFileL->isChecked() ); 592 mIsKapiFileR->setChecked( mIsKapiFileL->isChecked() );
593 } 593 }
594 594
595 if ( mIsLocal->isChecked () ) 595 if ( mIsLocal->isChecked () )
596 localFileWidget->show(); 596 localFileWidget->show();
597 else 597 else
598 localFileWidget->hide(); 598 localFileWidget->hide();
599 599
600 if ( mIsNotLocal->isChecked () ) 600 if ( mIsNotLocal->isChecked () )
601 remoteFileWidget->show(); 601 remoteFileWidget->show();
602 else 602 else
603 remoteFileWidget->hide(); 603 remoteFileWidget->hide();
604 604
605 if ( mIsPhone->isChecked () ) { 605 if ( mIsPhone->isChecked () ) {
606 phoneWidget->show(); 606 phoneWidget->show();
607 } 607 }
608 else { 608 else {
609 phoneWidget->hide(); 609 phoneWidget->hide();
610 } 610 }
611 if ( mIsPi->isChecked () ) { 611 if ( mIsPi->isChecked () ) {
612 piWidget->show(); 612 piWidget->show();
613 } 613 }
614 else { 614 else {
615 piWidget->hide(); 615 piWidget->hide();
616 } 616 }
617 617
618} 618}
619void KSyncPrefsDialog::deleteProfile() 619void KSyncPrefsDialog::deleteProfile()
620{ 620{
621 //qDebug("KSyncPrefsDialog::deleteProfile() "); 621 //qDebug("KSyncPrefsDialog::deleteProfile() ");
622 if ( currentSelection >= 0 ) { 622 if ( currentSelection >= 0 ) {
623 if ( currentSelection < 3 ) { 623 if ( currentSelection < 3 ) {
624 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); 624 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error"));
625 return; 625 return;
626 } 626 }
627 KSyncProfile* temp = mSyncProfiles.at(currentSelection); 627 KSyncProfile* temp = mSyncProfiles.at(currentSelection);
628 mSyncProfiles.remove( temp ); 628 mSyncProfiles.remove( temp );
629 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); 629 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection ));
630 insertProfiles(); 630 insertProfiles();
631 } 631 }
632} 632}
633 633
634void KSyncPrefsDialog::saveProfile() 634void KSyncPrefsDialog::saveProfile()
635{ 635{
636 KSyncProfile* prof; 636 KSyncProfile* prof;
637 if ( currentSelection >= 0 ) { 637 if ( currentSelection >= 0 ) {
638 prof = mSyncProfiles.at(currentSelection) ; 638 prof = mSyncProfiles.at(currentSelection) ;
639 639
640 prof->setRemotePw( mRemotePw->text()); 640 prof->setRemotePw( mRemotePw->text());
641 prof->setRemoteIP( mRemoteIP->text()); 641 prof->setRemoteIP( mRemoteIP->text());
642 prof->setRemotePort( mRemotePort->text()); 642 prof->setRemotePort( mRemotePort->text());
643 643
644 prof->setRemotePwAB( mRemotePwAB->text()); 644 prof->setRemotePwAB( mRemotePwAB->text());
645 prof->setRemoteIPAB( mRemoteIPAB->text()); 645 prof->setRemoteIPAB( mRemoteIPAB->text());
646 prof->setRemotePortAB( mRemotePortAB->text()); 646 prof->setRemotePortAB( mRemotePortAB->text());
647 647
648 prof->setRemotePwPWM( mRemotePwPWM->text()); 648 prof->setRemotePwPWM( mRemotePwPWM->text());
649 prof->setRemoteIPPWM( mRemoteIPPWM->text()); 649 prof->setRemoteIPPWM( mRemoteIPPWM->text());
650 prof->setRemotePortPWM( mRemotePortPWM->text()); 650 prof->setRemotePortPWM( mRemotePortPWM->text());
651 651
652 prof->setPreSyncCommand( mRemotePrecommand->text()); 652 prof->setPreSyncCommand( mRemotePrecommand->text());
653 prof->setPostSyncCommand( mRemotePostcommand->text() ); 653 prof->setPostSyncCommand( mRemotePostcommand->text() );
654 prof->setLocalTempFile( mLocalTempFile->text()); 654 prof->setLocalTempFile( mLocalTempFile->text());
655 prof->setRemoteFileName( mRemoteFile->text() ); 655 prof->setRemoteFileName( mRemoteFile->text() );
656 prof->setPreSyncCommandAB( mRemotePrecommandAB->text()); 656 prof->setPreSyncCommandAB( mRemotePrecommandAB->text());
657 prof->setPostSyncCommandAB( mRemotePostcommandAB->text() ); 657 prof->setPostSyncCommandAB( mRemotePostcommandAB->text() );
658 prof->setLocalTempFileAB( mLocalTempFileAB->text()); 658 prof->setLocalTempFileAB( mLocalTempFileAB->text());
659 prof->setRemoteFileNameAB( mRemoteFileAB->text() ); 659 prof->setRemoteFileNameAB( mRemoteFileAB->text() );
660 prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text()); 660 prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text());
661 prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() ); 661 prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() );
662 prof->setLocalTempFilePWM( mLocalTempFilePWM->text()); 662 prof->setLocalTempFilePWM( mLocalTempFilePWM->text());
663 prof->setRemoteFileNamePWM( mRemoteFilePWM->text() ); 663 prof->setRemoteFileNamePWM( mRemoteFilePWM->text() );
664 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); 664 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() );
665 prof->setAskForPreferences( mAskForPreferences->isChecked()); 665 prof->setAskForPreferences( mAskForPreferences->isChecked());
666 prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); 666 prof->setWriteBackExisting(mWriteBackExisting->isChecked() );
667 prof->setWriteBackFile( mWriteBackFile->isChecked()); 667 prof->setWriteBackFile( mWriteBackFile->isChecked());
668 prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); 668 prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
669 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() ); 669 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() );
670 prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() ); 670 prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() );
671 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; 671 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ;
672 prof->setSyncPrefs( syncprefs); 672 prof->setSyncPrefs( syncprefs);
673 prof->setIsLocalFileSync( mIsLocal->isChecked() ); 673 prof->setIsLocalFileSync( mIsLocal->isChecked() );
674 prof->setIsPhoneSync( mIsPhone->isChecked() ); 674 prof->setIsPhoneSync( mIsPhone->isChecked() );
675 prof->setIsPiSync( mIsPi->isChecked() ); 675 prof->setIsPiSync( mIsPi->isChecked() );
676 prof->setIsKapiFile( mIsKapiFileL->isChecked() ); 676 prof->setIsKapiFile( mIsKapiFileL->isChecked() );
677 prof->setWriteBackFuture(mWriteBackFuture->isChecked()); 677 prof->setWriteBackFuture(mWriteBackFuture->isChecked());
678 prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value()); 678 prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value());
679 prof->setWriteBackPastWeeks(mWriteBackPastWeeks->value()); 679 prof->setWriteBackPastWeeks(mWriteBackPastWeeks->value());
680 if ( mWriteContactToSIM ) 680 if ( mWriteContactToSIM )
681 prof->setWriteContactToSIM(mWriteContactToSIM->isChecked()); 681 prof->setWriteContactToSIM(mWriteContactToSIM->isChecked());
682 prof->setPhoneDevice( mPhoneDevice->text() ); 682 prof->setPhoneDevice( mPhoneDevice->text() );
683 prof->setPhoneConnection( mPhoneConnection->text() ); 683 prof->setPhoneConnection( mPhoneConnection->text() );
684 prof->setPhoneModel( mPhoneModel->text() ); 684 prof->setPhoneModel( mPhoneModel->text() );
685 prof->setFilterInCal ( mFilterInCal->currentText ()); 685 prof->setFilterInCal ( mFilterInCal->currentText ());
686 prof->setFilterOutCal ( mFilterOutCal ->currentText ()); 686 prof->setFilterOutCal ( mFilterOutCal ->currentText ());
687 prof->setFilterInAB ( mFilterInAB ->currentText ()); 687 prof->setFilterInAB ( mFilterInAB ->currentText ());
688 prof->setFilterOutAB ( mFilterOutAB ->currentText ()); 688 prof->setFilterOutAB ( mFilterOutAB ->currentText ());
689 } 689 }
690} 690}
691 691
692void KSyncPrefsDialog::insertProfiles() 692void KSyncPrefsDialog::insertProfiles()
693{ 693{
694 int curItem = mProfileBox->currentItem(); 694 int curItem = mProfileBox->currentItem();
695 mProfileBox->blockSignals( true ); 695 mProfileBox->blockSignals( true );
696 mProfileBox->clear(); 696 mProfileBox->clear();
697 mProfileBox->insertStringList (mSyncProfileNames ); 697 mProfileBox->insertStringList (mSyncProfileNames );
698 int item = mSyncProfileNames.count() -1; 698 int item = mSyncProfileNames.count() -1;
699 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) 699 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() )
700 mProfileBox->setCurrentItem( curItem ); 700 mProfileBox->setCurrentItem( curItem );
701 else if ( item >= 0 ) { 701 else if ( item >= 0 ) {
702 mProfileBox->setCurrentItem( item ); 702 mProfileBox->setCurrentItem( item );
703 } 703 }
704 currentSelection = -1; 704 currentSelection = -1;
705 if ( mSyncProfileNames.count() > 0 ) { 705 if ( mSyncProfileNames.count() > 0 ) {
706 //qDebug(" profileChanged( mProfileBox->currentItem() "); 706 //qDebug(" profileChanged( mProfileBox->currentItem() ");
707 profileChanged( mProfileBox->currentItem() ); 707 profileChanged( mProfileBox->currentItem() );
708 currentSelection = mProfileBox->currentItem(); 708 currentSelection = mProfileBox->currentItem();
709 } 709 }
710 mProfileBox->blockSignals( false ); 710 mProfileBox->blockSignals( false );
711} 711}
712 712
713void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) 713void KSyncPrefsDialog::addProfile ( KSyncProfile* temp )
714{ 714{
715 saveProfile(); 715 saveProfile();
716 mSyncProfiles.append( temp ); 716 mSyncProfiles.append( temp );
717 mSyncProfileNames << temp->getName(); 717 mSyncProfileNames << temp->getName();
718 insertProfiles(); 718 insertProfiles();
719 int last = mProfileBox->count() -1; 719 int last = mProfileBox->count() -1;
720 mProfileBox->blockSignals( true ); 720 mProfileBox->blockSignals( true );
721 mProfileBox->setCurrentItem( last ); 721 mProfileBox->setCurrentItem( last );
722 mProfileBox->blockSignals( false ); 722 mProfileBox->blockSignals( false );
723 profileChanged(last); 723 profileChanged(last);
724} 724}
725void KSyncPrefsDialog::newProfile() 725void KSyncPrefsDialog::newProfile()
726{ 726{
727 addProfile ( new KSyncProfile () ); 727 addProfile ( new KSyncProfile () );
728} 728}
729 729
730void KSyncPrefsDialog::cloneProfile() 730void KSyncPrefsDialog::cloneProfile()
731{ 731{
732 if ( currentSelection >= 0 ) 732 if ( currentSelection >= 0 )
733 addProfile (mSyncProfiles.at(currentSelection)->clone()) ; 733 addProfile (mSyncProfiles.at(currentSelection)->clone()) ;
734 else 734 else
735 newProfile(); 735 newProfile();
736} 736}
737 737
738void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) 738void KSyncPrefsDialog::setLocalMachineName ( const QString& name )
739{ 739{
740 mMyMachineName->setText( name ); 740 mMyMachineName->setText( name );
741 741
742} 742}
743QString KSyncPrefsDialog::getLocalMachineName ( ) 743QString KSyncPrefsDialog::getLocalMachineName ( )
744{ 744{
745 return mMyMachineName->text(); 745 return mMyMachineName->text();
746} 746}
747 747
748QStringList KSyncPrefsDialog::getSyncProfileNames() 748QStringList KSyncPrefsDialog::getSyncProfileNames()
749{ 749{
750 return mSyncProfileNames; 750 return mSyncProfileNames;
751} 751}
752void KSyncPrefsDialog::usrReadConfig() 752void KSyncPrefsDialog::usrReadConfig()
753{ 753{
754 //KConfig *config = KOGlobals::config(); 754 //KConfig *config = KOGlobals::config();
755 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 755 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
756 config.setGroup("General"); 756 config.setGroup("General");
757 mSyncProfileNames =config.readListEntry("SyncProfileNames"); 757 mSyncProfileNames =config.readListEntry("SyncProfileNames");
758 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined")); 758 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined"));
759 int i; 759 int i;
760 KSyncProfile* temp ; 760 KSyncProfile* temp ;
761 mSyncProfiles.clear(); 761 mSyncProfiles.clear();
762 for ( i = 0; i < mSyncProfileNames.count();++i ) { 762 for ( i = 0; i < mSyncProfileNames.count();++i ) {
763 temp = new KSyncProfile (); 763 temp = new KSyncProfile ();
764 temp->setName( mSyncProfileNames[i] ); 764 temp->setName( mSyncProfileNames[i] );
765 temp->readConfig( &config ); 765 temp->readConfig( &config );
766 mSyncProfiles.append( temp ); 766 mSyncProfiles.append( temp );
767 } 767 }
768 insertProfiles(); 768 insertProfiles();
769 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); 769 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName );
770} 770}
771 771
772 772
773void KSyncPrefsDialog::usrWriteConfig() 773void KSyncPrefsDialog::usrWriteConfig()
774{ 774{
775 saveProfile(); 775 saveProfile();
776 if ( currentSelection >= 0 ) 776 if ( currentSelection >= 0 )
777 profileChanged(currentSelection); 777 profileChanged(currentSelection);
778 //KConfig *config = KOGlobals::config(); 778 //KConfig *config = KOGlobals::config();
779 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 779 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
780 KSyncProfile* prof = mSyncProfiles.first(); 780 KSyncProfile* prof = mSyncProfiles.first();
781 QStringList externalSyncProfileNames; 781 QStringList externalSyncProfileNames;
782 externalSyncProfileNames.append("Sharp_DTM");; 782 externalSyncProfileNames.append("Sharp_DTM");;
783 while ( prof ) { 783 while ( prof ) {
784 prof->writeConfig(&config); 784 prof->writeConfig(&config);
785 if ( prof->getIsPhoneSync( ) ) 785 if ( prof->getIsPhoneSync( ) )
786 externalSyncProfileNames.append(prof->getName( ) ); 786 externalSyncProfileNames.append(prof->getName( ) );
787 prof = mSyncProfiles.next(); 787 prof = mSyncProfiles.next();
788 } 788 }
789 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; 789 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames;
790 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); 790 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text();
791 config.setGroup("General"); 791 config.setGroup("General");
792 config.writeEntry("SyncProfileNames",mSyncProfileNames); 792 config.writeEntry("SyncProfileNames",mSyncProfileNames);
793 config.writeEntry("ExternSyncProfiles",externalSyncProfileNames); 793 config.writeEntry("ExternSyncProfiles",externalSyncProfileNames);
794 config.writeEntry("LocalMachineName",mMyMachineName->text()); 794 config.writeEntry("LocalMachineName",mMyMachineName->text());
795 config.sync(); 795 config.sync();
796} 796}
797 797
798void KSyncPrefsDialog::helpDevice() 798void KSyncPrefsDialog::helpDevice()
799{ 799{
800 QString hint = i18n("Insert device where\nphone is connected. E.g.:\n"); 800 QString hint = i18n("Insert device where\nphone is connected. E.g.:\n");
801#ifdef _WIN32_ 801#ifdef _WIN32_
802 hint += "Leave empty for Irda.\n" 802 hint += "Leave empty for Irda.\n"
803 "com1:\n(first serial port)\n" 803 "com1:\n(first serial port)\n"
804 "usb not supported\n" 804 "usb not supported\n"
805 "???\n(bluetooth device address)\n"; 805 "???\n(bluetooth device address)\n";
806 806
807#else 807#else
808 hint += "/dev/ircomm\n(Irda)\n" 808 hint += "/dev/ircomm\n(Irda)\n"
809 "/dev/ttyS0\n(first serial port)\n" 809 "/dev/ttyS0\n(first serial port)\n"
810 "/dev/ttyUSB0\n(first device usb port)\n" 810 "/dev/ttyUSB0\n(first device usb port)\n"
811 "???\n(bluetooth device address)\n"; 811 "???\n(bluetooth device address)\n";
812#endif 812#endif
813 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 813 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
814} 814}
815void KSyncPrefsDialog::helpModel() 815void KSyncPrefsDialog::helpModel()
816{ 816{
817 QString hint = i18n("Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n"); 817 QString hint = i18n("Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n");
818 hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection"; 818 hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection";
819 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 819 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
820 820
821} 821}
822void KSyncPrefsDialog::helpConnection() 822void KSyncPrefsDialog::helpConnection()
823{ 823{
824 QString hint = i18n("Insert kind of connection,e.g.:\n"); 824 QString hint = i18n("Insert kind of connection,e.g.:\n");
825 hint += "irda | Nokia FBUS over infrared\n" 825 hint += "irda | Nokia FBUS over infrared\n"
826 "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n" 826 "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n"
827 "irdaobex | set also model as obex\n" 827 "irdaobex | set also model as obex\n"
828 "fbus | Nokia FBUS2 serial\n"; 828 "fbus | Nokia FBUS2 serial\n";
829 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 829 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
830} 830}