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