summaryrefslogtreecommitdiffabout
path: root/libkdepim
Unidiff
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/kpimprefs.cpp9
-rw-r--r--libkdepim/kpimprefs.h3
-rw-r--r--libkdepim/ksyncmanager.cpp166
-rw-r--r--libkdepim/ksyncmanager.h3
4 files changed, 103 insertions, 78 deletions
diff --git a/libkdepim/kpimprefs.cpp b/libkdepim/kpimprefs.cpp
index 0a2f5f1..c21ebaa 100644
--- a/libkdepim/kpimprefs.cpp
+++ b/libkdepim/kpimprefs.cpp
@@ -17,51 +17,58 @@
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/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <kglobal.h> 31#include <kglobal.h>
32#include <kconfig.h> 32#include <kconfig.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <kdebug.h> 34#include <kdebug.h>
35 35
36#include "kpimprefs.h" 36#include "kpimprefs.h"
37 37
38KPimPrefs::KPimPrefs( const QString &name ) : 38KPimPrefs::KPimPrefs( const QString &name ) :
39 KPrefs( name ) 39 KPrefs( name )
40{ 40{
41 config()->setGroup("General"); 41#ifdef _WIN32_
42 QString hdp= locateLocal("data","korganizer")+"\\\\";
43#else
44 QString hdp= locateLocal("data","korganizer")+"/";
45#endif
46 config()->setGroup("SyncOptions");
42 addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); 47 addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" );
43 addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" ); 48 addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" );
49 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" );
50 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3);
44} 51}
45 52
46KPimPrefs::~KPimPrefs() 53KPimPrefs::~KPimPrefs()
47{ 54{
48} 55}
49 56
50void KPimPrefs::usrSetDefaults() 57void KPimPrefs::usrSetDefaults()
51{ 58{
52 setCategoryDefaults(); 59 setCategoryDefaults();
53} 60}
54 61
55void KPimPrefs::usrReadConfig() 62void KPimPrefs::usrReadConfig()
56{ 63{
57 kdDebug(5300) << "KPimPrefs::usrReadConfig()" << endl; 64 kdDebug(5300) << "KPimPrefs::usrReadConfig()" << endl;
58 65
59 config()->setGroup("General"); 66 config()->setGroup("General");
60 mCustomCategories = config()->readListEntry("Custom Categories"); 67 mCustomCategories = config()->readListEntry("Custom Categories");
61 if (mCustomCategories.isEmpty()) setCategoryDefaults(); 68 if (mCustomCategories.isEmpty()) setCategoryDefaults();
62} 69}
63 70
64 71
65void KPimPrefs::usrWriteConfig() 72void KPimPrefs::usrWriteConfig()
66{ 73{
67 config()->setGroup("General"); 74 config()->setGroup("General");
diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h
index fde8093..9346f7d 100644
--- a/libkdepim/kpimprefs.h
+++ b/libkdepim/kpimprefs.h
@@ -36,35 +36,36 @@ $Id$
36#include "kprefs.h" 36#include "kprefs.h"
37 37
38class KPimPrefs : public KPrefs 38class KPimPrefs : public KPrefs
39{ 39{
40 public: 40 public:
41 41
42 KPimPrefs( const QString &name = QString::null ); 42 KPimPrefs( const QString &name = QString::null );
43 43
44 virtual ~KPimPrefs(); 44 virtual ~KPimPrefs();
45 45
46 /** Set preferences to default values */ 46 /** Set preferences to default values */
47 void usrSetDefaults(); 47 void usrSetDefaults();
48 48
49 /** Read preferences from config file */ 49 /** Read preferences from config file */
50 void usrReadConfig(); 50 void usrReadConfig();
51 51
52 /** Write preferences to config file */ 52 /** Write preferences to config file */
53 void usrWriteConfig(); 53 void usrWriteConfig();
54 54
55 55
56 public: 56 public:
57 QStringList mCustomCategories; 57 QStringList mCustomCategories;
58 QString mPassiveSyncPort; 58 QString mPassiveSyncPort;
59 QString mPassiveSyncPw; 59 QString mPassiveSyncPw;
60 60 int mRingSyncAlgoPrefs;
61 QString mLastSyncedLocalFile;
61 62
62 63
63 protected: 64 protected:
64 virtual void setCategoryDefaults(); 65 virtual void setCategoryDefaults();
65 66
66 67
67 68
68}; 69};
69 70
70#endif 71#endif
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index fad9a76..568c2a9 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -55,100 +55,104 @@
55#include <kfiledialog.h> 55#include <kfiledialog.h>
56 56
57KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 57KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
58 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) 58 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu)
59{ 59{
60 mServerSocket = 0; 60 mServerSocket = 0;
61 bar = new QProgressBar ( 1, 0 ); 61 bar = new QProgressBar ( 1, 0 );
62 bar->setCaption (""); 62 bar->setCaption ("");
63 63
64 int w = 300; 64 int w = 300;
65 if ( QApplication::desktop()->width() < 320 ) 65 if ( QApplication::desktop()->width() < 320 )
66 w = 220; 66 w = 220;
67 int h = bar->sizeHint().height() ; 67 int h = bar->sizeHint().height() ;
68 int dw = QApplication::desktop()->width(); 68 int dw = QApplication::desktop()->width();
69 int dh = QApplication::desktop()->height(); 69 int dh = QApplication::desktop()->height();
70 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 70 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
71 71
72} 72}
73 73
74KSyncManager::~KSyncManager() 74KSyncManager::~KSyncManager()
75{ 75{
76 delete bar; 76 delete bar;
77} 77}
78 78
79//LR ok 79
80void KSyncManager::fillSyncMenu() 80void KSyncManager::fillSyncMenu()
81{ 81{
82 if ( mSyncMenu->count() ) 82 if ( mSyncMenu->count() )
83 mSyncMenu->clear(); 83 mSyncMenu->clear();
84 84
85 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 85 mSyncMenu->insertItem( i18n("Configure..."), 0 );
86 mSyncMenu->insertSeparator(); 86 mSyncMenu->insertSeparator();
87 if ( mServerSocket == 0 ) { 87 if ( mServerSocket == 0 ) {
88 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 88 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
89 } else { 89 } else {
90 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 90 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
91 } 91 }
92 mSyncMenu->insertSeparator(); 92 mSyncMenu->insertSeparator();
93 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 93 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
94 mSyncMenu->insertSeparator(); 94 mSyncMenu->insertSeparator();
95 95
96 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 96 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
97 config.setGroup("General"); 97 config.setGroup("General");
98 QStringList prof = config.readListEntry("SyncProfileNames"); 98 QStringList prof = config.readListEntry("SyncProfileNames");
99 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 99 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
100 if ( prof.count() < 2 ) { 100 if ( prof.count() < 2 ) {
101 prof.clear(); 101 prof.clear();
102 prof << i18n("Sharp_DTM"); 102 prof << i18n("Sharp_DTM");
103 prof << i18n("Local_file"); 103 prof << i18n("Local_file");
104 prof << i18n("Last_file");
104 KSyncProfile* temp = new KSyncProfile (); 105 KSyncProfile* temp = new KSyncProfile ();
105 temp->setName( prof[0] ); 106 temp->setName( prof[0] );
106 temp->writeConfig(&config); 107 temp->writeConfig(&config);
107 temp->setName( prof[1] ); 108 temp->setName( prof[1] );
108 temp->writeConfig(&config); 109 temp->writeConfig(&config);
110 temp->setName( prof[2] );
111 temp->writeConfig(&config);
109 config.setGroup("General"); 112 config.setGroup("General");
110 config.writeEntry("SyncProfileNames",prof); 113 config.writeEntry("SyncProfileNames",prof);
111 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 114 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
112 config.sync(); 115 config.sync();
113 delete temp; 116 delete temp;
114 } 117 }
115 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 118 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
116 mSyncProfileNames = prof; 119 mSyncProfileNames = prof;
117 unsigned int i; 120 unsigned int i;
118 for ( i = 0; i < prof.count(); ++i ) { 121 for ( i = 0; i < prof.count(); ++i ) {
119 mSyncMenu->insertItem( prof[i], 1000+i ); 122 mSyncMenu->insertItem( prof[i], 1000+i );
120 if ( i == 2 ) 123 if ( i == 2 )
121 mSyncMenu->insertSeparator(); 124 mSyncMenu->insertSeparator();
122 } 125 }
123 QDir app_dir; 126 QDir app_dir;
124 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 127 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
125 if ( mTargetApp == PWMPI) { 128 if ( mTargetApp == PWMPI) {
126 mSyncMenu->removeItem( 1000 ); 129 mSyncMenu->removeItem( 1000 );
127 } 130 }
128 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 131 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
129 mSyncMenu->setItemEnabled( 1000, false ); 132 mSyncMenu->removeItem( 1000 );
130 } 133 }
134 mSyncMenu->removeItem( 1002 );
131} 135}
132 136
133void KSyncManager::slotSyncMenu( int action ) 137void KSyncManager::slotSyncMenu( int action )
134{ 138{
135 //qDebug("syncaction %d ", action); 139 //qDebug("syncaction %d ", action);
136 if ( action == 0 ) { 140 if ( action == 0 ) {
137 141
138 // seems to be a Qt2 event handling bug 142 // seems to be a Qt2 event handling bug
139 // syncmenu.clear causes a segfault at first time 143 // syncmenu.clear causes a segfault at first time
140 // when we call it after the main event loop, it is ok 144 // when we call it after the main event loop, it is ok
141 // same behaviour when calling OM/Pi via QCOP for the first time 145 // same behaviour when calling OM/Pi via QCOP for the first time
142 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 146 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
143 //confSync(); 147 //confSync();
144 148
145 return; 149 return;
146 } 150 }
147 if ( action == 1 ) { 151 if ( action == 1 ) {
148 multiSync( true ); 152 multiSync( true );
149 return; 153 return;
150 } 154 }
151 if ( action == 2 ) { 155 if ( action == 2 ) {
152 enableQuick(); 156 enableQuick();
153 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 157 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
154 return; 158 return;
@@ -170,329 +174,348 @@ void KSyncManager::slotSyncMenu( int action )
170 mCurrentSyncName = mLocalMachineName ; 174 mCurrentSyncName = mLocalMachineName ;
171 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 175 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
172 KSyncProfile* temp = new KSyncProfile (); 176 KSyncProfile* temp = new KSyncProfile ();
173 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 177 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
174 temp->readConfig(&config); 178 temp->readConfig(&config);
175 mAskForPreferences = temp->getAskForPreferences(); 179 mAskForPreferences = temp->getAskForPreferences();
176 mSyncAlgoPrefs = temp->getSyncPrefs(); 180 mSyncAlgoPrefs = temp->getSyncPrefs();
177 mWriteBackFile = temp->getWriteBackFile(); 181 mWriteBackFile = temp->getWriteBackFile();
178 mWriteBackExistingOnly = temp->getWriteBackExisting(); 182 mWriteBackExistingOnly = temp->getWriteBackExisting();
179 mWriteBackInFuture = 0; 183 mWriteBackInFuture = 0;
180 if ( temp->getWriteBackFuture() ) 184 if ( temp->getWriteBackFuture() )
181 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 185 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
182 mShowSyncSummary = temp->getShowSummaryAfterSync(); 186 mShowSyncSummary = temp->getShowSummaryAfterSync();
183 if ( action == 1000 ) { 187 if ( action == 1000 ) {
184 syncSharp(); 188 syncSharp();
185 189
186 } else if ( action == 1001 ) { 190 } else if ( action == 1001 ) {
187 syncLocalFile(); 191 syncLocalFile();
188 192
189 } else if ( action == 1002 ) { 193 } else if ( action == 1002 ) {
190 quickSyncLocalFile(); 194 quickSyncLocalFile();
191 195
192 } else if ( action >= 1003 ) { 196 } else if ( action >= 1003 ) {
193 if ( temp->getIsLocalFileSync() ) { 197 if ( temp->getIsLocalFileSync() ) {
194 switch(mTargetApp) 198 switch(mTargetApp)
195 { 199 {
196 case (KAPI): 200 case (KAPI):
197 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 201 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
198 mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 202 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
199 break; 203 break;
200 case (KOPI): 204 case (KOPI):
201 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 205 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
202 mLastSyncedLocalFile = temp->getRemoteFileName(); 206 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
203 break; 207 break;
204 case (PWMPI): 208 case (PWMPI):
205 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 209 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
206 mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 210 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
207 break; 211 break;
208 default: 212 default:
209 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 213 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
210 break; 214 break;
211 215
212 } 216 }
213 } else { 217 } else {
214 if ( temp->getIsPhoneSync() ) { 218 if ( temp->getIsPhoneSync() ) {
215 mPhoneDevice = temp->getPhoneDevice( ) ; 219 mPhoneDevice = temp->getPhoneDevice( ) ;
216 mPhoneConnection = temp->getPhoneConnection( ); 220 mPhoneConnection = temp->getPhoneConnection( );
217 mPhoneModel = temp->getPhoneModel( ); 221 mPhoneModel = temp->getPhoneModel( );
218 syncPhone(); 222 syncPhone();
219 } else if ( temp->getIsPiSync() ) { 223 } else if ( temp->getIsPiSync() ) {
220 if ( mTargetApp == KAPI ) { 224 if ( mTargetApp == KAPI ) {
221 mPassWordPiSync = temp->getRemotePwAB(); 225 mPassWordPiSync = temp->getRemotePwAB();
222 mActiveSyncPort = temp->getRemotePortAB(); 226 mActiveSyncPort = temp->getRemotePortAB();
223 mActiveSyncIP = temp->getRemoteIPAB(); 227 mActiveSyncIP = temp->getRemoteIPAB();
224 } else if ( mTargetApp == KOPI ) { 228 } else if ( mTargetApp == KOPI ) {
225 mPassWordPiSync = temp->getRemotePw(); 229 mPassWordPiSync = temp->getRemotePw();
226 mActiveSyncPort = temp->getRemotePort(); 230 mActiveSyncPort = temp->getRemotePort();
227 mActiveSyncIP = temp->getRemoteIP(); 231 mActiveSyncIP = temp->getRemoteIP();
228 } else { 232 } else {
229 mPassWordPiSync = temp->getRemotePwPWM(); 233 mPassWordPiSync = temp->getRemotePwPWM();
230 mActiveSyncPort = temp->getRemotePortPWM(); 234 mActiveSyncPort = temp->getRemotePortPWM();
231 mActiveSyncIP = temp->getRemoteIPPWM(); 235 mActiveSyncIP = temp->getRemoteIPPWM();
232 } 236 }
233 syncPi(); 237 syncPi();
234 } else 238 } else
235 syncRemote( temp ); 239 syncRemote( temp );
236 240
237 } 241 }
238 } 242 }
239 delete temp; 243 delete temp;
240 setBlockSave(false); 244 setBlockSave(false);
241} 245}
246
242void KSyncManager::enableQuick() 247void KSyncManager::enableQuick()
243{ 248{
244 QDialog dia ( 0, "input-dialog", true ); 249 QDialog dia ( 0, "input-dialog", true );
245 QLineEdit lab ( &dia ); 250 QLineEdit lab ( &dia );
246 QVBoxLayout lay( &dia ); 251 QVBoxLayout lay( &dia );
247 lab.setText( mPrefs->mPassiveSyncPort ); 252 lab.setText( mPrefs->mPassiveSyncPort );
248 lay.setMargin(7); 253 lay.setMargin(7);
249 lay.setSpacing(7); 254 lay.setSpacing(7);
250 int po = 9197+mTargetApp; 255 int po = 9197+mTargetApp;
251 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 256 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
252 lay.addWidget( &label); 257 lay.addWidget( &label);
253 lay.addWidget( &lab); 258 lay.addWidget( &lab);
254 259
255 QLineEdit lepw ( &dia ); 260 QLineEdit lepw ( &dia );
256 lepw.setText( mPrefs->mPassiveSyncPw ); 261 lepw.setText( mPrefs->mPassiveSyncPw );
257 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 262 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
258 lay.addWidget( &label2); 263 lay.addWidget( &label2);
259 lay.addWidget( &lepw); 264 lay.addWidget( &lepw);
260 dia.setFixedSize( 230,80 ); 265 dia.setFixedSize( 230,80 );
261 dia.setCaption( i18n("Enter port for Pi-Sync") ); 266 dia.setCaption( i18n("Enter port for Pi-Sync") );
262 QPushButton pb ( "OK", &dia); 267 QPushButton pb ( "OK", &dia);
263 lay.addWidget( &pb ); 268 lay.addWidget( &pb );
264 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 269 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
265 dia.show(); 270 dia.show();
266 if ( ! dia.exec() ) 271 if ( ! dia.exec() )
267 return; 272 return;
268 dia.hide(); 273 dia.hide();
269 qApp->processEvents(); 274 qApp->processEvents();
270 mPrefs->mPassiveSyncPw = lepw.text(); 275 mPrefs->mPassiveSyncPw = lepw.text();
271 mPrefs->mPassiveSyncPort = lab.text(); 276 mPrefs->mPassiveSyncPort = lab.text();
272 bool ok; 277 bool ok;
273 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 278 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
274 if ( ! ok ) { 279 if ( ! ok ) {
275 KMessageBox::information( 0, i18n("No valid port")); 280 KMessageBox::information( 0, i18n("No valid port"));
276 return; 281 return;
277 } 282 }
278 //qDebug("port %d ", port); 283 //qDebug("port %d ", port);
279 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 284 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
280 mServerSocket->setFileName( defaultFileName() ); 285 mServerSocket->setFileName( defaultFileName() );
281 //qDebug("connected "); 286 //qDebug("connected ");
282 if ( !mServerSocket->ok() ) { 287 if ( !mServerSocket->ok() ) {
283 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 288 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
284 delete mServerSocket; 289 delete mServerSocket;
285 mServerSocket = 0; 290 mServerSocket = 0;
286 return; 291 return;
287 } 292 }
288 //connect( mServerSocket, SIGNAL ( saveFile() ),this, SIGNAL ( save() ) );
289 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 293 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
290 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 294 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
291} 295}
292 296
293void KSyncManager::syncLocalFile() 297void KSyncManager::syncLocalFile()
294{ 298{
295 299
296 QString fn =mLastSyncedLocalFile; 300 QString fn =mPrefs->mLastSyncedLocalFile;
297 QString ext; 301 QString ext;
298 302
299 switch(mTargetApp) 303 switch(mTargetApp)
300 { 304 {
301 case (KAPI): 305 case (KAPI):
302 ext = "(*.vcf)"; 306 ext = "(*.vcf)";
303 break; 307 break;
304 case (KOPI): 308 case (KOPI):
305 ext = "(*.ics/*.vcs)"; 309 ext = "(*.ics/*.vcs)";
306 break; 310 break;
307 case (PWMPI): 311 case (PWMPI):
308 ext = "(*.pwm)"; 312 ext = "(*.pwm)";
309 break; 313 break;
310 default: 314 default:
311 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 315 qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
312 break; 316 break;
313 317
314 } 318 }
315 319
316 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 320 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
317 if ( fn == "" ) 321 if ( fn == "" )
318 return; 322 return;
319 if ( syncWithFile( fn, false ) ) { 323 if ( syncWithFile( fn, false ) ) {
320 qDebug("syncLocalFile() successful "); 324 qDebug("syncLocalFile() successful ");
321 } 325 }
322 326
323} 327}
328
324bool KSyncManager::syncWithFile( QString fn , bool quick ) 329bool KSyncManager::syncWithFile( QString fn , bool quick )
325{ 330{
326 bool ret = false; 331 bool ret = false;
327 QFileInfo info; 332 QFileInfo info;
328 info.setFile( fn ); 333 info.setFile( fn );
329 QString mess; 334 QString mess;
330 bool loadbup = true; 335 bool loadbup = true;
331 if ( !info. exists() ) { 336 if ( !info. exists() ) {
332 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 337 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
333 int result = QMessageBox::warning( mParent, i18n("Warning!"), 338 int result = QMessageBox::warning( mParent, i18n("Warning!"),
334 mess ); 339 mess );
335 return ret; 340 return ret;
336 } 341 }
337 int result = 0; 342 int result = 0;
338 if ( !quick ) { 343 if ( !quick ) {
339 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 344 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
340 result = QMessageBox::warning( mParent, i18n("Warning!"), 345 result = QMessageBox::warning( mParent, i18n("Warning!"),
341 mess, 346 mess,
342 i18n("Sync"), i18n("Cancel"), 0, 347 i18n("Sync"), i18n("Cancel"), 0,
343 0, 1 ); 348 0, 1 );
344 if ( result ) 349 if ( result )
345 return false; 350 return false;
346 } 351 }
347 if ( mAskForPreferences ) 352 if ( mAskForPreferences )
348 edit_sync_options(); 353 edit_sync_options();
349 if ( result == 0 ) { 354 if ( result == 0 ) {
350 //qDebug("Now sycing ... "); 355 //qDebug("Now sycing ... ");
351 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 356 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
352 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 357 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
353 else 358 else
354 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 359 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
355 if ( ! quick ) 360 if ( ! quick )
356 mLastSyncedLocalFile = fn; 361 mPrefs->mLastSyncedLocalFile = fn;
357 } 362 }
358 return ret; 363 return ret;
359} 364}
365
360void KSyncManager::quickSyncLocalFile() 366void KSyncManager::quickSyncLocalFile()
361{ 367{
362 368
363 if ( syncWithFile( mLastSyncedLocalFile, false ) ) { 369 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, false ) ) {
364 qDebug("quick syncLocalFile() successful "); 370 qDebug("quick syncLocalFile() successful ");
365 371
366 } 372 }
367} 373}
374
368void KSyncManager::multiSync( bool askforPrefs ) 375void KSyncManager::multiSync( bool askforPrefs )
369{ 376{
370 if (blockSave()) 377 if (blockSave())
371 return; 378 return;
372 setBlockSave(true); 379 setBlockSave(true);
373 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 380 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
374 if ( QMessageBox::information( mParent, i18n("Sync"), 381 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
375 question, 382 question,
376 i18n("Yes"), i18n("No"), 383 i18n("Yes"), i18n("No"),
377 0, 0 ) != 0 ) { 384 0, 0 ) != 0 ) {
378 setBlockSave(false); 385 setBlockSave(false);
379 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 386 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
380 return; 387 return;
381 } 388 }
382 mCurrentSyncDevice = i18n("Multiple profiles") ; 389 mCurrentSyncDevice = i18n("Multiple profiles") ;
383 mSyncAlgoPrefs = mRingSyncAlgoPrefs; 390 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
384 if ( askforPrefs ) { 391 if ( askforPrefs ) {
385 edit_sync_options(); 392 edit_sync_options();
386 mRingSyncAlgoPrefs = mSyncAlgoPrefs; 393 mRingSyncAlgoPrefs = mSyncAlgoPrefs;
387 } 394 }
388 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 395 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
389 qApp->processEvents(); 396 qApp->processEvents();
390 int num = ringSync() ; 397 int num = ringSync() ;
391 if ( num > 1 ) 398 if ( num > 1 )
392 ringSync(); 399 ringSync();
393 setBlockSave(false); 400 setBlockSave(false);
394 if ( num ) 401 if ( num )
395 emit save(); 402 emit save();
396 if ( num ) 403 if ( num )
397 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 404 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
398 else 405 else
399 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 406 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
400 return; 407 return;
401} 408}
409
402int KSyncManager::ringSync() 410int KSyncManager::ringSync()
403{ 411{
404 int syncedProfiles = 0; 412 int syncedProfiles = 0;
405 unsigned int i; 413 unsigned int i;
406 QTime timer; 414 QTime timer;
407 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 415 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
408 QStringList syncProfileNames = mSyncProfileNames; 416 QStringList syncProfileNames = mSyncProfileNames;
409 KSyncProfile* temp = new KSyncProfile (); 417 KSyncProfile* temp = new KSyncProfile ();
410 mAskForPreferences = false; 418 mAskForPreferences = false;
411 for ( i = 0; i < syncProfileNames.count(); ++i ) { 419 for ( i = 0; i < syncProfileNames.count(); ++i ) {
412 mCurrentSyncProfile = i; 420 mCurrentSyncProfile = i;
413 temp->setName(syncProfileNames[mCurrentSyncProfile]); 421 temp->setName(syncProfileNames[mCurrentSyncProfile]);
414 temp->readConfig(&config); 422 temp->readConfig(&config);
415 423
416 QString includeInRingSync; 424 QString includeInRingSync;
417 switch(mTargetApp) 425 switch(mTargetApp)
418 { 426 {
419 case (KAPI): 427 case (KAPI):
420 includeInRingSync = temp->getIncludeInRingSyncAB(); 428 includeInRingSync = temp->getIncludeInRingSyncAB();
421 break; 429 break;
422 case (KOPI): 430 case (KOPI):
423 includeInRingSync = temp->getIncludeInRingSync(); 431 includeInRingSync = temp->getIncludeInRingSync();
424 break; 432 break;
425 case (PWMPI): 433 case (PWMPI):
426 includeInRingSync = temp->getIncludeInRingSyncPWM(); 434 includeInRingSync = temp->getIncludeInRingSyncPWM();
427 break; 435 break;
428 default: 436 default:
429 qDebug("KSyncManager::ringSync: invalid apptype selected"); 437 qDebug("KSyncManager::ringSync: invalid apptype selected");
430 break; 438 break;
431 439
432 } 440 }
433 441
434 442
435 if ( includeInRingSync && ( i < 1 || i > 2 )) { 443 if ( includeInRingSync && ( i < 1 || i > 2 )) {
436 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 444 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
437 ++syncedProfiles; 445 ++syncedProfiles;
438 // mAskForPreferences = temp->getAskForPreferences(); 446 // mAskForPreferences = temp->getAskForPreferences();
439 mWriteBackFile = temp->getWriteBackFile(); 447 mWriteBackFile = temp->getWriteBackFile();
440 mWriteBackExistingOnly = temp->getWriteBackExisting(); 448 mWriteBackExistingOnly = temp->getWriteBackExisting();
441 mWriteBackInFuture = 0; 449 mWriteBackInFuture = 0;
442 if ( temp->getWriteBackFuture() ) 450 if ( temp->getWriteBackFuture() )
443 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 451 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
444 mShowSyncSummary = false; 452 mShowSyncSummary = false;
445 mCurrentSyncDevice = syncProfileNames[i] ; 453 mCurrentSyncDevice = syncProfileNames[i] ;
446 mCurrentSyncName = mLocalMachineName; 454 mCurrentSyncName = mLocalMachineName;
447 if ( i == 0 ) { 455 if ( i == 0 ) {
448 syncSharp(); 456 syncSharp();
449 } else { 457 } else {
450 if ( temp->getIsLocalFileSync() ) { 458 if ( temp->getIsLocalFileSync() ) {
451 switch(mTargetApp) 459 switch(mTargetApp)
452 { 460 {
453 case (KAPI): 461 case (KAPI):
454 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 462 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
455 mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 463 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
456 break; 464 break;
457 case (KOPI): 465 case (KOPI):
458 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 466 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
459 mLastSyncedLocalFile = temp->getRemoteFileName(); 467 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
460 break; 468 break;
461 case (PWMPI): 469 case (PWMPI):
462 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 470 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
463 mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 471 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
464 break; 472 break;
465 default: 473 default:
466 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 474 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
467 break; 475 break;
468 } 476 }
469 } else { 477 } else {
470 if ( temp->getIsPhoneSync() ) { 478 if ( temp->getIsPhoneSync() ) {
471 mPhoneDevice = temp->getPhoneDevice( ) ; 479 mPhoneDevice = temp->getPhoneDevice( ) ;
472 mPhoneConnection = temp->getPhoneConnection( ); 480 mPhoneConnection = temp->getPhoneConnection( );
473 mPhoneModel = temp->getPhoneModel( ); 481 mPhoneModel = temp->getPhoneModel( );
474 syncPhone(); 482 syncPhone();
483 } else if ( temp->getIsPiSync() ) {
484 if ( mTargetApp == KAPI ) {
485 mPassWordPiSync = temp->getRemotePwAB();
486 mActiveSyncPort = temp->getRemotePortAB();
487 mActiveSyncIP = temp->getRemoteIPAB();
488 } else if ( mTargetApp == KOPI ) {
489 mPassWordPiSync = temp->getRemotePw();
490 mActiveSyncPort = temp->getRemotePort();
491 mActiveSyncIP = temp->getRemoteIP();
492 } else {
493 mPassWordPiSync = temp->getRemotePwPWM();
494 mActiveSyncPort = temp->getRemotePortPWM();
495 mActiveSyncIP = temp->getRemoteIPPWM();
496 }
497 syncPi();
475 } else 498 } else
476 syncRemote( temp, false ); 499 syncRemote( temp, false );
477 500
478 } 501 }
479 } 502 }
480 timer.start(); 503 timer.start();
481 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 504 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
482 while ( timer.elapsed () < 2000 ) { 505 while ( timer.elapsed () < 2000 ) {
483 qApp->processEvents(); 506 qApp->processEvents();
484#ifndef _WIN32_ 507#ifndef _WIN32_
485 sleep (1); 508 sleep (1);
486#endif 509#endif
487 } 510 }
488 511
489 } 512 }
490 513
491 } 514 }
492 delete temp; 515 delete temp;
493 return syncedProfiles; 516 return syncedProfiles;
494} 517}
495 518
496void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 519void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
497{ 520{
498 QString question; 521 QString question;
@@ -537,61 +560,56 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
537 QString pwd = getPassword(); 560 QString pwd = getPassword();
538 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 561 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
539 562
540 } 563 }
541 int maxlen = 30; 564 int maxlen = 30;
542 if ( QApplication::desktop()->width() > 320 ) 565 if ( QApplication::desktop()->width() > 320 )
543 maxlen += 25; 566 maxlen += 25;
544 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 567 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
545 int fileSize = 0; 568 int fileSize = 0;
546 int result = system ( preCommand ); 569 int result = system ( preCommand );
547 // 0 : okay 570 // 0 : okay
548 // 256: no such file or dir 571 // 256: no such file or dir
549 // 572 //
550 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 573 qDebug("KO: Remote copy result(0 = okay): %d ",result );
551 if ( result != 0 ) { 574 if ( result != 0 ) {
552 unsigned int len = maxlen; 575 unsigned int len = maxlen;
553 while ( len < preCommand.length() ) { 576 while ( len < preCommand.length() ) {
554 preCommand.insert( len , "\n" ); 577 preCommand.insert( len , "\n" );
555 len += maxlen +2; 578 len += maxlen +2;
556 } 579 }
557 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; 580 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ;
558 QMessageBox::information( mParent, i18n("Sync - ERROR"), 581 QMessageBox::information( mParent, i18n("Sync - ERROR"),
559 question, 582 question,
560 i18n("Okay!")) ; 583 i18n("Okay!")) ;
561 mParent->topLevelWidget()->setCaption (""); 584 mParent->topLevelWidget()->setCaption ("KDE-Pim");
562 return; 585 return;
563 } 586 }
564 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 587 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
565 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 588 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
566 589
567
568
569 if ( syncWithFile( localTempFile, true ) ) { 590 if ( syncWithFile( localTempFile, true ) ) {
570// Event* e = mView->getLastSyncEvent(); 591
571// e->setReadOnly( false );
572// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
573// e->setReadOnly( true );
574 if ( mWriteBackFile ) { 592 if ( mWriteBackFile ) {
575 int fi; 593 int fi;
576 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 594 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
577 QString pwd = getPassword(); 595 QString pwd = getPassword();
578 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 596 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
579 597
580 } 598 }
581 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 599 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
582 result = system ( postCommand ); 600 result = system ( postCommand );
583 qDebug("Writing back file result: %d ", result); 601 qDebug("Writing back file result: %d ", result);
584 if ( result != 0 ) { 602 if ( result != 0 ) {
585 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 603 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
586 return; 604 return;
587 } else { 605 } else {
588 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 606 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
589 } 607 }
590 } 608 }
591 } 609 }
592 return; 610 return;
593} 611}
594 612
595void KSyncManager::edit_sync_options() 613void KSyncManager::edit_sync_options()
596{ 614{
597 //mDialogManager->showSyncOptions(); 615 //mDialogManager->showSyncOptions();
@@ -623,120 +641,120 @@ void KSyncManager::edit_sync_options()
623 case 2: 641 case 2:
624 newest.setChecked( true); 642 newest.setChecked( true);
625 break; 643 break;
626 case 3: 644 case 3:
627 ask.setChecked( true); 645 ask.setChecked( true);
628 break; 646 break;
629 case 4: 647 case 4:
630 f_loc.setChecked( true); 648 f_loc.setChecked( true);
631 break; 649 break;
632 case 5: 650 case 5:
633 f_rem.setChecked( true); 651 f_rem.setChecked( true);
634 break; 652 break;
635 case 6: 653 case 6:
636 // both.setChecked( true); 654 // both.setChecked( true);
637 break; 655 break;
638 default: 656 default:
639 break; 657 break;
640 } 658 }
641 if ( dia.exec() ) { 659 if ( dia.exec() ) {
642 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 660 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
643 } 661 }
644 662
645 663
646} 664}
665
647QString KSyncManager::getPassword( ) 666QString KSyncManager::getPassword( )
648{ 667{
649 QString retfile = ""; 668 QString retfile = "";
650 QDialog dia ( mParent, "input-dialog", true ); 669 QDialog dia ( mParent, "input-dialog", true );
651 QLineEdit lab ( &dia ); 670 QLineEdit lab ( &dia );
652 lab.setEchoMode( QLineEdit::Password ); 671 lab.setEchoMode( QLineEdit::Password );
653 QVBoxLayout lay( &dia ); 672 QVBoxLayout lay( &dia );
654 lay.setMargin(7); 673 lay.setMargin(7);
655 lay.setSpacing(7); 674 lay.setSpacing(7);
656 lay.addWidget( &lab); 675 lay.addWidget( &lab);
657 dia.setFixedSize( 230,50 ); 676 dia.setFixedSize( 230,50 );
658 dia.setCaption( i18n("Enter password") ); 677 dia.setCaption( i18n("Enter password") );
659 QPushButton pb ( "OK", &dia); 678 QPushButton pb ( "OK", &dia);
660 lay.addWidget( &pb ); 679 lay.addWidget( &pb );
661 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 680 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
662 dia.show(); 681 dia.show();
663 int res = dia.exec(); 682 int res = dia.exec();
664 if ( res ) 683 if ( res )
665 retfile = lab.text(); 684 retfile = lab.text();
666 dia.hide(); 685 dia.hide();
667 qApp->processEvents(); 686 qApp->processEvents();
668 return retfile; 687 return retfile;
669 688
670} 689}
671 690
672 691
673void KSyncManager::confSync() 692void KSyncManager::confSync()
674{ 693{
675 static KSyncPrefsDialog* sp = 0; 694 static KSyncPrefsDialog* sp = 0;
676 if ( ! sp ) { 695 if ( ! sp ) {
677 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 696 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
678 } 697 }
679 sp->usrReadConfig(); 698 sp->usrReadConfig();
680#ifndef DESKTOP_VERSION 699#ifndef DESKTOP_VERSION
681 sp->showMaximized(); 700 sp->showMaximized();
682#else 701#else
683 sp->show(); 702 sp->show();
684#endif 703#endif
685 sp->exec(); 704 sp->exec();
686 mSyncProfileNames = sp->getSyncProfileNames(); 705 mSyncProfileNames = sp->getSyncProfileNames();
687 mLocalMachineName = sp->getLocalMachineName (); 706 mLocalMachineName = sp->getLocalMachineName ();
688 fillSyncMenu(); 707 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
689} 708}
690 709
691void KSyncManager::syncSharp() 710void KSyncManager::syncSharp()
692{ 711{
712
693 if ( ! syncExternalApplication("sharp") ) 713 if ( ! syncExternalApplication("sharp") )
694 qDebug("ERROR sync sharp ");; 714 qDebug("ERROR sync sharp ");;
695} 715}
696 716
697bool KSyncManager::syncExternalApplication(QString resource) 717bool KSyncManager::syncExternalApplication(QString resource)
698{ 718{
699 719
700 emit save(); 720 emit save();
701 721
702 if ( mAskForPreferences ) 722 if ( mAskForPreferences )
703 edit_sync_options(); 723 edit_sync_options();
704 724
705 qDebug("sync %s", resource.latin1()); 725 qDebug("sync %s", resource.latin1());
706 726
707 bool syncOK = mImplementation->syncExternal(this, resource); 727 bool syncOK = mImplementation->syncExternal(this, resource);
708 728
709 return syncOK; 729 return syncOK;
710 730
711} 731}
712 732
713void KSyncManager::syncPhone() 733void KSyncManager::syncPhone()
714{ 734{
715 emit save();
716 735
717 qDebug("pending syncPhone(); "); 736 syncExternalApplication("phone");
718 //mView->syncPhone();
719 737
720} 738}
721 739
722void KSyncManager::showProgressBar(int percentage, QString caption, int total) 740void KSyncManager::showProgressBar(int percentage, QString caption, int total)
723{ 741{
724 if (!bar->isVisible()) 742 if (!bar->isVisible())
725 { 743 {
726 bar->setCaption (caption); 744 bar->setCaption (caption);
727 bar->setTotalSteps ( total ) ; 745 bar->setTotalSteps ( total ) ;
728 746
729 bar->show(); 747 bar->show();
730 } 748 }
731 749
732 bar->setProgress( percentage ); 750 bar->setProgress( percentage );
733} 751}
734 752
735void KSyncManager::hideProgressBar() 753void KSyncManager::hideProgressBar()
736{ 754{
737 bar->hide(); 755 bar->hide();
738} 756}
739 757
740bool KSyncManager::isProgressBarCanceled() 758bool KSyncManager::isProgressBarCanceled()
741{ 759{
742 return !bar->isVisible(); 760 return !bar->isVisible();
@@ -746,48 +764,49 @@ QString KSyncManager::syncFileName()
746{ 764{
747 765
748 QString fn = "tempfile"; 766 QString fn = "tempfile";
749 switch(mTargetApp) 767 switch(mTargetApp)
750 { 768 {
751 case (KAPI): 769 case (KAPI):
752 fn = "tempsyncab.vcf"; 770 fn = "tempsyncab.vcf";
753 break; 771 break;
754 case (KOPI): 772 case (KOPI):
755 fn = "tempsynccal.ics"; 773 fn = "tempsynccal.ics";
756 break; 774 break;
757 case (PWMPI): 775 case (PWMPI):
758 fn = "tempsyncpw.pwm"; 776 fn = "tempsyncpw.pwm";
759 break; 777 break;
760 default: 778 default:
761 break; 779 break;
762 } 780 }
763#ifdef _WIN32_ 781#ifdef _WIN32_
764 return locateLocal( "tmp", fn ); 782 return locateLocal( "tmp", fn );
765#else 783#else
766 return (QString( "/tmp/" )+ fn ); 784 return (QString( "/tmp/" )+ fn );
767#endif 785#endif
768} 786}
769 787
788
770void KSyncManager::syncPi() 789void KSyncManager::syncPi()
771{ 790{
772 qApp->processEvents(); 791 qApp->processEvents();
773 bool ok; 792 bool ok;
774 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 793 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
775 if ( ! ok ) { 794 if ( ! ok ) {
776 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 795 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
777 return; 796 return;
778 } 797 }
779 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); 798 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this );
780 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 799 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
781 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); 800 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") );
782 commandSocket->readFile( syncFileName() ); 801 commandSocket->readFile( syncFileName() );
783} 802}
784 803
785void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 804void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
786{ 805{
787 qDebug("MainWindow::deleteCommandSocket %d", state); 806 qDebug("MainWindow::deleteCommandSocket %d", state);
788 807
789 //enum { success, errorW, errorR, quiet }; 808 //enum { success, errorW, errorR, quiet };
790 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { 809 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) {
791 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 810 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
792 delete s; 811 delete s;
793 if ( state == KCommandSocket::errorR ) { 812 if ( state == KCommandSocket::errorR ) {
@@ -1132,25 +1151,24 @@ void KCommandSocket::readFileFromSocket()
1132 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1151 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1133 if ( mSocket->state() == QSocket::Idle ) 1152 if ( mSocket->state() == QSocket::Idle )
1134 deleteSocket(); 1153 deleteSocket();
1135} 1154}
1136 1155
1137void KCommandSocket::deleteSocket() 1156void KCommandSocket::deleteSocket()
1138{ 1157{
1139 if ( mTimerSocket->isActive () ) { 1158 if ( mTimerSocket->isActive () ) {
1140 mTimerSocket->stop(); 1159 mTimerSocket->stop();
1141 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); 1160 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? "));
1142 mRetVal = errorTO; 1161 mRetVal = errorTO;
1143 if ( mSocket ) { 1162 if ( mSocket ) {
1144 mSocket->close(); 1163 mSocket->close();
1145 if ( mSocket->state() == QSocket::Idle ) 1164 if ( mSocket->state() == QSocket::Idle )
1146 deleteSocket(); 1165 deleteSocket();
1147 return; 1166 return;
1148 } 1167 }
1149 } 1168 }
1150 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 1169 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
1151 if ( mSocket) 1170 if ( mSocket)
1152 delete mSocket; 1171 delete mSocket;
1153 mSocket = 0; 1172 mSocket = 0;
1154 emit commandFinished( this, mRetVal ); 1173 emit commandFinished( this, mRetVal );
1155} 1174}
1156
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 25892d8..7027894 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -96,110 +96,109 @@ private slots:
96 QString mHost; 96 QString mHost;
97 QString mFileName; 97 QString mFileName;
98 QTimer* mTimerSocket; 98 QTimer* mTimerSocket;
99 int mRetVal; 99 int mRetVal;
100 QTime mTime; 100 QTime mTime;
101 QString mFileString; 101 QString mFileString;
102 bool mFirst; 102 bool mFirst;
103}; 103};
104 104
105 105
106class KSyncManager : public QObject 106class KSyncManager : public QObject
107{ 107{
108 Q_OBJECT 108 Q_OBJECT
109 109
110 public: 110 public:
111 enum TargetApp { 111 enum TargetApp {
112 KOPI = 0, 112 KOPI = 0,
113 KAPI = 1, 113 KAPI = 1,
114 PWMPI = 2 }; 114 PWMPI = 2 };
115 115
116 116
117 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 117 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
118 ~KSyncManager() ; 118 ~KSyncManager() ;
119 119
120 void multiSync( bool askforPrefs );
120 bool blockSave() { return mBlockSaveFlag; } 121 bool blockSave() { return mBlockSaveFlag; }
121 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 122 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
122 void setDefaultFileName( QString s) { mDefFileName = s ;} 123 void setDefaultFileName( QString s) { mDefFileName = s ;}
123 QString defaultFileName() { return mDefFileName ;} 124 QString defaultFileName() { return mDefFileName ;}
124 QString syncFileName(); 125 QString syncFileName();
125 void fillSyncMenu(); 126 void fillSyncMenu();
126 127
127 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 128 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
128 QString getCurrentSyncName() { return mCurrentSyncName; } 129 QString getCurrentSyncName() { return mCurrentSyncName; }
129 130
130 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 131 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
131 void hideProgressBar(); 132 void hideProgressBar();
132 bool isProgressBarCanceled(); 133 bool isProgressBarCanceled();
133 134
134 // sync stuff 135 // sync stuff
135 QString mLocalMachineName; 136 QString mLocalMachineName;
136 QStringList mExternSyncProfiles; 137 QStringList mExternSyncProfiles;
137 QStringList mSyncProfileNames; 138 QStringList mSyncProfileNames;
138 bool mAskForPreferences; 139 bool mAskForPreferences;
139 bool mShowSyncSummary; 140 bool mShowSyncSummary;
140 bool mShowSyncEvents; 141 bool mShowSyncEvents;
141 bool mShowTodoInAgenda; 142 bool mShowTodoInAgenda;
142 bool mWriteBackExistingOnly; 143 bool mWriteBackExistingOnly;
143 int mSyncAlgoPrefs; 144 int mSyncAlgoPrefs;
144 int mRingSyncAlgoPrefs; 145 int mRingSyncAlgoPrefs;
145 bool mWriteBackFile; 146 bool mWriteBackFile;
146 int mWriteBackInFuture; 147 int mWriteBackInFuture;
147 QString mPhoneDevice; 148 QString mPhoneDevice;
148 QString mPhoneConnection; 149 QString mPhoneConnection;
149 QString mPhoneModel; 150 QString mPhoneModel;
150 QString mLastSyncedLocalFile; // save!
151 QString mPassWordPiSync; 151 QString mPassWordPiSync;
152 QString mActiveSyncPort; 152 QString mActiveSyncPort;
153 QString mActiveSyncIP ; 153 QString mActiveSyncIP ;
154 154
155 signals: 155 signals:
156 void save(); 156 void save();
157 void request_file(); 157 void request_file();
158 void getFile( bool ); 158 void getFile( bool );
159 159
160 public slots: 160 public slots:
161 void slotSyncMenu( int ); 161 void slotSyncMenu( int );
162 void deleteCommandSocket(KCommandSocket*s, int state); 162 void deleteCommandSocket(KCommandSocket*s, int state);
163 void readFileFromSocket(); 163 void readFileFromSocket();
164 164
165 private: 165 private:
166 // LR ******************************* 166 // LR *******************************
167 // sync stuff! 167 // sync stuff!
168 void syncPi(); 168 void syncPi();
169 KServerSocket * mServerSocket; 169 KServerSocket * mServerSocket;
170 void enableQuick(); 170 void enableQuick();
171 KPimPrefs* mPrefs; 171 KPimPrefs* mPrefs;
172 QString mDefFileName; 172 QString mDefFileName;
173 QString mCurrentSyncDevice; 173 QString mCurrentSyncDevice;
174 QString mCurrentSyncName; 174 QString mCurrentSyncName;
175 void quickSyncLocalFile(); 175 void quickSyncLocalFile();
176 bool syncWithFile( QString fn , bool quick ); 176 bool syncWithFile( QString fn , bool quick );
177 void syncLocalFile(); 177 void syncLocalFile();
178 void syncPhone(); 178 void syncPhone();
179 void syncSharp(); 179 void syncSharp();
180 bool syncExternalApplication(QString); 180 bool syncExternalApplication(QString);
181 void multiSync( bool askforPrefs );
182 int mCurrentSyncProfile ; 181 int mCurrentSyncProfile ;
183 void syncRemote( KSyncProfile* prof, bool ask = true); 182 void syncRemote( KSyncProfile* prof, bool ask = true);
184 void edit_sync_options(); 183 void edit_sync_options();
185 int ringSync(); 184 int ringSync();
186 QString getPassword( ); 185 QString getPassword( );
187 186
188 private slots: 187 private slots:
189 void confSync(); 188 void confSync();
190 // ********************* 189 // *********************
191 190
192 private: 191 private:
193 bool mBlockSaveFlag; 192 bool mBlockSaveFlag;
194 193
195 194
196 QWidget* mParent; 195 QWidget* mParent;
197 KSyncInterface* mImplementation; 196 KSyncInterface* mImplementation;
198 TargetApp mTargetApp; 197 TargetApp mTargetApp;
199 QPopupMenu* mSyncMenu; 198 QPopupMenu* mSyncMenu;
200 199
201 QProgressBar* bar; 200 QProgressBar* bar;
202 201
203 202
204 203
205 204