-rw-r--r-- | libkdepim/ksyncmanager.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 33b4a65..6c1f444 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -63,716 +63,724 @@ KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, Targ | |||
63 | { | 63 | { |
64 | mServerSocket = 0; | 64 | mServerSocket = 0; |
65 | bar = new QProgressBar ( 1, 0 ); | 65 | bar = new QProgressBar ( 1, 0 ); |
66 | bar->setCaption (""); | 66 | bar->setCaption (""); |
67 | mWriteBackInPast = 2; | 67 | mWriteBackInPast = 2; |
68 | int w = 300; | 68 | int w = 300; |
69 | if ( QApplication::desktop()->width() < 320 ) | 69 | if ( QApplication::desktop()->width() < 320 ) |
70 | w = 220; | 70 | w = 220; |
71 | int h = bar->sizeHint().height() ; | 71 | int h = bar->sizeHint().height() ; |
72 | int dw = QApplication::desktop()->width(); | 72 | int dw = QApplication::desktop()->width(); |
73 | int dh = QApplication::desktop()->height(); | 73 | int dh = QApplication::desktop()->height(); |
74 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 74 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
75 | if ( mPrefs->mPassiveSyncAutoStart ) | 75 | if ( mPrefs->mPassiveSyncAutoStart ) |
76 | enableQuick( false ); | 76 | enableQuick( false ); |
77 | 77 | ||
78 | } | 78 | } |
79 | 79 | ||
80 | KSyncManager::~KSyncManager() | 80 | KSyncManager::~KSyncManager() |
81 | { | 81 | { |
82 | delete bar; | 82 | delete bar; |
83 | } | 83 | } |
84 | 84 | ||
85 | 85 | ||
86 | void KSyncManager::fillSyncMenu() | 86 | void KSyncManager::fillSyncMenu() |
87 | { | 87 | { |
88 | if ( mSyncMenu->count() ) | 88 | if ( mSyncMenu->count() ) |
89 | mSyncMenu->clear(); | 89 | mSyncMenu->clear(); |
90 | 90 | ||
91 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 91 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
92 | mSyncMenu->insertSeparator(); | 92 | mSyncMenu->insertSeparator(); |
93 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); | 93 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); |
94 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); | 94 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); |
95 | clearMenu->insertItem( i18n("For all profiles"), 1 ); | 95 | clearMenu->insertItem( i18n("For all profiles"), 1 ); |
96 | clearMenu->insertSeparator(); | 96 | clearMenu->insertSeparator(); |
97 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); | 97 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); |
98 | mSyncMenu->insertSeparator(); | 98 | mSyncMenu->insertSeparator(); |
99 | if ( mServerSocket == 0 ) { | 99 | if ( mServerSocket == 0 ) { |
100 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 100 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
101 | } else { | 101 | } else { |
102 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 102 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
103 | } | 103 | } |
104 | mSyncMenu->insertSeparator(); | 104 | mSyncMenu->insertSeparator(); |
105 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); | 105 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); |
106 | mSyncMenu->insertSeparator(); | 106 | mSyncMenu->insertSeparator(); |
107 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 107 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
108 | config.setGroup("General"); | 108 | config.setGroup("General"); |
109 | QStringList prof = config.readListEntry("SyncProfileNames"); | 109 | QStringList prof = config.readListEntry("SyncProfileNames"); |
110 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 110 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
111 | if ( prof.count() < 2 ) { | 111 | if ( prof.count() < 2 ) { |
112 | prof.clear(); | 112 | prof.clear(); |
113 | QString externalName; | 113 | QString externalName; |
114 | #ifdef DESKTOP_VERSION | 114 | #ifdef DESKTOP_VERSION |
115 | #ifdef _WIN32_ | 115 | #ifdef _WIN32_ |
116 | externalName = "OutLook(not_implemented)"; | 116 | externalName = "OutLook(not_implemented)"; |
117 | #else | 117 | #else |
118 | externalName = "KDE_Desktop"; | 118 | externalName = "KDE_Desktop"; |
119 | #endif | 119 | #endif |
120 | #else | 120 | #else |
121 | externalName = "Sharp_DTM"; | 121 | externalName = "Sharp_DTM"; |
122 | #endif | 122 | #endif |
123 | prof << externalName; | 123 | prof << externalName; |
124 | prof << i18n("Local_file"); | 124 | prof << i18n("Local_file"); |
125 | prof << i18n("Last_file"); | 125 | prof << i18n("Last_file"); |
126 | KSyncProfile* temp = new KSyncProfile (); | 126 | KSyncProfile* temp = new KSyncProfile (); |
127 | temp->setName( prof[0] ); | 127 | temp->setName( prof[0] ); |
128 | temp->writeConfig(&config); | 128 | temp->writeConfig(&config); |
129 | temp->setName( prof[1] ); | 129 | temp->setName( prof[1] ); |
130 | temp->writeConfig(&config); | 130 | temp->writeConfig(&config); |
131 | temp->setName( prof[2] ); | 131 | temp->setName( prof[2] ); |
132 | temp->writeConfig(&config); | 132 | temp->writeConfig(&config); |
133 | config.setGroup("General"); | 133 | config.setGroup("General"); |
134 | config.writeEntry("SyncProfileNames",prof); | 134 | config.writeEntry("SyncProfileNames",prof); |
135 | config.writeEntry("ExternSyncProfiles",externalName); | 135 | config.writeEntry("ExternSyncProfiles",externalName); |
136 | config.sync(); | 136 | config.sync(); |
137 | delete temp; | 137 | delete temp; |
138 | } | 138 | } |
139 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 139 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
140 | mSyncProfileNames = prof; | 140 | mSyncProfileNames = prof; |
141 | unsigned int i; | 141 | unsigned int i; |
142 | for ( i = 0; i < prof.count(); ++i ) { | 142 | for ( i = 0; i < prof.count(); ++i ) { |
143 | mSyncMenu->insertItem( prof[i], 1000+i ); | 143 | mSyncMenu->insertItem( prof[i], 1000+i ); |
144 | clearMenu->insertItem( prof[i], 1000+i ); | 144 | clearMenu->insertItem( prof[i], 1000+i ); |
145 | if ( i == 2 ) | 145 | if ( i == 2 ) |
146 | mSyncMenu->insertSeparator(); | 146 | mSyncMenu->insertSeparator(); |
147 | } | 147 | } |
148 | QDir app_dir; | 148 | QDir app_dir; |
149 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 149 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
150 | if ( mTargetApp == PWMPI) { | 150 | if ( mTargetApp == PWMPI) { |
151 | mSyncMenu->removeItem( 1000 ); | 151 | mSyncMenu->removeItem( 1000 ); |
152 | clearMenu->removeItem( 1000 ); | 152 | clearMenu->removeItem( 1000 ); |
153 | } | 153 | } |
154 | #ifndef DESKTOP_VERSION | 154 | #ifndef DESKTOP_VERSION |
155 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 155 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
156 | mSyncMenu->removeItem( 1000 ); | 156 | mSyncMenu->removeItem( 1000 ); |
157 | clearMenu->removeItem( 1000 ); | 157 | clearMenu->removeItem( 1000 ); |
158 | } | 158 | } |
159 | #endif | 159 | #endif |
160 | mSyncMenu->removeItem( 1002 ); | 160 | mSyncMenu->removeItem( 1002 ); |
161 | clearMenu->removeItem( 1002 ); | 161 | clearMenu->removeItem( 1002 ); |
162 | } | 162 | } |
163 | void KSyncManager::slotClearMenu( int action ) | 163 | void KSyncManager::slotClearMenu( int action ) |
164 | { | 164 | { |
165 | QString syncDevice; | 165 | QString syncDevice; |
166 | if ( action > 999 ) { | 166 | if ( action > 999 ) { |
167 | syncDevice = mSyncProfileNames[action - 1000] ; | 167 | syncDevice = mSyncProfileNames[action - 1000] ; |
168 | } | 168 | } |
169 | 169 | ||
170 | 170 | ||
171 | 171 | ||
172 | int result = 0; | 172 | int result = 0; |
173 | QString sd; | 173 | QString sd; |
174 | if ( syncDevice.isEmpty() ) | 174 | if ( syncDevice.isEmpty() ) |
175 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); | 175 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); |
176 | else | 176 | else |
177 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); | 177 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); |
178 | 178 | ||
179 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, | 179 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, |
180 | 0, 1 ); | 180 | 0, 1 ); |
181 | if ( result ) | 181 | if ( result ) |
182 | return; | 182 | return; |
183 | mImplementation->removeSyncInfo( syncDevice ); | 183 | mImplementation->removeSyncInfo( syncDevice ); |
184 | } | 184 | } |
185 | void KSyncManager::slotSyncMenu( int action ) | 185 | void KSyncManager::slotSyncMenu( int action ) |
186 | { | 186 | { |
187 | qDebug("syncaction %d ", action); | 187 | qDebug("syncaction %d ", action); |
188 | if ( action == 5000 ) | 188 | if ( action == 5000 ) |
189 | return; | 189 | return; |
190 | mSyncWithDesktop = false; | 190 | mSyncWithDesktop = false; |
191 | if ( action == 0 ) { | 191 | if ( action == 0 ) { |
192 | 192 | ||
193 | // seems to be a Qt2 event handling bug | 193 | // seems to be a Qt2 event handling bug |
194 | // syncmenu.clear causes a segfault at first time | 194 | // syncmenu.clear causes a segfault at first time |
195 | // when we call it after the main event loop, it is ok | 195 | // when we call it after the main event loop, it is ok |
196 | // same behaviour when calling OM/Pi via QCOP for the first time | 196 | // same behaviour when calling OM/Pi via QCOP for the first time |
197 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 197 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
198 | //confSync(); | 198 | //confSync(); |
199 | 199 | ||
200 | return; | 200 | return; |
201 | } | 201 | } |
202 | if ( action == 1 ) { | 202 | if ( action == 1 ) { |
203 | multiSync( true ); | 203 | multiSync( true ); |
204 | return; | 204 | return; |
205 | } | 205 | } |
206 | if ( action == 2 ) { | 206 | if ( action == 2 ) { |
207 | enableQuick(); | 207 | enableQuick(); |
208 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 208 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
209 | return; | 209 | return; |
210 | } | 210 | } |
211 | if ( action == 3 ) { | 211 | if ( action == 3 ) { |
212 | delete mServerSocket; | 212 | delete mServerSocket; |
213 | mServerSocket = 0; | 213 | mServerSocket = 0; |
214 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 214 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
215 | return; | 215 | return; |
216 | } | 216 | } |
217 | 217 | ||
218 | if (blockSave()) | 218 | if (blockSave()) |
219 | return; | 219 | return; |
220 | 220 | ||
221 | setBlockSave(true); | 221 | setBlockSave(true); |
222 | bool silent = false; | 222 | bool silent = false; |
223 | if ( action == 999 ) { | 223 | if ( action == 999 ) { |
224 | //special mode for silent syncing | 224 | //special mode for silent syncing |
225 | action = 1000; | 225 | action = 1000; |
226 | silent = true; | 226 | silent = true; |
227 | } | 227 | } |
228 | 228 | ||
229 | mCurrentSyncProfile = action - 1000 ; | 229 | mCurrentSyncProfile = action - 1000 ; |
230 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; | 230 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
231 | mCurrentSyncName = mLocalMachineName ; | 231 | mCurrentSyncName = mLocalMachineName ; |
232 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 232 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
233 | KSyncProfile* temp = new KSyncProfile (); | 233 | KSyncProfile* temp = new KSyncProfile (); |
234 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); | 234 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
235 | temp->readConfig(&config); | 235 | temp->readConfig(&config); |
236 | if (silent) { | 236 | if (silent) { |
237 | mAskForPreferences = false; | 237 | mAskForPreferences = false; |
238 | mShowSyncSummary = false; | 238 | mShowSyncSummary = false; |
239 | mWriteBackFile = true; | 239 | mWriteBackFile = true; |
240 | mSyncAlgoPrefs = 2;// take newest | 240 | mSyncAlgoPrefs = 2;// take newest |
241 | } | 241 | } |
242 | else { | 242 | else { |
243 | mAskForPreferences = temp->getAskForPreferences(); | 243 | mAskForPreferences = temp->getAskForPreferences(); |
244 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 244 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
245 | mWriteBackFile = temp->getWriteBackFile(); | 245 | mWriteBackFile = temp->getWriteBackFile(); |
246 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 246 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
247 | } | 247 | } |
248 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 248 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
249 | mIsKapiFile = temp->getIsKapiFile(); | 249 | mIsKapiFile = temp->getIsKapiFile(); |
250 | mWriteBackInFuture = 0; | 250 | mWriteBackInFuture = 0; |
251 | if ( temp->getWriteBackFuture() ) { | 251 | if ( temp->getWriteBackFuture() ) { |
252 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 252 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
253 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 253 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
254 | } | 254 | } |
255 | 255 | mFilterInCal = temp->getFilterInCal(); | |
256 | mFilterOutCal = temp->getFilterOutCal(); | ||
257 | mFilterInAB = temp->getFilterInAB(); | ||
258 | mFilterOutAB = temp->getFilterOutAB(); | ||
259 | |||
256 | if ( action == 1000 ) { | 260 | if ( action == 1000 ) { |
257 | mIsKapiFile = false; | 261 | mIsKapiFile = false; |
258 | #ifdef DESKTOP_VERSION | 262 | #ifdef DESKTOP_VERSION |
259 | syncKDE(); | 263 | syncKDE(); |
260 | #else | 264 | #else |
261 | syncSharp(); | 265 | syncSharp(); |
262 | #endif | 266 | #endif |
263 | 267 | ||
264 | } else if ( action == 1001 ) { | 268 | } else if ( action == 1001 ) { |
265 | syncLocalFile(); | 269 | syncLocalFile(); |
266 | 270 | ||
267 | } else if ( action == 1002 ) { | 271 | } else if ( action == 1002 ) { |
268 | mWriteBackFile = false; | 272 | mWriteBackFile = false; |
269 | mAskForPreferences = false; | 273 | mAskForPreferences = false; |
270 | mShowSyncSummary = false; | 274 | mShowSyncSummary = false; |
271 | mSyncAlgoPrefs = 3; | 275 | mSyncAlgoPrefs = 3; |
272 | quickSyncLocalFile(); | 276 | quickSyncLocalFile(); |
273 | 277 | ||
274 | } else if ( action >= 1003 ) { | 278 | } else if ( action >= 1003 ) { |
275 | if ( temp->getIsLocalFileSync() ) { | 279 | if ( temp->getIsLocalFileSync() ) { |
276 | switch(mTargetApp) | 280 | switch(mTargetApp) |
277 | { | 281 | { |
278 | case (KAPI): | 282 | case (KAPI): |
279 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 283 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
280 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 284 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
281 | break; | 285 | break; |
282 | case (KOPI): | 286 | case (KOPI): |
283 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 287 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
284 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 288 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
285 | break; | 289 | break; |
286 | case (PWMPI): | 290 | case (PWMPI): |
287 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 291 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
288 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 292 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
289 | break; | 293 | break; |
290 | default: | 294 | default: |
291 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 295 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
292 | break; | 296 | break; |
293 | 297 | ||
294 | } | 298 | } |
295 | } else { | 299 | } else { |
296 | if ( temp->getIsPhoneSync() ) { | 300 | if ( temp->getIsPhoneSync() ) { |
297 | mPhoneDevice = temp->getPhoneDevice( ) ; | 301 | mPhoneDevice = temp->getPhoneDevice( ) ; |
298 | mPhoneConnection = temp->getPhoneConnection( ); | 302 | mPhoneConnection = temp->getPhoneConnection( ); |
299 | mPhoneModel = temp->getPhoneModel( ); | 303 | mPhoneModel = temp->getPhoneModel( ); |
300 | syncPhone(); | 304 | syncPhone(); |
301 | } else if ( temp->getIsPiSync() ) { | 305 | } else if ( temp->getIsPiSync() ) { |
302 | if ( mTargetApp == KAPI ) { | 306 | if ( mTargetApp == KAPI ) { |
303 | mPassWordPiSync = temp->getRemotePwAB(); | 307 | mPassWordPiSync = temp->getRemotePwAB(); |
304 | mActiveSyncPort = temp->getRemotePortAB(); | 308 | mActiveSyncPort = temp->getRemotePortAB(); |
305 | mActiveSyncIP = temp->getRemoteIPAB(); | 309 | mActiveSyncIP = temp->getRemoteIPAB(); |
306 | } else if ( mTargetApp == KOPI ) { | 310 | } else if ( mTargetApp == KOPI ) { |
307 | mPassWordPiSync = temp->getRemotePw(); | 311 | mPassWordPiSync = temp->getRemotePw(); |
308 | mActiveSyncPort = temp->getRemotePort(); | 312 | mActiveSyncPort = temp->getRemotePort(); |
309 | mActiveSyncIP = temp->getRemoteIP(); | 313 | mActiveSyncIP = temp->getRemoteIP(); |
310 | } else { | 314 | } else { |
311 | mPassWordPiSync = temp->getRemotePwPWM(); | 315 | mPassWordPiSync = temp->getRemotePwPWM(); |
312 | mActiveSyncPort = temp->getRemotePortPWM(); | 316 | mActiveSyncPort = temp->getRemotePortPWM(); |
313 | mActiveSyncIP = temp->getRemoteIPPWM(); | 317 | mActiveSyncIP = temp->getRemoteIPPWM(); |
314 | } | 318 | } |
315 | syncPi(); | 319 | syncPi(); |
316 | while ( !mPisyncFinished ) { | 320 | while ( !mPisyncFinished ) { |
317 | //qDebug("waiting "); | 321 | //qDebug("waiting "); |
318 | qApp->processEvents(); | 322 | qApp->processEvents(); |
319 | } | 323 | } |
320 | } else | 324 | } else |
321 | syncRemote( temp ); | 325 | syncRemote( temp ); |
322 | 326 | ||
323 | } | 327 | } |
324 | } | 328 | } |
325 | delete temp; | 329 | delete temp; |
326 | setBlockSave(false); | 330 | setBlockSave(false); |
327 | } | 331 | } |
328 | 332 | ||
329 | void KSyncManager::enableQuick( bool ask ) | 333 | void KSyncManager::enableQuick( bool ask ) |
330 | { | 334 | { |
331 | bool autoStart; | 335 | bool autoStart; |
332 | bool changed = false; | 336 | bool changed = false; |
333 | if ( ask ) { | 337 | if ( ask ) { |
334 | QDialog dia ( 0, "input-dialog", true ); | 338 | QDialog dia ( 0, "input-dialog", true ); |
335 | QLineEdit lab ( &dia ); | 339 | QLineEdit lab ( &dia ); |
336 | QVBoxLayout lay( &dia ); | 340 | QVBoxLayout lay( &dia ); |
337 | lab.setText( mPrefs->mPassiveSyncPort ); | 341 | lab.setText( mPrefs->mPassiveSyncPort ); |
338 | lay.setMargin(7); | 342 | lay.setMargin(7); |
339 | lay.setSpacing(7); | 343 | lay.setSpacing(7); |
340 | int po = 9197+mTargetApp; | 344 | int po = 9197+mTargetApp; |
341 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); | 345 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); |
342 | lay.addWidget( &label); | 346 | lay.addWidget( &label); |
343 | lay.addWidget( &lab); | 347 | lay.addWidget( &lab); |
344 | 348 | ||
345 | QLineEdit lepw ( &dia ); | 349 | QLineEdit lepw ( &dia ); |
346 | lepw.setText( mPrefs->mPassiveSyncPw ); | 350 | lepw.setText( mPrefs->mPassiveSyncPw ); |
347 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 351 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
348 | lay.addWidget( &label2); | 352 | lay.addWidget( &label2); |
349 | lay.addWidget( &lepw); | 353 | lay.addWidget( &lepw); |
350 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); | 354 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); |
351 | lay.addWidget( &autostart); | 355 | lay.addWidget( &autostart); |
352 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); | 356 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); |
353 | #ifdef DESKTOP_VERSION | 357 | #ifdef DESKTOP_VERSION |
354 | #ifdef _WIN32_ | 358 | #ifdef _WIN32_ |
355 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); | 359 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); |
356 | syncdesktop.hide();// not implemented! | 360 | syncdesktop.hide();// not implemented! |
357 | #else | 361 | #else |
358 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); | 362 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); |
359 | #endif | 363 | #endif |
360 | lay.addWidget( &syncdesktop); | 364 | lay.addWidget( &syncdesktop); |
361 | #else | 365 | #else |
362 | mPrefs->mPassiveSyncWithDesktop = false; | 366 | mPrefs->mPassiveSyncWithDesktop = false; |
363 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); | 367 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); |
364 | syncdesktop.hide(); | 368 | syncdesktop.hide(); |
365 | #endif | 369 | #endif |
366 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); | 370 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); |
367 | 371 | ||
368 | dia.setFixedSize( 230,120 ); | 372 | dia.setFixedSize( 230,120 ); |
369 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 373 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
370 | QPushButton pb ( "OK", &dia); | 374 | QPushButton pb ( "OK", &dia); |
371 | lay.addWidget( &pb ); | 375 | lay.addWidget( &pb ); |
372 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 376 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
373 | dia.show(); | 377 | dia.show(); |
374 | if ( ! dia.exec() ) | 378 | if ( ! dia.exec() ) |
375 | return; | 379 | return; |
376 | dia.hide(); | 380 | dia.hide(); |
377 | qApp->processEvents(); | 381 | qApp->processEvents(); |
378 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { | 382 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { |
379 | changed = true; | 383 | changed = true; |
380 | mPrefs->mPassiveSyncPw = lepw.text(); | 384 | mPrefs->mPassiveSyncPw = lepw.text(); |
381 | } | 385 | } |
382 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { | 386 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { |
383 | mPrefs->mPassiveSyncPort = lab.text(); | 387 | mPrefs->mPassiveSyncPort = lab.text(); |
384 | changed = true; | 388 | changed = true; |
385 | } | 389 | } |
386 | autoStart = autostart.isChecked(); | 390 | autoStart = autostart.isChecked(); |
387 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { | 391 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { |
388 | changed = true; | 392 | changed = true; |
389 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); | 393 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); |
390 | } | 394 | } |
391 | } | 395 | } |
392 | else | 396 | else |
393 | autoStart = mPrefs->mPassiveSyncAutoStart; | 397 | autoStart = mPrefs->mPassiveSyncAutoStart; |
394 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) | 398 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) |
395 | changed = true; | 399 | changed = true; |
396 | bool ok; | 400 | bool ok; |
397 | mPrefs->mPassiveSyncAutoStart = false; | 401 | mPrefs->mPassiveSyncAutoStart = false; |
398 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); | 402 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); |
399 | if ( ! ok ) { | 403 | if ( ! ok ) { |
400 | KMessageBox::information( 0, i18n("No valid port")); | 404 | KMessageBox::information( 0, i18n("No valid port")); |
401 | return; | 405 | return; |
402 | } | 406 | } |
403 | //qDebug("port %d ", port); | 407 | //qDebug("port %d ", port); |
404 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); | 408 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); |
405 | mServerSocket->setFileName( defaultFileName() );//bbb | 409 | mServerSocket->setFileName( defaultFileName() );//bbb |
406 | //qDebug("connected "); | 410 | //qDebug("connected "); |
407 | if ( !mServerSocket->ok() ) { | 411 | if ( !mServerSocket->ok() ) { |
408 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); | 412 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); |
409 | delete mServerSocket; | 413 | delete mServerSocket; |
410 | mServerSocket = 0; | 414 | mServerSocket = 0; |
411 | return; | 415 | return; |
412 | } | 416 | } |
413 | mPrefs->mPassiveSyncAutoStart = autoStart; | 417 | mPrefs->mPassiveSyncAutoStart = autoStart; |
414 | if ( changed ) { | 418 | if ( changed ) { |
415 | mPrefs->writeConfig(); | 419 | mPrefs->writeConfig(); |
416 | } | 420 | } |
417 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); | 421 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); |
418 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); | 422 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); |
419 | } | 423 | } |
420 | 424 | ||
421 | void KSyncManager::syncLocalFile() | 425 | void KSyncManager::syncLocalFile() |
422 | { | 426 | { |
423 | 427 | ||
424 | QString fn =mPrefs->mLastSyncedLocalFile; | 428 | QString fn =mPrefs->mLastSyncedLocalFile; |
425 | QString ext; | 429 | QString ext; |
426 | 430 | ||
427 | switch(mTargetApp) | 431 | switch(mTargetApp) |
428 | { | 432 | { |
429 | case (KAPI): | 433 | case (KAPI): |
430 | ext = "(*.vcf)"; | 434 | ext = "(*.vcf)"; |
431 | break; | 435 | break; |
432 | case (KOPI): | 436 | case (KOPI): |
433 | ext = "(*.ics/*.vcs)"; | 437 | ext = "(*.ics/*.vcs)"; |
434 | break; | 438 | break; |
435 | case (PWMPI): | 439 | case (PWMPI): |
436 | ext = "(*.pwm)"; | 440 | ext = "(*.pwm)"; |
437 | break; | 441 | break; |
438 | default: | 442 | default: |
439 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); | 443 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); |
440 | break; | 444 | break; |
441 | 445 | ||
442 | } | 446 | } |
443 | 447 | ||
444 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 448 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
445 | if ( fn == "" ) | 449 | if ( fn == "" ) |
446 | return; | 450 | return; |
447 | if ( syncWithFile( fn, false ) ) { | 451 | if ( syncWithFile( fn, false ) ) { |
448 | qDebug("syncLocalFile() successful "); | 452 | qDebug("syncLocalFile() successful "); |
449 | } | 453 | } |
450 | 454 | ||
451 | } | 455 | } |
452 | 456 | ||
453 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 457 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
454 | { | 458 | { |
455 | bool ret = false; | 459 | bool ret = false; |
456 | QFileInfo info; | 460 | QFileInfo info; |
457 | info.setFile( fn ); | 461 | info.setFile( fn ); |
458 | QString mess; | 462 | QString mess; |
459 | bool loadbup = true; | 463 | bool loadbup = true; |
460 | if ( !info. exists() ) { | 464 | if ( !info. exists() ) { |
461 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 465 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
462 | int result = QMessageBox::warning( mParent, i18n("Warning!"), | 466 | int result = QMessageBox::warning( mParent, i18n("Warning!"), |
463 | mess ); | 467 | mess ); |
464 | return ret; | 468 | return ret; |
465 | } | 469 | } |
466 | int result = 0; | 470 | int result = 0; |
467 | if ( !quick ) { | 471 | if ( !quick ) { |
468 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 472 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
469 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 473 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
470 | mess, | 474 | mess, |
471 | i18n("Sync"), i18n("Cancel"), 0, | 475 | i18n("Sync"), i18n("Cancel"), 0, |
472 | 0, 1 ); | 476 | 0, 1 ); |
473 | if ( result ) | 477 | if ( result ) |
474 | return false; | 478 | return false; |
475 | } | 479 | } |
476 | if ( mAskForPreferences ) | 480 | if ( mAskForPreferences ) |
477 | if ( !edit_sync_options()) { | 481 | if ( !edit_sync_options()) { |
478 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 482 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
479 | return false; | 483 | return false; |
480 | } | 484 | } |
481 | if ( result == 0 ) { | 485 | if ( result == 0 ) { |
482 | //qDebug("Now sycing ... "); | 486 | //qDebug("Now sycing ... "); |
483 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) | 487 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
484 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); | 488 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
485 | else | 489 | else |
486 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 490 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
487 | if ( ! quick ) | 491 | if ( ! quick ) |
488 | mPrefs->mLastSyncedLocalFile = fn; | 492 | mPrefs->mLastSyncedLocalFile = fn; |
489 | } | 493 | } |
490 | return ret; | 494 | return ret; |
491 | } | 495 | } |
492 | 496 | ||
493 | void KSyncManager::quickSyncLocalFile() | 497 | void KSyncManager::quickSyncLocalFile() |
494 | { | 498 | { |
495 | 499 | ||
496 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { | 500 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { |
497 | qDebug("quick syncLocalFile() successful "); | 501 | qDebug("quick syncLocalFile() successful "); |
498 | 502 | ||
499 | } | 503 | } |
500 | } | 504 | } |
501 | 505 | ||
502 | void KSyncManager::multiSync( bool askforPrefs ) | 506 | void KSyncManager::multiSync( bool askforPrefs ) |
503 | { | 507 | { |
504 | if (blockSave()) | 508 | if (blockSave()) |
505 | return; | 509 | return; |
506 | setBlockSave(true); | 510 | setBlockSave(true); |
507 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 511 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
508 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), | 512 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), |
509 | question, | 513 | question, |
510 | i18n("Yes"), i18n("No"), | 514 | i18n("Yes"), i18n("No"), |
511 | 0, 0 ) != 0 ) { | 515 | 0, 0 ) != 0 ) { |
512 | setBlockSave(false); | 516 | setBlockSave(false); |
513 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); | 517 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
514 | return; | 518 | return; |
515 | } | 519 | } |
516 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 520 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
517 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 521 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; |
518 | if ( askforPrefs ) { | 522 | if ( askforPrefs ) { |
519 | if ( !edit_sync_options()) { | 523 | if ( !edit_sync_options()) { |
520 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); | 524 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); |
521 | return; | 525 | return; |
522 | } | 526 | } |
523 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 527 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
524 | } | 528 | } |
525 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); | 529 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
526 | qApp->processEvents(); | 530 | qApp->processEvents(); |
527 | int num = ringSync() ; | 531 | int num = ringSync() ; |
528 | if ( num > 1 ) | 532 | if ( num > 1 ) |
529 | ringSync(); | 533 | ringSync(); |
530 | setBlockSave(false); | 534 | setBlockSave(false); |
531 | if ( num ) | 535 | if ( num ) |
532 | emit save(); | 536 | emit save(); |
533 | if ( num ) | 537 | if ( num ) |
534 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); | 538 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); |
535 | else | 539 | else |
536 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 540 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
537 | return; | 541 | return; |
538 | } | 542 | } |
539 | 543 | ||
540 | int KSyncManager::ringSync() | 544 | int KSyncManager::ringSync() |
541 | { | 545 | { |
542 | 546 | ||
543 | int syncedProfiles = 0; | 547 | int syncedProfiles = 0; |
544 | unsigned int i; | 548 | unsigned int i; |
545 | QTime timer; | 549 | QTime timer; |
546 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 550 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
547 | QStringList syncProfileNames = mSyncProfileNames; | 551 | QStringList syncProfileNames = mSyncProfileNames; |
548 | KSyncProfile* temp = new KSyncProfile (); | 552 | KSyncProfile* temp = new KSyncProfile (); |
549 | mAskForPreferences = false; | 553 | mAskForPreferences = false; |
550 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 554 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
551 | mCurrentSyncProfile = i; | 555 | mCurrentSyncProfile = i; |
552 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 556 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
553 | temp->readConfig(&config); | 557 | temp->readConfig(&config); |
554 | 558 | ||
555 | bool includeInRingSync; | 559 | bool includeInRingSync; |
556 | switch(mTargetApp) | 560 | switch(mTargetApp) |
557 | { | 561 | { |
558 | case (KAPI): | 562 | case (KAPI): |
559 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 563 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
560 | break; | 564 | break; |
561 | case (KOPI): | 565 | case (KOPI): |
562 | includeInRingSync = temp->getIncludeInRingSync(); | 566 | includeInRingSync = temp->getIncludeInRingSync(); |
563 | break; | 567 | break; |
564 | case (PWMPI): | 568 | case (PWMPI): |
565 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 569 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
566 | break; | 570 | break; |
567 | default: | 571 | default: |
568 | qDebug("KSyncManager::ringSync: invalid apptype selected"); | 572 | qDebug("KSyncManager::ringSync: invalid apptype selected"); |
569 | break; | 573 | break; |
570 | 574 | ||
571 | } | 575 | } |
572 | 576 | ||
573 | 577 | ||
574 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 578 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
575 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 579 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
576 | ++syncedProfiles; | 580 | ++syncedProfiles; |
577 | mSyncWithDesktop = false; | 581 | mSyncWithDesktop = false; |
578 | // mAskForPreferences = temp->getAskForPreferences(); | 582 | // mAskForPreferences = temp->getAskForPreferences(); |
579 | mWriteBackFile = temp->getWriteBackFile(); | 583 | mWriteBackFile = temp->getWriteBackFile(); |
580 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 584 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
581 | mIsKapiFile = temp->getIsKapiFile(); | 585 | mIsKapiFile = temp->getIsKapiFile(); |
582 | mWriteBackInFuture = 0; | 586 | mWriteBackInFuture = 0; |
583 | if ( temp->getWriteBackFuture() ) { | 587 | if ( temp->getWriteBackFuture() ) { |
584 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 588 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
585 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 589 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
586 | } | 590 | } |
591 | mFilterInCal = temp->getFilterInCal(); | ||
592 | mFilterOutCal = temp->getFilterOutCal(); | ||
593 | mFilterInAB = temp->getFilterInAB(); | ||
594 | mFilterOutAB = temp->getFilterOutAB(); | ||
587 | mShowSyncSummary = false; | 595 | mShowSyncSummary = false; |
588 | mCurrentSyncDevice = syncProfileNames[i] ; | 596 | mCurrentSyncDevice = syncProfileNames[i] ; |
589 | mCurrentSyncName = mLocalMachineName; | 597 | mCurrentSyncName = mLocalMachineName; |
590 | if ( i == 0 ) { | 598 | if ( i == 0 ) { |
591 | mIsKapiFile = false; | 599 | mIsKapiFile = false; |
592 | #ifdef DESKTOP_VERSION | 600 | #ifdef DESKTOP_VERSION |
593 | syncKDE(); | 601 | syncKDE(); |
594 | #else | 602 | #else |
595 | syncSharp(); | 603 | syncSharp(); |
596 | #endif | 604 | #endif |
597 | } else { | 605 | } else { |
598 | if ( temp->getIsLocalFileSync() ) { | 606 | if ( temp->getIsLocalFileSync() ) { |
599 | switch(mTargetApp) | 607 | switch(mTargetApp) |
600 | { | 608 | { |
601 | case (KAPI): | 609 | case (KAPI): |
602 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 610 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
603 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 611 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
604 | break; | 612 | break; |
605 | case (KOPI): | 613 | case (KOPI): |
606 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 614 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
607 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 615 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
608 | break; | 616 | break; |
609 | case (PWMPI): | 617 | case (PWMPI): |
610 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 618 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
611 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 619 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
612 | break; | 620 | break; |
613 | default: | 621 | default: |
614 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 622 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
615 | break; | 623 | break; |
616 | } | 624 | } |
617 | } else { | 625 | } else { |
618 | if ( temp->getIsPhoneSync() ) { | 626 | if ( temp->getIsPhoneSync() ) { |
619 | mPhoneDevice = temp->getPhoneDevice( ) ; | 627 | mPhoneDevice = temp->getPhoneDevice( ) ; |
620 | mPhoneConnection = temp->getPhoneConnection( ); | 628 | mPhoneConnection = temp->getPhoneConnection( ); |
621 | mPhoneModel = temp->getPhoneModel( ); | 629 | mPhoneModel = temp->getPhoneModel( ); |
622 | syncPhone(); | 630 | syncPhone(); |
623 | } else if ( temp->getIsPiSync() ) { | 631 | } else if ( temp->getIsPiSync() ) { |
624 | if ( mTargetApp == KAPI ) { | 632 | if ( mTargetApp == KAPI ) { |
625 | mPassWordPiSync = temp->getRemotePwAB(); | 633 | mPassWordPiSync = temp->getRemotePwAB(); |
626 | mActiveSyncPort = temp->getRemotePortAB(); | 634 | mActiveSyncPort = temp->getRemotePortAB(); |
627 | mActiveSyncIP = temp->getRemoteIPAB(); | 635 | mActiveSyncIP = temp->getRemoteIPAB(); |
628 | } else if ( mTargetApp == KOPI ) { | 636 | } else if ( mTargetApp == KOPI ) { |
629 | mPassWordPiSync = temp->getRemotePw(); | 637 | mPassWordPiSync = temp->getRemotePw(); |
630 | mActiveSyncPort = temp->getRemotePort(); | 638 | mActiveSyncPort = temp->getRemotePort(); |
631 | mActiveSyncIP = temp->getRemoteIP(); | 639 | mActiveSyncIP = temp->getRemoteIP(); |
632 | } else { | 640 | } else { |
633 | mPassWordPiSync = temp->getRemotePwPWM(); | 641 | mPassWordPiSync = temp->getRemotePwPWM(); |
634 | mActiveSyncPort = temp->getRemotePortPWM(); | 642 | mActiveSyncPort = temp->getRemotePortPWM(); |
635 | mActiveSyncIP = temp->getRemoteIPPWM(); | 643 | mActiveSyncIP = temp->getRemoteIPPWM(); |
636 | } | 644 | } |
637 | syncPi(); | 645 | syncPi(); |
638 | while ( !mPisyncFinished ) { | 646 | while ( !mPisyncFinished ) { |
639 | //qDebug("waiting "); | 647 | //qDebug("waiting "); |
640 | qApp->processEvents(); | 648 | qApp->processEvents(); |
641 | } | 649 | } |
642 | timer.start(); | 650 | timer.start(); |
643 | while ( timer.elapsed () < 2000 ) { | 651 | while ( timer.elapsed () < 2000 ) { |
644 | qApp->processEvents(); | 652 | qApp->processEvents(); |
645 | } | 653 | } |
646 | } else | 654 | } else |
647 | syncRemote( temp, false ); | 655 | syncRemote( temp, false ); |
648 | 656 | ||
649 | } | 657 | } |
650 | } | 658 | } |
651 | timer.start(); | 659 | timer.start(); |
652 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 660 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
653 | while ( timer.elapsed () < 2000 ) { | 661 | while ( timer.elapsed () < 2000 ) { |
654 | qApp->processEvents(); | 662 | qApp->processEvents(); |
655 | #ifndef _WIN32_ | 663 | #ifndef _WIN32_ |
656 | sleep (1); | 664 | sleep (1); |
657 | #endif | 665 | #endif |
658 | } | 666 | } |
659 | 667 | ||
660 | } | 668 | } |
661 | 669 | ||
662 | } | 670 | } |
663 | delete temp; | 671 | delete temp; |
664 | return syncedProfiles; | 672 | return syncedProfiles; |
665 | } | 673 | } |
666 | 674 | ||
667 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | 675 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) |
668 | { | 676 | { |
669 | QString question; | 677 | QString question; |
670 | if ( ask ) { | 678 | if ( ask ) { |
671 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 679 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
672 | if ( QMessageBox::information( mParent, i18n("Sync"), | 680 | if ( QMessageBox::information( mParent, i18n("Sync"), |
673 | question, | 681 | question, |
674 | i18n("Yes"), i18n("No"), | 682 | i18n("Yes"), i18n("No"), |
675 | 0, 0 ) != 0 ) | 683 | 0, 0 ) != 0 ) |
676 | return; | 684 | return; |
677 | } | 685 | } |
678 | 686 | ||
679 | QString preCommand; | 687 | QString preCommand; |
680 | QString localTempFile; | 688 | QString localTempFile; |
681 | QString postCommand; | 689 | QString postCommand; |
682 | 690 | ||
683 | switch(mTargetApp) | 691 | switch(mTargetApp) |
684 | { | 692 | { |
685 | case (KAPI): | 693 | case (KAPI): |
686 | preCommand = prof->getPreSyncCommandAB(); | 694 | preCommand = prof->getPreSyncCommandAB(); |
687 | postCommand = prof->getPostSyncCommandAB(); | 695 | postCommand = prof->getPostSyncCommandAB(); |
688 | localTempFile = prof->getLocalTempFileAB(); | 696 | localTempFile = prof->getLocalTempFileAB(); |
689 | break; | 697 | break; |
690 | case (KOPI): | 698 | case (KOPI): |
691 | preCommand = prof->getPreSyncCommand(); | 699 | preCommand = prof->getPreSyncCommand(); |
692 | postCommand = prof->getPostSyncCommand(); | 700 | postCommand = prof->getPostSyncCommand(); |
693 | localTempFile = prof->getLocalTempFile(); | 701 | localTempFile = prof->getLocalTempFile(); |
694 | break; | 702 | break; |
695 | case (PWMPI): | 703 | case (PWMPI): |
696 | preCommand = prof->getPreSyncCommandPWM(); | 704 | preCommand = prof->getPreSyncCommandPWM(); |
697 | postCommand = prof->getPostSyncCommandPWM(); | 705 | postCommand = prof->getPostSyncCommandPWM(); |
698 | localTempFile = prof->getLocalTempFilePWM(); | 706 | localTempFile = prof->getLocalTempFilePWM(); |
699 | break; | 707 | break; |
700 | default: | 708 | default: |
701 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); | 709 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); |
702 | break; | 710 | break; |
703 | } | 711 | } |
704 | 712 | ||
705 | 713 | ||
706 | int fi; | 714 | int fi; |
707 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { | 715 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { |
708 | QString pwd = getPassword(); | 716 | QString pwd = getPassword(); |
709 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); | 717 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); |
710 | 718 | ||
711 | } | 719 | } |
712 | int maxlen = 30; | 720 | int maxlen = 30; |
713 | if ( QApplication::desktop()->width() > 320 ) | 721 | if ( QApplication::desktop()->width() > 320 ) |
714 | maxlen += 25; | 722 | maxlen += 25; |
715 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); | 723 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); |
716 | int fileSize = 0; | 724 | int fileSize = 0; |
717 | int result = system ( preCommand ); | 725 | int result = system ( preCommand ); |
718 | // 0 : okay | 726 | // 0 : okay |
719 | // 256: no such file or dir | 727 | // 256: no such file or dir |
720 | // | 728 | // |
721 | qDebug("Sync: Remote copy result(0 = okay): %d ",result ); | 729 | qDebug("Sync: Remote copy result(0 = okay): %d ",result ); |
722 | if ( result != 0 ) { | 730 | if ( result != 0 ) { |
723 | unsigned int len = maxlen; | 731 | unsigned int len = maxlen; |
724 | while ( len < preCommand.length() ) { | 732 | while ( len < preCommand.length() ) { |
725 | preCommand.insert( len , "\n" ); | 733 | preCommand.insert( len , "\n" ); |
726 | len += maxlen +2; | 734 | len += maxlen +2; |
727 | } | 735 | } |
728 | 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) ; | 736 | 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) ; |
729 | QMessageBox::information( mParent, i18n("Sync - ERROR"), | 737 | QMessageBox::information( mParent, i18n("Sync - ERROR"), |
730 | question, | 738 | question, |
731 | i18n("Okay!")) ; | 739 | i18n("Okay!")) ; |
732 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); | 740 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); |
733 | return; | 741 | return; |
734 | } | 742 | } |
735 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); | 743 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); |
736 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 744 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
737 | 745 | ||
738 | if ( syncWithFile( localTempFile, true ) ) { | 746 | if ( syncWithFile( localTempFile, true ) ) { |
739 | 747 | ||
740 | if ( mWriteBackFile ) { | 748 | if ( mWriteBackFile ) { |
741 | int fi; | 749 | int fi; |
742 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { | 750 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { |
743 | QString pwd = getPassword(); | 751 | QString pwd = getPassword(); |
744 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); | 752 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); |
745 | 753 | ||
746 | } | 754 | } |
747 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); | 755 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); |
748 | result = system ( postCommand ); | 756 | result = system ( postCommand ); |
749 | qDebug("Sync:Writing back file result: %d ", result); | 757 | qDebug("Sync:Writing back file result: %d ", result); |
750 | if ( result != 0 ) { | 758 | if ( result != 0 ) { |
751 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 759 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
752 | return; | 760 | return; |
753 | } else { | 761 | } else { |
754 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 762 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
755 | } | 763 | } |
756 | } | 764 | } |
757 | } | 765 | } |
758 | return; | 766 | return; |
759 | } | 767 | } |
760 | bool KSyncManager::edit_pisync_options() | 768 | bool KSyncManager::edit_pisync_options() |
761 | { | 769 | { |
762 | QDialog dia( mParent, "dia", true ); | 770 | QDialog dia( mParent, "dia", true ); |
763 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); | 771 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); |
764 | QVBoxLayout lay ( &dia ); | 772 | QVBoxLayout lay ( &dia ); |
765 | lay.setSpacing( 5 ); | 773 | lay.setSpacing( 5 ); |
766 | lay.setMargin( 3 ); | 774 | lay.setMargin( 3 ); |
767 | QLabel lab1 ( i18n("Password for remote access:"), &dia); | 775 | QLabel lab1 ( i18n("Password for remote access:"), &dia); |
768 | lay.addWidget( &lab1 ); | 776 | lay.addWidget( &lab1 ); |
769 | QLineEdit le1 (&dia ); | 777 | QLineEdit le1 (&dia ); |
770 | lay.addWidget( &le1 ); | 778 | lay.addWidget( &le1 ); |
771 | QLabel lab2 ( i18n("Remote IP address:"), &dia); | 779 | QLabel lab2 ( i18n("Remote IP address:"), &dia); |
772 | lay.addWidget( &lab2 ); | 780 | lay.addWidget( &lab2 ); |
773 | QLineEdit le2 (&dia ); | 781 | QLineEdit le2 (&dia ); |
774 | lay.addWidget( &le2 ); | 782 | lay.addWidget( &le2 ); |
775 | QLabel lab3 ( i18n("Remote port number:"), &dia); | 783 | QLabel lab3 ( i18n("Remote port number:"), &dia); |
776 | lay.addWidget( &lab3 ); | 784 | lay.addWidget( &lab3 ); |
777 | QLineEdit le3 (&dia ); | 785 | QLineEdit le3 (&dia ); |
778 | lay.addWidget( &le3 ); | 786 | lay.addWidget( &le3 ); |