summaryrefslogtreecommitdiffabout
path: root/libkdepim
Unidiff
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp51
-rw-r--r--libkdepim/ksyncmanager.h8
-rw-r--r--libkdepim/ksyncprefsdialog.cpp6
3 files changed, 50 insertions, 15 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index d71264f..a64eb34 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,1720 +1,1751 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21// $Id$ 21// $Id$
22 22
23#include "ksyncmanager.h" 23#include "ksyncmanager.h"
24 24
25#include <stdlib.h> 25#include <stdlib.h>
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#include <unistd.h> 28#include <unistd.h>
29#endif 29#endif
30 30
31 31
32#include "ksyncprofile.h" 32#include "ksyncprofile.h"
33#include "ksyncprefsdialog.h" 33#include "ksyncprefsdialog.h"
34#include "kpimprefs.h" 34#include "kpimprefs.h"
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <qdir.h> 37#include <qdir.h>
38#include <qprogressbar.h> 38#include <qprogressbar.h>
39#include <qpopupmenu.h> 39#include <qpopupmenu.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qradiobutton.h> 41#include <qradiobutton.h>
42#include <qbuttongroup.h> 42#include <qbuttongroup.h>
43#include <qtimer.h> 43#include <qtimer.h>
44#include <qmessagebox.h> 44#include <qmessagebox.h>
45#include <qapplication.h> 45#include <qapplication.h>
46#include <qlineedit.h> 46#include <qlineedit.h>
47#include <qdialog.h> 47#include <qdialog.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qtextcodec.h> 49#include <qtextcodec.h>
50#include <qlabel.h> 50#include <qlabel.h>
51#include <qcheckbox.h> 51#include <qcheckbox.h>
52#include <qapplication.h> 52#include <qapplication.h>
53 53
54#include <klocale.h> 54#include <klocale.h>
55#include <kglobal.h> 55#include <kglobal.h>
56#include <kconfig.h> 56#include <kconfig.h>
57#include <kfiledialog.h> 57#include <kfiledialog.h>
58 58
59QDateTime KSyncManager::mRequestedSyncEvent; 59QDateTime KSyncManager::mRequestedSyncEvent;
60 60
61 61
62KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 62KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
63 : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) 63 : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu)
64{ 64{
65 mServerSocket = 0; 65 mServerSocket = 0;
66 bar = new QProgressBar ( 1, 0 ); 66 bar = new QProgressBar ( 1, 0 );
67 bar->setCaption (""); 67 bar->setCaption ("");
68 mWriteBackInPast = 2; 68 mWriteBackInPast = 2;
69 69
70 70
71} 71}
72 72
73KSyncManager::~KSyncManager() 73KSyncManager::~KSyncManager()
74{ 74{
75 delete bar; 75 delete bar;
76} 76}
77 77
78void KSyncManager::setDefaultFileName( QString s) 78void KSyncManager::setDefaultFileName( QString s)
79{ 79{
80 mDefFileName = s ; 80 mDefFileName = s ;
81 if ( mPrefs->mPassiveSyncAutoStart ) 81 if ( mPrefs->mPassiveSyncAutoStart )
82 enableQuick( false ); 82 enableQuick( false );
83} 83}
84 84
85void KSyncManager::fillSyncMenu() 85void KSyncManager::fillSyncMenu()
86{ 86{
87 if ( mSyncMenu->count() ) 87 if ( mSyncMenu->count() )
88 mSyncMenu->clear(); 88 mSyncMenu->clear();
89 89
90 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 90 mSyncMenu->insertItem( i18n("Configure..."), 0 );
91 mSyncMenu->insertSeparator(); 91 mSyncMenu->insertSeparator();
92 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); 92 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu );
93 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); 93 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 );
94 clearMenu->insertItem( i18n("For all profiles"), 1 ); 94 clearMenu->insertItem( i18n("For all profiles"), 1 );
95 clearMenu->insertSeparator(); 95 clearMenu->insertSeparator();
96 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); 96 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) );
97 mSyncMenu->insertSeparator(); 97 mSyncMenu->insertSeparator();
98 if ( mServerSocket == 0 ) { 98 if ( mServerSocket == 0 ) {
99 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 99 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
100 } else { 100 } else {
101 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 101 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
102 } 102 }
103 mSyncMenu->insertSeparator(); 103 mSyncMenu->insertSeparator();
104 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 104 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
105 mSyncMenu->insertSeparator(); 105 mSyncMenu->insertSeparator();
106 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 106 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
107 config.setGroup("General"); 107 config.setGroup("General");
108 QStringList prof = config.readListEntry("SyncProfileNames"); 108 QStringList prof = config.readListEntry("SyncProfileNames");
109 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 109 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
110 if ( prof.count() < 2 ) { 110 if ( prof.count() < 2 ) {
111 prof.clear(); 111 prof.clear();
112 QString externalName; 112 QString externalName;
113#ifdef DESKTOP_VERSION 113#ifdef DESKTOP_VERSION
114#ifdef _WIN32_ 114#ifdef _WIN32_
115 externalName = "OutLook(not_implemented)"; 115 externalName = "OutLook(not_implemented)";
116#else 116#else
117 externalName = "KDE_Desktop"; 117 externalName = "KDE_Desktop";
118#endif 118#endif
119#else 119#else
120 externalName = "Sharp_DTM"; 120 externalName = "Sharp_DTM";
121#endif 121#endif
122 prof << externalName; 122 prof << externalName;
123 prof << i18n("Local_file"); 123 prof << i18n("Local_file");
124 prof << i18n("Last_file"); 124 prof << i18n("Last_file");
125 KSyncProfile* temp = new KSyncProfile (); 125 KSyncProfile* temp = new KSyncProfile ();
126 temp->setName( prof[0] ); 126 temp->setName( prof[0] );
127 temp->writeConfig(&config); 127 temp->writeConfig(&config);
128 temp->setName( prof[1] ); 128 temp->setName( prof[1] );
129 temp->writeConfig(&config); 129 temp->writeConfig(&config);
130 temp->setName( prof[2] ); 130 temp->setName( prof[2] );
131 temp->writeConfig(&config); 131 temp->writeConfig(&config);
132 config.setGroup("General"); 132 config.setGroup("General");
133 config.writeEntry("SyncProfileNames",prof); 133 config.writeEntry("SyncProfileNames",prof);
134 config.writeEntry("ExternSyncProfiles",externalName); 134 config.writeEntry("ExternSyncProfiles",externalName);
135 config.sync(); 135 config.sync();
136 delete temp; 136 delete temp;
137 } 137 }
138 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 138 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
139 mSyncProfileNames = prof; 139 mSyncProfileNames = prof;
140 unsigned int i; 140 unsigned int i;
141 for ( i = 0; i < prof.count(); ++i ) { 141 for ( i = 0; i < prof.count(); ++i ) {
142 QString insertText = prof[i]; 142 QString insertText = prof[i];
143 if ( i == 0 ) { 143 if ( i == 0 ) {
144#ifdef DESKTOP_VERSION 144#ifdef DESKTOP_VERSION
145#ifdef _WIN32_ 145#ifdef _WIN32_
146 insertText = "OutLook(not_implemented)"; 146 insertText = "OutLook(not_implemented)";
147#else 147#else
148 insertText = "KDE_Desktop"; 148 insertText = "KDE_Desktop";
149#endif 149#endif
150#else 150#else
151 insertText = "Sharp_DTM"; 151 insertText = "Sharp_DTM";
152#endif 152#endif
153 } 153 }
154 mSyncMenu->insertItem( insertText, 1000+i ); 154 mSyncMenu->insertItem( insertText, 1000+i );
155 clearMenu->insertItem( insertText, 1000+i ); 155 clearMenu->insertItem( insertText, 1000+i );
156 if ( i == 2 ) 156 if ( i == 2 )
157 mSyncMenu->insertSeparator(); 157 mSyncMenu->insertSeparator();
158 } 158 }
159 QDir app_dir; 159 QDir app_dir;
160 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 160 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
161 if ( mTargetApp == PWMPI) { 161 if ( mTargetApp == PWMPI) {
162 mSyncMenu->removeItem( 1000 ); 162 mSyncMenu->removeItem( 1000 );
163 clearMenu->removeItem( 1000 ); 163 clearMenu->removeItem( 1000 );
164 } 164 }
165#ifndef DESKTOP_VERSION 165#ifndef DESKTOP_VERSION
166 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 166 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
167 mSyncMenu->removeItem( 1000 ); 167 mSyncMenu->removeItem( 1000 );
168 clearMenu->removeItem( 1000 ); 168 clearMenu->removeItem( 1000 );
169 } 169 }
170#endif 170#endif
171 mSyncMenu->removeItem( 1002 ); 171 mSyncMenu->removeItem( 1002 );
172 clearMenu->removeItem( 1002 ); 172 clearMenu->removeItem( 1002 );
173} 173}
174void KSyncManager::slotClearMenu( int action ) 174void KSyncManager::slotClearMenu( int action )
175{ 175{
176 QString syncDevice; 176 QString syncDevice;
177 if ( action > 999 ) { 177 if ( action > 999 ) {
178 syncDevice = mSyncProfileNames[action - 1000] ; 178 syncDevice = mSyncProfileNames[action - 1000] ;
179 } 179 }
180 180
181 181
182 182
183 int result = 0; 183 int result = 0;
184 QString sd; 184 QString sd;
185 if ( syncDevice.isEmpty() ) 185 if ( syncDevice.isEmpty() )
186 sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); 186 sd = i18n("Do you want to\nclear all sync info\nof all profiles?");
187 else 187 else
188 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); 188 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice );
189 189
190 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, 190 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0,
191 0, 1 ); 191 0, 1 );
192 if ( result ) 192 if ( result )
193 return; 193 return;
194 mImplementation->removeSyncInfo( syncDevice ); 194 mImplementation->removeSyncInfo( syncDevice );
195} 195}
196void KSyncManager::slotSyncMenu( int action ) 196void KSyncManager::slotSyncMenu( int action )
197{ 197{
198 qDebug("KSM::syncaction %d ", action); 198 qDebug("KSM::syncaction %d ", action);
199 mCurrentResourceLocal = "";
199 if ( action == 5000 ) 200 if ( action == 5000 )
200 return; 201 return;
201 mSyncWithDesktop = false; 202 mSyncWithDesktop = false;
202 if ( action == 0 ) { 203 if ( action == 0 ) {
203 204
204 // seems to be a Qt2 event handling bug 205 // seems to be a Qt2 event handling bug
205 // syncmenu.clear causes a segfault at first time 206 // syncmenu.clear causes a segfault at first time
206 // when we call it after the main event loop, it is ok 207 // when we call it after the main event loop, it is ok
207 // same behaviour when calling OM/Pi via QCOP for the first time 208 // same behaviour when calling OM/Pi via QCOP for the first time
208 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 209 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
209 //confSync(); 210 //confSync();
210 211
211 return; 212 return;
212 } 213 }
213 if ( action == 1 ) { 214 if ( action == 1 ) {
214 multiSync( true ); 215 multiSync( true );
215 return; 216 return;
216 } 217 }
217 if ( action == 2 ) { 218 if ( action == 2 ) {
218 enableQuick(); 219 enableQuick();
219 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 220 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
220 return; 221 return;
221 } 222 }
222 if ( action == 3 ) { 223 if ( action == 3 ) {
223 delete mServerSocket; 224 delete mServerSocket;
224 mServerSocket = 0; 225 mServerSocket = 0;
225 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 226 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
226 return; 227 return;
227 } 228 }
228 229
229 if (blockSave()) 230 if (blockSave())
230 return; 231 return;
231 232
232 setBlockSave(true); 233 setBlockSave(true);
233 bool silent = false; 234 bool silent = false;
234 if ( action == 999 ) { 235 if ( action == 999 ) {
235 //special mode for silent syncing 236 //special mode for silent syncing
236 action = 1000; 237 action = 1000;
237 silent = true; 238 silent = true;
238 } 239 }
239 240
240 mCurrentSyncProfile = action - 1000 ; 241 mCurrentSyncProfile = action - 1000 ;
241 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 242 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
242 mCurrentSyncName = mLocalMachineName ; 243 mCurrentSyncName = mLocalMachineName ;
243 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 244 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
244 KSyncProfile* temp = new KSyncProfile (); 245 KSyncProfile* temp = new KSyncProfile ();
245 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 246 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
246 temp->readConfig(&config); 247 temp->readConfig(&config);
247 if (silent) { 248 if (silent) {
248 mAskForPreferences = false; 249 mAskForPreferences = false;
249 mShowSyncSummary = false; 250 mShowSyncSummary = false;
250 mWriteBackFile = true; 251 mWriteBackFile = true;
251 mSyncAlgoPrefs = 2;// take newest 252 mSyncAlgoPrefs = 2;// take newest
252 } 253 }
253 else { 254 else {
254 mAskForPreferences = temp->getAskForPreferences(); 255 mAskForPreferences = temp->getAskForPreferences();
255 mShowSyncSummary = temp->getShowSummaryAfterSync(); 256 mShowSyncSummary = temp->getShowSummaryAfterSync();
256 mWriteBackFile = temp->getWriteBackFile(); 257 mWriteBackFile = temp->getWriteBackFile();
257 mSyncAlgoPrefs = temp->getSyncPrefs(); 258 mSyncAlgoPrefs = temp->getSyncPrefs();
258 } 259 }
259 mWriteBackExistingOnly = temp->getWriteBackExisting(); 260 mWriteBackExistingOnly = temp->getWriteBackExisting();
260 mIsKapiFile = temp->getIsKapiFile(); 261 mIsKapiFile = temp->getIsKapiFile();
261 mWriteBackInFuture = 0; 262 mWriteBackInFuture = 0;
262 if ( temp->getWriteBackFuture() ) { 263 if ( temp->getWriteBackFuture() ) {
263 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 264 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
264 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 265 mWriteBackInPast = temp->getWriteBackPastWeeks( );
265 } 266 }
266 mFilterInCal = temp->getFilterInCal(); 267 mFilterInCal = temp->getFilterInCal();
267 mFilterOutCal = temp->getFilterOutCal(); 268 mFilterOutCal = temp->getFilterOutCal();
268 mFilterInAB = temp->getFilterInAB(); 269 mFilterInAB = temp->getFilterInAB();
269 mFilterOutAB = temp->getFilterOutAB(); 270 mFilterOutAB = temp->getFilterOutAB();
270 271
271 if ( action == 1000 ) { 272 if ( action == 1000 ) {
272 mIsKapiFile = false; 273 mIsKapiFile = false;
273#ifdef DESKTOP_VERSION 274#ifdef DESKTOP_VERSION
274 syncKDE(); 275 syncKDE();
275#else 276#else
276 syncSharp(); 277 syncSharp();
277#endif 278#endif
278 279
279 } else if ( action == 1001 ) { 280 } else if ( action == 1001 ) {
280 syncLocalFile(); 281 syncLocalFile();
281 282
282 } else if ( action == 1002 ) { 283 } else if ( action == 1002 ) {
283 mWriteBackFile = false; 284 mWriteBackFile = false;
284 mAskForPreferences = false; 285 mAskForPreferences = false;
285 mShowSyncSummary = false; 286 mShowSyncSummary = false;
286 mSyncAlgoPrefs = 3; 287 mSyncAlgoPrefs = 3;
287 quickSyncLocalFile(); 288 quickSyncLocalFile();
288 289
289 } else if ( action >= 1003 ) { 290 } else if ( action >= 1003 ) {
290 if ( temp->getIsLocalFileSync() ) { 291 if ( temp->getIsLocalFileSync() ) {
291 switch(mTargetApp) 292 switch(mTargetApp)
292 { 293 {
293 case (KAPI): 294 case (KAPI):
294 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 295 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
295 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 296 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
296 break; 297 break;
297 case (KOPI): 298 case (KOPI):
298 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 299 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
299 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 300 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
300 break; 301 break;
301 case (PWMPI): 302 case (PWMPI):
302 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 303 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
303 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 304 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
304 break; 305 break;
305 default: 306 default:
306 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 307 qDebug("KSM::slotSyncMenu: invalid apptype selected");
307 break; 308 break;
308 309
309 } 310 }
310 } else { 311 } else {
311 if ( temp->getIsPhoneSync() ) { 312 if ( temp->getIsPhoneSync() ) {
312 mPhoneDevice = temp->getPhoneDevice( ) ; 313 mPhoneDevice = temp->getPhoneDevice( ) ;
313 mPhoneConnection = temp->getPhoneConnection( ); 314 mPhoneConnection = temp->getPhoneConnection( );
314 mPhoneModel = temp->getPhoneModel( ); 315 mPhoneModel = temp->getPhoneModel( );
315 syncPhone(); 316 syncPhone();
316 } else if ( temp->getIsPiSync() ) { 317 } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) {
318 mSpecificResources.clear();
317 if ( mTargetApp == KAPI ) { 319 if ( mTargetApp == KAPI ) {
318 mPassWordPiSync = temp->getRemotePwAB(); 320 mPassWordPiSync = temp->getRemotePwAB();
319 mActiveSyncPort = temp->getRemotePortAB(); 321 mActiveSyncPort = temp->getRemotePortAB();
320 mActiveSyncIP = temp->getRemoteIPAB(); 322 mActiveSyncIP = temp->getRemoteIPAB();
321 } else if ( mTargetApp == KOPI ) { 323 } else if ( mTargetApp == KOPI ) {
324 if ( temp->getIsPiSyncSpec() )
325 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() );
322 mPassWordPiSync = temp->getRemotePw(); 326 mPassWordPiSync = temp->getRemotePw();
323 mActiveSyncPort = temp->getRemotePort(); 327 mActiveSyncPort = temp->getRemotePort();
324 mActiveSyncIP = temp->getRemoteIP(); 328 mActiveSyncIP = temp->getRemoteIP();
325 } else { 329 } else {
326 mPassWordPiSync = temp->getRemotePwPWM(); 330 mPassWordPiSync = temp->getRemotePwPWM();
327 mActiveSyncPort = temp->getRemotePortPWM(); 331 mActiveSyncPort = temp->getRemotePortPWM();
328 mActiveSyncIP = temp->getRemoteIPPWM(); 332 mActiveSyncIP = temp->getRemoteIPPWM();
329 } 333 }
330 syncPi(); 334 syncPi();
331 while ( !mPisyncFinished ) { 335 while ( !mPisyncFinished ) {
332 //qDebug("waiting "); 336 //qDebug("waiting ");
333 qApp->processEvents(); 337 qApp->processEvents();
334 } 338 }
335 } else 339 } else
336 syncRemote( temp ); 340 syncRemote( temp );
337 341
338 } 342 }
339 } 343 }
340 delete temp; 344 delete temp;
341 setBlockSave(false); 345 setBlockSave(false);
342} 346}
343 347
344void KSyncManager::enableQuick( bool ask ) 348void KSyncManager::enableQuick( bool ask )
345{ 349{
346 bool autoStart; 350 bool autoStart;
347 bool changed = false; 351 bool changed = false;
348 if ( ask ) { 352 if ( ask ) {
349 QDialog dia ( 0, "input-dialog", true ); 353 QDialog dia ( 0, "input-dialog", true );
350 QLineEdit lab ( &dia ); 354 QLineEdit lab ( &dia );
351 QVBoxLayout lay( &dia ); 355 QVBoxLayout lay( &dia );
352 lab.setText( mPrefs->mPassiveSyncPort ); 356 lab.setText( mPrefs->mPassiveSyncPort );
353 lay.setMargin(7); 357 lay.setMargin(7);
354 lay.setSpacing(7); 358 lay.setSpacing(7);
355 int po = 9197+mTargetApp; 359 int po = 9197+mTargetApp;
356 QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); 360 QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia );
357 lay.addWidget( &label); 361 lay.addWidget( &label);
358 lay.addWidget( &lab); 362 lay.addWidget( &lab);
359 363
360 QLineEdit lepw ( &dia ); 364 QLineEdit lepw ( &dia );
361 lepw.setText( mPrefs->mPassiveSyncPw ); 365 lepw.setText( mPrefs->mPassiveSyncPw );
362 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 366 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
363 lay.addWidget( &label2); 367 lay.addWidget( &label2);
364 lay.addWidget( &lepw); 368 lay.addWidget( &lepw);
365 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); 369 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia );
366 lay.addWidget( &autostart); 370 lay.addWidget( &autostart);
367 autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); 371 autostart.setChecked( mPrefs->mPassiveSyncAutoStart );
368#ifdef DESKTOP_VERSION 372#ifdef DESKTOP_VERSION
369#ifdef _WIN32_ 373#ifdef _WIN32_
370 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); 374 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia );
371 syncdesktop.hide();// not implemented! 375 syncdesktop.hide();// not implemented!
372#else 376#else
373 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); 377 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia );
374#endif 378#endif
375 lay.addWidget( &syncdesktop); 379 lay.addWidget( &syncdesktop);
376#else 380#else
377 mPrefs->mPassiveSyncWithDesktop = false; 381 mPrefs->mPassiveSyncWithDesktop = false;
378 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); 382 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
379 syncdesktop.hide(); 383 syncdesktop.hide();
380#endif 384#endif
381 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); 385 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
382 386
383 QPushButton pb ( "OK", &dia); 387 QPushButton pb ( "OK", &dia);
384 lay.addWidget( &pb ); 388 lay.addWidget( &pb );
385 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 389 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
386 dia.resize( 230,120 ); 390 dia.resize( 230,120 );
387 dia.setCaption( i18n("Enter port for Pi-Sync") ); 391 dia.setCaption( i18n("Enter port for Pi-Sync") );
388 dia.show(); 392 dia.show();
389#ifndef DESKTOP_VERSION 393#ifndef DESKTOP_VERSION
390 int dw = QApplication::desktop()->width(); 394 int dw = QApplication::desktop()->width();
391 int dh = QApplication::desktop()->height(); 395 int dh = QApplication::desktop()->height();
392 dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); 396 dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 );
393#endif 397#endif
394 if ( ! dia.exec() ) 398 if ( ! dia.exec() )
395 return; 399 return;
396 dia.hide(); 400 dia.hide();
397 qApp->processEvents(); 401 qApp->processEvents();
398 if ( mPrefs->mPassiveSyncPw != lepw.text() ) { 402 if ( mPrefs->mPassiveSyncPw != lepw.text() ) {
399 changed = true; 403 changed = true;
400 mPrefs->mPassiveSyncPw = lepw.text(); 404 mPrefs->mPassiveSyncPw = lepw.text();
401 } 405 }
402 if ( mPrefs->mPassiveSyncPort != lab.text() ) { 406 if ( mPrefs->mPassiveSyncPort != lab.text() ) {
403 mPrefs->mPassiveSyncPort = lab.text(); 407 mPrefs->mPassiveSyncPort = lab.text();
404 changed = true; 408 changed = true;
405 } 409 }
406 autoStart = autostart.isChecked(); 410 autoStart = autostart.isChecked();
407 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { 411 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) {
408 changed = true; 412 changed = true;
409 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); 413 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked();
410 } 414 }
411 } 415 }
412 else 416 else
413 autoStart = mPrefs->mPassiveSyncAutoStart; 417 autoStart = mPrefs->mPassiveSyncAutoStart;
414 if ( autoStart != mPrefs->mPassiveSyncAutoStart ) 418 if ( autoStart != mPrefs->mPassiveSyncAutoStart )
415 changed = true; 419 changed = true;
416 bool ok; 420 bool ok;
417 mPrefs->mPassiveSyncAutoStart = false; 421 mPrefs->mPassiveSyncAutoStart = false;
418 Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); 422 Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok);
419 qDebug("%d ", port_t); 423 qDebug("%d ", port_t);
420 if ( ! ok || port_t > 65535 ) { 424 if ( ! ok || port_t > 65535 ) {
421 KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); 425 KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error"));
422 return; 426 return;
423 } 427 }
424 Q_UINT16 port = port_t; 428 Q_UINT16 port = port_t;
425 //qDebug("port %d ", port); 429 //qDebug("port %d ", port);
426 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 430 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
427 mServerSocket->setFileName( defaultFileName() );//bbb 431 mServerSocket->setFileName( defaultFileName() );//bbb
428 if ( !mServerSocket->ok() ) { 432 if ( !mServerSocket->ok() ) {
429 QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); 433 QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) );
430 delete mServerSocket; 434 delete mServerSocket;
431 mServerSocket = 0; 435 mServerSocket = 0;
432 return; 436 return;
433 } 437 }
434 mPrefs->mPassiveSyncAutoStart = autoStart; 438 mPrefs->mPassiveSyncAutoStart = autoStart;
435 if ( changed ) { 439 if ( changed ) {
436 mPrefs->writeConfig(); 440 mPrefs->writeConfig();
437 } 441 }
438 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 442 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
439 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 443 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
440} 444}
441void KSyncManager::displayErrorPort() 445void KSyncManager::displayErrorPort()
442{ 446{
443 KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); 447 KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error"));
444} 448}
445void KSyncManager::syncLocalFile() 449void KSyncManager::syncLocalFile()
446{ 450{
447 451
448 QString fn =mPrefs->mLastSyncedLocalFile; 452 QString fn =mPrefs->mLastSyncedLocalFile;
449 QString ext; 453 QString ext;
450 454
451 switch(mTargetApp) 455 switch(mTargetApp)
452 { 456 {
453 case (KAPI): 457 case (KAPI):
454 ext = "(*.vcf)"; 458 ext = "(*.vcf)";
455 break; 459 break;
456 case (KOPI): 460 case (KOPI):
457 ext = "(*.ics/*.vcs)"; 461 ext = "(*.ics/*.vcs)";
458 break; 462 break;
459 case (PWMPI): 463 case (PWMPI):
460 ext = "(*.pwm)"; 464 ext = "(*.pwm)";
461 break; 465 break;
462 default: 466 default:
463 qDebug("KSM::syncLocalFile: invalid apptype selected"); 467 qDebug("KSM::syncLocalFile: invalid apptype selected");
464 break; 468 break;
465 469
466 } 470 }
467 471
468 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 472 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
469 if ( fn == "" ) 473 if ( fn == "" )
470 return; 474 return;
471 if ( syncWithFile( fn, false ) ) { 475 if ( syncWithFile( fn, false ) ) {
472 qDebug("KSM::syncLocalFile() successful "); 476 qDebug("KSM::syncLocalFile() successful ");
473 } 477 }
474 478
475} 479}
476 480
477bool KSyncManager::syncWithFile( QString fn , bool quick ) 481bool KSyncManager::syncWithFile( QString fn , bool quick )
478{ 482{
479 bool ret = false; 483 bool ret = false;
480 QFileInfo info; 484 QFileInfo info;
481 info.setFile( fn ); 485 info.setFile( fn );
482 QString mess; 486 QString mess;
483 if ( !info. exists() ) { 487 if ( !info. exists() ) {
484 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 488 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
485 QMessageBox::warning( mParent, i18n("Warning!"), 489 QMessageBox::warning( mParent, i18n("Warning!"),
486 mess ); 490 mess );
487 return ret; 491 return ret;
488 } 492 }
489 int result = 0; 493 int result = 0;
490 if ( !quick ) { 494 if ( !quick ) {
491 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 495 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
492 result = QMessageBox::warning( mParent, i18n("Warning!"), 496 result = QMessageBox::warning( mParent, i18n("Warning!"),
493 mess, 497 mess,
494 i18n("Sync"), i18n("Cancel"), 0, 498 i18n("Sync"), i18n("Cancel"), 0,
495 0, 1 ); 499 0, 1 );
496 if ( result ) 500 if ( result )
497 return false; 501 return false;
498 } 502 }
499 if ( mAskForPreferences ) 503 if ( mAskForPreferences )
500 if ( !edit_sync_options()) { 504 if ( !edit_sync_options()) {
501 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 505 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
502 return false; 506 return false;
503 } 507 }
504 if ( result == 0 ) { 508 if ( result == 0 ) {
505 //qDebug("Now sycing ... "); 509 //qDebug("Now sycing ... ");
506 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 510 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) )
507 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 511 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
508 else 512 else
509 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 513 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
510 if ( ! quick ) 514 if ( ! quick )
511 mPrefs->mLastSyncedLocalFile = fn; 515 mPrefs->mLastSyncedLocalFile = fn;
512 } 516 }
513 return ret; 517 return ret;
514} 518}
515 519
516void KSyncManager::quickSyncLocalFile() 520void KSyncManager::quickSyncLocalFile()
517{ 521{
518 522
519 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { 523 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
520 qDebug("KSM::quick syncLocalFile() successful "); 524 qDebug("KSM::quick syncLocalFile() successful ");
521 525
522 } 526 }
523} 527}
524 528
525void KSyncManager::multiSync( bool askforPrefs ) 529void KSyncManager::multiSync( bool askforPrefs )
526{ 530{
527 if (blockSave()) 531 if (blockSave())
528 return; 532 return;
529 setBlockSave(true); 533 setBlockSave(true);
534 mCurrentResourceLocal = "";
530 if ( askforPrefs ) { 535 if ( askforPrefs ) {
531 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 536 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
532 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 537 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
533 question, 538 question,
534 i18n("Yes"), i18n("No"), 539 i18n("Yes"), i18n("No"),
535 0, 0 ) != 0 ) { 540 0, 0 ) != 0 ) {
536 setBlockSave(false); 541 setBlockSave(false);
537 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 542 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
538 return; 543 return;
539 } 544 }
540 } 545 }
541 mCurrentSyncDevice = i18n("Multiple profiles") ; 546 mCurrentSyncDevice = i18n("Multiple profiles") ;
542 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 547 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
543 if ( askforPrefs ) { 548 if ( askforPrefs ) {
544 if ( !edit_sync_options()) { 549 if ( !edit_sync_options()) {
545 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); 550 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") );
546 return; 551 return;
547 } 552 }
548 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; 553 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
549 } 554 }
550 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 555 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
551 qApp->processEvents(); 556 qApp->processEvents();
552 int num = ringSync() ; 557 int num = ringSync() ;
553 if ( num > 1 ) 558 if ( num > 1 )
554 ringSync(); 559 ringSync();
555 setBlockSave(false); 560 setBlockSave(false);
556 if ( num ) 561 if ( num )
557 emit save(); 562 emit save();
558 if ( num ) 563 if ( num )
559 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); 564 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
560 else 565 else
561 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 566 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
562 return; 567 return;
563} 568}
564 569
565int KSyncManager::ringSync() 570int KSyncManager::ringSync()
566{ 571{
567 572
568 int syncedProfiles = 0; 573 int syncedProfiles = 0;
569 unsigned int i; 574 unsigned int i;
570 QTime timer; 575 QTime timer;
571 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 576 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
572 QStringList syncProfileNames = mSyncProfileNames; 577 QStringList syncProfileNames = mSyncProfileNames;
573 KSyncProfile* temp = new KSyncProfile (); 578 KSyncProfile* temp = new KSyncProfile ();
574 mAskForPreferences = false; 579 mAskForPreferences = false;
580 mCurrentResourceLocal = "";
575 for ( i = 0; i < syncProfileNames.count(); ++i ) { 581 for ( i = 0; i < syncProfileNames.count(); ++i ) {
576 mCurrentSyncProfile = i; 582 mCurrentSyncProfile = i;
577 temp->setName(syncProfileNames[mCurrentSyncProfile]); 583 temp->setName(syncProfileNames[mCurrentSyncProfile]);
578 temp->readConfig(&config); 584 temp->readConfig(&config);
579 585
580 bool includeInRingSync = false; 586 bool includeInRingSync = false;
581 switch(mTargetApp) 587 switch(mTargetApp)
582 { 588 {
583 case (KAPI): 589 case (KAPI):
584 includeInRingSync = temp->getIncludeInRingSyncAB(); 590 includeInRingSync = temp->getIncludeInRingSyncAB();
585 break; 591 break;
586 case (KOPI): 592 case (KOPI):
587 includeInRingSync = temp->getIncludeInRingSync(); 593 includeInRingSync = temp->getIncludeInRingSync();
588 break; 594 break;
589 case (PWMPI): 595 case (PWMPI):
590 includeInRingSync = temp->getIncludeInRingSyncPWM(); 596 includeInRingSync = temp->getIncludeInRingSyncPWM();
591 break; 597 break;
592 default: 598 default:
593 qDebug("KSM::ringSync: invalid apptype selected"); 599 qDebug("KSM::ringSync: invalid apptype selected");
594 break; 600 break;
595 601
596 } 602 }
597 603
598 604
599 if ( includeInRingSync && ( i < 1 || i > 2 )) { 605 if ( includeInRingSync && ( i < 1 || i > 2 )) {
600 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 606 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
601 ++syncedProfiles; 607 ++syncedProfiles;
602 mSyncWithDesktop = false; 608 mSyncWithDesktop = false;
603 // mAskForPreferences = temp->getAskForPreferences(); 609 // mAskForPreferences = temp->getAskForPreferences();
604 mWriteBackFile = temp->getWriteBackFile(); 610 mWriteBackFile = temp->getWriteBackFile();
605 mWriteBackExistingOnly = temp->getWriteBackExisting(); 611 mWriteBackExistingOnly = temp->getWriteBackExisting();
606 mIsKapiFile = temp->getIsKapiFile(); 612 mIsKapiFile = temp->getIsKapiFile();
607 mWriteBackInFuture = 0; 613 mWriteBackInFuture = 0;
608 if ( temp->getWriteBackFuture() ) { 614 if ( temp->getWriteBackFuture() ) {
609 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 615 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
610 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 616 mWriteBackInPast = temp->getWriteBackPastWeeks( );
611 } 617 }
612 mFilterInCal = temp->getFilterInCal(); 618 mFilterInCal = temp->getFilterInCal();
613 mFilterOutCal = temp->getFilterOutCal(); 619 mFilterOutCal = temp->getFilterOutCal();
614 mFilterInAB = temp->getFilterInAB(); 620 mFilterInAB = temp->getFilterInAB();
615 mFilterOutAB = temp->getFilterOutAB(); 621 mFilterOutAB = temp->getFilterOutAB();
616 mShowSyncSummary = false; 622 mShowSyncSummary = false;
617 mCurrentSyncDevice = syncProfileNames[i] ; 623 mCurrentSyncDevice = syncProfileNames[i] ;
618 mCurrentSyncName = mLocalMachineName; 624 mCurrentSyncName = mLocalMachineName;
619 if ( i == 0 ) { 625 if ( i == 0 ) {
620 mIsKapiFile = false; 626 mIsKapiFile = false;
621#ifdef DESKTOP_VERSION 627#ifdef DESKTOP_VERSION
622 syncKDE(); 628 syncKDE();
623#else 629#else
624 syncSharp(); 630 syncSharp();
625#endif 631#endif
626 } else { 632 } else {
627 if ( temp->getIsLocalFileSync() ) { 633 if ( temp->getIsLocalFileSync() ) {
628 switch(mTargetApp) 634 switch(mTargetApp)
629 { 635 {
630 case (KAPI): 636 case (KAPI):
631 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 637 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
632 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 638 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
633 break; 639 break;
634 case (KOPI): 640 case (KOPI):
635 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 641 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
636 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 642 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
637 break; 643 break;
638 case (PWMPI): 644 case (PWMPI):
639 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 645 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
640 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 646 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
641 break; 647 break;
642 default: 648 default:
643 qDebug("KSM: invalid apptype selected"); 649 qDebug("KSM: invalid apptype selected");
644 break; 650 break;
645 } 651 }
646 } else { 652 } else {
647 if ( temp->getIsPhoneSync() ) { 653 if ( temp->getIsPhoneSync() ) {
648 mPhoneDevice = temp->getPhoneDevice( ) ; 654 mPhoneDevice = temp->getPhoneDevice( ) ;
649 mPhoneConnection = temp->getPhoneConnection( ); 655 mPhoneConnection = temp->getPhoneConnection( );
650 mPhoneModel = temp->getPhoneModel( ); 656 mPhoneModel = temp->getPhoneModel( );
651 syncPhone(); 657 syncPhone();
652 } else if ( temp->getIsPiSync() ) { 658 } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) {
659 mSpecificResources.clear();
653 if ( mTargetApp == KAPI ) { 660 if ( mTargetApp == KAPI ) {
654 mPassWordPiSync = temp->getRemotePwAB(); 661 mPassWordPiSync = temp->getRemotePwAB();
655 mActiveSyncPort = temp->getRemotePortAB(); 662 mActiveSyncPort = temp->getRemotePortAB();
656 mActiveSyncIP = temp->getRemoteIPAB(); 663 mActiveSyncIP = temp->getRemoteIPAB();
657 } else if ( mTargetApp == KOPI ) { 664 } else if ( mTargetApp == KOPI ) {
665 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() );
658 mPassWordPiSync = temp->getRemotePw(); 666 mPassWordPiSync = temp->getRemotePw();
659 mActiveSyncPort = temp->getRemotePort(); 667 mActiveSyncPort = temp->getRemotePort();
660 mActiveSyncIP = temp->getRemoteIP(); 668 mActiveSyncIP = temp->getRemoteIP();
661 } else { 669 } else {
662 mPassWordPiSync = temp->getRemotePwPWM(); 670 mPassWordPiSync = temp->getRemotePwPWM();
663 mActiveSyncPort = temp->getRemotePortPWM(); 671 mActiveSyncPort = temp->getRemotePortPWM();
664 mActiveSyncIP = temp->getRemoteIPPWM(); 672 mActiveSyncIP = temp->getRemoteIPPWM();
665 } 673 }
666 syncPi(); 674 syncPi();
667 while ( !mPisyncFinished ) { 675 while ( !mPisyncFinished ) {
668 //qDebug("waiting "); 676 //qDebug("waiting ");
669 qApp->processEvents(); 677 qApp->processEvents();
670 } 678 }
671 timer.start(); 679 timer.start();
672 while ( timer.elapsed () < 2000 ) { 680 while ( timer.elapsed () < 2000 ) {
673 qApp->processEvents(); 681 qApp->processEvents();
674 } 682 }
675 } else 683 } else
676 syncRemote( temp, false ); 684 syncRemote( temp, false );
677 685
678 } 686 }
679 } 687 }
680 timer.start(); 688 timer.start();
681 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 689 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
682 while ( timer.elapsed () < 2000 ) { 690 while ( timer.elapsed () < 2000 ) {
683 qApp->processEvents(); 691 qApp->processEvents();
684#ifndef _WIN32_ 692#ifndef _WIN32_
685 sleep (1); 693 sleep (1);
686#endif 694#endif
687 } 695 }
688 696
689 } 697 }
690 698
691 } 699 }
692 delete temp; 700 delete temp;
693 return syncedProfiles; 701 return syncedProfiles;
694} 702}
695 703
696void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 704void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
697{ 705{
698 QString question; 706 QString question;
699 if ( ask ) { 707 if ( ask ) {
700 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 708 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
701 if ( QMessageBox::information( mParent, i18n("Sync"), 709 if ( QMessageBox::information( mParent, i18n("Sync"),
702 question, 710 question,
703 i18n("Yes"), i18n("No"), 711 i18n("Yes"), i18n("No"),
704 0, 0 ) != 0 ) 712 0, 0 ) != 0 )
705 return; 713 return;
706 } 714 }
707 715
708 QString preCommand; 716 QString preCommand;
709 QString localTempFile; 717 QString localTempFile;
710 QString postCommand; 718 QString postCommand;
711 719
712 switch(mTargetApp) 720 switch(mTargetApp)
713 { 721 {
714 case (KAPI): 722 case (KAPI):
715 preCommand = prof->getPreSyncCommandAB(); 723 preCommand = prof->getPreSyncCommandAB();
716 postCommand = prof->getPostSyncCommandAB(); 724 postCommand = prof->getPostSyncCommandAB();
717 localTempFile = prof->getLocalTempFileAB(); 725 localTempFile = prof->getLocalTempFileAB();
718 break; 726 break;
719 case (KOPI): 727 case (KOPI):
720 preCommand = prof->getPreSyncCommand(); 728 preCommand = prof->getPreSyncCommand();
721 postCommand = prof->getPostSyncCommand(); 729 postCommand = prof->getPostSyncCommand();
722 localTempFile = prof->getLocalTempFile(); 730 localTempFile = prof->getLocalTempFile();
723 break; 731 break;
724 case (PWMPI): 732 case (PWMPI):
725 preCommand = prof->getPreSyncCommandPWM(); 733 preCommand = prof->getPreSyncCommandPWM();
726 postCommand = prof->getPostSyncCommandPWM(); 734 postCommand = prof->getPostSyncCommandPWM();
727 localTempFile = prof->getLocalTempFilePWM(); 735 localTempFile = prof->getLocalTempFilePWM();
728 break; 736 break;
729 default: 737 default:
730 qDebug("KSM::syncRemote: invalid apptype selected"); 738 qDebug("KSM::syncRemote: invalid apptype selected");
731 break; 739 break;
732 } 740 }
733 741
734 742
735 int fi; 743 int fi;
736 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 744 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
737 QString pwd = getPassword(); 745 QString pwd = getPassword();
738 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 746 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
739 747
740 } 748 }
741 int maxlen = 30; 749 int maxlen = 30;
742 if ( QApplication::desktop()->width() > 320 ) 750 if ( QApplication::desktop()->width() > 320 )
743 maxlen += 25; 751 maxlen += 25;
744 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 752 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
745 int fileSize = 0; 753 int fileSize = 0;
746 int result = system ( preCommand ); 754 int result = system ( preCommand );
747 // 0 : okay 755 // 0 : okay
748 // 256: no such file or dir 756 // 256: no such file or dir
749 // 757 //
750 qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); 758 qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result );
751 if ( result != 0 ) { 759 if ( result != 0 ) {
752 unsigned int len = maxlen; 760 unsigned int len = maxlen;
753 while ( len < preCommand.length() ) { 761 while ( len < preCommand.length() ) {
754 preCommand.insert( len , "\n" ); 762 preCommand.insert( len , "\n" );
755 len += maxlen +2; 763 len += maxlen +2;
756 } 764 }
757 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) ; 765 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) ;
758 QMessageBox::information( mParent, i18n("Sync - ERROR"), 766 QMessageBox::information( mParent, i18n("Sync - ERROR"),
759 question, 767 question,
760 i18n("Okay!")) ; 768 i18n("Okay!")) ;
761 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 769 mParent->topLevelWidget()->setCaption ("KDE-Pim");
762 return; 770 return;
763 } 771 }
764 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 772 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
765 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 773 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
766 774
767 if ( syncWithFile( localTempFile, true ) ) { 775 if ( syncWithFile( localTempFile, true ) ) {
768 776
769 if ( mWriteBackFile ) { 777 if ( mWriteBackFile ) {
770 int fi; 778 int fi;
771 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 779 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
772 QString pwd = getPassword(); 780 QString pwd = getPassword();
773 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 781 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
774 782
775 } 783 }
776 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 784 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
777 result = system ( postCommand ); 785 result = system ( postCommand );
778 qDebug("KSM::Sync:Writing back file result: %d ", result); 786 qDebug("KSM::Sync:Writing back file result: %d ", result);
779 if ( result != 0 ) { 787 if ( result != 0 ) {
780 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 788 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
781 return; 789 return;
782 } else { 790 } else {
783 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 791 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
784 } 792 }
785 } 793 }
786 } 794 }
787 return; 795 return;
788} 796}
789bool KSyncManager::edit_pisync_options() 797bool KSyncManager::edit_pisync_options()
790{ 798{
791 QDialog dia( mParent, "dia", true ); 799 QDialog dia( mParent, "dia", true );
792 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 800 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
793 QVBoxLayout lay ( &dia ); 801 QVBoxLayout lay ( &dia );
794 lay.setSpacing( 5 ); 802 lay.setSpacing( 5 );
795 lay.setMargin( 3 ); 803 lay.setMargin( 3 );
796 QLabel lab1 ( i18n("Password for remote access:"), &dia); 804 QLabel lab1 ( i18n("Password for remote access:"), &dia);
797 lay.addWidget( &lab1 ); 805 lay.addWidget( &lab1 );
798 QLineEdit le1 (&dia ); 806 QLineEdit le1 (&dia );
799 lay.addWidget( &le1 ); 807 lay.addWidget( &le1 );
800 QLabel lab2 ( i18n("Remote IP address:"), &dia); 808 QLabel lab2 ( i18n("Remote IP address:"), &dia);
801 lay.addWidget( &lab2 ); 809 lay.addWidget( &lab2 );
802 QLineEdit le2 (&dia ); 810 QLineEdit le2 (&dia );
803 lay.addWidget( &le2 ); 811 lay.addWidget( &le2 );
804 QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia); 812 QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia);
805 lay.addWidget( &lab3 ); 813 lay.addWidget( &lab3 );
806 QLineEdit le3 (&dia ); 814 QLineEdit le3 (&dia );
807 lay.addWidget( &le3 ); 815 lay.addWidget( &le3 );
808 QPushButton pb ( "OK", &dia); 816 QPushButton pb ( "OK", &dia);
809 lay.addWidget( &pb ); 817 lay.addWidget( &pb );
810 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 818 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
811 le1.setText( mPassWordPiSync ); 819 le1.setText( mPassWordPiSync );
812 le2.setText( mActiveSyncIP ); 820 le2.setText( mActiveSyncIP );
813 le3.setText( mActiveSyncPort ); 821 le3.setText( mActiveSyncPort );
814 if ( dia.exec() ) { 822 if ( dia.exec() ) {
815 mPassWordPiSync = le1.text(); 823 mPassWordPiSync = le1.text();
816 mActiveSyncPort = le3.text(); 824 mActiveSyncPort = le3.text();
817 mActiveSyncIP = le2.text(); 825 mActiveSyncIP = le2.text();
818 return true; 826 return true;
819 } 827 }
820 return false; 828 return false;
821} 829}
822bool KSyncManager::edit_sync_options() 830bool KSyncManager::edit_sync_options()
823{ 831{
824 832
825 QDialog dia( mParent, "dia", true ); 833 QDialog dia( mParent, "dia", true );
826 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 834 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
827 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 835 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
828 QVBoxLayout lay ( &dia ); 836 QVBoxLayout lay ( &dia );
829 lay.setSpacing( 2 ); 837 lay.setSpacing( 2 );
830 lay.setMargin( 3 ); 838 lay.setMargin( 3 );
831 lay.addWidget(&gr); 839 lay.addWidget(&gr);
832 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 840 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
833 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 841 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
834 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 842 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
835 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 843 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
836 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 844 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
837 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 845 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
838 //QRadioButton both( i18n("Take both on conflict"), &gr ); 846 //QRadioButton both( i18n("Take both on conflict"), &gr );
839 QPushButton pb ( "OK", &dia); 847 QPushButton pb ( "OK", &dia);
840 lay.addWidget( &pb ); 848 lay.addWidget( &pb );
841 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 849 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
842 switch ( mSyncAlgoPrefs ) { 850 switch ( mSyncAlgoPrefs ) {
843 case 0: 851 case 0:
844 loc.setChecked( true); 852 loc.setChecked( true);
845 break; 853 break;
846 case 1: 854 case 1:
847 rem.setChecked( true ); 855 rem.setChecked( true );
848 break; 856 break;
849 case 2: 857 case 2:
850 newest.setChecked( true); 858 newest.setChecked( true);
851 break; 859 break;
852 case 3: 860 case 3:
853 ask.setChecked( true); 861 ask.setChecked( true);
854 break; 862 break;
855 case 4: 863 case 4:
856 f_loc.setChecked( true); 864 f_loc.setChecked( true);
857 break; 865 break;
858 case 5: 866 case 5:
859 f_rem.setChecked( true); 867 f_rem.setChecked( true);
860 break; 868 break;
861 case 6: 869 case 6:
862 // both.setChecked( true); 870 // both.setChecked( true);
863 break; 871 break;
864 default: 872 default:
865 break; 873 break;
866 } 874 }
867 if ( dia.exec() ) { 875 if ( dia.exec() ) {
868 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 876 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
869 return true; 877 return true;
870 } 878 }
871 return false; 879 return false;
872} 880}
873 881
874QString KSyncManager::getPassword( ) 882QString KSyncManager::getPassword( )
875{ 883{
876 QString retfile = ""; 884 QString retfile = "";
877 QDialog dia ( mParent, "input-dialog", true ); 885 QDialog dia ( mParent, "input-dialog", true );
878 QLineEdit lab ( &dia ); 886 QLineEdit lab ( &dia );
879 lab.setEchoMode( QLineEdit::Password ); 887 lab.setEchoMode( QLineEdit::Password );
880 QVBoxLayout lay( &dia ); 888 QVBoxLayout lay( &dia );
881 lay.setMargin(7); 889 lay.setMargin(7);
882 lay.setSpacing(7); 890 lay.setSpacing(7);
883 lay.addWidget( &lab); 891 lay.addWidget( &lab);
884 dia.setFixedSize( 230,50 ); 892 dia.setFixedSize( 230,50 );
885 dia.setCaption( i18n("Enter password") ); 893 dia.setCaption( i18n("Enter password") );
886 QPushButton pb ( "OK", &dia); 894 QPushButton pb ( "OK", &dia);
887 lay.addWidget( &pb ); 895 lay.addWidget( &pb );
888 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 896 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
889 dia.show(); 897 dia.show();
890 int res = dia.exec(); 898 int res = dia.exec();
891 if ( res ) 899 if ( res )
892 retfile = lab.text(); 900 retfile = lab.text();
893 dia.hide(); 901 dia.hide();
894 qApp->processEvents(); 902 qApp->processEvents();
895 return retfile; 903 return retfile;
896 904
897} 905}
898 906
899 907
900void KSyncManager::confSync() 908void KSyncManager::confSync()
901{ 909{
902 static KSyncPrefsDialog* sp = 0; 910 static KSyncPrefsDialog* sp = 0;
903 if ( ! sp ) { 911 if ( ! sp ) {
904 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 912 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
905 } 913 }
906 sp->usrReadConfig(); 914 sp->usrReadConfig();
907#ifndef DESKTOP_VERSION 915#ifndef DESKTOP_VERSION
908 sp->showMaximized(); 916 sp->showMaximized();
909#else 917#else
910 sp->show(); 918 sp->show();
911#endif 919#endif
912 sp->exec(); 920 sp->exec();
913 QStringList oldSyncProfileNames = mSyncProfileNames; 921 QStringList oldSyncProfileNames = mSyncProfileNames;
914 mSyncProfileNames = sp->getSyncProfileNames(); 922 mSyncProfileNames = sp->getSyncProfileNames();
915 mLocalMachineName = sp->getLocalMachineName (); 923 mLocalMachineName = sp->getLocalMachineName ();
916 int ii; 924 int ii;
917 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { 925 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) {
918 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) 926 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) )
919 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); 927 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] );
920 } 928 }
921 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 929 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
922} 930}
923void KSyncManager::syncKDE() 931void KSyncManager::syncKDE()
924{ 932{
925 mSyncWithDesktop = true; 933 mSyncWithDesktop = true;
926 emit save(); 934 emit save();
927 switch(mTargetApp) 935 switch(mTargetApp)
928 { 936 {
929 case (KAPI): 937 case (KAPI):
930 { 938 {
931#ifdef DESKTOP_VERSION 939#ifdef DESKTOP_VERSION
932 QString command = "kdeabdump33"; 940 QString command = "kdeabdump33";
933 QString commandfile = "kdeabdump33"; 941 QString commandfile = "kdeabdump33";
934 QString commandpath = qApp->applicationDirPath () + "/"; 942 QString commandpath = qApp->applicationDirPath () + "/";
935#else 943#else
936 QString command = "kdeabdump33"; 944 QString command = "kdeabdump33";
937 QString commandfile = "kdeabdump33"; 945 QString commandfile = "kdeabdump33";
938 QString commandpath = QDir::homeDirPath ()+"/"; 946 QString commandpath = QDir::homeDirPath ()+"/";
939#endif 947#endif
940 if ( ! QFile::exists ( commandpath+commandfile ) ) 948 if ( ! QFile::exists ( commandpath+commandfile ) )
941 command = commandfile; 949 command = commandfile;
942 else 950 else
943 command = commandpath+commandfile; 951 command = commandpath+commandfile;
944 952
945 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; 953 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf";
946 int result = system ( command.latin1()); 954 int result = system ( command.latin1());
947 qDebug("AB dump 33 command call result: %d ", result); 955 qDebug("AB dump 33 command call result: %d ", result);
948 if ( result != 0 ) { 956 if ( result != 0 ) {
949 qDebug("Calling AB dump version 33 failed. Trying 34... "); 957 qDebug("Calling AB dump version 33 failed. Trying 34... ");
950 commandfile = "kdeabdump34"; 958 commandfile = "kdeabdump34";
951 if ( ! QFile::exists ( commandpath+commandfile ) ) 959 if ( ! QFile::exists ( commandpath+commandfile ) )
952 command = commandfile; 960 command = commandfile;
953 else 961 else
954 command = commandpath+commandfile; 962 command = commandpath+commandfile;
955 result = system ( command.latin1()); 963 result = system ( command.latin1());
956 qDebug("AB dump 34 command call result: %d ", result); 964 qDebug("AB dump 34 command call result: %d ", result);
957 if ( result != 0 ) { 965 if ( result != 0 ) {
958 KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); 966 KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath ));
959 return; 967 return;
960 } 968 }
961 } 969 }
962 if ( syncWithFile( fileName,true ) ) { 970 if ( syncWithFile( fileName,true ) ) {
963 if ( mWriteBackFile ) { 971 if ( mWriteBackFile ) {
964 command += " --read"; 972 command += " --read";
965 system ( command.latin1()); 973 system ( command.latin1());
966 } 974 }
967 } 975 }
968 976
969 } 977 }
970 break; 978 break;
971 case (KOPI): 979 case (KOPI):
972 { 980 {
973#ifdef DESKTOP_VERSION 981#ifdef DESKTOP_VERSION
974 QString command = "kdecaldump33"; 982 QString command = "kdecaldump33";
975 QString commandfile = "kdecaldump33"; 983 QString commandfile = "kdecaldump33";
976 QString commandpath = qApp->applicationDirPath () + "/"; 984 QString commandpath = qApp->applicationDirPath () + "/";
977#else 985#else
978 QString command = "kdecaldump33"; 986 QString command = "kdecaldump33";
979 QString commandfile = "kdecaldump33"; 987 QString commandfile = "kdecaldump33";
980 QString commandpath = QDir::homeDirPath ()+"/"; 988 QString commandpath = QDir::homeDirPath ()+"/";
981#endif 989#endif
982 if ( ! QFile::exists ( commandpath+commandfile ) ) 990 if ( ! QFile::exists ( commandpath+commandfile ) )
983 command = commandfile; 991 command = commandfile;
984 else 992 else
985 command = commandpath+commandfile; 993 command = commandpath+commandfile;
986 994
987 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; 995 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
988 int result = system ( command.latin1()); 996 int result = system ( command.latin1());
989 qDebug("Cal dump 33 command call result result: %d ", result); 997 qDebug("Cal dump 33 command call result result: %d ", result);
990 if ( result != 0 ) { 998 if ( result != 0 ) {
991 qDebug("Calling CAL dump version 33 failed. Trying 34... "); 999 qDebug("Calling CAL dump version 33 failed. Trying 34... ");
992 commandfile = "kdecaldump34"; 1000 commandfile = "kdecaldump34";
993 if ( ! QFile::exists ( commandpath+commandfile ) ) 1001 if ( ! QFile::exists ( commandpath+commandfile ) )
994 command = commandfile; 1002 command = commandfile;
995 else 1003 else
996 command = commandpath+commandfile; 1004 command = commandpath+commandfile;
997 result = system ( command.latin1()); 1005 result = system ( command.latin1());
998 qDebug("Cal dump 34 command call result result: %d ", result); 1006 qDebug("Cal dump 34 command call result result: %d ", result);
999 if ( result != 0 ) { 1007 if ( result != 0 ) {
1000 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); 1008 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath ));
1001 return; 1009 return;
1002 } 1010 }
1003 } 1011 }
1004 if ( syncWithFile( fileName,true ) ) { 1012 if ( syncWithFile( fileName,true ) ) {
1005 if ( mWriteBackFile ) { 1013 if ( mWriteBackFile ) {
1006 command += " --read"; 1014 command += " --read";
1007 system ( command.latin1()); 1015 system ( command.latin1());
1008 } 1016 }
1009 } 1017 }
1010 1018
1011 } 1019 }
1012 break; 1020 break;
1013 case (PWMPI): 1021 case (PWMPI):
1014 1022
1015 break; 1023 break;
1016 default: 1024 default:
1017 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 1025 qDebug("KSM::slotSyncMenu: invalid apptype selected");
1018 break; 1026 break;
1019 1027
1020 } 1028 }
1021} 1029}
1022 1030
1023void KSyncManager::syncSharp() 1031void KSyncManager::syncSharp()
1024{ 1032{
1025 1033
1026 if ( ! syncExternalApplication("sharp") ) 1034 if ( ! syncExternalApplication("sharp") )
1027 qDebug("KSM::ERROR sync sharp "); 1035 qDebug("KSM::ERROR sync sharp ");
1028} 1036}
1029 1037
1030bool KSyncManager::syncExternalApplication(QString resource) 1038bool KSyncManager::syncExternalApplication(QString resource)
1031{ 1039{
1032 1040
1033 emit save(); 1041 emit save();
1034 1042
1035 if ( mAskForPreferences ) 1043 if ( mAskForPreferences )
1036 if ( !edit_sync_options()) { 1044 if ( !edit_sync_options()) {
1037 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1045 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1038 return false; 1046 return false;
1039 } 1047 }
1040 1048
1041 qDebug("KSM::Sync extern %s", resource.latin1()); 1049 qDebug("KSM::Sync extern %s", resource.latin1());
1042 1050
1043 bool syncOK = mImplementation->syncExternal(this, resource); 1051 bool syncOK = mImplementation->syncExternal(this, resource);
1044 1052
1045 return syncOK; 1053 return syncOK;
1046 1054
1047} 1055}
1048 1056
1049void KSyncManager::syncPhone() 1057void KSyncManager::syncPhone()
1050{ 1058{
1051 1059
1052 syncExternalApplication("phone"); 1060 syncExternalApplication("phone");
1053 1061
1054} 1062}
1055 1063
1056void KSyncManager::showProgressBar(int percentage, QString caption, int total) 1064void KSyncManager::showProgressBar(int percentage, QString caption, int total)
1057{ 1065{
1058 if (!bar->isVisible()) 1066 if (!bar->isVisible())
1059 { 1067 {
1060 int w = 300; 1068 int w = 300;
1061 if ( QApplication::desktop()->width() < 320 ) 1069 if ( QApplication::desktop()->width() < 320 )
1062 w = 220; 1070 w = 220;
1063 int h = bar->sizeHint().height() ; 1071 int h = bar->sizeHint().height() ;
1064 int dw = QApplication::desktop()->width(); 1072 int dw = QApplication::desktop()->width();
1065 int dh = QApplication::desktop()->height(); 1073 int dh = QApplication::desktop()->height();
1066 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1074 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1067 bar->setCaption (caption); 1075 bar->setCaption (caption);
1068 bar->setTotalSteps ( total ) ; 1076 bar->setTotalSteps ( total ) ;
1069 bar->show(); 1077 bar->show();
1070 } 1078 }
1071 bar->raise(); 1079 bar->raise();
1072 bar->setProgress( percentage ); 1080 bar->setProgress( percentage );
1073 qApp->processEvents(); 1081 qApp->processEvents();
1074} 1082}
1075 1083
1076void KSyncManager::hideProgressBar() 1084void KSyncManager::hideProgressBar()
1077{ 1085{
1078 bar->hide(); 1086 bar->hide();
1079 qApp->processEvents(); 1087 qApp->processEvents();
1080} 1088}
1081 1089
1082bool KSyncManager::isProgressBarCanceled() 1090bool KSyncManager::isProgressBarCanceled()
1083{ 1091{
1084 return !bar->isVisible(); 1092 return !bar->isVisible();
1085} 1093}
1086 1094
1087QString KSyncManager::syncFileName() 1095QString KSyncManager::syncFileName()
1088{ 1096{
1089 1097
1090 QString fn = "tempfile"; 1098 QString fn = "tempfile";
1091 switch(mTargetApp) 1099 switch(mTargetApp)
1092 { 1100 {
1093 case (KAPI): 1101 case (KAPI):
1094 fn = "tempsyncab.vcf"; 1102 fn = "tempsyncab.vcf";
1095 break; 1103 break;
1096 case (KOPI): 1104 case (KOPI):
1097 fn = "tempsynccal.ics"; 1105 fn = "tempsynccal.ics";
1098 break; 1106 break;
1099 case (PWMPI): 1107 case (PWMPI):
1100 fn = "tempsyncpw.pwm"; 1108 fn = "tempsyncpw.pwm";
1101 break; 1109 break;
1102 default: 1110 default:
1103 break; 1111 break;
1104 } 1112 }
1105#ifdef DESKTOP_VERSION 1113#ifdef DESKTOP_VERSION
1106 return locateLocal( "tmp", fn ); 1114 return locateLocal( "tmp", fn );
1107#else 1115#else
1108 return (QString( "/tmp/" )+ fn ); 1116 return (QString( "/tmp/" )+ fn );
1109#endif 1117#endif
1110} 1118}
1111 1119
1112void KSyncManager::syncPi() 1120void KSyncManager::syncPi()
1113{ 1121{
1114 mIsKapiFile = true; 1122 mIsKapiFile = true;
1115 mPisyncFinished = false; 1123 mPisyncFinished = false;
1116 qApp->processEvents(); 1124 qApp->processEvents();
1117 if ( mAskForPreferences ) 1125 if ( mAskForPreferences )
1118 if ( !edit_pisync_options()) { 1126 if ( !edit_pisync_options()) {
1119 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1127 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1120 mPisyncFinished = true; 1128 mPisyncFinished = true;
1121 return; 1129 return;
1122 } 1130 }
1123 bool ok; 1131 bool ok;
1124 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 1132 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
1125 if ( ! ok ) { 1133 if ( ! ok ) {
1126 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1134 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
1127 mPisyncFinished = true; 1135 mPisyncFinished = true;
1128 return; 1136 return;
1129 } 1137 }
1130 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); 1138 mCurrentResourceLocal = "";
1131 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1139 mCurrentResourceRemote = "";
1132 commandSocket->readFile( syncFileName() ); 1140 if ( mSpecificResources.count() ) {
1141 int startLocal = 0;
1142 int startRemote = mSpecificResources.count()/2;
1143 while ( startLocal < mSpecificResources.count()/2 ) {
1144 mPisyncFinished = false;
1145 mCurrentResourceLocal = mSpecificResources[ startLocal ];
1146 mCurrentResourceRemote = mSpecificResources[ startRemote ];
1147 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1148 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1149 commandSocket->readFile( syncFileName() );
1150 while ( !mPisyncFinished ) {
1151 //qDebug("waiting ");
1152 qApp->processEvents();
1153 }
1154 ++startLocal;
1155 }
1156 } else {
1157 KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1158 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1159 commandSocket->readFile( syncFileName() );
1160 }
1133} 1161}
1134 1162
1135void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 1163void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1136{ 1164{
1137 //enum { success, errorW, errorR, quiet }; 1165 //enum { success, errorW, errorR, quiet };
1138 1166
1139 1167
1140 1168
1141 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || 1169 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW ||
1142 state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { 1170 state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) {
1143 if ( state == KCommandSocket::errorPW ) 1171 if ( state == KCommandSocket::errorPW )
1144 mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); 1172 mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") );
1145 else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) 1173 else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO )
1146 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 1174 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
1147 else if ( state == KCommandSocket::errorCA ) 1175 else if ( state == KCommandSocket::errorCA )
1148 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); 1176 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") );
1149 else if ( state == KCommandSocket::errorFI ) 1177 else if ( state == KCommandSocket::errorFI )
1150 mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); 1178 mParent->topLevelWidget()->setCaption( i18n("File error on remote.") );
1151 else if ( state == KCommandSocket::errorED ) 1179 else if ( state == KCommandSocket::errorED )
1152 mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); 1180 mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") );
1153 else if ( state == KCommandSocket::errorUN ) 1181 else if ( state == KCommandSocket::errorUN )
1154 mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); 1182 mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") );
1155 delete s; 1183 delete s;
1156 if ( state == KCommandSocket::errorR ) { 1184 if ( state == KCommandSocket::errorR ) {
1157 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); 1185 KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget());
1158 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1186 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1159 commandSocket->sendStop(); 1187 commandSocket->sendStop();
1160 } 1188 }
1161 mPisyncFinished = true; 1189 mPisyncFinished = true;
1162 return; 1190 return;
1163 1191
1164 } else if ( state == KCommandSocket::errorW ) { 1192 } else if ( state == KCommandSocket::errorW ) {
1165 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 1193 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
1166 mPisyncFinished = true; 1194 mPisyncFinished = true;
1167 1195
1168 } else if ( state == KCommandSocket::successR ) { 1196 } else if ( state == KCommandSocket::successR ) {
1169 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1197 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
1170 1198
1171 } else if ( state == KCommandSocket::successW ) { 1199 } else if ( state == KCommandSocket::successW ) {
1172 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); 1200 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
1173 mPisyncFinished = true; 1201 mPisyncFinished = true;
1174 } else if ( state == KCommandSocket::quiet ){ 1202 } else if ( state == KCommandSocket::quiet ){
1175 qDebug("KSS: quiet "); 1203 qDebug("KSS: quiet ");
1176 mPisyncFinished = true; 1204 mPisyncFinished = true;
1177 } else { 1205 } else {
1178 qDebug("KSS: Error: unknown state: %d ", state); 1206 qDebug("KSS: Error: unknown state: %d ", state);
1179 mPisyncFinished = true; 1207 mPisyncFinished = true;
1180 } 1208 }
1181 1209
1182 delete s; 1210 delete s;
1183} 1211}
1184 1212
1185void KSyncManager::readFileFromSocket() 1213void KSyncManager::readFileFromSocket()
1186{ 1214{
1187 QString fileName = syncFileName(); 1215 QString fileName = syncFileName();
1188 bool syncOK = true; 1216 bool syncOK = true;
1189 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 1217 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
1190 if ( ! syncWithFile( fileName , true ) ) { 1218 if ( ! syncWithFile( fileName , true ) ) {
1191 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 1219 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
1192 syncOK = false; 1220 syncOK = false;
1193 } 1221 }
1194 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); 1222 KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() );
1195 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1223 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1196 if ( mWriteBackFile && syncOK ) { 1224 if ( mWriteBackFile && syncOK ) {
1197 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); 1225 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") );
1198 commandSocket->writeFile( fileName ); 1226 commandSocket->writeFile( fileName );
1199 } 1227 }
1200 else { 1228 else {
1201 commandSocket->sendStop(); 1229 commandSocket->sendStop();
1202 if ( syncOK ) 1230 if ( syncOK )
1203 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1231 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1204 mPisyncFinished = true; 1232 mPisyncFinished = true;
1205 } 1233 }
1206} 1234}
1207 1235
1208KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 1236KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
1209{ 1237{
1210 mPassWord = pw; 1238 mPassWord = pw;
1211 mSocket = 0; 1239 mSocket = 0;
1212 mSyncActionDialog = 0; 1240 mSyncActionDialog = 0;
1213 blockRC = false; 1241 blockRC = false;
1214 mErrorMessage = 0; 1242 mErrorMessage = 0;
1215} 1243}
1216 1244
1217void KServerSocket::newConnection ( int socket ) 1245void KServerSocket::newConnection ( int socket )
1218{ 1246{
1219 // qDebug("KServerSocket:New connection %d ", socket); 1247 // qDebug("KServerSocket:New connection %d ", socket);
1220 if ( mSocket ) { 1248 if ( mSocket ) {
1221 qDebug("KSS::newConnection Socket deleted! "); 1249 qDebug("KSS::newConnection Socket deleted! ");
1222 delete mSocket; 1250 delete mSocket;
1223 mSocket = 0; 1251 mSocket = 0;
1224 } 1252 }
1225 mSocket = new QSocket( this ); 1253 mSocket = new QSocket( this );
1226 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1254 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1227 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1255 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1228 mSocket->setSocket( socket ); 1256 mSocket->setSocket( socket );
1229} 1257}
1230 1258
1231void KServerSocket::discardClient() 1259void KServerSocket::discardClient()
1232{ 1260{
1233 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1261 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1234} 1262}
1235void KServerSocket::deleteSocket() 1263void KServerSocket::deleteSocket()
1236{ 1264{
1237 qDebug("KSS::deleteSocket"); 1265 qDebug("KSS::deleteSocket");
1238 if ( mSocket ) { 1266 if ( mSocket ) {
1239 delete mSocket; 1267 delete mSocket;
1240 mSocket = 0; 1268 mSocket = 0;
1241 } 1269 }
1242 if ( mErrorMessage ) 1270 if ( mErrorMessage )
1243 QTimer::singleShot( 10, this , SLOT ( displayErrorMessage())); 1271 QTimer::singleShot( 10, this , SLOT ( displayErrorMessage()));
1244} 1272}
1245void KServerSocket::readClient() 1273void KServerSocket::readClient()
1246{ 1274{
1247 if ( blockRC ) 1275 if ( blockRC )
1248 return; 1276 return;
1249 if ( mSocket == 0 ) { 1277 if ( mSocket == 0 ) {
1250 qDebug("ERROR::KSS::readClient(): mSocket == 0 "); 1278 qDebug("ERROR::KSS::readClient(): mSocket == 0 ");
1251 return; 1279 return;
1252 } 1280 }
1253 if ( mErrorMessage ) { 1281 if ( mErrorMessage ) {
1254 mErrorMessage = 999; 1282 mErrorMessage = 999;
1255 error_connect("ERROR_ED\r\n\r\n"); 1283 error_connect("ERROR_ED\r\n\r\n");
1256 return; 1284 return;
1257 } 1285 }
1258 mErrorMessage = 0; 1286 mErrorMessage = 0;
1259 //qDebug("KServerSocket::readClient()"); 1287 //qDebug("KServerSocket::readClient()");
1260 if ( mSocket->canReadLine() ) { 1288 if ( mSocket->canReadLine() ) {
1261 QString line = mSocket->readLine(); 1289 QString line = mSocket->readLine();
1262 //qDebug("KServerSocket readline: %s ", line.latin1()); 1290 //qDebug("KServerSocket readline: %s ", line.latin1());
1263 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 1291 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
1264 if ( tokens[0] == "GET" ) { 1292 if ( tokens[0] == "GET" ) {
1265 if ( tokens[1] == mPassWord ) { 1293 if ( tokens[1] == mPassWord ) {
1266 //emit sendFile( mSocket ); 1294 //emit sendFile( mSocket );
1267 bool ok = false; 1295 bool ok = false;
1268 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); 1296 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok);
1269 if ( ok ) { 1297 if ( ok ) {
1270 KSyncManager::mRequestedSyncEvent = dt; 1298 KSyncManager::mRequestedSyncEvent = dt;
1271 } 1299 }
1272 else 1300 else
1273 KSyncManager::mRequestedSyncEvent = QDateTime(); 1301 KSyncManager::mRequestedSyncEvent = QDateTime();
1274 send_file(); 1302 send_file();
1275 } 1303 }
1276 else { 1304 else {
1277 mErrorMessage = 1; 1305 mErrorMessage = 1;
1278 error_connect("ERROR_PW\r\n\r\n"); 1306 error_connect("ERROR_PW\r\n\r\n");
1279 } 1307 }
1280 } 1308 }
1281 if ( tokens[0] == "PUT" ) { 1309 if ( tokens[0] == "PUT" ) {
1282 if ( tokens[1] == mPassWord ) { 1310 if ( tokens[1] == mPassWord ) {
1283 //emit getFile( mSocket ); 1311 //emit getFile( mSocket );
1284 blockRC = true; 1312 blockRC = true;
1285 get_file(); 1313 get_file();
1286 } 1314 }
1287 else { 1315 else {
1288 mErrorMessage = 2; 1316 mErrorMessage = 2;
1289 error_connect("ERROR_PW\r\n\r\n"); 1317 error_connect("ERROR_PW\r\n\r\n");
1290 end_connect(); 1318 end_connect();
1291 } 1319 }
1292 } 1320 }
1293 if ( tokens[0] == "STOP" ) { 1321 if ( tokens[0] == "STOP" ) {
1294 //emit endConnect(); 1322 //emit endConnect();
1295 end_connect(); 1323 end_connect();
1296 } 1324 }
1297 } 1325 }
1298} 1326}
1299void KServerSocket::displayErrorMessage() 1327void KServerSocket::displayErrorMessage()
1300{ 1328{
1301 if ( mErrorMessage == 1 ) { 1329 if ( mErrorMessage == 1 ) {
1302 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error")); 1330 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error"));
1303 mErrorMessage = 0; 1331 mErrorMessage = 0;
1304 } 1332 }
1305 else if ( mErrorMessage == 2 ) { 1333 else if ( mErrorMessage == 2 ) {
1306 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); 1334 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error"));
1307 mErrorMessage = 0; 1335 mErrorMessage = 0;
1308 } 1336 }
1309} 1337}
1310void KServerSocket::error_connect( QString errmess ) 1338void KServerSocket::error_connect( QString errmess )
1311{ 1339{
1312 QTextStream os( mSocket ); 1340 QTextStream os( mSocket );
1313 os.setEncoding( QTextStream::Latin1 ); 1341 os.setEncoding( QTextStream::Latin1 );
1314 os << errmess ; 1342 os << errmess ;
1315 mSocket->close(); 1343 mSocket->close();
1316 if ( mSocket->state() == QSocket::Idle ) { 1344 if ( mSocket->state() == QSocket::Idle ) {
1317 QTimer::singleShot( 0, this , SLOT ( discardClient())); 1345 QTimer::singleShot( 0, this , SLOT ( discardClient()));
1318 } 1346 }
1319} 1347}
1320void KServerSocket::end_connect() 1348void KServerSocket::end_connect()
1321{ 1349{
1322 delete mSyncActionDialog; 1350 delete mSyncActionDialog;
1323 mSyncActionDialog = 0; 1351 mSyncActionDialog = 0;
1324} 1352}
1325void KServerSocket::send_file() 1353void KServerSocket::send_file()
1326{ 1354{
1327 //qDebug("MainWindow::sendFile(QSocket* s) "); 1355 //qDebug("MainWindow::sendFile(QSocket* s) ");
1328 if ( mSyncActionDialog ) 1356 if ( mSyncActionDialog )
1329 delete mSyncActionDialog; 1357 delete mSyncActionDialog;
1330 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 1358 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
1331 mSyncActionDialog->setCaption(i18n("Received sync request")); 1359 mSyncActionDialog->setCaption(i18n("Received sync request"));
1332 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 1360 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
1333 label->setAlignment ( Qt::AlignHCenter ); 1361 label->setAlignment ( Qt::AlignHCenter );
1334 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1362 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
1335 lay->addWidget( label); 1363 lay->addWidget( label);
1336 lay->setMargin(7); 1364 lay->setMargin(7);
1337 lay->setSpacing(7); 1365 lay->setSpacing(7);
1338 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1366 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1339 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); 1367 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent );
1340 //secs = 333; 1368 //secs = 333;
1341 if ( secs < 0 ) 1369 if ( secs < 0 )
1342 secs = secs * (-1); 1370 secs = secs * (-1);
1343 if ( secs > 30 ) 1371 if ( secs > 30 )
1344 //if ( true ) 1372 //if ( true )
1345 { 1373 {
1346 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); 1374 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs );
1347 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1375 QLabel* label = new QLabel( warning, mSyncActionDialog );
1348 label->setAlignment ( Qt::AlignHCenter ); 1376 label->setAlignment ( Qt::AlignHCenter );
1349 lay->addWidget( label); 1377 lay->addWidget( label);
1350 if ( secs > 180 ) 1378 if ( secs > 180 )
1351 { 1379 {
1352 if ( secs > 300 ) { 1380 if ( secs > 300 ) {
1353 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { 1381 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) {
1354 qDebug("KSS::Sync cancelled ,cs"); 1382 qDebug("KSS::Sync cancelled ,cs");
1355 mErrorMessage = 0; 1383 mErrorMessage = 0;
1356 end_connect(); 1384 end_connect();
1357 error_connect("ERROR_CA\r\n\r\n"); 1385 error_connect("ERROR_CA\r\n\r\n");
1358 return ; 1386 return ;
1359 } 1387 }
1360 } 1388 }
1361 QFont f = label->font(); 1389 QFont f = label->font();
1362 f.setPointSize ( f.pointSize() *2 ); 1390 f.setPointSize ( f.pointSize() *2 );
1363 f. setBold (true ); 1391 f. setBold (true );
1364 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1392 QLabel* label = new QLabel( warning, mSyncActionDialog );
1365 label->setFont( f ); 1393 label->setFont( f );
1366 warning = i18n("ADJUST\nYOUR\nCLOCKS!"); 1394 warning = i18n("ADJUST\nYOUR\nCLOCKS!");
1367 label->setText( warning ); 1395 label->setText( warning );
1368 label->setAlignment ( Qt::AlignHCenter ); 1396 label->setAlignment ( Qt::AlignHCenter );
1369 lay->addWidget( label); 1397 lay->addWidget( label);
1370 mSyncActionDialog->setFixedSize( 230, 300); 1398 mSyncActionDialog->setFixedSize( 230, 300);
1371 } else { 1399 } else {
1372 mSyncActionDialog->setFixedSize( 230, 200); 1400 mSyncActionDialog->setFixedSize( 230, 200);
1373 } 1401 }
1374 } else { 1402 } else {
1375 mSyncActionDialog->setFixedSize( 230, 120); 1403 mSyncActionDialog->setFixedSize( 230, 120);
1376 } 1404 }
1377 } else 1405 } else
1378 mSyncActionDialog->setFixedSize( 230, 120); 1406 mSyncActionDialog->setFixedSize( 230, 120);
1379 mSyncActionDialog->show(); 1407 mSyncActionDialog->show();
1380 mSyncActionDialog->raise(); 1408 mSyncActionDialog->raise();
1381 emit request_file(); 1409 emit request_file();
1382 qApp->processEvents(); 1410 qApp->processEvents();
1383 QString fileName = mFileName; 1411 QString fileName = mFileName;
1384 QFile file( fileName ); 1412 QFile file( fileName );
1385 if (!file.open( IO_ReadOnly ) ) { 1413 if (!file.open( IO_ReadOnly ) ) {
1386 mErrorMessage = 0; 1414 mErrorMessage = 0;
1387 end_connect(); 1415 end_connect();
1388 error_connect("ERROR_FI\r\n\r\n"); 1416 error_connect("ERROR_FI\r\n\r\n");
1389 return ; 1417 return ;
1390 } 1418 }
1391 mSyncActionDialog->setCaption( i18n("Sending file...") ); 1419 mSyncActionDialog->setCaption( i18n("Sending file...") );
1392 QTextStream ts( &file ); 1420 QTextStream ts( &file );
1393 ts.setEncoding( QTextStream::Latin1 ); 1421 ts.setEncoding( QTextStream::Latin1 );
1394 1422
1395 QTextStream os( mSocket ); 1423 QTextStream os( mSocket );
1396 os.setEncoding( QTextStream::Latin1 ); 1424 os.setEncoding( QTextStream::Latin1 );
1397 while ( ! ts.atEnd() ) { 1425 while ( ! ts.atEnd() ) {
1398 os << ts.readLine() << "\r\n"; 1426 os << ts.readLine() << "\r\n";
1399 } 1427 }
1400 os << "\r\n"; 1428 os << "\r\n";
1401 //os << ts.read(); 1429 //os << ts.read();
1402 file.close(); 1430 file.close();
1403 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 1431 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
1404 mSocket->close(); 1432 mSocket->close();
1405 if ( mSocket->state() == QSocket::Idle ) 1433 if ( mSocket->state() == QSocket::Idle )
1406 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1434 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1407} 1435}
1408void KServerSocket::get_file() 1436void KServerSocket::get_file()
1409{ 1437{
1410 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 1438 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
1411 1439
1412 piTime.start(); 1440 piTime.start();
1413 piFileString = ""; 1441 piFileString = "";
1414 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 1442 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
1415} 1443}
1416 1444
1417 1445
1418void KServerSocket::readBackFileFromSocket() 1446void KServerSocket::readBackFileFromSocket()
1419{ 1447{
1420 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 1448 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
1421 while ( mSocket->canReadLine () ) { 1449 while ( mSocket->canReadLine () ) {
1422 piTime.restart(); 1450 piTime.restart();
1423 QString line = mSocket->readLine (); 1451 QString line = mSocket->readLine ();
1424 piFileString += line; 1452 piFileString += line;
1425 //qDebug("readline: %s ", line.latin1()); 1453 //qDebug("readline: %s ", line.latin1());
1426 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 1454 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
1427 1455
1428 } 1456 }
1429 if ( piTime.elapsed () < 3000 ) { 1457 if ( piTime.elapsed () < 3000 ) {
1430 // wait for more 1458 // wait for more
1431 //qDebug("waitformore "); 1459 //qDebug("waitformore ");
1432 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 1460 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
1433 return; 1461 return;
1434 } 1462 }
1435 QString fileName = mFileName; 1463 QString fileName = mFileName;
1436 QFile file ( fileName ); 1464 QFile file ( fileName );
1437 if (!file.open( IO_WriteOnly ) ) { 1465 if (!file.open( IO_WriteOnly ) ) {
1438 delete mSyncActionDialog; 1466 delete mSyncActionDialog;
1439 mSyncActionDialog = 0; 1467 mSyncActionDialog = 0;
1440 qDebug("KSS:Error open read back file "); 1468 qDebug("KSS:Error open read back file ");
1441 piFileString = ""; 1469 piFileString = "";
1442 emit file_received( false ); 1470 emit file_received( false );
1443 blockRC = false; 1471 blockRC = false;
1444 return ; 1472 return ;
1445 1473
1446 } 1474 }
1447 1475
1448 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1476 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1449 QTextStream ts ( &file ); 1477 QTextStream ts ( &file );
1450 ts.setEncoding( QTextStream::Latin1 ); 1478 ts.setEncoding( QTextStream::Latin1 );
1451 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 1479 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1452 ts << piFileString; 1480 ts << piFileString;
1453 mSocket->close(); 1481 mSocket->close();
1454 if ( mSocket->state() == QSocket::Idle ) 1482 if ( mSocket->state() == QSocket::Idle )
1455 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1483 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1456 file.close(); 1484 file.close();
1457 piFileString = ""; 1485 piFileString = "";
1458 emit file_received( true ); 1486 emit file_received( true );
1459 delete mSyncActionDialog; 1487 delete mSyncActionDialog;
1460 mSyncActionDialog = 0; 1488 mSyncActionDialog = 0;
1461 blockRC = false; 1489 blockRC = false;
1462 1490
1463} 1491}
1464 1492
1465KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) 1493KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name )
1466{ 1494{
1495 mRemoteResource = remres;
1496 if ( mRemoteResource.isEmpty() )
1497 mRemoteResource = "ALL";
1467 mPassWord = password; 1498 mPassWord = password;
1468 mSocket = 0; 1499 mSocket = 0;
1469 mFirst = false; 1500 mFirst = false;
1470 mFirstLine = true; 1501 mFirstLine = true;
1471 mPort = port; 1502 mPort = port;
1472 mHost = host; 1503 mHost = host;
1473 tlw = cap; 1504 tlw = cap;
1474 mRetVal = quiet; 1505 mRetVal = quiet;
1475 mTimerSocket = new QTimer ( this ); 1506 mTimerSocket = new QTimer ( this );
1476 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) ); 1507 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) );
1477 mConnectProgress.setCaption( i18n("Pi-Sync") ); 1508 mConnectProgress.setCaption( i18n("Pi-Sync") );
1478 connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) ); 1509 connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) );
1479 mConnectCount = -1; 1510 mConnectCount = -1;
1480} 1511}
1481void KCommandSocket::sendFileRequest() 1512void KCommandSocket::sendFileRequest()
1482{ 1513{
1483 if ( tlw ) 1514 if ( tlw )
1484 tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); 1515 tlw->setCaption( i18n("Connected! Sending request for remote file ...") );
1485 mConnectProgress.hide(); 1516 mConnectProgress.hide();
1486 mConnectCount = 300;mConnectMax = 300; 1517 mConnectCount = 300;mConnectMax = 300;
1487 mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); 1518 mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") );
1488 mTimerSocket->start( 100, true ); 1519 mTimerSocket->start( 100, true );
1489 QTextStream os( mSocket ); 1520 QTextStream os( mSocket );
1490 os.setEncoding( QTextStream::Latin1 ); 1521 os.setEncoding( QTextStream::Latin1 );
1491 1522
1492 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); 1523 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate );
1493 os << "GET " << mPassWord << curDt <<"\r\n\r\n"; 1524 os << "GET " << mPassWord << curDt << mRemoteResource << "\r\n\r\n";
1494} 1525}
1495 1526
1496void KCommandSocket::readFile( QString fn ) 1527void KCommandSocket::readFile( QString fn )
1497{ 1528{
1498 if ( !mSocket ) { 1529 if ( !mSocket ) {
1499 mSocket = new QSocket( this ); 1530 mSocket = new QSocket( this );
1500 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1531 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1501 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1532 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1502 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); 1533 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() ));
1503 } 1534 }
1504 mFileString = ""; 1535 mFileString = "";
1505 mFileName = fn; 1536 mFileName = fn;
1506 mFirst = true; 1537 mFirst = true;
1507 if ( tlw ) 1538 if ( tlw )
1508 tlw->setCaption( i18n("Trying to connect to remote...") ); 1539 tlw->setCaption( i18n("Trying to connect to remote...") );
1509 mConnectCount = 30;mConnectMax = 30; 1540 mConnectCount = 30;mConnectMax = 30;
1510 mTimerSocket->start( 1000, true ); 1541 mTimerSocket->start( 1000, true );
1511 mSocket->connectToHost( mHost, mPort ); 1542 mSocket->connectToHost( mHost, mPort );
1512 qDebug("KSS: Waiting for connection"); 1543 qDebug("KSS: Waiting for connection");
1513} 1544}
1514void KCommandSocket::updateConnectDialog() 1545void KCommandSocket::updateConnectDialog()
1515{ 1546{
1516 1547
1517 if ( mConnectCount == mConnectMax ) { 1548 if ( mConnectCount == mConnectMax ) {
1518 //qDebug("MAXX %d", mConnectMax); 1549 //qDebug("MAXX %d", mConnectMax);
1519 mConnectProgress.setTotalSteps ( 30 ); 1550 mConnectProgress.setTotalSteps ( 30 );
1520 mConnectProgress.show(); 1551 mConnectProgress.show();
1521 mConnectProgress.setLabelText( i18n("Trying to connect to remote...") ); 1552 mConnectProgress.setLabelText( i18n("Trying to connect to remote...") );
1522 } 1553 }
1523 //qDebug("updateConnectDialog() %d", mConnectCount); 1554 //qDebug("updateConnectDialog() %d", mConnectCount);
1524 mConnectProgress.raise(); 1555 mConnectProgress.raise();
1525 mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 ); 1556 mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 );
1526 --mConnectCount; 1557 --mConnectCount;
1527 if ( mConnectCount > 0 ) 1558 if ( mConnectCount > 0 )
1528 mTimerSocket->start( 1000, true ); 1559 mTimerSocket->start( 1000, true );
1529 else 1560 else
1530 deleteSocket(); 1561 deleteSocket();
1531 1562
1532} 1563}
1533void KCommandSocket::writeFile( QString fileName ) 1564void KCommandSocket::writeFile( QString fileName )
1534{ 1565{
1535 if ( !mSocket ) { 1566 if ( !mSocket ) {
1536 mSocket = new QSocket( this ); 1567 mSocket = new QSocket( this );
1537 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1568 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1538 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 1569 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1539 } 1570 }
1540 mFileName = fileName ; 1571 mFileName = fileName ;
1541 mConnectCount = 30;mConnectMax = 30; 1572 mConnectCount = 30;mConnectMax = 30;
1542 mTimerSocket->start( 1000, true ); 1573 mTimerSocket->start( 1000, true );
1543 mSocket->connectToHost( mHost, mPort ); 1574 mSocket->connectToHost( mHost, mPort );
1544} 1575}
1545void KCommandSocket::writeFileToSocket() 1576void KCommandSocket::writeFileToSocket()
1546{ 1577{
1547 mTimerSocket->stop(); 1578 mTimerSocket->stop();
1548 QFile file2( mFileName ); 1579 QFile file2( mFileName );
1549 if (!file2.open( IO_ReadOnly ) ) { 1580 if (!file2.open( IO_ReadOnly ) ) {
1550 mConnectProgress.hide(); 1581 mConnectProgress.hide();
1551 mConnectCount = -1; 1582 mConnectCount = -1;
1552 mRetVal= errorW; 1583 mRetVal= errorW;
1553 mSocket->close(); 1584 mSocket->close();
1554 if ( mSocket->state() == QSocket::Idle ) 1585 if ( mSocket->state() == QSocket::Idle )
1555 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1586 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1556 return ; 1587 return ;
1557 } 1588 }
1558 mConnectProgress.setTotalSteps ( file2.size() ); 1589 mConnectProgress.setTotalSteps ( file2.size() );
1559 mConnectProgress.show(); 1590 mConnectProgress.show();
1560 int count = 0; 1591 int count = 0;
1561 mConnectProgress.setLabelText( i18n("Sending back synced file...") ); 1592 mConnectProgress.setLabelText( i18n("Sending back synced file...") );
1562 mConnectProgress.setProgress( count ); 1593 mConnectProgress.setProgress( count );
1563 mConnectProgress.blockSignals( true ); 1594 mConnectProgress.blockSignals( true );
1564 QTextStream ts2( &file2 ); 1595 QTextStream ts2( &file2 );
1565 ts2.setEncoding( QTextStream::Latin1 ); 1596 ts2.setEncoding( QTextStream::Latin1 );
1566 QTextStream os2( mSocket ); 1597 QTextStream os2( mSocket );
1567 os2.setEncoding( QTextStream::Latin1 ); 1598 os2.setEncoding( QTextStream::Latin1 );
1568 os2 << "PUT " << mPassWord << "\r\n\r\n";; 1599 os2 << "PUT " << mPassWord << "\r\n\r\n";;
1569 int byteCount = 0; 1600 int byteCount = 0;
1570 int byteMax = file2.size()/53; 1601 int byteMax = file2.size()/53;
1571 while ( ! ts2.atEnd() ) { 1602 while ( ! ts2.atEnd() ) {
1572 qApp->processEvents(); 1603 qApp->processEvents();
1573 if ( byteCount > byteMax ) { 1604 if ( byteCount > byteMax ) {
1574 byteCount = 0; 1605 byteCount = 0;
1575 mConnectProgress.setProgress( count ); 1606 mConnectProgress.setProgress( count );
1576 } 1607 }
1577 QString temp = ts2.readLine(); 1608 QString temp = ts2.readLine();
1578 count += temp.length(); 1609 count += temp.length();
1579 byteCount += temp.length(); 1610 byteCount += temp.length();
1580 os2 << temp << "\r\n"; 1611 os2 << temp << "\r\n";
1581 } 1612 }
1582 file2.close(); 1613 file2.close();
1583 mConnectProgress.hide(); 1614 mConnectProgress.hide();
1584 mConnectCount = -1; 1615 mConnectCount = -1;
1585 os2 << "\r\n"; 1616 os2 << "\r\n";
1586 mRetVal= successW; 1617 mRetVal= successW;
1587 mSocket->close(); 1618 mSocket->close();
1588 if ( mSocket->state() == QSocket::Idle ) 1619 if ( mSocket->state() == QSocket::Idle )
1589 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1620 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1590 mConnectProgress.blockSignals( false ); 1621 mConnectProgress.blockSignals( false );
1591} 1622}
1592void KCommandSocket::sendStop() 1623void KCommandSocket::sendStop()
1593{ 1624{
1594 if ( !mSocket ) { 1625 if ( !mSocket ) {
1595 mSocket = new QSocket( this ); 1626 mSocket = new QSocket( this );
1596 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1627 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1597 } 1628 }
1598 mSocket->connectToHost( mHost, mPort ); 1629 mSocket->connectToHost( mHost, mPort );
1599 QTextStream os2( mSocket ); 1630 QTextStream os2( mSocket );
1600 os2.setEncoding( QTextStream::Latin1 ); 1631 os2.setEncoding( QTextStream::Latin1 );
1601 os2 << "STOP\r\n\r\n"; 1632 os2 << "STOP\r\n\r\n";
1602 mSocket->close(); 1633 mSocket->close();
1603 if ( mSocket->state() == QSocket::Idle ) 1634 if ( mSocket->state() == QSocket::Idle )
1604 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1635 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1605} 1636}
1606 1637
1607void KCommandSocket::startReadFileFromSocket() 1638void KCommandSocket::startReadFileFromSocket()
1608{ 1639{
1609 if ( ! mFirst ) 1640 if ( ! mFirst )
1610 return; 1641 return;
1611 mConnectProgress.setLabelText( i18n("Receiving file from remote...") ); 1642 mConnectProgress.setLabelText( i18n("Receiving file from remote...") );
1612 mFirst = false; 1643 mFirst = false;
1613 mFileString = ""; 1644 mFileString = "";
1614 mTime.start(); 1645 mTime.start();
1615 mFirstLine = true; 1646 mFirstLine = true;
1616 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 1647 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
1617 1648
1618} 1649}
1619void KCommandSocket::readFileFromSocket() 1650void KCommandSocket::readFileFromSocket()
1620{ 1651{
1621 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 1652 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
1622 while ( mSocket->canReadLine () ) { 1653 while ( mSocket->canReadLine () ) {
1623 mTime.restart(); 1654 mTime.restart();
1624 QString line = mSocket->readLine (); 1655 QString line = mSocket->readLine ();
1625 if ( mFirstLine ) { 1656 if ( mFirstLine ) {
1626 mFirstLine = false; 1657 mFirstLine = false;
1627 if ( line.left( 6 ) == "ERROR_" ) { 1658 if ( line.left( 6 ) == "ERROR_" ) {
1628 mTimerSocket->stop(); 1659 mTimerSocket->stop();
1629 mConnectCount = -1; 1660 mConnectCount = -1;
1630 if ( line.left( 8 ) == "ERROR_PW" ) { 1661 if ( line.left( 8 ) == "ERROR_PW" ) {
1631 mRetVal = errorPW; 1662 mRetVal = errorPW;
1632 deleteSocket(); 1663 deleteSocket();
1633 return ; 1664 return ;
1634 } 1665 }
1635 if ( line.left( 8 ) == "ERROR_CA" ) { 1666 if ( line.left( 8 ) == "ERROR_CA" ) {
1636 mRetVal = errorCA; 1667 mRetVal = errorCA;
1637 deleteSocket(); 1668 deleteSocket();
1638 return ; 1669 return ;
1639 } 1670 }
1640 if ( line.left( 8 ) == "ERROR_FI" ) { 1671 if ( line.left( 8 ) == "ERROR_FI" ) {
1641 mRetVal = errorFI; 1672 mRetVal = errorFI;
1642 deleteSocket(); 1673 deleteSocket();
1643 return ; 1674 return ;
1644 } 1675 }
1645 if ( line.left( 8 ) == "ERROR_ED" ) { 1676 if ( line.left( 8 ) == "ERROR_ED" ) {
1646 mRetVal = errorED; 1677 mRetVal = errorED;
1647 deleteSocket(); 1678 deleteSocket();
1648 return ; 1679 return ;
1649 } 1680 }
1650 mRetVal = errorUN; 1681 mRetVal = errorUN;
1651 deleteSocket(); 1682 deleteSocket();
1652 return ; 1683 return ;
1653 } 1684 }
1654 } 1685 }
1655 mFileString += line; 1686 mFileString += line;
1656 //qDebug("readline: %s ", line.latin1()); 1687 //qDebug("readline: %s ", line.latin1());
1657 } 1688 }
1658 if ( mTime.elapsed () < 3000 ) { 1689 if ( mTime.elapsed () < 3000 ) {
1659 // wait for more 1690 // wait for more
1660 //qDebug("waitformore "); 1691 //qDebug("waitformore ");
1661 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 1692 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
1662 return; 1693 return;
1663 } 1694 }
1664 mTimerSocket->stop(); 1695 mTimerSocket->stop();
1665 mConnectCount = -1; 1696 mConnectCount = -1;
1666 mConnectProgress.hide(); 1697 mConnectProgress.hide();
1667 QString fileName = mFileName; 1698 QString fileName = mFileName;
1668 QFile file ( fileName ); 1699 QFile file ( fileName );
1669 if (!file.open( IO_WriteOnly ) ) { 1700 if (!file.open( IO_WriteOnly ) ) {
1670 mFileString = ""; 1701 mFileString = "";
1671 mRetVal = errorR; 1702 mRetVal = errorR;
1672 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); 1703 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() );
1673 deleteSocket(); 1704 deleteSocket();
1674 return ; 1705 return ;
1675 1706
1676 } 1707 }
1677 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1708 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1678 QTextStream ts ( &file ); 1709 QTextStream ts ( &file );
1679 ts.setEncoding( QTextStream::Latin1 ); 1710 ts.setEncoding( QTextStream::Latin1 );
1680 ts << mFileString; 1711 ts << mFileString;
1681 file.close(); 1712 file.close();
1682 mFileString = ""; 1713 mFileString = "";
1683 mRetVal = successR; 1714 mRetVal = successR;
1684 mSocket->close(); 1715 mSocket->close();
1685 // if state is not idle, deleteSocket(); is called via 1716 // if state is not idle, deleteSocket(); is called via
1686 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1717 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1687 if ( mSocket->state() == QSocket::Idle ) 1718 if ( mSocket->state() == QSocket::Idle )
1688 deleteSocket(); 1719 deleteSocket();
1689} 1720}
1690 1721
1691void KCommandSocket::deleteSocket() 1722void KCommandSocket::deleteSocket()
1692{ 1723{
1693 //qDebug("KCommandSocket::deleteSocket() "); 1724 //qDebug("KCommandSocket::deleteSocket() ");
1694 mConnectProgress.hide(); 1725 mConnectProgress.hide();
1695 1726
1696 if ( mConnectCount >= 0 ) { 1727 if ( mConnectCount >= 0 ) {
1697 mTimerSocket->stop(); 1728 mTimerSocket->stop();
1698 mRetVal = errorTO; 1729 mRetVal = errorTO;
1699 qDebug("KCS::Connection to remote host timed out"); 1730 qDebug("KCS::Connection to remote host timed out");
1700 if ( mSocket ) { 1731 if ( mSocket ) {
1701 mSocket->close(); 1732 mSocket->close();
1702 //if ( mSocket->state() == QSocket::Idle ) 1733 //if ( mSocket->state() == QSocket::Idle )
1703 // deleteSocket(); 1734 // deleteSocket();
1704 delete mSocket; 1735 delete mSocket;
1705 mSocket = 0; 1736 mSocket = 0;
1706 } 1737 }
1707 if ( mConnectCount == 0 ) 1738 if ( mConnectCount == 0 )
1708 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?")); 1739 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?"));
1709 else if ( tlw ) 1740 else if ( tlw )
1710 tlw->setCaption( i18n("Connection to remote host cancelled!") ); 1741 tlw->setCaption( i18n("Connection to remote host cancelled!") );
1711 emit commandFinished( this, mRetVal ); 1742 emit commandFinished( this, mRetVal );
1712 return; 1743 return;
1713 } 1744 }
1714 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 1745 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
1715 if ( mSocket) 1746 if ( mSocket)
1716 delete mSocket; 1747 delete mSocket;
1717 mSocket = 0; 1748 mSocket = 0;
1718 qDebug("commandFinished "); 1749 qDebug("commandFinished ");
1719 emit commandFinished( this, mRetVal ); 1750 emit commandFinished( this, mRetVal );
1720} 1751}
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index d3734da..f4654ce 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,237 +1,241 @@
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#include <qprogressdialog.h> 32#include <qprogressdialog.h>
33#include <kdialog.h> 33#include <kdialog.h>
34 34
35class QPopupMenu; 35class QPopupMenu;
36class KSyncProfile; 36class KSyncProfile;
37class KPimPrefs; 37class KPimPrefs;
38class QWidget; 38class QWidget;
39class KSyncManager; 39class KSyncManager;
40class KSyncInterface; 40class KSyncInterface;
41class QProgressBar; 41class QProgressBar;
42 42
43 43
44class KServerSocket : public QServerSocket 44class KServerSocket : public QServerSocket
45{ 45{
46 Q_OBJECT 46 Q_OBJECT
47 47
48 public: 48 public:
49 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); 49 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
50 50
51 void newConnection ( int socket ) ; 51 void newConnection ( int socket ) ;
52 void setFileName( QString fn ) {mFileName = fn;}; 52 void setFileName( QString fn ) {mFileName = fn;};
53 signals: 53 signals:
54 void file_received( bool ); 54 void file_received( bool );
55 void request_file(); 55 void request_file();
56 void saveFile(); 56 void saveFile();
57 void endConnect(); 57 void endConnect();
58 private slots: 58 private slots:
59 void discardClient(); 59 void discardClient();
60 void deleteSocket(); 60 void deleteSocket();
61 void readClient(); 61 void readClient();
62 void displayErrorMessage(); 62 void displayErrorMessage();
63 void readBackFileFromSocket(); 63 void readBackFileFromSocket();
64 private : 64 private :
65 int mErrorMessage; 65 int mErrorMessage;
66 bool blockRC; 66 bool blockRC;
67 void send_file(); 67 void send_file();
68 void get_file(); 68 void get_file();
69 void end_connect(); 69 void end_connect();
70 void error_connect( QString ); 70 void error_connect( QString );
71 QDialog* mSyncActionDialog; 71 QDialog* mSyncActionDialog;
72 QSocket* mSocket; 72 QSocket* mSocket;
73 QString mPassWord; 73 QString mPassWord;
74 QString mFileName; 74 QString mFileName;
75 QTime piTime; 75 QTime piTime;
76 QString piFileString; 76 QString piFileString;
77}; 77};
78 78
79class KCommandSocket : public QObject 79class KCommandSocket : public QObject
80{ 80{
81 Q_OBJECT 81 Q_OBJECT
82 public: 82 public:
83 enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet }; 83 enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet };
84 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 ); 84 KCommandSocket (QString remoteResource, QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 );
85 void readFile( QString ); 85 void readFile( QString );
86 void writeFile( QString ); 86 void writeFile( QString );
87 void sendStop(); 87 void sendStop();
88 88
89 private slots : 89 private slots :
90 void sendFileRequest(); 90 void sendFileRequest();
91 void updateConnectDialog(); 91 void updateConnectDialog();
92 92
93 signals: 93 signals:
94 void commandFinished( KCommandSocket*, int ); 94 void commandFinished( KCommandSocket*, int );
95 private slots: 95 private slots:
96 void startReadFileFromSocket(); 96 void startReadFileFromSocket();
97 void readFileFromSocket(); 97 void readFileFromSocket();
98 void deleteSocket(); 98 void deleteSocket();
99 void writeFileToSocket(); 99 void writeFileToSocket();
100 private : 100 private :
101 QString mRemoteResource;
101 int mConnectCount; 102 int mConnectCount;
102 int mConnectMax; 103 int mConnectMax;
103 KProgressDialog mConnectProgress; 104 KProgressDialog mConnectProgress;
104 QWidget* tlw; 105 QWidget* tlw;
105 QSocket* mSocket; 106 QSocket* mSocket;
106 QString mPassWord; 107 QString mPassWord;
107 Q_UINT16 mPort; 108 Q_UINT16 mPort;
108 QString mHost; 109 QString mHost;
109 QString mFileName; 110 QString mFileName;
110 QTimer* mTimerSocket; 111 QTimer* mTimerSocket;
111 int mRetVal; 112 int mRetVal;
112 QTime mTime; 113 QTime mTime;
113 QString mFileString; 114 QString mFileString;
114 bool mFirst; 115 bool mFirst;
115 bool mFirstLine; 116 bool mFirstLine;
116}; 117};
117 118
118 119
119class KSyncManager : public QObject 120class KSyncManager : public QObject
120{ 121{
121 Q_OBJECT 122 Q_OBJECT
122 123
123 public: 124 public:
124 enum TargetApp { 125 enum TargetApp {
125 KOPI = 0, 126 KOPI = 0,
126 KAPI = 1, 127 KAPI = 1,
127 PWMPI = 2 }; 128 PWMPI = 2 };
128 129
129 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 130 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
130 ~KSyncManager() ; 131 ~KSyncManager() ;
131 132
132 void multiSync( bool askforPrefs ); 133 void multiSync( bool askforPrefs );
133 bool blockSave() { return mBlockSaveFlag; } 134 bool blockSave() { return mBlockSaveFlag; }
134 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 135 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
135 void setDefaultFileName( QString s) ; 136 void setDefaultFileName( QString s) ;
136 QString defaultFileName() { return mDefFileName ;} 137 QString defaultFileName() { return mDefFileName ;}
137 QString syncFileName(); 138 QString syncFileName();
138 void enableQuick( bool ask = true); 139 void enableQuick( bool ask = true);
139 140
140 bool syncWithDesktop () { return mSyncWithDesktop;} 141 bool syncWithDesktop () { return mSyncWithDesktop;}
141 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 142 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
142 QString getCurrentSyncName() { return mCurrentSyncName; } 143 QString getCurrentSyncName() { return mCurrentSyncName; }
143 144
144 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 145 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
145 void hideProgressBar(); 146 void hideProgressBar();
146 bool isProgressBarCanceled(); 147 bool isProgressBarCanceled();
147 148
148 // sync stuff 149 // sync stuff
149 QString mLocalMachineName; 150 QString mLocalMachineName;
150 QStringList mExternSyncProfiles; 151 QStringList mExternSyncProfiles;
151 QStringList mSyncProfileNames; 152 QStringList mSyncProfileNames;
152 bool mAskForPreferences; 153 bool mAskForPreferences;
153 bool mShowSyncSummary; 154 bool mShowSyncSummary;
154 bool mIsKapiFile; 155 bool mIsKapiFile;
155 bool mWriteBackExistingOnly; 156 bool mWriteBackExistingOnly;
156 int mSyncAlgoPrefs; 157 int mSyncAlgoPrefs;
157 bool mWriteBackFile; 158 bool mWriteBackFile;
158 int mWriteBackInFuture; 159 int mWriteBackInFuture;
159 int mWriteBackInPast; 160 int mWriteBackInPast;
160 QString mPhoneDevice; 161 QString mPhoneDevice;
161 QString mPhoneConnection; 162 QString mPhoneConnection;
162 QString mPhoneModel; 163 QString mPhoneModel;
163 QString mPassWordPiSync; 164 QString mPassWordPiSync;
164 QString mActiveSyncPort; 165 QString mActiveSyncPort;
165 QString mActiveSyncIP ; 166 QString mActiveSyncIP ;
166 QString mFilterInCal; 167 QString mFilterInCal;
167 QString mFilterOutCal; 168 QString mFilterOutCal;
168 QString mFilterInAB; 169 QString mFilterInAB;
169 QString mFilterOutAB; 170 QString mFilterOutAB;
170 static QDateTime mRequestedSyncEvent; 171 static QDateTime mRequestedSyncEvent;
171 172
172 signals: 173 signals:
173 void save(); 174 void save();
174 void request_file(); 175 void request_file();
175 void getFile( bool ); 176 void getFile( bool );
176 177
177 public slots: 178 public slots:
178 void slotSyncMenu( int ); 179 void slotSyncMenu( int );
179 void slotClearMenu( int action ); 180 void slotClearMenu( int action );
180 void deleteCommandSocket(KCommandSocket*s, int state); 181 void deleteCommandSocket(KCommandSocket*s, int state);
181 void readFileFromSocket(); 182 void readFileFromSocket();
182 void fillSyncMenu(); 183 void fillSyncMenu();
183 184
184 private: 185 private:
185 void syncPi(); 186 void syncPi();
186 KServerSocket * mServerSocket; 187 KServerSocket * mServerSocket;
187 KPimPrefs* mPrefs; 188 KPimPrefs* mPrefs;
188 QString mDefFileName; 189 QString mDefFileName;
189 QString mCurrentSyncDevice; 190 QString mCurrentSyncDevice;
190 QString mCurrentSyncName; 191 QString mCurrentSyncName;
191 void quickSyncLocalFile(); 192 void quickSyncLocalFile();
192 bool syncWithFile( QString fn , bool quick ); 193 bool syncWithFile( QString fn , bool quick );
193 void syncLocalFile(); 194 void syncLocalFile();
194 void syncPhone(); 195 void syncPhone();
195 void syncSharp(); 196 void syncSharp();
196 void syncKDE(); 197 void syncKDE();
197 bool syncExternalApplication(QString); 198 bool syncExternalApplication(QString);
198 int mCurrentSyncProfile ; 199 int mCurrentSyncProfile ;
199 void syncRemote( KSyncProfile* prof, bool ask = true); 200 void syncRemote( KSyncProfile* prof, bool ask = true);
200 bool edit_sync_options(); 201 bool edit_sync_options();
201 bool edit_pisync_options(); 202 bool edit_pisync_options();
202 int ringSync(); 203 int ringSync();
203 QString getPassword( ); 204 QString getPassword( );
204 bool mPisyncFinished; 205 bool mPisyncFinished;
206 QStringList mSpecificResources;
207 QString mCurrentResourceLocal;
208 QString mCurrentResourceRemote;
205 bool mBlockSaveFlag; 209 bool mBlockSaveFlag;
206 QWidget* mParent; 210 QWidget* mParent;
207 KSyncInterface* mImplementation; 211 KSyncInterface* mImplementation;
208 TargetApp mTargetApp; 212 TargetApp mTargetApp;
209 QPopupMenu* mSyncMenu; 213 QPopupMenu* mSyncMenu;
210 QProgressBar* bar; 214 QProgressBar* bar;
211 bool mSyncWithDesktop; 215 bool mSyncWithDesktop;
212 216
213private slots: 217private slots:
214 void displayErrorPort(); 218 void displayErrorPort();
215 void confSync(); 219 void confSync();
216 220
217 221
218}; 222};
219 223
220 224
221class KSyncInterface 225class KSyncInterface
222{ 226{
223 public : 227 public :
224 virtual void removeSyncInfo( QString syncProfile) = 0; 228 virtual void removeSyncInfo( QString syncProfile) = 0;
225 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; 229 virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0;
226 virtual bool syncExternal(KSyncManager* manager, QString resource) 230 virtual bool syncExternal(KSyncManager* manager, QString resource)
227 { 231 {
228 // empty implementation, because some syncable applications do not 232 // empty implementation, because some syncable applications do not
229 // have an external(sharpdtm) syncmode, like pwmanager. 233 // have an external(sharpdtm) syncmode, like pwmanager.
230 return false; 234 return false;
231 } 235 }
232 236
233 237
234}; 238};
235 239
236 240
237#endif 241#endif
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp
index 292cde1..27f7932 100644
--- a/libkdepim/ksyncprefsdialog.cpp
+++ b/libkdepim/ksyncprefsdialog.cpp
@@ -1,903 +1,903 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qgroupbox.h> 26#include <qgroupbox.h>
27#include <qbuttongroup.h> 27#include <qbuttongroup.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qfont.h> 29#include <qfont.h>
30#include <qslider.h> 30#include <qslider.h>
31#include <qfile.h> 31#include <qfile.h>
32#include <qdir.h> 32#include <qdir.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qvbox.h> 35#include <qvbox.h>
36#include <qhbox.h> 36#include <qhbox.h>
37#include <qspinbox.h> 37#include <qspinbox.h>
38#include <qdatetime.h> 38#include <qdatetime.h>
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qradiobutton.h> 40#include <qradiobutton.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qstrlist.h> 42#include <qstrlist.h>
43#include <qapplication.h> 43#include <qapplication.h>
44#include <qlayout.h> 44#include <qlayout.h>
45#include <qscrollview.h> 45#include <qscrollview.h>
46#include <qvgroupbox.h> 46#include <qvgroupbox.h>
47#include <qhgroupbox.h> 47#include <qhgroupbox.h>
48 48
49#include <kcolorbutton.h> 49#include <kcolorbutton.h>
50#include <kdebug.h> 50#include <kdebug.h>
51#include <klocale.h> 51#include <klocale.h>
52#include <kglobal.h> 52#include <kglobal.h>
53#include <kfontdialog.h> 53#include <kfontdialog.h>
54#include <kmessagebox.h> 54#include <kmessagebox.h>
55#include <kcolordialog.h> 55#include <kcolordialog.h>
56#include <kiconloader.h> 56#include <kiconloader.h>
57#include <kemailsettings.h> 57#include <kemailsettings.h>
58#include <kstandarddirs.h> 58#include <kstandarddirs.h>
59#include <kfiledialog.h> 59#include <kfiledialog.h>
60#include <kmessagebox.h> 60#include <kmessagebox.h>
61 61
62//#include <kurlrequester.h> 62//#include <kurlrequester.h>
63#include <klineedit.h> 63#include <klineedit.h>
64#include "ksyncprofile.h" 64#include "ksyncprofile.h"
65 65
66 66
67//#include "koprefs.h" 67//#include "koprefs.h"
68 68
69#include "ksyncprefsdialog.h" 69#include "ksyncprefsdialog.h"
70//#include "koglobals.h" 70//#include "koglobals.h"
71 71
72 72
73KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) : 73KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) :
74 KDialog(parent,name,true) 74 KDialog(parent,name,true)
75{ 75{
76 76
77 setCaption( i18n("Synchronization Preferences")); 77 setCaption( i18n("Synchronization Preferences"));
78 78
79 mSyncProfiles.setAutoDelete( true ); 79 mSyncProfiles.setAutoDelete( true );
80 setupSyncAlgTab(); 80 setupSyncAlgTab();
81} 81}
82 82
83 83
84KSyncPrefsDialog::~KSyncPrefsDialog() 84KSyncPrefsDialog::~KSyncPrefsDialog()
85{ 85{
86} 86}
87 87
88void KSyncPrefsDialog::setupSyncAlgTab() 88void KSyncPrefsDialog::setupSyncAlgTab()
89{ 89{
90 QLabel * lab; 90 QLabel * lab;
91 //QFrame *page = addPage(i18n("Sync Prefs"),0,0); 91 //QFrame *page = addPage(i18n("Sync Prefs"),0,0);
92 QVBox * mainbox = new QVBox( this ); 92 QVBox * mainbox = new QVBox( this );
93 QScrollView* sv = new QScrollView( mainbox ); 93 QScrollView* sv = new QScrollView( mainbox );
94 QHBoxLayout * lay = new QHBoxLayout( this ); 94 QHBoxLayout * lay = new QHBoxLayout( this );
95 lay->addWidget( mainbox ); 95 lay->addWidget( mainbox );
96 QHBox * b_box = new QHBox( mainbox ); 96 QHBox * b_box = new QHBox( mainbox );
97 97
98 QPushButton* button = new QPushButton( i18n("Ok"), b_box ); 98 QPushButton* button = new QPushButton( i18n("Ok"), b_box );
99 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); 99 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) );
100 button = new QPushButton( i18n("Cancel"), b_box ); 100 button = new QPushButton( i18n("Cancel"), b_box );
101 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); 101 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) );
102 //QBoxLayout * sl = new QVBoxLayout(this ); 102 //QBoxLayout * sl = new QVBoxLayout(this );
103 //sl->addWidget ( sv ); 103 //sl->addWidget ( sv );
104 sv->setResizePolicy ( QScrollView::AutoOneFit ); 104 sv->setResizePolicy ( QScrollView::AutoOneFit );
105 QFrame *topFrame = new QFrame ( sv ); 105 QFrame *topFrame = new QFrame ( sv );
106 sv->addChild( topFrame ); 106 sv->addChild( topFrame );
107 mSetupSyncAlgTab = topFrame; 107 mSetupSyncAlgTab = topFrame;
108 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 108 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
109 topLayout->setSpacing(spacingHint()); 109 topLayout->setSpacing(spacingHint());
110 topLayout->setMargin(marginHint()); 110 topLayout->setMargin(marginHint());
111 111
112 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); 112 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame);
113 int iii = 0; 113 int iii = 0;
114 //topLayout->addMultiCellWidget(lab , iii,iii,0,1); 114 //topLayout->addMultiCellWidget(lab , iii,iii,0,1);
115 //++iii; 115 //++iii;
116 116
117 mMyMachineName = new QLineEdit(topFrame); 117 mMyMachineName = new QLineEdit(topFrame);
118 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); 118 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame);
119 topLayout->addWidget(lab ,iii,0); 119 topLayout->addWidget(lab ,iii,0);
120 topLayout->addWidget(mMyMachineName,iii,1); 120 topLayout->addWidget(mMyMachineName,iii,1);
121 ++iii; 121 ++iii;
122 122
123 QHBox* buttonbox = new QHBox( topFrame); 123 QHBox* buttonbox = new QHBox( topFrame);
124 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); 124 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1);
125 ++iii; 125 ++iii;
126 button = new QPushButton( i18n("New profile"), buttonbox ); 126 button = new QPushButton( i18n("New profile"), buttonbox );
127 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); 127 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) );
128 128
129 button = new QPushButton( i18n("Clone profile"), buttonbox ); 129 button = new QPushButton( i18n("Clone profile"), buttonbox );
130 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); 130 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) );
131 131
132 button = new QPushButton( i18n("Delete profile"), buttonbox ); 132 button = new QPushButton( i18n("Delete profile"), buttonbox );
133 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); 133 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) );
134 134
135 mProfileBox = new QComboBox(topFrame); 135 mProfileBox = new QComboBox(topFrame);
136 mProfileBox->setEditable ( true ); 136 mProfileBox->setEditable ( true );
137 mProfileBox->setInsertionPolicy(QComboBox::NoInsertion); 137 mProfileBox->setInsertionPolicy(QComboBox::NoInsertion);
138 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); 138 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) );
139 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); 139 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) );
140 140
141 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); 141 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame);
142 topLayout->addWidget(lab ,iii,0); 142 topLayout->addWidget(lab ,iii,0);
143 topLayout->addWidget(mProfileBox, iii,1); 143 topLayout->addWidget(mProfileBox, iii,1);
144 ++iii; 144 ++iii;
145 145
146 146
147 147
148 QHGroupBox *iims = new QHGroupBox( i18n("Multiple Sync options"), topFrame); 148 QHGroupBox *iims = new QHGroupBox( i18n("Multiple Sync options"), topFrame);
149 new QLabel( i18n("Include in multiple "), iims ); 149 new QLabel( i18n("Include in multiple "), iims );
150 mIncludeInRing = new QCheckBox( i18n("calendar "), iims ); 150 mIncludeInRing = new QCheckBox( i18n("calendar "), iims );
151 mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims ); 151 mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims );
152 mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims ); 152 mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims );
153 new QLabel( i18n(" sync"), iims ); 153 new QLabel( i18n(" sync"), iims );
154 topLayout->addMultiCellWidget(iims, iii,iii,0,1); 154 topLayout->addMultiCellWidget(iims, iii,iii,0,1);
155 ++iii; 155 ++iii;
156 QVGroupBox* gb0 = new QVGroupBox( i18n("Sync algo options"), topFrame); 156 QVGroupBox* gb0 = new QVGroupBox( i18n("Sync algo options"), topFrame);
157 topLayout->addMultiCellWidget(gb0, iii,iii,0,1); 157 topLayout->addMultiCellWidget(gb0, iii,iii,0,1);
158 ++iii; 158 ++iii;
159 QButtonGroup* gr; 159 QButtonGroup* gr;
160 { 160 {
161 QVGroupBox* topFrame = gb0; 161 QVGroupBox* topFrame = gb0;
162 162
163 163
164 164
165 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); 165 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame );
166 //topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); 166 //topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1);
167 //++iii; 167 //++iii;
168 gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); 168 gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame);
169 //topLayout->addMultiCellWidget(gr, iii,iii,0,1); 169 //topLayout->addMultiCellWidget(gr, iii,iii,0,1);
170 //++iii; 170 //++iii;
171 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); 171 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr );
172 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); 172 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr );
173 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); 173 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr );
174 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); 174 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr );
175 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); 175 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr );
176 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); 176 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr );
177 // both = new QRadioButton ( i18n("Take both on conflict"), gr ); 177 // both = new QRadioButton ( i18n("Take both on conflict"), gr );
178 178
179 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); 179 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame );
180 //topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); 180 //topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1);
181 //++iii; 181 //++iii;
182 182
183#if 0 183#if 0
184 QHGroupBox* gb51 = new QHGroupBox( i18n("Local resources to sync with:"), topFrame); 184 QHGroupBox* gb51 = new QHGroupBox( i18n("Local resources to sync with:"), topFrame);
185 { 185 {
186 QVBox * fibo2 = new QVBox ( gb51 ); 186 QVBox * fibo2 = new QVBox ( gb51 );
187 new QLabel ( i18n("Calendar resources:"), fibo2 ); 187 new QLabel ( i18n("Calendar resources:"), fibo2 );
188 //mFilterInCal = new QComboBox( fibo2 ); 188 //mFilterInCal = new QComboBox( fibo2 );
189 fibo2 = new QVBox ( gb51 ); 189 fibo2 = new QVBox ( gb51 );
190 new QLabel ( i18n("Addressbook resources:"), fibo2 ); 190 new QLabel ( i18n("Addressbook resources:"), fibo2 );
191 //mFilterInAB = new QComboBox( fibo2 ); 191 //mFilterInAB = new QComboBox( fibo2 );
192 } 192 }
193#endif 193#endif
194 QHGroupBox* gb5 = new QHGroupBox( i18n("Apply filter when adding data to local:"), topFrame); 194 QHGroupBox* gb5 = new QHGroupBox( i18n("Apply filter when adding data to local:"), topFrame);
195 QVBox * fibo2 = new QVBox ( gb5 ); 195 QVBox * fibo2 = new QVBox ( gb5 );
196 new QLabel ( i18n("Incoming calendar filter:"), fibo2 ); 196 new QLabel ( i18n("Incoming calendar filter:"), fibo2 );
197 mFilterInCal = new QComboBox( fibo2 ); 197 mFilterInCal = new QComboBox( fibo2 );
198 fibo2 = new QVBox ( gb5 ); 198 fibo2 = new QVBox ( gb5 );
199 new QLabel ( i18n("Incoming addressbook filter:"), fibo2 ); 199 new QLabel ( i18n("Incoming addressbook filter:"), fibo2 );
200 mFilterInAB = new QComboBox( fibo2 ); 200 mFilterInAB = new QComboBox( fibo2 );
201 201
202 mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame ); 202 mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame );
203 // topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); 203 // topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1);
204 // ++iii; 204 // ++iii;
205 205
206 QVGroupBox* gb2 = new QVGroupBox( i18n("Write back options"), topFrame); 206 QVGroupBox* gb2 = new QVGroupBox( i18n("Write back options"), topFrame);
207 //topLayout->addMultiCellWidget(gb2, iii,iii,0,1); 207 //topLayout->addMultiCellWidget(gb2, iii,iii,0,1);
208 //++iii; 208 //++iii;
209 { 209 {
210 QVGroupBox*topFrame = gb2; 210 QVGroupBox*topFrame = gb2;
211 mWriteBackExisting= new QCheckBox( i18n("Write back (on remote) existing entries only"), topFrame ); 211 mWriteBackExisting= new QCheckBox( i18n("Write back (on remote) existing entries only"), topFrame );
212 QHGroupBox* gb4 = new QHGroupBox( i18n("Apply filter when adding data to remote:"), topFrame); 212 QHGroupBox* gb4 = new QHGroupBox( i18n("Apply filter when adding data to remote:"), topFrame);
213 QVBox * fibo = new QVBox ( gb4 ); 213 QVBox * fibo = new QVBox ( gb4 );
214 new QLabel ( i18n("Outgoing calendar filter:"), fibo ); 214 new QLabel ( i18n("Outgoing calendar filter:"), fibo );
215 mFilterOutCal = new QComboBox( fibo ); 215 mFilterOutCal = new QComboBox( fibo );
216 fibo = new QVBox ( gb4 ); 216 fibo = new QVBox ( gb4 );
217 new QLabel ( i18n("Outgoing addressbook filter:"), fibo ); 217 new QLabel ( i18n("Outgoing addressbook filter:"), fibo );
218 mFilterOutAB = new QComboBox( fibo ); 218 mFilterOutAB = new QComboBox( fibo );
219 //topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); 219 //topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1);
220 //++iii; 220 //++iii;
221 mWriteBackFuture= new QCheckBox( i18n("Write back (calendar) entries for time period only"), topFrame ); 221 mWriteBackFuture= new QCheckBox( i18n("Write back (calendar) entries for time period only"), topFrame );
222 //topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1); 222 //topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1);
223 //++iii; 223 //++iii;
224 QHGroupBox* gb3 = new QHGroupBox( i18n("Time period"), topFrame); 224 QHGroupBox* gb3 = new QHGroupBox( i18n("Time period"), topFrame);
225 connect ( mWriteBackFuture, SIGNAL( toggled ( bool ) ), gb3, SLOT ( setEnabled ( bool ) ) ); 225 connect ( mWriteBackFuture, SIGNAL( toggled ( bool ) ), gb3, SLOT ( setEnabled ( bool ) ) );
226 new QLabel( i18n("From ") , gb3 ); 226 new QLabel( i18n("From ") , gb3 );
227 mWriteBackPastWeeks= new QSpinBox(1,104, 1, gb3); 227 mWriteBackPastWeeks= new QSpinBox(1,104, 1, gb3);
228 new QLabel( i18n(" weeks in the past to ") , gb3 ); 228 new QLabel( i18n(" weeks in the past to ") , gb3 );
229 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, gb3); 229 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, gb3);
230 new QLabel( i18n(" weeks in the future ") , gb3 ); 230 new QLabel( i18n(" weeks in the future ") , gb3 );
231 //topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1); 231 //topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1);
232 //++iii; 232 //++iii;
233 gb3->setEnabled( false ); 233 gb3->setEnabled( false );
234 connect ( mWriteBackExisting, SIGNAL( toggled ( bool ) ), gb4, SLOT ( setDisabled ( bool ) ) ); 234 connect ( mWriteBackExisting, SIGNAL( toggled ( bool ) ), gb4, SLOT ( setDisabled ( bool ) ) );
235 } 235 }
236 connect ( mWriteBackFile, SIGNAL( toggled ( bool ) ), gb2, SLOT ( setEnabled ( bool ) ) ); 236 connect ( mWriteBackFile, SIGNAL( toggled ( bool ) ), gb2, SLOT ( setEnabled ( bool ) ) );
237 237
238 } 238 }
239 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); 239 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame);
240 gr = proGr; 240 gr = proGr;
241 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 241 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
242 ++iii; 242 ++iii;
243 mIsLocal = new QRadioButton ( i18n("Local file"), gr ); 243 mIsLocal = new QRadioButton ( i18n("Local file"), gr );
244 mIsPi = new QRadioButton ( i18n("Pi-Sync - all resources ( direct Kx/Pi to Kx/Pi sync )"), gr ); 244 mIsPi = new QRadioButton ( i18n("Pi-Sync - all resources ( direct Kx/Pi to Kx/Pi sync )"), gr );
245 connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 245 connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
246 mIsPiSpecific = new QRadioButton ( i18n("Pi-Sync - selected resources ( direct Kx/Pi to Kx/Pi sync )"), gr ); 246 mIsPiSpecific = new QRadioButton ( i18n("Pi-Sync - selected resources ( direct Kx/Pi to Kx/Pi sync )"), gr );
247 connect (mIsPiSpecific, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 247 connect (mIsPiSpecific, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
248 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); 248 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr );
249 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 249 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
250 mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr ); 250 mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr );
251 connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 251 connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
252 252
253 QVGroupBox* gb1 = new QVGroupBox( i18n("Profile kind specific settings"), topFrame); 253 QVGroupBox* gb1 = new QVGroupBox( i18n("Profile kind specific settings"), topFrame);
254 topLayout->addMultiCellWidget(gb1, iii,iii,0,1); 254 topLayout->addMultiCellWidget(gb1, iii,iii,0,1);
255 ++iii; 255 ++iii;
256 256
257 // ****************************************** 257 // ******************************************
258 // Profile kind specific settings 258 // Profile kind specific settings
259 { 259 {
260 // *** phone ******************************* 260 // *** phone *******************************
261 QVGroupBox* topFrame = gb1; 261 QVGroupBox* topFrame = gb1;
262 phoneWidget = new QVBox( topFrame); 262 phoneWidget = new QVBox( topFrame);
263 //topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1); 263 //topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1);
264 //++iii; 264 //++iii;
265 mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget ); 265 mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget );
266 QHBox* temphb = new QHBox( phoneWidget ); 266 QHBox* temphb = new QHBox( phoneWidget );
267 new QLabel( i18n("I/O device: "), temphb ); 267 new QLabel( i18n("I/O device: "), temphb );
268 mPhoneDevice = new QLineEdit( temphb); 268 mPhoneDevice = new QLineEdit( temphb);
269 button = new QPushButton( i18n("Help..."), temphb ); 269 button = new QPushButton( i18n("Help..."), temphb );
270 connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) ); 270 connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) );
271 271
272 272
273 temphb = new QHBox( phoneWidget ); 273 temphb = new QHBox( phoneWidget );
274 new QLabel( i18n("Connection: "), temphb ); 274 new QLabel( i18n("Connection: "), temphb );
275 mPhoneConnection = new QLineEdit( temphb); 275 mPhoneConnection = new QLineEdit( temphb);
276 button = new QPushButton( i18n("Help..."), temphb ); 276 button = new QPushButton( i18n("Help..."), temphb );
277 connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) ); 277 connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) );
278 278
279 279
280 temphb = new QHBox( phoneWidget ); 280 temphb = new QHBox( phoneWidget );
281 new QLabel( i18n("Model(opt.): "), temphb ); 281 new QLabel( i18n("Model(opt.): "), temphb );
282 mPhoneModel = new QLineEdit( temphb); 282 mPhoneModel = new QLineEdit( temphb);
283 button = new QPushButton( i18n("Help..."), temphb ); 283 button = new QPushButton( i18n("Help..."), temphb );
284 connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) ); 284 connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) );
285 285
286 // *** local******************************* 286 // *** local*******************************
287 localFileWidget = new QVBox( topFrame); 287 localFileWidget = new QVBox( topFrame);
288 //topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); 288 //topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1);
289 //++iii; 289 //++iii;
290 temphb = new QHBox( localFileWidget ); 290 temphb = new QHBox( localFileWidget );
291 291
292 lab = new QLabel( i18n("Local file Cal:"), temphb ); 292 lab = new QLabel( i18n("Local file Cal:"), temphb );
293 lab = new QLabel( i18n("Local file ABook:"), temphb ); 293 lab = new QLabel( i18n("Local file ABook:"), temphb );
294 lab = new QLabel( i18n("Local file PWMgr:"), temphb ); 294 lab = new QLabel( i18n("Local file PWMgr:"), temphb );
295 temphb = new QHBox( localFileWidget ); 295 temphb = new QHBox( localFileWidget );
296 button = new QPushButton( i18n("Choose..."), temphb ); 296 button = new QPushButton( i18n("Choose..."), temphb );
297 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); 297 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) );
298 button = new QPushButton( i18n("Choose..."), temphb ); 298 button = new QPushButton( i18n("Choose..."), temphb );
299 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) ); 299 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) );
300 button = new QPushButton( i18n("Choose..."), temphb ); 300 button = new QPushButton( i18n("Choose..."), temphb );
301 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) ); 301 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) );
302 temphb = new QHBox( localFileWidget ); 302 temphb = new QHBox( localFileWidget );
303 303
304 mRemoteFile = new QLineEdit( temphb); 304 mRemoteFile = new QLineEdit( temphb);
305 mRemoteFileAB = new QLineEdit( temphb); 305 mRemoteFileAB = new QLineEdit( temphb);
306 mRemoteFilePWM = new QLineEdit( temphb); 306 mRemoteFilePWM = new QLineEdit( temphb);
307 mIsKapiFileL = new QCheckBox( i18n("Addressbook file (*.vcf) is used by KA/Pi"), localFileWidget ); 307 mIsKapiFileL = new QCheckBox( i18n("Addressbook file (*.vcf) is used by KA/Pi"), localFileWidget );
308 308
309 309
310 // *** remote******************************* 310 // *** remote*******************************
311 remoteFileWidget = new QVBox( topFrame); 311 remoteFileWidget = new QVBox( topFrame);
312 //topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); 312 //topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1);
313 //++iii; 313 //++iii;
314 temphb = new QHBox( remoteFileWidget ); 314 temphb = new QHBox( remoteFileWidget );
315 new QLabel( i18n("Calendar:"), temphb); 315 new QLabel( i18n("Calendar:"), temphb);
316 new QLabel( i18n("AddressBook:"), temphb); 316 new QLabel( i18n("AddressBook:"), temphb);
317 new QLabel( i18n("PWManager:"), temphb); 317 new QLabel( i18n("PWManager:"), temphb);
318 318
319 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); 319 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget);
320 temphb = new QHBox( remoteFileWidget ); 320 temphb = new QHBox( remoteFileWidget );
321 mRemotePrecommand = new QLineEdit(temphb); 321 mRemotePrecommand = new QLineEdit(temphb);
322 mRemotePrecommandAB = new QLineEdit(temphb); 322 mRemotePrecommandAB = new QLineEdit(temphb);
323 mRemotePrecommandPWM = new QLineEdit(temphb); 323 mRemotePrecommandPWM = new QLineEdit(temphb);
324 324
325 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); 325 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget);
326 temphb = new QHBox( remoteFileWidget ); 326 temphb = new QHBox( remoteFileWidget );
327 mLocalTempFile = new QLineEdit(temphb); 327 mLocalTempFile = new QLineEdit(temphb);
328 mLocalTempFileAB = new QLineEdit(temphb); 328 mLocalTempFileAB = new QLineEdit(temphb);
329 mLocalTempFilePWM = new QLineEdit(temphb); 329 mLocalTempFilePWM = new QLineEdit(temphb);
330 330
331 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); 331 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget);
332 temphb = new QHBox( remoteFileWidget ); 332 temphb = new QHBox( remoteFileWidget );
333 mRemotePostcommand = new QLineEdit(temphb ); 333 mRemotePostcommand = new QLineEdit(temphb );
334 mRemotePostcommandAB = new QLineEdit(temphb ); 334 mRemotePostcommandAB = new QLineEdit(temphb );
335 mRemotePostcommandPWM = new QLineEdit(temphb ); 335 mRemotePostcommandPWM = new QLineEdit(temphb );
336 mIsKapiFileR = new QCheckBox( i18n("Addressbook file is used by KA/Pi"), remoteFileWidget ); 336 mIsKapiFileR = new QCheckBox( i18n("Addressbook file is used by KA/Pi"), remoteFileWidget );
337 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); 337 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget);
338 temphb = new QHBox( remoteFileWidget ); 338 temphb = new QHBox( remoteFileWidget );
339 button = new QPushButton( i18n("ssh/scp"), temphb ); 339 button = new QPushButton( i18n("ssh/scp"), temphb );
340 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); 340 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) );
341 button = new QPushButton( i18n("ftp"), temphb ); 341 button = new QPushButton( i18n("ftp"), temphb );
342 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); 342 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) );
343 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); 343 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget);
344 344
345 // *** pi-sync******************************* 345 // *** pi-sync*******************************
346 piWidget = new QVBox( topFrame); 346 piWidget = new QVBox( topFrame);
347 //topLayout->addMultiCellWidget(piWidget, iii,iii,0,1); 347 //topLayout->addMultiCellWidget(piWidget, iii,iii,0,1);
348 //++iii; 348 //++iii;
349 temphb = new QHBox( piWidget ); 349 temphb = new QHBox( piWidget );
350 new QLabel( i18n("Calendar:"), temphb); 350 new QLabel( i18n("Calendar:"), temphb);
351 new QLabel( i18n("AddressBook:"), temphb); 351 new QLabel( i18n("AddressBook:"), temphb);
352 new QLabel( i18n("PWManager:"), temphb); 352 new QLabel( i18n("PWManager:"), temphb);
353 353
354 lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget); 354 lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget);
355 temphb = new QHBox( piWidget ); 355 temphb = new QHBox( piWidget );
356 mRemotePw = new QLineEdit(temphb); 356 mRemotePw = new QLineEdit(temphb);
357 mRemotePwAB = new QLineEdit(temphb); 357 mRemotePwAB = new QLineEdit(temphb);
358 mRemotePwPWM = new QLineEdit(temphb); 358 mRemotePwPWM = new QLineEdit(temphb);
359 359
360 lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget); 360 lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget);
361 temphb = new QHBox( piWidget ); 361 temphb = new QHBox( piWidget );
362 mRemoteIP = new QLineEdit(temphb); 362 mRemoteIP = new QLineEdit(temphb);
363 mRemoteIPAB = new QLineEdit(temphb); 363 mRemoteIPAB = new QLineEdit(temphb);
364 mRemoteIPPWM = new QLineEdit(temphb); 364 mRemoteIPPWM = new QLineEdit(temphb);
365 365
366 lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget); 366 lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget);
367 temphb = new QHBox( piWidget ); 367 temphb = new QHBox( piWidget );
368 mRemotePort = new QLineEdit(temphb); 368 mRemotePort = new QLineEdit(temphb);
369 mRemotePortAB = new QLineEdit(temphb); 369 mRemotePortAB = new QLineEdit(temphb);
370 mRemotePortPWM = new QLineEdit(temphb); 370 mRemotePortPWM = new QLineEdit(temphb);
371 371
372 lab = new QLabel( i18n("Local/remote Resource sync partners"), piWidget); 372 lab = new QLabel( i18n("Local/remote Resource sync partners"), piWidget);
373 mTableBox = new QHBox( piWidget ); 373 mTableBox = new QHBox( piWidget );
374 mResTableKopi = new QTable( 1, 1, mTableBox ); 374 mResTableKopi = new QTable( 1, 1, mTableBox );
375 mResTableKapi = new QTable( 1, 1, mTableBox ); 375 mResTableKapi = new QTable( 1, 1, mTableBox );
376 mResTablePwmpi = new QTable( 1, 1, mTableBox ); 376 mResTablePwmpi = new QTable( 1, 1, mTableBox );
377 mResTableKopi->horizontalHeader()->setLabel( 0, i18n("Remote") ); 377 mResTableKopi->horizontalHeader()->setLabel( 0, i18n("Remote") );
378 mResTableKapi->horizontalHeader()->setLabel( 0, i18n("Remote") ); 378 mResTableKapi->horizontalHeader()->setLabel( 0, i18n("Remote") );
379 mResTablePwmpi->horizontalHeader()->setLabel( 0, i18n("Remote") ); 379 mResTablePwmpi->horizontalHeader()->setLabel( 0, i18n("Remote") );
380 mResTableKopi->setLeftMargin( 80 ); 380 mResTableKopi->setLeftMargin( 80 );
381 } 381 }
382 // ****************************************** 382 // ******************************************
383 // Profile kind specific settings END 383 // Profile kind specific settings END
384 384
385} 385}
386 386
387void KSyncPrefsDialog::readResources() 387void KSyncPrefsDialog::readResources()
388{ 388{
389 mResourcesKopi.clear(); 389 mResourcesKopi.clear();
390 mResourcesKapi.clear(); 390 mResourcesKapi.clear();
391 KConfig fc(locateLocal("config","kopicalendarrc")); 391 KConfig fc(locateLocal("config","kopicalendarrc"));
392 fc.setGroup("CC"); 392 fc.setGroup("CC");
393 int numCals = fc.readNumEntry("NumberCalendars",0 ); 393 int numCals = fc.readNumEntry("NumberCalendars",0 );
394 int curCal = 1; 394 int curCal = 1;
395 while ( curCal <= numCals ) { 395 while ( curCal <= numCals ) {
396 QString prefix = "Cal_" +QString::number( curCal ); 396 QString prefix = "Cal_" +QString::number( curCal );
397 QString name = fc.readEntry( prefix+"_Name", "Calendar"); 397 QString name = fc.readEntry( prefix+"_Name", "Calendar");
398 mResourcesKopi.append( name ); 398 mResourcesKopi.append( name );
399 ++curCal; 399 ++curCal;
400 } 400 }
401 mResTableKopi->setNumRows( mResourcesKopi.count() ); 401 mResTableKopi->setNumRows( mResourcesKopi.count() );
402 int i; 402 int i;
403 for ( i = 0;i < mResourcesKopi.count(); ++i ) { 403 for ( i = 0;i < mResourcesKopi.count(); ++i ) {
404 mResTableKopi->verticalHeader ()->setLabel( i, mResourcesKopi[i] ); 404 mResTableKopi->verticalHeader ()->setLabel( i, mResourcesKopi[i] );
405 } 405 }
406} 406}
407void KSyncPrefsDialog::readFilter() 407void KSyncPrefsDialog::readFilter()
408{ 408{
409 mFilterKapi.clear(); 409 mFilterKapi.clear();
410 mFilterKopi.clear(); 410 mFilterKopi.clear();
411 KConfig cfgko(locateLocal("config","korganizerrc")); 411 KConfig cfgko(locateLocal("config","korganizerrc"));
412 KConfig cfgka(locateLocal("config","kaddressbookrc")); 412 KConfig cfgka(locateLocal("config","kaddressbookrc"));
413 cfgko.setGroup("General"); 413 cfgko.setGroup("General");
414 mFilterKopi = cfgko.readListEntry("CalendarFilters"); 414 mFilterKopi = cfgko.readListEntry("CalendarFilters");
415 cfgka.setGroup("Filter"); 415 cfgka.setGroup("Filter");
416 int count = cfgka.readNumEntry( "Count", 0 ); 416 int count = cfgka.readNumEntry( "Count", 0 );
417 for ( int i = 0; i < count; i++ ) { 417 for ( int i = 0; i < count; i++ ) {
418 cfgka.setGroup("Filter_"+QString::number( i ) ); 418 cfgka.setGroup("Filter_"+QString::number( i ) );
419 mFilterKapi.append( cfgka.readEntry("Name", "internal error") ); 419 mFilterKapi.append( cfgka.readEntry("Name", "internal error") );
420 } 420 }
421 mFilterOutCal->clear(); 421 mFilterOutCal->clear();
422 mFilterInCal->clear(); 422 mFilterInCal->clear();
423 mFilterOutAB->clear(); 423 mFilterOutAB->clear();
424 mFilterInAB->clear(); 424 mFilterInAB->clear();
425 QStringList temp = mFilterKopi; 425 QStringList temp = mFilterKopi;
426 temp.prepend(i18n("No Filter") ); 426 temp.prepend(i18n("No Filter") );
427 mFilterOutCal->insertStringList( temp ); 427 mFilterOutCal->insertStringList( temp );
428 mFilterInCal->insertStringList( temp ); 428 mFilterInCal->insertStringList( temp );
429 temp = mFilterKapi; 429 temp = mFilterKapi;
430 temp.prepend(i18n("No Filter") ); 430 temp.prepend(i18n("No Filter") );
431 mFilterOutAB->insertStringList( temp ); 431 mFilterOutAB->insertStringList( temp );
432 mFilterInAB->insertStringList( temp ); 432 mFilterInAB->insertStringList( temp );
433} 433}
434 434
435void KSyncPrefsDialog::slotOK() 435void KSyncPrefsDialog::slotOK()
436{ 436{
437 if ( mMyMachineName->text() == "undefined" ) { 437 if ( mMyMachineName->text() == "undefined" ) {
438 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); 438 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error"));
439 return; 439 return;
440 } 440 }
441 int i; 441 int i;
442 for (i = 0; i < mSyncProfileNames.count(); ++ i) { 442 for (i = 0; i < mSyncProfileNames.count(); ++ i) {
443 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { 443 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) {
444 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); 444 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error"));
445 return; 445 return;
446 } 446 }
447 } 447 }
448 usrWriteConfig(); 448 usrWriteConfig();
449 QDialog::accept(); 449 QDialog::accept();
450} 450}
451void KSyncPrefsDialog::accept() 451void KSyncPrefsDialog::accept()
452{ 452{
453 slotOK(); 453 slotOK();
454} 454}
455void KSyncPrefsDialog::chooseFile() 455void KSyncPrefsDialog::chooseFile()
456{ 456{
457 QString fn = QDir::homeDirPath(); 457 QString fn = QDir::homeDirPath();
458 458
459 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 459 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
460 if ( fn == "" ) 460 if ( fn == "" )
461 return; 461 return;
462 mRemoteFile->setText( fn ); 462 mRemoteFile->setText( fn );
463} 463}
464 464
465void KSyncPrefsDialog::chooseFileAB() 465void KSyncPrefsDialog::chooseFileAB()
466{ 466{
467 QString fn = QDir::homeDirPath(); 467 QString fn = QDir::homeDirPath();
468 468
469 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this ); 469 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this );
470 if ( fn == "" ) 470 if ( fn == "" )
471 return; 471 return;
472 mRemoteFileAB->setText( fn ); 472 mRemoteFileAB->setText( fn );
473} 473}
474 474
475void KSyncPrefsDialog::chooseFilePWM() 475void KSyncPrefsDialog::chooseFilePWM()
476{ 476{
477 QString fn = QDir::homeDirPath(); 477 QString fn = QDir::homeDirPath();
478 478
479 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this ); 479 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this );
480 if ( fn == "" ) 480 if ( fn == "" )
481 return; 481 return;
482 mRemoteFilePWM->setText( fn ); 482 mRemoteFilePWM->setText( fn );
483} 483}
484 484
485void KSyncPrefsDialog::textChanged( const QString & s ) 485void KSyncPrefsDialog::textChanged( const QString & s )
486{ 486{
487 if ( mProfileBox->count() == 0 ) 487 if ( mProfileBox->count() == 0 )
488 return; 488 return;
489 if ( currentSelection < 3 ) { 489 if ( currentSelection < 3 ) {
490 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); 490 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error"));
491 mProfileBox->blockSignals( true ); 491 mProfileBox->blockSignals( true );
492 mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); 492 mProfileBox->setCurrentItem(mProfileBox-> currentItem ());
493 mProfileBox->blockSignals( false ); 493 mProfileBox->blockSignals( false );
494 return; 494 return;
495 } 495 }
496 //qDebug("cur i %d ",mProfileBox-> currentItem () ); 496 //qDebug("cur i %d ",mProfileBox-> currentItem () );
497 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; 497 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ;
498 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; 498 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ;
499 prof->setName( s ); 499 prof->setName( s );
500 mSyncProfileNames[mProfileBox-> currentItem ()] = s; 500 mSyncProfileNames[mProfileBox-> currentItem ()] = s;
501} 501}
502void KSyncPrefsDialog::profileChanged( int item ) 502void KSyncPrefsDialog::profileChanged( int item )
503{ 503{
504 //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() ); 504 //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() );
505 KSyncProfile* prof; 505 KSyncProfile* prof;
506 saveProfile(); 506 saveProfile();
507 readFilter(); 507 readFilter();
508 readResources(); 508 readResources();
509 currentSelection = item; 509 currentSelection = item;
510 prof = mSyncProfiles.at(item) ; 510 prof = mSyncProfiles.at(item) ;
511 511
512 mRemotePw->setText(prof->getRemotePw()); 512 mRemotePw->setText(prof->getRemotePw());
513 mRemoteIP->setText(prof->getRemoteIP()); 513 mRemoteIP->setText(prof->getRemoteIP());
514 mRemotePort->setText(prof->getRemotePort()); 514 mRemotePort->setText(prof->getRemotePort());
515 515
516 mRemotePwAB->setText(prof->getRemotePwAB()); 516 mRemotePwAB->setText(prof->getRemotePwAB());
517 mRemoteIPAB->setText(prof->getRemoteIPAB()); 517 mRemoteIPAB->setText(prof->getRemoteIPAB());
518 mRemotePortAB->setText(prof->getRemotePortAB()); 518 mRemotePortAB->setText(prof->getRemotePortAB());
519 519
520 mRemotePwPWM->setText(prof->getRemotePwPWM()); 520 mRemotePwPWM->setText(prof->getRemotePwPWM());
521 mRemoteIPPWM->setText(prof->getRemoteIPPWM()); 521 mRemoteIPPWM->setText(prof->getRemoteIPPWM());
522 mRemotePortPWM->setText(prof->getRemotePortPWM()); 522 mRemotePortPWM->setText(prof->getRemotePortPWM());
523 523
524 mRemotePrecommand->setText(prof->getPreSyncCommand()); 524 mRemotePrecommand->setText(prof->getPreSyncCommand());
525 mRemotePostcommand->setText(prof->getPostSyncCommand()); 525 mRemotePostcommand->setText(prof->getPostSyncCommand());
526 mLocalTempFile->setText(prof->getLocalTempFile()); 526 mLocalTempFile->setText(prof->getLocalTempFile());
527 mRemoteFile->setText(prof->getRemoteFileName()) ; 527 mRemoteFile->setText(prof->getRemoteFileName()) ;
528 528
529 mRemotePrecommandAB->setText(prof->getPreSyncCommandAB()); 529 mRemotePrecommandAB->setText(prof->getPreSyncCommandAB());
530 mRemotePostcommandAB->setText(prof->getPostSyncCommandAB()); 530 mRemotePostcommandAB->setText(prof->getPostSyncCommandAB());
531 mLocalTempFileAB->setText(prof->getLocalTempFileAB()); 531 mLocalTempFileAB->setText(prof->getLocalTempFileAB());
532 mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ; 532 mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ;
533 533
534 mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM()); 534 mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM());
535 mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM()); 535 mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM());
536 mLocalTempFilePWM->setText(prof->getLocalTempFilePWM()); 536 mLocalTempFilePWM->setText(prof->getLocalTempFilePWM());
537 mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ; 537 mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ;
538 538
539 if ( mWriteContactToSIM ) 539 if ( mWriteContactToSIM )
540 mWriteContactToSIM->setChecked( prof->getWriteContactToSIM()); 540 mWriteContactToSIM->setChecked( prof->getWriteContactToSIM());
541 mPhoneDevice->setText(prof->getPhoneDevice()); 541 mPhoneDevice->setText(prof->getPhoneDevice());
542 mPhoneConnection->setText(prof->getPhoneConnection()); 542 mPhoneConnection->setText(prof->getPhoneConnection());
543 mPhoneModel->setText(prof->getPhoneModel()); 543 mPhoneModel->setText(prof->getPhoneModel());
544 544
545 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); 545 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
546 mAskForPreferences->setChecked( prof->getAskForPreferences()); 546 mAskForPreferences->setChecked( prof->getAskForPreferences());
547 mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); 547 mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
548 mWriteBackFile->setChecked( prof->getWriteBackFile()); 548 mWriteBackFile->setChecked( prof->getWriteBackFile());
549 mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); 549 mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
550 mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() ); 550 mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() );
551 mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() ); 551 mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() );
552 mWriteBackFuture->setChecked( prof->getWriteBackFuture()); 552 mWriteBackFuture->setChecked( prof->getWriteBackFuture());
553 mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() ); 553 mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() );
554 mWriteBackPastWeeks->setValue( prof->getWriteBackPastWeeks() ); 554 mWriteBackPastWeeks->setValue( prof->getWriteBackPastWeeks() );
555 555
556 mFilterInCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterInCal () ) + 1 ); 556 mFilterInCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterInCal () ) + 1 );
557 mFilterOutCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterOutCal () ) + 1 ); 557 mFilterOutCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterOutCal () ) + 1 );
558 mFilterInAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterInAB () ) + 1 ); 558 mFilterInAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterInAB () ) + 1 );
559 mFilterOutAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterOutAB () ) + 1 ); 559 mFilterOutAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterOutAB () ) + 1 );
560 560
561 switch ( prof->getSyncPrefs() ) { 561 switch ( prof->getSyncPrefs() ) {
562 case 0: 562 case 0:
563 loc->setChecked( true); 563 loc->setChecked( true);
564 break; 564 break;
565 case 1: 565 case 1:
566 rem->setChecked( true ); 566 rem->setChecked( true );
567 break; 567 break;
568 case 2: 568 case 2:
569 newest->setChecked( true); 569 newest->setChecked( true);
570 break; 570 break;
571 case 3: 571 case 3:
572 ask->setChecked( true); 572 ask->setChecked( true);
573 break; 573 break;
574 case 4: 574 case 4:
575 f_loc->setChecked( true); 575 f_loc->setChecked( true);
576 break; 576 break;
577 case 5: 577 case 5:
578 f_rem->setChecked( true); 578 f_rem->setChecked( true);
579 break; 579 break;
580 case 6: 580 case 6:
581 //both->setChecked( true); 581 //both->setChecked( true);
582 break; 582 break;
583 default: 583 default:
584 break; 584 break;
585 } 585 }
586 mIsLocal->setChecked(prof->getIsLocalFileSync()) ; 586 mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
587 mIsPhone->setChecked(prof->getIsPhoneSync()) ; 587 mIsPhone->setChecked(prof->getIsPhoneSync()) ;
588 mIsPi->setChecked(prof->getIsPiSync()) ; 588 mIsPi->setChecked(prof->getIsPiSync()) ;
589 mIsPiSpecific->setChecked(prof->getIsPiSyncSpec()) ; 589 mIsPiSpecific->setChecked(prof->getIsPiSyncSpec()) ;
590 mIsKapiFileL->setChecked(prof->getIsKapiFile()) ; 590 mIsKapiFileL->setChecked(prof->getIsKapiFile()) ;
591 mIsKapiFileR->setChecked(prof->getIsKapiFile()) ; 591 mIsKapiFileR->setChecked(prof->getIsKapiFile()) ;
592 592
593 593
594 QStringList res = QStringList::split( ":",prof->getResSpecKopi()); 594 QStringList res = QStringList::split( ":",prof->getResSpecKopi());
595 int i; 595 int i= res.count()/2;
596 for ( i = 0;i < res.count(); ++i ) { 596 for ( ;i < res.count(); ++i ) {
597 mResTableKopi->setText( i, 0, res[i] ); 597 mResTableKopi->setText( i, 0, res[i] );
598 } 598 }
599 res = QStringList::split( ":",prof->getResSpecKapi()); 599 res = QStringList::split( ":",prof->getResSpecKapi());
600 for ( i = 0;i < res.count(); ++i ) { 600 for ( i = 0;i < res.count(); ++i ) {
601 mResTableKapi->setText( i, 0, res[i] ); 601 mResTableKapi->setText( i, 0, res[i] );
602 } 602 }
603 mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() &&!prof->getIsPiSyncSpec()); 603 mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() &&!prof->getIsPiSyncSpec());
604 proGr->setEnabled( item > 2 ); 604 proGr->setEnabled( item > 2 );
605 if ( item < 3 ) { 605 if ( item < 3 ) {
606 localFileWidget->hide(); 606 localFileWidget->hide();
607 remoteFileWidget->hide(); 607 remoteFileWidget->hide();
608 phoneWidget->hide(); 608 phoneWidget->hide();
609 piWidget->hide(); 609 piWidget->hide();
610 610
611 } else 611 } else
612 kindChanged( prof->getIsLocalFileSync() ); 612 kindChanged( prof->getIsLocalFileSync() );
613} 613}
614 614
615void KSyncPrefsDialog::fillSSH() 615void KSyncPrefsDialog::fillSSH()
616{ 616{
617 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 617 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
618 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 618 mLocalTempFile->setText("/tmp/mycalendar.ics" );
619 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); 619 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" );
620 mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); 620 mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
621 mLocalTempFileAB->setText("/tmp/std.vcf" ); 621 mLocalTempFileAB->setText("/tmp/std.vcf" );
622 mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" ); 622 mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" );
623 mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); 623 mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
624 mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); 624 mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
625 mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" ); 625 mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" );
626} 626}
627void KSyncPrefsDialog::fillFTP() 627void KSyncPrefsDialog::fillFTP()
628{ 628{
629 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); 629 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" );
630 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 630 mLocalTempFile->setText("/tmp/mycalendar.ics" );
631 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 631 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
632 mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" ); 632 mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" );
633 mLocalTempFileAB->setText("/tmp/std.vcf" ); 633 mLocalTempFileAB->setText("/tmp/std.vcf" );
634 mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); 634 mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
635 635
636 mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" ); 636 mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" );
637 mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); 637 mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
638 mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); 638 mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
639 639
640} 640}
641void KSyncPrefsDialog::kindChanged( bool b ) 641void KSyncPrefsDialog::kindChanged( bool b )
642{ 642{
643 643
644 if ( mIsLocal->isChecked () ) { 644 if ( mIsLocal->isChecked () ) {
645 mIsKapiFileL->setChecked( mIsKapiFileR->isChecked() ); 645 mIsKapiFileL->setChecked( mIsKapiFileR->isChecked() );
646 } else { 646 } else {
647 mIsKapiFileR->setChecked( mIsKapiFileL->isChecked() ); 647 mIsKapiFileR->setChecked( mIsKapiFileL->isChecked() );
648 } 648 }
649 649
650 if ( mIsLocal->isChecked () ) 650 if ( mIsLocal->isChecked () )
651 localFileWidget->show(); 651 localFileWidget->show();
652 else 652 else
653 localFileWidget->hide(); 653 localFileWidget->hide();
654 654
655 if ( mIsNotLocal->isChecked () ) 655 if ( mIsNotLocal->isChecked () )
656 remoteFileWidget->show(); 656 remoteFileWidget->show();
657 else 657 else
658 remoteFileWidget->hide(); 658 remoteFileWidget->hide();
659 659
660 if ( mIsPhone->isChecked () ) { 660 if ( mIsPhone->isChecked () ) {
661 phoneWidget->show(); 661 phoneWidget->show();
662 } 662 }
663 else { 663 else {
664 phoneWidget->hide(); 664 phoneWidget->hide();
665 } 665 }
666 666
667 if ( mIsPi->isChecked () || mIsPiSpecific->isChecked () ) { 667 if ( mIsPi->isChecked () || mIsPiSpecific->isChecked () ) {
668 piWidget->show(); 668 piWidget->show();
669 if (mIsPiSpecific->isChecked () ) { 669 if (mIsPiSpecific->isChecked () ) {
670 mTableBox->show(); 670 mTableBox->show();
671 } 671 }
672 else { 672 else {
673 mTableBox->hide(); 673 mTableBox->hide();
674 } 674 }
675 } 675 }
676 else { 676 else {
677 piWidget->hide(); 677 piWidget->hide();
678 } 678 }
679 679
680 680
681} 681}
682void KSyncPrefsDialog::deleteProfile() 682void KSyncPrefsDialog::deleteProfile()
683{ 683{
684 //qDebug("KSyncPrefsDialog::deleteProfile() "); 684 //qDebug("KSyncPrefsDialog::deleteProfile() ");
685 if ( currentSelection >= 0 ) { 685 if ( currentSelection >= 0 ) {
686 if ( currentSelection < 3 ) { 686 if ( currentSelection < 3 ) {
687 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); 687 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error"));
688 return; 688 return;
689 } 689 }
690 KSyncProfile* temp = mSyncProfiles.at(currentSelection); 690 KSyncProfile* temp = mSyncProfiles.at(currentSelection);
691 mSyncProfiles.remove( temp ); 691 mSyncProfiles.remove( temp );
692 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); 692 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection ));
693 insertProfiles(); 693 insertProfiles();
694 } 694 }
695} 695}
696 696
697void KSyncPrefsDialog::saveProfile() 697void KSyncPrefsDialog::saveProfile()
698{ 698{
699 KSyncProfile* prof; 699 KSyncProfile* prof;
700 if ( currentSelection >= 0 ) { 700 if ( currentSelection >= 0 ) {
701 prof = mSyncProfiles.at(currentSelection) ; 701 prof = mSyncProfiles.at(currentSelection) ;
702 702
703 prof->setRemotePw( mRemotePw->text()); 703 prof->setRemotePw( mRemotePw->text());
704 prof->setRemoteIP( mRemoteIP->text()); 704 prof->setRemoteIP( mRemoteIP->text());
705 prof->setRemotePort( mRemotePort->text()); 705 prof->setRemotePort( mRemotePort->text());
706 706
707 prof->setRemotePwAB( mRemotePwAB->text()); 707 prof->setRemotePwAB( mRemotePwAB->text());
708 prof->setRemoteIPAB( mRemoteIPAB->text()); 708 prof->setRemoteIPAB( mRemoteIPAB->text());
709 prof->setRemotePortAB( mRemotePortAB->text()); 709 prof->setRemotePortAB( mRemotePortAB->text());
710 710
711 prof->setRemotePwPWM( mRemotePwPWM->text()); 711 prof->setRemotePwPWM( mRemotePwPWM->text());
712 prof->setRemoteIPPWM( mRemoteIPPWM->text()); 712 prof->setRemoteIPPWM( mRemoteIPPWM->text());
713 prof->setRemotePortPWM( mRemotePortPWM->text()); 713 prof->setRemotePortPWM( mRemotePortPWM->text());
714 714
715 prof->setPreSyncCommand( mRemotePrecommand->text()); 715 prof->setPreSyncCommand( mRemotePrecommand->text());
716 prof->setPostSyncCommand( mRemotePostcommand->text() ); 716 prof->setPostSyncCommand( mRemotePostcommand->text() );
717 prof->setLocalTempFile( mLocalTempFile->text()); 717 prof->setLocalTempFile( mLocalTempFile->text());
718 prof->setRemoteFileName( mRemoteFile->text() ); 718 prof->setRemoteFileName( mRemoteFile->text() );
719 prof->setPreSyncCommandAB( mRemotePrecommandAB->text()); 719 prof->setPreSyncCommandAB( mRemotePrecommandAB->text());
720 prof->setPostSyncCommandAB( mRemotePostcommandAB->text() ); 720 prof->setPostSyncCommandAB( mRemotePostcommandAB->text() );
721 prof->setLocalTempFileAB( mLocalTempFileAB->text()); 721 prof->setLocalTempFileAB( mLocalTempFileAB->text());
722 prof->setRemoteFileNameAB( mRemoteFileAB->text() ); 722 prof->setRemoteFileNameAB( mRemoteFileAB->text() );
723 prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text()); 723 prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text());
724 prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() ); 724 prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() );
725 prof->setLocalTempFilePWM( mLocalTempFilePWM->text()); 725 prof->setLocalTempFilePWM( mLocalTempFilePWM->text());
726 prof->setRemoteFileNamePWM( mRemoteFilePWM->text() ); 726 prof->setRemoteFileNamePWM( mRemoteFilePWM->text() );
727 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); 727 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() );
728 prof->setAskForPreferences( mAskForPreferences->isChecked()); 728 prof->setAskForPreferences( mAskForPreferences->isChecked());
729 prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); 729 prof->setWriteBackExisting(mWriteBackExisting->isChecked() );
730 prof->setWriteBackFile( mWriteBackFile->isChecked()); 730 prof->setWriteBackFile( mWriteBackFile->isChecked());
731 prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); 731 prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
732 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() ); 732 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() );
733 prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() ); 733 prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() );
734 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; 734 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ;
735 prof->setSyncPrefs( syncprefs); 735 prof->setSyncPrefs( syncprefs);
736 prof->setIsLocalFileSync( mIsLocal->isChecked() ); 736 prof->setIsLocalFileSync( mIsLocal->isChecked() );
737 prof->setIsPhoneSync( mIsPhone->isChecked() ); 737 prof->setIsPhoneSync( mIsPhone->isChecked() );
738 prof->setIsPiSync( mIsPi->isChecked() ); 738 prof->setIsPiSync( mIsPi->isChecked() );
739 prof->setIsPiSyncSpec( mIsPiSpecific->isChecked() ); 739 prof->setIsPiSyncSpec( mIsPiSpecific->isChecked() );
740 prof->setIsKapiFile( mIsKapiFileL->isChecked() ); 740 prof->setIsKapiFile( mIsKapiFileL->isChecked() );
741 prof->setWriteBackFuture(mWriteBackFuture->isChecked()); 741 prof->setWriteBackFuture(mWriteBackFuture->isChecked());
742 prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value()); 742 prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value());
743 prof->setWriteBackPastWeeks(mWriteBackPastWeeks->value()); 743 prof->setWriteBackPastWeeks(mWriteBackPastWeeks->value());
744 if ( mWriteContactToSIM ) 744 if ( mWriteContactToSIM )
745 prof->setWriteContactToSIM(mWriteContactToSIM->isChecked()); 745 prof->setWriteContactToSIM(mWriteContactToSIM->isChecked());
746 prof->setPhoneDevice( mPhoneDevice->text() ); 746 prof->setPhoneDevice( mPhoneDevice->text() );
747 prof->setPhoneConnection( mPhoneConnection->text() ); 747 prof->setPhoneConnection( mPhoneConnection->text() );
748 prof->setPhoneModel( mPhoneModel->text() ); 748 prof->setPhoneModel( mPhoneModel->text() );
749 prof->setFilterInCal ( mFilterInCal->currentText ()); 749 prof->setFilterInCal ( mFilterInCal->currentText ());
750 prof->setFilterOutCal ( mFilterOutCal ->currentText ()); 750 prof->setFilterOutCal ( mFilterOutCal ->currentText ());
751 prof->setFilterInAB ( mFilterInAB ->currentText ()); 751 prof->setFilterInAB ( mFilterInAB ->currentText ());
752 prof->setFilterOutAB ( mFilterOutAB ->currentText ()); 752 prof->setFilterOutAB ( mFilterOutAB ->currentText ());
753 if ( mIsPiSpecific->isChecked() ) { 753 if ( mIsPiSpecific->isChecked() ) {
754 754
755 QStringList res; 755 QStringList res = mResourcesKopi;
756 int i; 756 int i;
757 for ( i = 0;i < mResourcesKopi.count(); ++i ) { 757 for ( i = 0;i < mResourcesKopi.count(); ++i ) {
758 res.append( mResTableKopi->text( i, 0 )); 758 res.append( mResTableKopi->text( i, 0 ));
759 } 759 }
760 prof->setResSpecKopi( res.join(":")); 760 prof->setResSpecKopi( res.join(":"));
761 } 761 }
762 } 762 }
763} 763}
764 764
765void KSyncPrefsDialog::insertProfiles() 765void KSyncPrefsDialog::insertProfiles()
766{ 766{
767 int curItem = mProfileBox->currentItem(); 767 int curItem = mProfileBox->currentItem();
768 mProfileBox->blockSignals( true ); 768 mProfileBox->blockSignals( true );
769 mProfileBox->clear(); 769 mProfileBox->clear();
770 mProfileBox->insertStringList (mSyncProfileNames ); 770 mProfileBox->insertStringList (mSyncProfileNames );
771 int item = mSyncProfileNames.count() -1; 771 int item = mSyncProfileNames.count() -1;
772 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) 772 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() )
773 mProfileBox->setCurrentItem( curItem ); 773 mProfileBox->setCurrentItem( curItem );
774 else if ( item >= 0 ) { 774 else if ( item >= 0 ) {
775 mProfileBox->setCurrentItem( item ); 775 mProfileBox->setCurrentItem( item );
776 } 776 }
777 currentSelection = -1; 777 currentSelection = -1;
778 if ( mSyncProfileNames.count() > 0 ) { 778 if ( mSyncProfileNames.count() > 0 ) {
779 //qDebug(" profileChanged( mProfileBox->currentItem() "); 779 //qDebug(" profileChanged( mProfileBox->currentItem() ");
780 profileChanged( mProfileBox->currentItem() ); 780 profileChanged( mProfileBox->currentItem() );
781 currentSelection = mProfileBox->currentItem(); 781 currentSelection = mProfileBox->currentItem();
782 } 782 }
783 mProfileBox->blockSignals( false ); 783 mProfileBox->blockSignals( false );
784} 784}
785 785
786void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) 786void KSyncPrefsDialog::addProfile ( KSyncProfile* temp )
787{ 787{
788 saveProfile(); 788 saveProfile();
789 mSyncProfiles.append( temp ); 789 mSyncProfiles.append( temp );
790 mSyncProfileNames << temp->getName(); 790 mSyncProfileNames << temp->getName();
791 insertProfiles(); 791 insertProfiles();
792 int last = mProfileBox->count() -1; 792 int last = mProfileBox->count() -1;
793 mProfileBox->blockSignals( true ); 793 mProfileBox->blockSignals( true );
794 mProfileBox->setCurrentItem( last ); 794 mProfileBox->setCurrentItem( last );
795 mProfileBox->blockSignals( false ); 795 mProfileBox->blockSignals( false );
796 profileChanged(last); 796 profileChanged(last);
797} 797}
798void KSyncPrefsDialog::newProfile() 798void KSyncPrefsDialog::newProfile()
799{ 799{
800 addProfile ( new KSyncProfile () ); 800 addProfile ( new KSyncProfile () );
801} 801}
802 802
803void KSyncPrefsDialog::cloneProfile() 803void KSyncPrefsDialog::cloneProfile()
804{ 804{
805 if ( currentSelection >= 0 ) 805 if ( currentSelection >= 0 )
806 addProfile (mSyncProfiles.at(currentSelection)->clone()) ; 806 addProfile (mSyncProfiles.at(currentSelection)->clone()) ;
807 else 807 else
808 newProfile(); 808 newProfile();
809} 809}
810 810
811void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) 811void KSyncPrefsDialog::setLocalMachineName ( const QString& name )
812{ 812{
813 mMyMachineName->setText( name ); 813 mMyMachineName->setText( name );
814 814
815} 815}
816QString KSyncPrefsDialog::getLocalMachineName ( ) 816QString KSyncPrefsDialog::getLocalMachineName ( )
817{ 817{
818 return mMyMachineName->text(); 818 return mMyMachineName->text();
819} 819}
820 820
821QStringList KSyncPrefsDialog::getSyncProfileNames() 821QStringList KSyncPrefsDialog::getSyncProfileNames()
822{ 822{
823 return mSyncProfileNames; 823 return mSyncProfileNames;
824} 824}
825void KSyncPrefsDialog::usrReadConfig() 825void KSyncPrefsDialog::usrReadConfig()
826{ 826{
827 //KConfig *config = KOGlobals::config(); 827 //KConfig *config = KOGlobals::config();
828 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 828 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
829 config.setGroup("General"); 829 config.setGroup("General");
830 mSyncProfileNames =config.readListEntry("SyncProfileNames"); 830 mSyncProfileNames =config.readListEntry("SyncProfileNames");
831 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined")); 831 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined"));
832 int i; 832 int i;
833 KSyncProfile* temp ; 833 KSyncProfile* temp ;
834 mSyncProfiles.clear(); 834 mSyncProfiles.clear();
835 for ( i = 0; i < mSyncProfileNames.count();++i ) { 835 for ( i = 0; i < mSyncProfileNames.count();++i ) {
836 temp = new KSyncProfile (); 836 temp = new KSyncProfile ();
837 temp->setName( mSyncProfileNames[i] ); 837 temp->setName( mSyncProfileNames[i] );
838 temp->readConfig( &config ); 838 temp->readConfig( &config );
839 mSyncProfiles.append( temp ); 839 mSyncProfiles.append( temp );
840 } 840 }
841 insertProfiles(); 841 insertProfiles();
842 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); 842 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName );
843} 843}
844 844
845 845
846void KSyncPrefsDialog::usrWriteConfig() 846void KSyncPrefsDialog::usrWriteConfig()
847{ 847{
848 saveProfile(); 848 saveProfile();
849 if ( currentSelection >= 0 ) 849 if ( currentSelection >= 0 )
850 profileChanged(currentSelection); 850 profileChanged(currentSelection);
851 //KConfig *config = KOGlobals::config(); 851 //KConfig *config = KOGlobals::config();
852 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 852 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
853 KSyncProfile* prof = mSyncProfiles.first(); 853 KSyncProfile* prof = mSyncProfiles.first();
854 QStringList externalSyncProfileNames; 854 QStringList externalSyncProfileNames;
855 externalSyncProfileNames.append("Sharp_DTM");; 855 externalSyncProfileNames.append("Sharp_DTM");;
856 while ( prof ) { 856 while ( prof ) {
857 prof->writeConfig(&config); 857 prof->writeConfig(&config);
858 if ( prof->getIsPhoneSync( ) ) 858 if ( prof->getIsPhoneSync( ) )
859 externalSyncProfileNames.append(prof->getName( ) ); 859 externalSyncProfileNames.append(prof->getName( ) );
860 prof = mSyncProfiles.next(); 860 prof = mSyncProfiles.next();
861 } 861 }
862 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; 862 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames;
863 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); 863 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text();
864 config.setGroup("General"); 864 config.setGroup("General");
865 config.writeEntry("SyncProfileNames",mSyncProfileNames); 865 config.writeEntry("SyncProfileNames",mSyncProfileNames);
866 config.writeEntry("ExternSyncProfiles",externalSyncProfileNames); 866 config.writeEntry("ExternSyncProfiles",externalSyncProfileNames);
867 config.writeEntry("LocalMachineName",mMyMachineName->text()); 867 config.writeEntry("LocalMachineName",mMyMachineName->text());
868 config.sync(); 868 config.sync();
869} 869}
870 870
871void KSyncPrefsDialog::helpDevice() 871void KSyncPrefsDialog::helpDevice()
872{ 872{
873 QString hint = i18n("Insert device where\nphone is connected. E.g.:\n"); 873 QString hint = i18n("Insert device where\nphone is connected. E.g.:\n");
874#ifdef _WIN32_ 874#ifdef _WIN32_
875 hint += "Leave empty for Irda.\n" 875 hint += "Leave empty for Irda.\n"
876 "com1:\n(first serial port)\n" 876 "com1:\n(first serial port)\n"
877 "usb not supported\n" 877 "usb not supported\n"
878 "???\n(bluetooth device address)\n"; 878 "???\n(bluetooth device address)\n";
879 879
880#else 880#else
881 hint += "/dev/ircomm\n(Irda)\n" 881 hint += "/dev/ircomm\n(Irda)\n"
882 "/dev/ttyS0\n(first serial port)\n" 882 "/dev/ttyS0\n(first serial port)\n"
883 "/dev/ttyUSB0\n(first device usb port)\n" 883 "/dev/ttyUSB0\n(first device usb port)\n"
884 "???\n(bluetooth device address)\n"; 884 "???\n(bluetooth device address)\n";
885#endif 885#endif
886 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 886 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
887} 887}
888void KSyncPrefsDialog::helpModel() 888void KSyncPrefsDialog::helpModel()
889{ 889{
890 QString hint = i18n("Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n"); 890 QString hint = i18n("Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n");
891 hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection"; 891 hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection";
892 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 892 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
893 893
894} 894}
895void KSyncPrefsDialog::helpConnection() 895void KSyncPrefsDialog::helpConnection()
896{ 896{
897 QString hint = i18n("Insert kind of connection,e.g.:\n"); 897 QString hint = i18n("Insert kind of connection,e.g.:\n");
898 hint += "irda | Nokia FBUS over infrared\n" 898 hint += "irda | Nokia FBUS over infrared\n"
899 "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n" 899 "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n"
900 "irdaobex | set also model as obex\n" 900 "irdaobex | set also model as obex\n"
901 "fbus | Nokia FBUS2 serial\n"; 901 "fbus | Nokia FBUS2 serial\n";
902 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 902 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
903} 903}