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