summaryrefslogtreecommitdiffabout
path: root/libkdepim
Unidiff
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp44
-rw-r--r--libkdepim/ksyncmanager.h1
2 files changed, 45 insertions, 0 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 5175f94..7ee56e4 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,1127 +1,1171 @@
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 51
52#include <klocale.h> 52#include <klocale.h>
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kconfig.h> 54#include <kconfig.h>
55#include <kfiledialog.h> 55#include <kfiledialog.h>
56 56
57KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 57KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
58 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) 58 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu)
59{ 59{
60 mServerSocket = 0; 60 mServerSocket = 0;
61 bar = new QProgressBar ( 1, 0 ); 61 bar = new QProgressBar ( 1, 0 );
62 bar->setCaption (""); 62 bar->setCaption ("");
63 63
64 int w = 300; 64 int w = 300;
65 if ( QApplication::desktop()->width() < 320 ) 65 if ( QApplication::desktop()->width() < 320 )
66 w = 220; 66 w = 220;
67 int h = bar->sizeHint().height() ; 67 int h = bar->sizeHint().height() ;
68 int dw = QApplication::desktop()->width(); 68 int dw = QApplication::desktop()->width();
69 int dh = QApplication::desktop()->height(); 69 int dh = QApplication::desktop()->height();
70 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 70 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
71 71
72} 72}
73 73
74KSyncManager::~KSyncManager() 74KSyncManager::~KSyncManager()
75{ 75{
76 delete bar; 76 delete bar;
77} 77}
78 78
79 79
80void KSyncManager::fillSyncMenu() 80void KSyncManager::fillSyncMenu()
81{ 81{
82 if ( mSyncMenu->count() ) 82 if ( mSyncMenu->count() )
83 mSyncMenu->clear(); 83 mSyncMenu->clear();
84 84
85 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 85 mSyncMenu->insertItem( i18n("Configure..."), 0 );
86 mSyncMenu->insertSeparator(); 86 mSyncMenu->insertSeparator();
87 if ( mServerSocket == 0 ) { 87 if ( mServerSocket == 0 ) {
88 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 88 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
89 } else { 89 } else {
90 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 90 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
91 } 91 }
92 mSyncMenu->insertSeparator(); 92 mSyncMenu->insertSeparator();
93 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 93 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
94 mSyncMenu->insertSeparator(); 94 mSyncMenu->insertSeparator();
95 95
96 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 96 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
97 config.setGroup("General"); 97 config.setGroup("General");
98 QStringList prof = config.readListEntry("SyncProfileNames"); 98 QStringList prof = config.readListEntry("SyncProfileNames");
99 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 99 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
100 if ( prof.count() < 2 ) { 100 if ( prof.count() < 2 ) {
101 prof.clear(); 101 prof.clear();
102#ifdef DESKTOP_VERSION
103#ifdef _WIN32_
104 prof << i18n("OutLook(not_implemented)");
105#else
106 prof << i18n("KDE_Desktop");
107#endif
108#else
102 prof << i18n("Sharp_DTM"); 109 prof << i18n("Sharp_DTM");
110#endif
103 prof << i18n("Local_file"); 111 prof << i18n("Local_file");
104 prof << i18n("Last_file"); 112 prof << i18n("Last_file");
105 KSyncProfile* temp = new KSyncProfile (); 113 KSyncProfile* temp = new KSyncProfile ();
106 temp->setName( prof[0] ); 114 temp->setName( prof[0] );
107 temp->writeConfig(&config); 115 temp->writeConfig(&config);
108 temp->setName( prof[1] ); 116 temp->setName( prof[1] );
109 temp->writeConfig(&config); 117 temp->writeConfig(&config);
110 temp->setName( prof[2] ); 118 temp->setName( prof[2] );
111 temp->writeConfig(&config); 119 temp->writeConfig(&config);
112 config.setGroup("General"); 120 config.setGroup("General");
113 config.writeEntry("SyncProfileNames",prof); 121 config.writeEntry("SyncProfileNames",prof);
114 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 122 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
115 config.sync(); 123 config.sync();
116 delete temp; 124 delete temp;
117 } 125 }
118 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 126 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
119 mSyncProfileNames = prof; 127 mSyncProfileNames = prof;
120 unsigned int i; 128 unsigned int i;
121 for ( i = 0; i < prof.count(); ++i ) { 129 for ( i = 0; i < prof.count(); ++i ) {
122 mSyncMenu->insertItem( prof[i], 1000+i ); 130 mSyncMenu->insertItem( prof[i], 1000+i );
123 if ( i == 2 ) 131 if ( i == 2 )
124 mSyncMenu->insertSeparator(); 132 mSyncMenu->insertSeparator();
125 } 133 }
126 QDir app_dir; 134 QDir app_dir;
127 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 135 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
128 if ( mTargetApp == PWMPI) { 136 if ( mTargetApp == PWMPI) {
129 mSyncMenu->removeItem( 1000 ); 137 mSyncMenu->removeItem( 1000 );
130 } 138 }
139#ifndef DESKTOP_VERSION
131 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 140 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
132 mSyncMenu->removeItem( 1000 ); 141 mSyncMenu->removeItem( 1000 );
133 } 142 }
143#endif
134 mSyncMenu->removeItem( 1002 ); 144 mSyncMenu->removeItem( 1002 );
135} 145}
136 146
137void KSyncManager::slotSyncMenu( int action ) 147void KSyncManager::slotSyncMenu( int action )
138{ 148{
139 //qDebug("syncaction %d ", action); 149 //qDebug("syncaction %d ", action);
140 if ( action == 0 ) { 150 if ( action == 0 ) {
141 151
142 // seems to be a Qt2 event handling bug 152 // seems to be a Qt2 event handling bug
143 // syncmenu.clear causes a segfault at first time 153 // syncmenu.clear causes a segfault at first time
144 // when we call it after the main event loop, it is ok 154 // when we call it after the main event loop, it is ok
145 // same behaviour when calling OM/Pi via QCOP for the first time 155 // same behaviour when calling OM/Pi via QCOP for the first time
146 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 156 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
147 //confSync(); 157 //confSync();
148 158
149 return; 159 return;
150 } 160 }
151 if ( action == 1 ) { 161 if ( action == 1 ) {
152 multiSync( true ); 162 multiSync( true );
153 return; 163 return;
154 } 164 }
155 if ( action == 2 ) { 165 if ( action == 2 ) {
156 enableQuick(); 166 enableQuick();
157 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 167 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
158 return; 168 return;
159 } 169 }
160 if ( action == 3 ) { 170 if ( action == 3 ) {
161 delete mServerSocket; 171 delete mServerSocket;
162 mServerSocket = 0; 172 mServerSocket = 0;
163 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 173 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
164 return; 174 return;
165 } 175 }
166 176
167 if (blockSave()) 177 if (blockSave())
168 return; 178 return;
169 179
170 setBlockSave(true); 180 setBlockSave(true);
171 181
172 mCurrentSyncProfile = action - 1000 ; 182 mCurrentSyncProfile = action - 1000 ;
173 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 183 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
174 mCurrentSyncName = mLocalMachineName ; 184 mCurrentSyncName = mLocalMachineName ;
175 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 185 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
176 KSyncProfile* temp = new KSyncProfile (); 186 KSyncProfile* temp = new KSyncProfile ();
177 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 187 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
178 temp->readConfig(&config); 188 temp->readConfig(&config);
179 mAskForPreferences = temp->getAskForPreferences(); 189 mAskForPreferences = temp->getAskForPreferences();
180 mSyncAlgoPrefs = temp->getSyncPrefs(); 190 mSyncAlgoPrefs = temp->getSyncPrefs();
181 mWriteBackFile = temp->getWriteBackFile(); 191 mWriteBackFile = temp->getWriteBackFile();
182 mWriteBackExistingOnly = temp->getWriteBackExisting(); 192 mWriteBackExistingOnly = temp->getWriteBackExisting();
183 mIsKapiFile = temp->getIsKapiFile(); 193 mIsKapiFile = temp->getIsKapiFile();
184 mWriteBackInFuture = 0; 194 mWriteBackInFuture = 0;
185 if ( temp->getWriteBackFuture() ) 195 if ( temp->getWriteBackFuture() )
186 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 196 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
187 mShowSyncSummary = temp->getShowSummaryAfterSync(); 197 mShowSyncSummary = temp->getShowSummaryAfterSync();
188 if ( action == 1000 ) { 198 if ( action == 1000 ) {
199#ifdef DESKTOP_VERSION
200 syncKDE();
201#else
189 syncSharp(); 202 syncSharp();
203#endif
190 204
191 } else if ( action == 1001 ) { 205 } else if ( action == 1001 ) {
192 syncLocalFile(); 206 syncLocalFile();
193 207
194 } else if ( action == 1002 ) { 208 } else if ( action == 1002 ) {
195 mWriteBackFile = false; 209 mWriteBackFile = false;
196 mAskForPreferences = false; 210 mAskForPreferences = false;
197 mShowSyncSummary = false; 211 mShowSyncSummary = false;
198 mSyncAlgoPrefs = 3; 212 mSyncAlgoPrefs = 3;
199 quickSyncLocalFile(); 213 quickSyncLocalFile();
200 214
201 } else if ( action >= 1003 ) { 215 } else if ( action >= 1003 ) {
202 if ( temp->getIsLocalFileSync() ) { 216 if ( temp->getIsLocalFileSync() ) {
203 switch(mTargetApp) 217 switch(mTargetApp)
204 { 218 {
205 case (KAPI): 219 case (KAPI):
206 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 220 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
207 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 221 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
208 break; 222 break;
209 case (KOPI): 223 case (KOPI):
210 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 224 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
211 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 225 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
212 break; 226 break;
213 case (PWMPI): 227 case (PWMPI):
214 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 228 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
215 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 229 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
216 break; 230 break;
217 default: 231 default:
218 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 232 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
219 break; 233 break;
220 234
221 } 235 }
222 } else { 236 } else {
223 if ( temp->getIsPhoneSync() ) { 237 if ( temp->getIsPhoneSync() ) {
224 mPhoneDevice = temp->getPhoneDevice( ) ; 238 mPhoneDevice = temp->getPhoneDevice( ) ;
225 mPhoneConnection = temp->getPhoneConnection( ); 239 mPhoneConnection = temp->getPhoneConnection( );
226 mPhoneModel = temp->getPhoneModel( ); 240 mPhoneModel = temp->getPhoneModel( );
227 syncPhone(); 241 syncPhone();
228 } else if ( temp->getIsPiSync() ) { 242 } else if ( temp->getIsPiSync() ) {
229 if ( mTargetApp == KAPI ) { 243 if ( mTargetApp == KAPI ) {
230 mPassWordPiSync = temp->getRemotePwAB(); 244 mPassWordPiSync = temp->getRemotePwAB();
231 mActiveSyncPort = temp->getRemotePortAB(); 245 mActiveSyncPort = temp->getRemotePortAB();
232 mActiveSyncIP = temp->getRemoteIPAB(); 246 mActiveSyncIP = temp->getRemoteIPAB();
233 } else if ( mTargetApp == KOPI ) { 247 } else if ( mTargetApp == KOPI ) {
234 mPassWordPiSync = temp->getRemotePw(); 248 mPassWordPiSync = temp->getRemotePw();
235 mActiveSyncPort = temp->getRemotePort(); 249 mActiveSyncPort = temp->getRemotePort();
236 mActiveSyncIP = temp->getRemoteIP(); 250 mActiveSyncIP = temp->getRemoteIP();
237 } else { 251 } else {
238 mPassWordPiSync = temp->getRemotePwPWM(); 252 mPassWordPiSync = temp->getRemotePwPWM();
239 mActiveSyncPort = temp->getRemotePortPWM(); 253 mActiveSyncPort = temp->getRemotePortPWM();
240 mActiveSyncIP = temp->getRemoteIPPWM(); 254 mActiveSyncIP = temp->getRemoteIPPWM();
241 } 255 }
242 syncPi(); 256 syncPi();
243 } else 257 } else
244 syncRemote( temp ); 258 syncRemote( temp );
245 259
246 } 260 }
247 } 261 }
248 delete temp; 262 delete temp;
249 setBlockSave(false); 263 setBlockSave(false);
250} 264}
251 265
252void KSyncManager::enableQuick() 266void KSyncManager::enableQuick()
253{ 267{
254 QDialog dia ( 0, "input-dialog", true ); 268 QDialog dia ( 0, "input-dialog", true );
255 QLineEdit lab ( &dia ); 269 QLineEdit lab ( &dia );
256 QVBoxLayout lay( &dia ); 270 QVBoxLayout lay( &dia );
257 lab.setText( mPrefs->mPassiveSyncPort ); 271 lab.setText( mPrefs->mPassiveSyncPort );
258 lay.setMargin(7); 272 lay.setMargin(7);
259 lay.setSpacing(7); 273 lay.setSpacing(7);
260 int po = 9197+mTargetApp; 274 int po = 9197+mTargetApp;
261 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 275 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
262 lay.addWidget( &label); 276 lay.addWidget( &label);
263 lay.addWidget( &lab); 277 lay.addWidget( &lab);
264 278
265 QLineEdit lepw ( &dia ); 279 QLineEdit lepw ( &dia );
266 lepw.setText( mPrefs->mPassiveSyncPw ); 280 lepw.setText( mPrefs->mPassiveSyncPw );
267 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 281 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
268 lay.addWidget( &label2); 282 lay.addWidget( &label2);
269 lay.addWidget( &lepw); 283 lay.addWidget( &lepw);
270 dia.setFixedSize( 230,80 ); 284 dia.setFixedSize( 230,80 );
271 dia.setCaption( i18n("Enter port for Pi-Sync") ); 285 dia.setCaption( i18n("Enter port for Pi-Sync") );
272 QPushButton pb ( "OK", &dia); 286 QPushButton pb ( "OK", &dia);
273 lay.addWidget( &pb ); 287 lay.addWidget( &pb );
274 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 288 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
275 dia.show(); 289 dia.show();
276 if ( ! dia.exec() ) 290 if ( ! dia.exec() )
277 return; 291 return;
278 dia.hide(); 292 dia.hide();
279 qApp->processEvents(); 293 qApp->processEvents();
280 mPrefs->mPassiveSyncPw = lepw.text(); 294 mPrefs->mPassiveSyncPw = lepw.text();
281 mPrefs->mPassiveSyncPort = lab.text(); 295 mPrefs->mPassiveSyncPort = lab.text();
282 bool ok; 296 bool ok;
283 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 297 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
284 if ( ! ok ) { 298 if ( ! ok ) {
285 KMessageBox::information( 0, i18n("No valid port")); 299 KMessageBox::information( 0, i18n("No valid port"));
286 return; 300 return;
287 } 301 }
288 //qDebug("port %d ", port); 302 //qDebug("port %d ", port);
289 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 303 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
290 mServerSocket->setFileName( defaultFileName() ); 304 mServerSocket->setFileName( defaultFileName() );
291 //qDebug("connected "); 305 //qDebug("connected ");
292 if ( !mServerSocket->ok() ) { 306 if ( !mServerSocket->ok() ) {
293 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 307 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
294 delete mServerSocket; 308 delete mServerSocket;
295 mServerSocket = 0; 309 mServerSocket = 0;
296 return; 310 return;
297 } 311 }
298 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 312 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
299 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 313 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
300} 314}
301 315
302void KSyncManager::syncLocalFile() 316void KSyncManager::syncLocalFile()
303{ 317{
304 318
305 QString fn =mPrefs->mLastSyncedLocalFile; 319 QString fn =mPrefs->mLastSyncedLocalFile;
306 QString ext; 320 QString ext;
307 321
308 switch(mTargetApp) 322 switch(mTargetApp)
309 { 323 {
310 case (KAPI): 324 case (KAPI):
311 ext = "(*.vcf)"; 325 ext = "(*.vcf)";
312 break; 326 break;
313 case (KOPI): 327 case (KOPI):
314 ext = "(*.ics/*.vcs)"; 328 ext = "(*.ics/*.vcs)";
315 break; 329 break;
316 case (PWMPI): 330 case (PWMPI):
317 ext = "(*.pwm)"; 331 ext = "(*.pwm)";
318 break; 332 break;
319 default: 333 default:
320 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 334 qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
321 break; 335 break;
322 336
323 } 337 }
324 338
325 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 339 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
326 if ( fn == "" ) 340 if ( fn == "" )
327 return; 341 return;
328 if ( syncWithFile( fn, false ) ) { 342 if ( syncWithFile( fn, false ) ) {
329 qDebug("syncLocalFile() successful "); 343 qDebug("syncLocalFile() successful ");
330 } 344 }
331 345
332} 346}
333 347
334bool KSyncManager::syncWithFile( QString fn , bool quick ) 348bool KSyncManager::syncWithFile( QString fn , bool quick )
335{ 349{
336 bool ret = false; 350 bool ret = false;
337 QFileInfo info; 351 QFileInfo info;
338 info.setFile( fn ); 352 info.setFile( fn );
339 QString mess; 353 QString mess;
340 bool loadbup = true; 354 bool loadbup = true;
341 if ( !info. exists() ) { 355 if ( !info. exists() ) {
342 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 356 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
343 int result = QMessageBox::warning( mParent, i18n("Warning!"), 357 int result = QMessageBox::warning( mParent, i18n("Warning!"),
344 mess ); 358 mess );
345 return ret; 359 return ret;
346 } 360 }
347 int result = 0; 361 int result = 0;
348 if ( !quick ) { 362 if ( !quick ) {
349 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 363 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
350 result = QMessageBox::warning( mParent, i18n("Warning!"), 364 result = QMessageBox::warning( mParent, i18n("Warning!"),
351 mess, 365 mess,
352 i18n("Sync"), i18n("Cancel"), 0, 366 i18n("Sync"), i18n("Cancel"), 0,
353 0, 1 ); 367 0, 1 );
354 if ( result ) 368 if ( result )
355 return false; 369 return false;
356 } 370 }
357 if ( mAskForPreferences ) 371 if ( mAskForPreferences )
358 edit_sync_options(); 372 edit_sync_options();
359 if ( result == 0 ) { 373 if ( result == 0 ) {
360 //qDebug("Now sycing ... "); 374 //qDebug("Now sycing ... ");
361 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 375 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
362 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 376 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
363 else 377 else
364 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 378 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
365 if ( ! quick ) 379 if ( ! quick )
366 mPrefs->mLastSyncedLocalFile = fn; 380 mPrefs->mLastSyncedLocalFile = fn;
367 } 381 }
368 return ret; 382 return ret;
369} 383}
370 384
371void KSyncManager::quickSyncLocalFile() 385void KSyncManager::quickSyncLocalFile()
372{ 386{
373 387
374 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { 388 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
375 qDebug("quick syncLocalFile() successful "); 389 qDebug("quick syncLocalFile() successful ");
376 390
377 } 391 }
378} 392}
379 393
380void KSyncManager::multiSync( bool askforPrefs ) 394void KSyncManager::multiSync( bool askforPrefs )
381{ 395{
382 if (blockSave()) 396 if (blockSave())
383 return; 397 return;
384 setBlockSave(true); 398 setBlockSave(true);
385 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 399 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
386 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 400 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
387 question, 401 question,
388 i18n("Yes"), i18n("No"), 402 i18n("Yes"), i18n("No"),
389 0, 0 ) != 0 ) { 403 0, 0 ) != 0 ) {
390 setBlockSave(false); 404 setBlockSave(false);
391 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 405 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
392 return; 406 return;
393 } 407 }
394 mCurrentSyncDevice = i18n("Multiple profiles") ; 408 mCurrentSyncDevice = i18n("Multiple profiles") ;
395 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 409 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
396 if ( askforPrefs ) { 410 if ( askforPrefs ) {
397 edit_sync_options(); 411 edit_sync_options();
398 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; 412 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
399 } 413 }
400 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 414 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
401 qApp->processEvents(); 415 qApp->processEvents();
402 int num = ringSync() ; 416 int num = ringSync() ;
403 if ( num > 1 ) 417 if ( num > 1 )
404 ringSync(); 418 ringSync();
405 setBlockSave(false); 419 setBlockSave(false);
406 if ( num ) 420 if ( num )
407 emit save(); 421 emit save();
408 if ( num ) 422 if ( num )
409 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); 423 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
410 else 424 else
411 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 425 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
412 return; 426 return;
413} 427}
414 428
415int KSyncManager::ringSync() 429int KSyncManager::ringSync()
416{ 430{
417 int syncedProfiles = 0; 431 int syncedProfiles = 0;
418 unsigned int i; 432 unsigned int i;
419 QTime timer; 433 QTime timer;
420 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 434 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
421 QStringList syncProfileNames = mSyncProfileNames; 435 QStringList syncProfileNames = mSyncProfileNames;
422 KSyncProfile* temp = new KSyncProfile (); 436 KSyncProfile* temp = new KSyncProfile ();
423 mAskForPreferences = false; 437 mAskForPreferences = false;
424 for ( i = 0; i < syncProfileNames.count(); ++i ) { 438 for ( i = 0; i < syncProfileNames.count(); ++i ) {
425 mCurrentSyncProfile = i; 439 mCurrentSyncProfile = i;
426 temp->setName(syncProfileNames[mCurrentSyncProfile]); 440 temp->setName(syncProfileNames[mCurrentSyncProfile]);
427 temp->readConfig(&config); 441 temp->readConfig(&config);
428 442
429 bool includeInRingSync; 443 bool includeInRingSync;
430 switch(mTargetApp) 444 switch(mTargetApp)
431 { 445 {
432 case (KAPI): 446 case (KAPI):
433 includeInRingSync = temp->getIncludeInRingSyncAB(); 447 includeInRingSync = temp->getIncludeInRingSyncAB();
434 break; 448 break;
435 case (KOPI): 449 case (KOPI):
436 includeInRingSync = temp->getIncludeInRingSync(); 450 includeInRingSync = temp->getIncludeInRingSync();
437 break; 451 break;
438 case (PWMPI): 452 case (PWMPI):
439 includeInRingSync = temp->getIncludeInRingSyncPWM(); 453 includeInRingSync = temp->getIncludeInRingSyncPWM();
440 break; 454 break;
441 default: 455 default:
442 qDebug("KSyncManager::ringSync: invalid apptype selected"); 456 qDebug("KSyncManager::ringSync: invalid apptype selected");
443 break; 457 break;
444 458
445 } 459 }
446 460
447 461
448 if ( includeInRingSync && ( i < 1 || i > 2 )) { 462 if ( includeInRingSync && ( i < 1 || i > 2 )) {
449 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 463 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
450 ++syncedProfiles; 464 ++syncedProfiles;
451 // mAskForPreferences = temp->getAskForPreferences(); 465 // mAskForPreferences = temp->getAskForPreferences();
452 mWriteBackFile = temp->getWriteBackFile(); 466 mWriteBackFile = temp->getWriteBackFile();
453 mWriteBackExistingOnly = temp->getWriteBackExisting(); 467 mWriteBackExistingOnly = temp->getWriteBackExisting();
454 mWriteBackInFuture = 0; 468 mWriteBackInFuture = 0;
455 if ( temp->getWriteBackFuture() ) 469 if ( temp->getWriteBackFuture() )
456 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 470 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
457 mShowSyncSummary = false; 471 mShowSyncSummary = false;
458 mCurrentSyncDevice = syncProfileNames[i] ; 472 mCurrentSyncDevice = syncProfileNames[i] ;
459 mCurrentSyncName = mLocalMachineName; 473 mCurrentSyncName = mLocalMachineName;
460 if ( i == 0 ) { 474 if ( i == 0 ) {
461 syncSharp(); 475 syncSharp();
462 } else { 476 } else {
463 if ( temp->getIsLocalFileSync() ) { 477 if ( temp->getIsLocalFileSync() ) {
464 switch(mTargetApp) 478 switch(mTargetApp)
465 { 479 {
466 case (KAPI): 480 case (KAPI):
467 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 481 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
468 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 482 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
469 break; 483 break;
470 case (KOPI): 484 case (KOPI):
471 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 485 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
472 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 486 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
473 break; 487 break;
474 case (PWMPI): 488 case (PWMPI):
475 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 489 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
476 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 490 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
477 break; 491 break;
478 default: 492 default:
479 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 493 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
480 break; 494 break;
481 } 495 }
482 } else { 496 } else {
483 if ( temp->getIsPhoneSync() ) { 497 if ( temp->getIsPhoneSync() ) {
484 mPhoneDevice = temp->getPhoneDevice( ) ; 498 mPhoneDevice = temp->getPhoneDevice( ) ;
485 mPhoneConnection = temp->getPhoneConnection( ); 499 mPhoneConnection = temp->getPhoneConnection( );
486 mPhoneModel = temp->getPhoneModel( ); 500 mPhoneModel = temp->getPhoneModel( );
487 syncPhone(); 501 syncPhone();
488 } else if ( temp->getIsPiSync() ) { 502 } else if ( temp->getIsPiSync() ) {
489 if ( mTargetApp == KAPI ) { 503 if ( mTargetApp == KAPI ) {
490 mPassWordPiSync = temp->getRemotePwAB(); 504 mPassWordPiSync = temp->getRemotePwAB();
491 mActiveSyncPort = temp->getRemotePortAB(); 505 mActiveSyncPort = temp->getRemotePortAB();
492 mActiveSyncIP = temp->getRemoteIPAB(); 506 mActiveSyncIP = temp->getRemoteIPAB();
493 } else if ( mTargetApp == KOPI ) { 507 } else if ( mTargetApp == KOPI ) {
494 mPassWordPiSync = temp->getRemotePw(); 508 mPassWordPiSync = temp->getRemotePw();
495 mActiveSyncPort = temp->getRemotePort(); 509 mActiveSyncPort = temp->getRemotePort();
496 mActiveSyncIP = temp->getRemoteIP(); 510 mActiveSyncIP = temp->getRemoteIP();
497 } else { 511 } else {
498 mPassWordPiSync = temp->getRemotePwPWM(); 512 mPassWordPiSync = temp->getRemotePwPWM();
499 mActiveSyncPort = temp->getRemotePortPWM(); 513 mActiveSyncPort = temp->getRemotePortPWM();
500 mActiveSyncIP = temp->getRemoteIPPWM(); 514 mActiveSyncIP = temp->getRemoteIPPWM();
501 } 515 }
502 syncPi(); 516 syncPi();
503 } else 517 } else
504 syncRemote( temp, false ); 518 syncRemote( temp, false );
505 519
506 } 520 }
507 } 521 }
508 timer.start(); 522 timer.start();
509 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 523 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
510 while ( timer.elapsed () < 2000 ) { 524 while ( timer.elapsed () < 2000 ) {
511 qApp->processEvents(); 525 qApp->processEvents();
512#ifndef _WIN32_ 526#ifndef _WIN32_
513 sleep (1); 527 sleep (1);
514#endif 528#endif
515 } 529 }
516 530
517 } 531 }
518 532
519 } 533 }
520 delete temp; 534 delete temp;
521 return syncedProfiles; 535 return syncedProfiles;
522} 536}
523 537
524void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 538void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
525{ 539{
526 QString question; 540 QString question;
527 if ( ask ) { 541 if ( ask ) {
528 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 542 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
529 if ( QMessageBox::information( mParent, i18n("Sync"), 543 if ( QMessageBox::information( mParent, i18n("Sync"),
530 question, 544 question,
531 i18n("Yes"), i18n("No"), 545 i18n("Yes"), i18n("No"),
532 0, 0 ) != 0 ) 546 0, 0 ) != 0 )
533 return; 547 return;
534 } 548 }
535 549
536 QString preCommand; 550 QString preCommand;
537 QString localTempFile; 551 QString localTempFile;
538 QString postCommand; 552 QString postCommand;
539 553
540 switch(mTargetApp) 554 switch(mTargetApp)
541 { 555 {
542 case (KAPI): 556 case (KAPI):
543 preCommand = prof->getPreSyncCommandAB(); 557 preCommand = prof->getPreSyncCommandAB();
544 postCommand = prof->getPostSyncCommandAB(); 558 postCommand = prof->getPostSyncCommandAB();
545 localTempFile = prof->getLocalTempFileAB(); 559 localTempFile = prof->getLocalTempFileAB();
546 break; 560 break;
547 case (KOPI): 561 case (KOPI):
548 preCommand = prof->getPreSyncCommand(); 562 preCommand = prof->getPreSyncCommand();
549 postCommand = prof->getPostSyncCommand(); 563 postCommand = prof->getPostSyncCommand();
550 localTempFile = prof->getLocalTempFile(); 564 localTempFile = prof->getLocalTempFile();
551 break; 565 break;
552 case (PWMPI): 566 case (PWMPI):
553 preCommand = prof->getPreSyncCommandPWM(); 567 preCommand = prof->getPreSyncCommandPWM();
554 postCommand = prof->getPostSyncCommandPWM(); 568 postCommand = prof->getPostSyncCommandPWM();
555 localTempFile = prof->getLocalTempFilePWM(); 569 localTempFile = prof->getLocalTempFilePWM();
556 break; 570 break;
557 default: 571 default:
558 qDebug("KSyncManager::syncRemote: invalid apptype selected"); 572 qDebug("KSyncManager::syncRemote: invalid apptype selected");
559 break; 573 break;
560 } 574 }
561 575
562 576
563 int fi; 577 int fi;
564 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 578 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
565 QString pwd = getPassword(); 579 QString pwd = getPassword();
566 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 580 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
567 581
568 } 582 }
569 int maxlen = 30; 583 int maxlen = 30;
570 if ( QApplication::desktop()->width() > 320 ) 584 if ( QApplication::desktop()->width() > 320 )
571 maxlen += 25; 585 maxlen += 25;
572 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 586 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
573 int fileSize = 0; 587 int fileSize = 0;
574 int result = system ( preCommand ); 588 int result = system ( preCommand );
575 // 0 : okay 589 // 0 : okay
576 // 256: no such file or dir 590 // 256: no such file or dir
577 // 591 //
578 qDebug("Sync: Remote copy result(0 = okay): %d ",result ); 592 qDebug("Sync: Remote copy result(0 = okay): %d ",result );
579 if ( result != 0 ) { 593 if ( result != 0 ) {
580 unsigned int len = maxlen; 594 unsigned int len = maxlen;
581 while ( len < preCommand.length() ) { 595 while ( len < preCommand.length() ) {
582 preCommand.insert( len , "\n" ); 596 preCommand.insert( len , "\n" );
583 len += maxlen +2; 597 len += maxlen +2;
584 } 598 }
585 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) ; 599 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) ;
586 QMessageBox::information( mParent, i18n("Sync - ERROR"), 600 QMessageBox::information( mParent, i18n("Sync - ERROR"),
587 question, 601 question,
588 i18n("Okay!")) ; 602 i18n("Okay!")) ;
589 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 603 mParent->topLevelWidget()->setCaption ("KDE-Pim");
590 return; 604 return;
591 } 605 }
592 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 606 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
593 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 607 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
594 608
595 if ( syncWithFile( localTempFile, true ) ) { 609 if ( syncWithFile( localTempFile, true ) ) {
596 610
597 if ( mWriteBackFile ) { 611 if ( mWriteBackFile ) {
598 int fi; 612 int fi;
599 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 613 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
600 QString pwd = getPassword(); 614 QString pwd = getPassword();
601 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 615 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
602 616
603 } 617 }
604 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 618 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
605 result = system ( postCommand ); 619 result = system ( postCommand );
606 qDebug("Sync:Writing back file result: %d ", result); 620 qDebug("Sync:Writing back file result: %d ", result);
607 if ( result != 0 ) { 621 if ( result != 0 ) {
608 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 622 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
609 return; 623 return;
610 } else { 624 } else {
611 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 625 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
612 } 626 }
613 } 627 }
614 } 628 }
615 return; 629 return;
616} 630}
617void KSyncManager::edit_pisync_options() 631void KSyncManager::edit_pisync_options()
618{ 632{
619 QDialog dia( mParent, "dia", true ); 633 QDialog dia( mParent, "dia", true );
620 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 634 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
621 QVBoxLayout lay ( &dia ); 635 QVBoxLayout lay ( &dia );
622 lay.setSpacing( 5 ); 636 lay.setSpacing( 5 );
623 lay.setMargin( 3 ); 637 lay.setMargin( 3 );
624 QLabel lab1 ( i18n("Password for remote access:"), &dia); 638 QLabel lab1 ( i18n("Password for remote access:"), &dia);
625 lay.addWidget( &lab1 ); 639 lay.addWidget( &lab1 );
626 QLineEdit le1 (&dia ); 640 QLineEdit le1 (&dia );
627 lay.addWidget( &le1 ); 641 lay.addWidget( &le1 );
628 QLabel lab2 ( i18n("Remote IP address:"), &dia); 642 QLabel lab2 ( i18n("Remote IP address:"), &dia);
629 lay.addWidget( &lab2 ); 643 lay.addWidget( &lab2 );
630 QLineEdit le2 (&dia ); 644 QLineEdit le2 (&dia );
631 lay.addWidget( &le2 ); 645 lay.addWidget( &le2 );
632 QLabel lab3 ( i18n("Remote port number:"), &dia); 646 QLabel lab3 ( i18n("Remote port number:"), &dia);
633 lay.addWidget( &lab3 ); 647 lay.addWidget( &lab3 );
634 QLineEdit le3 (&dia ); 648 QLineEdit le3 (&dia );
635 lay.addWidget( &le3 ); 649 lay.addWidget( &le3 );
636 QPushButton pb ( "OK", &dia); 650 QPushButton pb ( "OK", &dia);
637 lay.addWidget( &pb ); 651 lay.addWidget( &pb );
638 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 652 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
639 le1.setText( mPassWordPiSync ); 653 le1.setText( mPassWordPiSync );
640 le2.setText( mActiveSyncIP ); 654 le2.setText( mActiveSyncIP );
641 le3.setText( mActiveSyncPort ); 655 le3.setText( mActiveSyncPort );
642 if ( dia.exec() ) { 656 if ( dia.exec() ) {
643 mPassWordPiSync = le1.text(); 657 mPassWordPiSync = le1.text();
644 mActiveSyncPort = le3.text(); 658 mActiveSyncPort = le3.text();
645 mActiveSyncIP = le2.text(); 659 mActiveSyncIP = le2.text();
646 } 660 }
647 661
648} 662}
649void KSyncManager::edit_sync_options() 663void KSyncManager::edit_sync_options()
650{ 664{
651 665
652 QDialog dia( mParent, "dia", true ); 666 QDialog dia( mParent, "dia", true );
653 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 667 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
654 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 668 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
655 QVBoxLayout lay ( &dia ); 669 QVBoxLayout lay ( &dia );
656 lay.setSpacing( 2 ); 670 lay.setSpacing( 2 );
657 lay.setMargin( 3 ); 671 lay.setMargin( 3 );
658 lay.addWidget(&gr); 672 lay.addWidget(&gr);
659 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 673 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
660 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 674 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
661 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 675 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
662 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 676 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
663 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 677 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
664 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 678 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
665 //QRadioButton both( i18n("Take both on conflict"), &gr ); 679 //QRadioButton both( i18n("Take both on conflict"), &gr );
666 QPushButton pb ( "OK", &dia); 680 QPushButton pb ( "OK", &dia);
667 lay.addWidget( &pb ); 681 lay.addWidget( &pb );
668 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 682 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
669 switch ( mSyncAlgoPrefs ) { 683 switch ( mSyncAlgoPrefs ) {
670 case 0: 684 case 0:
671 loc.setChecked( true); 685 loc.setChecked( true);
672 break; 686 break;
673 case 1: 687 case 1:
674 rem.setChecked( true ); 688 rem.setChecked( true );
675 break; 689 break;
676 case 2: 690 case 2:
677 newest.setChecked( true); 691 newest.setChecked( true);
678 break; 692 break;
679 case 3: 693 case 3:
680 ask.setChecked( true); 694 ask.setChecked( true);
681 break; 695 break;
682 case 4: 696 case 4:
683 f_loc.setChecked( true); 697 f_loc.setChecked( true);
684 break; 698 break;
685 case 5: 699 case 5:
686 f_rem.setChecked( true); 700 f_rem.setChecked( true);
687 break; 701 break;
688 case 6: 702 case 6:
689 // both.setChecked( true); 703 // both.setChecked( true);
690 break; 704 break;
691 default: 705 default:
692 break; 706 break;
693 } 707 }
694 if ( dia.exec() ) { 708 if ( dia.exec() ) {
695 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 709 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
696 } 710 }
697 711
698 712
699} 713}
700 714
701QString KSyncManager::getPassword( ) 715QString KSyncManager::getPassword( )
702{ 716{
703 QString retfile = ""; 717 QString retfile = "";
704 QDialog dia ( mParent, "input-dialog", true ); 718 QDialog dia ( mParent, "input-dialog", true );
705 QLineEdit lab ( &dia ); 719 QLineEdit lab ( &dia );
706 lab.setEchoMode( QLineEdit::Password ); 720 lab.setEchoMode( QLineEdit::Password );
707 QVBoxLayout lay( &dia ); 721 QVBoxLayout lay( &dia );
708 lay.setMargin(7); 722 lay.setMargin(7);
709 lay.setSpacing(7); 723 lay.setSpacing(7);
710 lay.addWidget( &lab); 724 lay.addWidget( &lab);
711 dia.setFixedSize( 230,50 ); 725 dia.setFixedSize( 230,50 );
712 dia.setCaption( i18n("Enter password") ); 726 dia.setCaption( i18n("Enter password") );
713 QPushButton pb ( "OK", &dia); 727 QPushButton pb ( "OK", &dia);
714 lay.addWidget( &pb ); 728 lay.addWidget( &pb );
715 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 729 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
716 dia.show(); 730 dia.show();
717 int res = dia.exec(); 731 int res = dia.exec();
718 if ( res ) 732 if ( res )
719 retfile = lab.text(); 733 retfile = lab.text();
720 dia.hide(); 734 dia.hide();
721 qApp->processEvents(); 735 qApp->processEvents();
722 return retfile; 736 return retfile;
723 737
724} 738}
725 739
726 740
727void KSyncManager::confSync() 741void KSyncManager::confSync()
728{ 742{
729 static KSyncPrefsDialog* sp = 0; 743 static KSyncPrefsDialog* sp = 0;
730 if ( ! sp ) { 744 if ( ! sp ) {
731 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 745 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
732 } 746 }
733 sp->usrReadConfig(); 747 sp->usrReadConfig();
734#ifndef DESKTOP_VERSION 748#ifndef DESKTOP_VERSION
735 sp->showMaximized(); 749 sp->showMaximized();
736#else 750#else
737 sp->show(); 751 sp->show();
738#endif 752#endif
739 sp->exec(); 753 sp->exec();
740 mSyncProfileNames = sp->getSyncProfileNames(); 754 mSyncProfileNames = sp->getSyncProfileNames();
741 mLocalMachineName = sp->getLocalMachineName (); 755 mLocalMachineName = sp->getLocalMachineName ();
742 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 756 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
743} 757}
758void KSyncManager::syncKDE()
759{
760 emit save();
761 switch(mTargetApp)
762 {
763 case (KAPI):
764
765 break;
766 case (KOPI):
767 {
768 QString command ="./kdecaldump";
769 system ( command.latin1());
770 if ( syncWithFile( "/tmp/kdedumpall.ics",true ) ) {
771 if ( mWriteBackFile ) {
772 command += " --read";
773 system ( command.latin1());
774 }
775 }
776
777 }
778 break;
779 case (PWMPI):
780
781 break;
782 default:
783 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
784 break;
785
786 }
787}
744 788
745void KSyncManager::syncSharp() 789void KSyncManager::syncSharp()
746{ 790{
747 791
748 if ( ! syncExternalApplication("sharp") ) 792 if ( ! syncExternalApplication("sharp") )
749 qDebug("ERROR sync sharp "); 793 qDebug("ERROR sync sharp ");
750} 794}
751 795
752bool KSyncManager::syncExternalApplication(QString resource) 796bool KSyncManager::syncExternalApplication(QString resource)
753{ 797{
754 798
755 emit save(); 799 emit save();
756 800
757 if ( mAskForPreferences ) 801 if ( mAskForPreferences )
758 edit_sync_options(); 802 edit_sync_options();
759 803
760 qDebug("Sync extern %s", resource.latin1()); 804 qDebug("Sync extern %s", resource.latin1());
761 805
762 bool syncOK = mImplementation->syncExternal(this, resource); 806 bool syncOK = mImplementation->syncExternal(this, resource);
763 807
764 return syncOK; 808 return syncOK;
765 809
766} 810}
767 811
768void KSyncManager::syncPhone() 812void KSyncManager::syncPhone()
769{ 813{
770 814
771 syncExternalApplication("phone"); 815 syncExternalApplication("phone");
772 816
773} 817}
774 818
775void KSyncManager::showProgressBar(int percentage, QString caption, int total) 819void KSyncManager::showProgressBar(int percentage, QString caption, int total)
776{ 820{
777 if (!bar->isVisible()) 821 if (!bar->isVisible())
778 { 822 {
779 bar->setCaption (caption); 823 bar->setCaption (caption);
780 bar->setTotalSteps ( total ) ; 824 bar->setTotalSteps ( total ) ;
781 825
782 bar->show(); 826 bar->show();
783 } 827 }
784 828
785 bar->setProgress( percentage ); 829 bar->setProgress( percentage );
786} 830}
787 831
788void KSyncManager::hideProgressBar() 832void KSyncManager::hideProgressBar()
789{ 833{
790 bar->hide(); 834 bar->hide();
791} 835}
792 836
793bool KSyncManager::isProgressBarCanceled() 837bool KSyncManager::isProgressBarCanceled()
794{ 838{
795 return !bar->isVisible(); 839 return !bar->isVisible();
796} 840}
797 841
798QString KSyncManager::syncFileName() 842QString KSyncManager::syncFileName()
799{ 843{
800 844
801 QString fn = "tempfile"; 845 QString fn = "tempfile";
802 switch(mTargetApp) 846 switch(mTargetApp)
803 { 847 {
804 case (KAPI): 848 case (KAPI):
805 fn = "tempsyncab.vcf"; 849 fn = "tempsyncab.vcf";
806 break; 850 break;
807 case (KOPI): 851 case (KOPI):
808 fn = "tempsynccal.ics"; 852 fn = "tempsynccal.ics";
809 break; 853 break;
810 case (PWMPI): 854 case (PWMPI):
811 fn = "tempsyncpw.pwm"; 855 fn = "tempsyncpw.pwm";
812 break; 856 break;
813 default: 857 default:
814 break; 858 break;
815 } 859 }
816#ifdef _WIN32_ 860#ifdef _WIN32_
817 return locateLocal( "tmp", fn ); 861 return locateLocal( "tmp", fn );
818#else 862#else
819 return (QString( "/tmp/" )+ fn ); 863 return (QString( "/tmp/" )+ fn );
820#endif 864#endif
821} 865}
822 866
823void KSyncManager::syncPi() 867void KSyncManager::syncPi()
824{ 868{
825 qApp->processEvents(); 869 qApp->processEvents();
826 if ( mAskForPreferences ) 870 if ( mAskForPreferences )
827 edit_pisync_options(); 871 edit_pisync_options();
828 bool ok; 872 bool ok;
829 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 873 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
830 if ( ! ok ) { 874 if ( ! ok ) {
831 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 875 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
832 return; 876 return;
833 } 877 }
834 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); 878 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this );
835 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 879 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
836 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); 880 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") );
837 commandSocket->readFile( syncFileName() ); 881 commandSocket->readFile( syncFileName() );
838} 882}
839 883
840void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 884void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
841{ 885{
842 //enum { success, errorW, errorR, quiet }; 886 //enum { success, errorW, errorR, quiet };
843 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { 887 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) {
844 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 888 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
845 delete s; 889 delete s;
846 if ( state == KCommandSocket::errorR ) { 890 if ( state == KCommandSocket::errorR ) {
847 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 891 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
848 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 892 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
849 commandSocket->sendStop(); 893 commandSocket->sendStop();
850 } 894 }
851 return; 895 return;
852 896
853 } else if ( state == KCommandSocket::errorW ) { 897 } else if ( state == KCommandSocket::errorW ) {
854 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 898 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
855 899
856 } else if ( state == KCommandSocket::successR ) { 900 } else if ( state == KCommandSocket::successR ) {
857 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 901 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
858 902
859 } else if ( state == KCommandSocket::successW ) { 903 } else if ( state == KCommandSocket::successW ) {
860 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 904 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
861 } 905 }
862 906
863 delete s; 907 delete s;
864} 908}
865 909
866void KSyncManager::readFileFromSocket() 910void KSyncManager::readFileFromSocket()
867{ 911{
868 QString fileName = syncFileName(); 912 QString fileName = syncFileName();
869 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 913 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
870 if ( ! syncWithFile( fileName , true ) ) { 914 if ( ! syncWithFile( fileName , true ) ) {
871 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 915 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
872 return; 916 return;
873 } 917 }
874 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 918 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
875 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 919 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
876 if ( mWriteBackFile ) 920 if ( mWriteBackFile )
877 commandSocket->writeFile( fileName ); 921 commandSocket->writeFile( fileName );
878 else { 922 else {
879 commandSocket->sendStop(); 923 commandSocket->sendStop();
880 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 924 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
881 } 925 }
882} 926}
883 927
884KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 928KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
885{ 929{
886 mPassWord = pw; 930 mPassWord = pw;
887 mSocket = 0; 931 mSocket = 0;
888 mSyncActionDialog = 0; 932 mSyncActionDialog = 0;
889 blockRC = false; 933 blockRC = false;
890}; 934};
891 935
892void KServerSocket::newConnection ( int socket ) 936void KServerSocket::newConnection ( int socket )
893{ 937{
894 // qDebug("KServerSocket:New connection %d ", socket); 938 // qDebug("KServerSocket:New connection %d ", socket);
895 if ( mSocket ) { 939 if ( mSocket ) {
896 qDebug("KServerSocket::newConnection Socket deleted! "); 940 qDebug("KServerSocket::newConnection Socket deleted! ");
897 delete mSocket; 941 delete mSocket;
898 mSocket = 0; 942 mSocket = 0;
899 } 943 }
900 mSocket = new QSocket( this ); 944 mSocket = new QSocket( this );
901 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 945 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
902 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 946 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
903 mSocket->setSocket( socket ); 947 mSocket->setSocket( socket );
904} 948}
905 949
906void KServerSocket::discardClient() 950void KServerSocket::discardClient()
907{ 951{
908 //qDebug(" KServerSocket::discardClient()"); 952 //qDebug(" KServerSocket::discardClient()");
909 if ( mSocket ) { 953 if ( mSocket ) {
910 delete mSocket; 954 delete mSocket;
911 mSocket = 0; 955 mSocket = 0;
912 } 956 }
913 //emit endConnect(); 957 //emit endConnect();
914} 958}
915void KServerSocket::readClient() 959void KServerSocket::readClient()
916{ 960{
917 if ( blockRC ) 961 if ( blockRC )
918 return; 962 return;
919 if ( mSocket == 0 ) { 963 if ( mSocket == 0 ) {
920 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 964 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
921 return; 965 return;
922 } 966 }
923 //qDebug("KServerSocket::readClient()"); 967 //qDebug("KServerSocket::readClient()");
924 if ( mSocket->canReadLine() ) { 968 if ( mSocket->canReadLine() ) {
925 QString line = mSocket->readLine(); 969 QString line = mSocket->readLine();
926 //qDebug("KServerSocket readline: %s ", line.latin1()); 970 //qDebug("KServerSocket readline: %s ", line.latin1());
927 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 971 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
928 if ( tokens[0] == "GET" ) { 972 if ( tokens[0] == "GET" ) {
929 if ( tokens[1] == mPassWord ) 973 if ( tokens[1] == mPassWord )
930 //emit sendFile( mSocket ); 974 //emit sendFile( mSocket );
931 send_file(); 975 send_file();
932 else { 976 else {
933 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); 977 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"));
934 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 978 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
935 } 979 }
936 } 980 }
937 if ( tokens[0] == "PUT" ) { 981 if ( tokens[0] == "PUT" ) {
938 if ( tokens[1] == mPassWord ) { 982 if ( tokens[1] == mPassWord ) {
939 //emit getFile( mSocket ); 983 //emit getFile( mSocket );
940 blockRC = true; 984 blockRC = true;
941 get_file(); 985 get_file();
942 } 986 }
943 else { 987 else {
944 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); 988 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"));
945 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 989 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
946 } 990 }
947 } 991 }
948 if ( tokens[0] == "STOP" ) { 992 if ( tokens[0] == "STOP" ) {
949 //emit endConnect(); 993 //emit endConnect();
950 end_connect(); 994 end_connect();
951 } 995 }
952 } 996 }
953} 997}
954void KServerSocket::end_connect() 998void KServerSocket::end_connect()
955{ 999{
956 delete mSyncActionDialog; 1000 delete mSyncActionDialog;
957 mSyncActionDialog = 0; 1001 mSyncActionDialog = 0;
958} 1002}
959void KServerSocket::send_file() 1003void KServerSocket::send_file()
960{ 1004{
961 //qDebug("MainWindow::sendFile(QSocket* s) "); 1005 //qDebug("MainWindow::sendFile(QSocket* s) ");
962 if ( mSyncActionDialog ) 1006 if ( mSyncActionDialog )
963 delete mSyncActionDialog; 1007 delete mSyncActionDialog;
964 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 1008 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
965 mSyncActionDialog->setCaption(i18n("Received sync request")); 1009 mSyncActionDialog->setCaption(i18n("Received sync request"));
966 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 1010 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
967 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1011 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
968 lay->addWidget( label); 1012 lay->addWidget( label);
969 lay->setMargin(7); 1013 lay->setMargin(7);
970 lay->setSpacing(7); 1014 lay->setSpacing(7);
971 mSyncActionDialog->setFixedSize( 230, 120); 1015 mSyncActionDialog->setFixedSize( 230, 120);
972 mSyncActionDialog->show(); 1016 mSyncActionDialog->show();
973 mSyncActionDialog->raise(); 1017 mSyncActionDialog->raise();
974 emit request_file(); 1018 emit request_file();
975 qApp->processEvents(); 1019 qApp->processEvents();
976 QString fileName = mFileName; 1020 QString fileName = mFileName;
977 QFile file( fileName ); 1021 QFile file( fileName );
978 if (!file.open( IO_ReadOnly ) ) { 1022 if (!file.open( IO_ReadOnly ) ) {
979 delete mSyncActionDialog; 1023 delete mSyncActionDialog;
980 mSyncActionDialog = 0; 1024 mSyncActionDialog = 0;
981 qDebug("KSS::error open file "); 1025 qDebug("KSS::error open file ");
982 mSocket->close(); 1026 mSocket->close();
983 if ( mSocket->state() == QSocket::Idle ) 1027 if ( mSocket->state() == QSocket::Idle )
984 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1028 QTimer::singleShot( 10, this , SLOT ( discardClient()));
985 return ; 1029 return ;
986 1030
987 } 1031 }
988 mSyncActionDialog->setCaption( i18n("Sending file...") ); 1032 mSyncActionDialog->setCaption( i18n("Sending file...") );
989 QTextStream ts( &file ); 1033 QTextStream ts( &file );
990 ts.setEncoding( QTextStream::Latin1 ); 1034 ts.setEncoding( QTextStream::Latin1 );
991 1035
992 QTextStream os( mSocket ); 1036 QTextStream os( mSocket );
993 os.setEncoding( QTextStream::Latin1 ); 1037 os.setEncoding( QTextStream::Latin1 );
994 while ( ! ts.atEnd() ) { 1038 while ( ! ts.atEnd() ) {
995 os << ts.readLine() << "\r\n"; 1039 os << ts.readLine() << "\r\n";
996 } 1040 }
997 //os << ts.read(); 1041 //os << ts.read();
998 file.close(); 1042 file.close();
999 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 1043 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
1000 mSocket->close(); 1044 mSocket->close();
1001 if ( mSocket->state() == QSocket::Idle ) 1045 if ( mSocket->state() == QSocket::Idle )
1002 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1046 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1003} 1047}
1004void KServerSocket::get_file() 1048void KServerSocket::get_file()
1005{ 1049{
1006 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 1050 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
1007 1051
1008 piTime.start(); 1052 piTime.start();
1009 piFileString = ""; 1053 piFileString = "";
1010 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 1054 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
1011} 1055}
1012 1056
1013 1057
1014void KServerSocket::readBackFileFromSocket() 1058void KServerSocket::readBackFileFromSocket()
1015{ 1059{
1016 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 1060 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
1017 while ( mSocket->canReadLine () ) { 1061 while ( mSocket->canReadLine () ) {
1018 piTime.restart(); 1062 piTime.restart();
1019 QString line = mSocket->readLine (); 1063 QString line = mSocket->readLine ();
1020 piFileString += line; 1064 piFileString += line;
1021 //qDebug("readline: %s ", line.latin1()); 1065 //qDebug("readline: %s ", line.latin1());
1022 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 1066 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
1023 1067
1024 } 1068 }
1025 if ( piTime.elapsed () < 3000 ) { 1069 if ( piTime.elapsed () < 3000 ) {
1026 // wait for more 1070 // wait for more
1027 //qDebug("waitformore "); 1071 //qDebug("waitformore ");
1028 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 1072 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
1029 return; 1073 return;
1030 } 1074 }
1031 QString fileName = mFileName; 1075 QString fileName = mFileName;
1032 QFile file ( fileName ); 1076 QFile file ( fileName );
1033 if (!file.open( IO_WriteOnly ) ) { 1077 if (!file.open( IO_WriteOnly ) ) {
1034 delete mSyncActionDialog; 1078 delete mSyncActionDialog;
1035 mSyncActionDialog = 0; 1079 mSyncActionDialog = 0;
1036 qDebug("KSS:Error open read back file "); 1080 qDebug("KSS:Error open read back file ");
1037 piFileString = ""; 1081 piFileString = "";
1038 emit file_received( false ); 1082 emit file_received( false );
1039 blockRC = false; 1083 blockRC = false;
1040 return ; 1084 return ;
1041 1085
1042 } 1086 }
1043 1087
1044 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1088 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1045 QTextStream ts ( &file ); 1089 QTextStream ts ( &file );
1046 ts.setEncoding( QTextStream::Latin1 ); 1090 ts.setEncoding( QTextStream::Latin1 );
1047 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 1091 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1048 ts << piFileString; 1092 ts << piFileString;
1049 mSocket->close(); 1093 mSocket->close();
1050 if ( mSocket->state() == QSocket::Idle ) 1094 if ( mSocket->state() == QSocket::Idle )
1051 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1095 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1052 file.close(); 1096 file.close();
1053 delete mSyncActionDialog; 1097 delete mSyncActionDialog;
1054 mSyncActionDialog = 0; 1098 mSyncActionDialog = 0;
1055 piFileString = ""; 1099 piFileString = "";
1056 blockRC = false; 1100 blockRC = false;
1057 emit file_received( true ); 1101 emit file_received( true );
1058 1102
1059} 1103}
1060 1104
1061KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) 1105KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
1062{ 1106{
1063 mPassWord = password; 1107 mPassWord = password;
1064 mSocket = 0; 1108 mSocket = 0;
1065 mPort = port; 1109 mPort = port;
1066 mHost = host; 1110 mHost = host;
1067 1111
1068 mRetVal = quiet; 1112 mRetVal = quiet;
1069 mTimerSocket = new QTimer ( this ); 1113 mTimerSocket = new QTimer ( this );
1070 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); 1114 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
1071} 1115}
1072void KCommandSocket::readFile( QString fn ) 1116void KCommandSocket::readFile( QString fn )
1073{ 1117{
1074 if ( !mSocket ) { 1118 if ( !mSocket ) {
1075 mSocket = new QSocket( this ); 1119 mSocket = new QSocket( this );
1076 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1120 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1077 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1121 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1078 } 1122 }
1079 mFileString = ""; 1123 mFileString = "";
1080 mFileName = fn; 1124 mFileName = fn;
1081 mFirst = true; 1125 mFirst = true;
1082 mSocket->connectToHost( mHost, mPort ); 1126 mSocket->connectToHost( mHost, mPort );
1083 QTextStream os( mSocket ); 1127 QTextStream os( mSocket );
1084 os.setEncoding( QTextStream::Latin1 ); 1128 os.setEncoding( QTextStream::Latin1 );
1085 os << "GET " << mPassWord << "\r\n"; 1129 os << "GET " << mPassWord << "\r\n";
1086 mTimerSocket->start( 10000 ); 1130 mTimerSocket->start( 10000 );
1087} 1131}
1088 1132
1089void KCommandSocket::writeFile( QString fileName ) 1133void KCommandSocket::writeFile( QString fileName )
1090{ 1134{
1091 if ( !mSocket ) { 1135 if ( !mSocket ) {
1092 mSocket = new QSocket( this ); 1136 mSocket = new QSocket( this );
1093 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1137 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1094 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 1138 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1095 } 1139 }
1096 mFileName = fileName ; 1140 mFileName = fileName ;
1097 mSocket->connectToHost( mHost, mPort ); 1141 mSocket->connectToHost( mHost, mPort );
1098} 1142}
1099void KCommandSocket::writeFileToSocket() 1143void KCommandSocket::writeFileToSocket()
1100{ 1144{
1101 QFile file2( mFileName ); 1145 QFile file2( mFileName );
1102 if (!file2.open( IO_ReadOnly ) ) { 1146 if (!file2.open( IO_ReadOnly ) ) {
1103 mRetVal= errorW; 1147 mRetVal= errorW;
1104 mSocket->close(); 1148 mSocket->close();
1105 if ( mSocket->state() == QSocket::Idle ) 1149 if ( mSocket->state() == QSocket::Idle )
1106 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1150 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1107 return ; 1151 return ;
1108 } 1152 }
1109 QTextStream ts2( &file2 ); 1153 QTextStream ts2( &file2 );
1110 ts2.setEncoding( QTextStream::Latin1 ); 1154 ts2.setEncoding( QTextStream::Latin1 );
1111 QTextStream os2( mSocket ); 1155 QTextStream os2( mSocket );
1112 os2.setEncoding( QTextStream::Latin1 ); 1156 os2.setEncoding( QTextStream::Latin1 );
1113 os2 << "PUT " << mPassWord << "\r\n";; 1157 os2 << "PUT " << mPassWord << "\r\n";;
1114 while ( ! ts2.atEnd() ) { 1158 while ( ! ts2.atEnd() ) {
1115 os2 << ts2.readLine() << "\r\n"; 1159 os2 << ts2.readLine() << "\r\n";
1116 } 1160 }
1117 mRetVal= successW; 1161 mRetVal= successW;
1118 file2.close(); 1162 file2.close();
1119 mSocket->close(); 1163 mSocket->close();
1120 if ( mSocket->state() == QSocket::Idle ) 1164 if ( mSocket->state() == QSocket::Idle )
1121 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1165 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1122} 1166}
1123void KCommandSocket::sendStop() 1167void KCommandSocket::sendStop()
1124{ 1168{
1125 if ( !mSocket ) { 1169 if ( !mSocket ) {
1126 mSocket = new QSocket( this ); 1170 mSocket = new QSocket( this );
1127 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1171 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 9094aac..7d5b05e 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,209 +1,210 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 19
20 $Id$ 20 $Id$
21*/ 21*/
22#ifndef _KSYNCMANAGER_H 22#ifndef _KSYNCMANAGER_H
23#define _KSYNCMANAGER_H 23#define _KSYNCMANAGER_H
24 24
25#include <qobject.h> 25#include <qobject.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qsocket.h> 27#include <qsocket.h>
28#include <qdatetime.h> 28#include <qdatetime.h>
29#include <qserversocket.h> 29#include <qserversocket.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qregexp.h> 31#include <qregexp.h>
32 32
33class QPopupMenu; 33class QPopupMenu;
34class KSyncProfile; 34class KSyncProfile;
35class KPimPrefs; 35class KPimPrefs;
36class QWidget; 36class QWidget;
37class KSyncManager; 37class KSyncManager;
38class KSyncInterface; 38class KSyncInterface;
39class QProgressBar; 39class QProgressBar;
40 40
41 41
42class KServerSocket : public QServerSocket 42class KServerSocket : public QServerSocket
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45 45
46 public: 46 public:
47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); 47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
48 48
49 void newConnection ( int socket ) ; 49 void newConnection ( int socket ) ;
50 void setFileName( QString fn ) {mFileName = fn;}; 50 void setFileName( QString fn ) {mFileName = fn;};
51 signals: 51 signals:
52 void file_received( bool ); 52 void file_received( bool );
53 void request_file(); 53 void request_file();
54 void saveFile(); 54 void saveFile();
55 void endConnect(); 55 void endConnect();
56 private slots: 56 private slots:
57 void discardClient(); 57 void discardClient();
58 void readClient(); 58 void readClient();
59 void readBackFileFromSocket(); 59 void readBackFileFromSocket();
60 private : 60 private :
61 bool blockRC; 61 bool blockRC;
62 void send_file(); 62 void send_file();
63 void get_file(); 63 void get_file();
64 void end_connect(); 64 void end_connect();
65 QDialog* mSyncActionDialog; 65 QDialog* mSyncActionDialog;
66 QSocket* mSocket; 66 QSocket* mSocket;
67 QString mPassWord; 67 QString mPassWord;
68 QString mFileName; 68 QString mFileName;
69 QTime piTime; 69 QTime piTime;
70 QString piFileString; 70 QString piFileString;
71}; 71};
72 72
73class KCommandSocket : public QObject 73class KCommandSocket : public QObject
74{ 74{
75 Q_OBJECT 75 Q_OBJECT
76 public: 76 public:
77 enum state { successR, errorR, successW, errorW, errorTO, quiet }; 77 enum state { successR, errorR, successW, errorW, errorTO, quiet };
78 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); 78 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
79 void readFile( QString ); 79 void readFile( QString );
80 void writeFile( QString ); 80 void writeFile( QString );
81 void sendStop(); 81 void sendStop();
82 82
83 signals: 83 signals:
84 void commandFinished( KCommandSocket*, int ); 84 void commandFinished( KCommandSocket*, int );
85 private slots: 85 private slots:
86 void startReadFileFromSocket(); 86 void startReadFileFromSocket();
87 void readFileFromSocket(); 87 void readFileFromSocket();
88 void deleteSocket(); 88 void deleteSocket();
89 void writeFileToSocket(); 89 void writeFileToSocket();
90 private : 90 private :
91 QSocket* mSocket; 91 QSocket* mSocket;
92 QString mPassWord; 92 QString mPassWord;
93 Q_UINT16 mPort; 93 Q_UINT16 mPort;
94 QString mHost; 94 QString mHost;
95 QString mFileName; 95 QString mFileName;
96 QTimer* mTimerSocket; 96 QTimer* mTimerSocket;
97 int mRetVal; 97 int mRetVal;
98 QTime mTime; 98 QTime mTime;
99 QString mFileString; 99 QString mFileString;
100 bool mFirst; 100 bool mFirst;
101}; 101};
102 102
103 103
104class KSyncManager : public QObject 104class KSyncManager : public QObject
105{ 105{
106 Q_OBJECT 106 Q_OBJECT
107 107
108 public: 108 public:
109 enum TargetApp { 109 enum TargetApp {
110 KOPI = 0, 110 KOPI = 0,
111 KAPI = 1, 111 KAPI = 1,
112 PWMPI = 2 }; 112 PWMPI = 2 };
113 113
114 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 114 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
115 ~KSyncManager() ; 115 ~KSyncManager() ;
116 116
117 void multiSync( bool askforPrefs ); 117 void multiSync( bool askforPrefs );
118 bool blockSave() { return mBlockSaveFlag; } 118 bool blockSave() { return mBlockSaveFlag; }
119 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 119 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
120 void setDefaultFileName( QString s) { mDefFileName = s ;} 120 void setDefaultFileName( QString s) { mDefFileName = s ;}
121 QString defaultFileName() { return mDefFileName ;} 121 QString defaultFileName() { return mDefFileName ;}
122 QString syncFileName(); 122 QString syncFileName();
123 123
124 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 124 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
125 QString getCurrentSyncName() { return mCurrentSyncName; } 125 QString getCurrentSyncName() { return mCurrentSyncName; }
126 126
127 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 127 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
128 void hideProgressBar(); 128 void hideProgressBar();
129 bool isProgressBarCanceled(); 129 bool isProgressBarCanceled();
130 130
131 // sync stuff 131 // sync stuff
132 QString mLocalMachineName; 132 QString mLocalMachineName;
133 QStringList mExternSyncProfiles; 133 QStringList mExternSyncProfiles;
134 QStringList mSyncProfileNames; 134 QStringList mSyncProfileNames;
135 bool mAskForPreferences; 135 bool mAskForPreferences;
136 bool mShowSyncSummary; 136 bool mShowSyncSummary;
137 bool mIsKapiFile; 137 bool mIsKapiFile;
138 bool mWriteBackExistingOnly; 138 bool mWriteBackExistingOnly;
139 int mSyncAlgoPrefs; 139 int mSyncAlgoPrefs;
140 bool mWriteBackFile; 140 bool mWriteBackFile;
141 int mWriteBackInFuture; 141 int mWriteBackInFuture;
142 QString mPhoneDevice; 142 QString mPhoneDevice;
143 QString mPhoneConnection; 143 QString mPhoneConnection;
144 QString mPhoneModel; 144 QString mPhoneModel;
145 QString mPassWordPiSync; 145 QString mPassWordPiSync;
146 QString mActiveSyncPort; 146 QString mActiveSyncPort;
147 QString mActiveSyncIP ; 147 QString mActiveSyncIP ;
148 148
149 signals: 149 signals:
150 void save(); 150 void save();
151 void request_file(); 151 void request_file();
152 void getFile( bool ); 152 void getFile( bool );
153 153
154 public slots: 154 public slots:
155 void slotSyncMenu( int ); 155 void slotSyncMenu( int );
156 void deleteCommandSocket(KCommandSocket*s, int state); 156 void deleteCommandSocket(KCommandSocket*s, int state);
157 void readFileFromSocket(); 157 void readFileFromSocket();
158 void fillSyncMenu(); 158 void fillSyncMenu();
159 159
160 private: 160 private:
161 void syncPi(); 161 void syncPi();
162 KServerSocket * mServerSocket; 162 KServerSocket * mServerSocket;
163 void enableQuick(); 163 void enableQuick();
164 KPimPrefs* mPrefs; 164 KPimPrefs* mPrefs;
165 QString mDefFileName; 165 QString mDefFileName;
166 QString mCurrentSyncDevice; 166 QString mCurrentSyncDevice;
167 QString mCurrentSyncName; 167 QString mCurrentSyncName;
168 void quickSyncLocalFile(); 168 void quickSyncLocalFile();
169 bool syncWithFile( QString fn , bool quick ); 169 bool syncWithFile( QString fn , bool quick );
170 void syncLocalFile(); 170 void syncLocalFile();
171 void syncPhone(); 171 void syncPhone();
172 void syncSharp(); 172 void syncSharp();
173 void syncKDE();
173 bool syncExternalApplication(QString); 174 bool syncExternalApplication(QString);
174 int mCurrentSyncProfile ; 175 int mCurrentSyncProfile ;
175 void syncRemote( KSyncProfile* prof, bool ask = true); 176 void syncRemote( KSyncProfile* prof, bool ask = true);
176 void edit_sync_options(); 177 void edit_sync_options();
177 void edit_pisync_options(); 178 void edit_pisync_options();
178 int ringSync(); 179 int ringSync();
179 QString getPassword( ); 180 QString getPassword( );
180 181
181 private slots: 182 private slots:
182 void confSync(); 183 void confSync();
183 private: 184 private:
184 bool mBlockSaveFlag; 185 bool mBlockSaveFlag;
185 QWidget* mParent; 186 QWidget* mParent;
186 KSyncInterface* mImplementation; 187 KSyncInterface* mImplementation;
187 TargetApp mTargetApp; 188 TargetApp mTargetApp;
188 QPopupMenu* mSyncMenu; 189 QPopupMenu* mSyncMenu;
189 QProgressBar* bar; 190 QProgressBar* bar;
190 191
191}; 192};
192 193
193 194
194class KSyncInterface 195class KSyncInterface
195{ 196{
196 public : 197 public :
197 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; 198 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0;
198 virtual bool syncExternal(KSyncManager* manager, QString resource) 199 virtual bool syncExternal(KSyncManager* manager, QString resource)
199 { 200 {
200 // empty implementation, because some syncable applications do not 201 // empty implementation, because some syncable applications do not
201 // have an external(sharpdtm) syncmode, like pwmanager. 202 // have an external(sharpdtm) syncmode, like pwmanager.
202 return false; 203 return false;
203 } 204 }
204 205
205 206
206}; 207};
207 208
208 209
209#endif 210#endif