-rw-r--r-- | libkdepim/ksyncmanager.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 4d859ce..f80c2a6 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -65,1366 +65,1371 @@ KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, Targ | |||
65 | mServerSocket = 0; | 65 | mServerSocket = 0; |
66 | bar = new QProgressBar ( 1, 0 ); | 66 | bar = new QProgressBar ( 1, 0 ); |
67 | bar->setCaption (""); | 67 | bar->setCaption (""); |
68 | mWriteBackInPast = 2; | 68 | mWriteBackInPast = 2; |
69 | 69 | ||
70 | 70 | ||
71 | } | 71 | } |
72 | 72 | ||
73 | KSyncManager::~KSyncManager() | 73 | KSyncManager::~KSyncManager() |
74 | { | 74 | { |
75 | delete bar; | 75 | delete bar; |
76 | } | 76 | } |
77 | 77 | ||
78 | void KSyncManager::setDefaultFileName( QString s) | 78 | void KSyncManager::setDefaultFileName( QString s) |
79 | { | 79 | { |
80 | mDefFileName = s ; | 80 | mDefFileName = s ; |
81 | if ( mPrefs->mPassiveSyncAutoStart ) | 81 | if ( mPrefs->mPassiveSyncAutoStart ) |
82 | enableQuick( false ); | 82 | enableQuick( false ); |
83 | } | 83 | } |
84 | 84 | ||
85 | void KSyncManager::fillSyncMenu() | 85 | void KSyncManager::fillSyncMenu() |
86 | { | 86 | { |
87 | if ( mSyncMenu->count() ) | 87 | if ( mSyncMenu->count() ) |
88 | mSyncMenu->clear(); | 88 | mSyncMenu->clear(); |
89 | 89 | ||
90 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 90 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
91 | mSyncMenu->insertSeparator(); | 91 | mSyncMenu->insertSeparator(); |
92 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); | 92 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); |
93 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); | 93 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); |
94 | clearMenu->insertItem( i18n("For all profiles"), 1 ); | 94 | clearMenu->insertItem( i18n("For all profiles"), 1 ); |
95 | clearMenu->insertSeparator(); | 95 | clearMenu->insertSeparator(); |
96 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); | 96 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); |
97 | mSyncMenu->insertSeparator(); | 97 | mSyncMenu->insertSeparator(); |
98 | if ( mServerSocket == 0 ) { | 98 | if ( mServerSocket == 0 ) { |
99 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 99 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
100 | } else { | 100 | } else { |
101 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 101 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
102 | } | 102 | } |
103 | mSyncMenu->insertSeparator(); | 103 | mSyncMenu->insertSeparator(); |
104 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); | 104 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); |
105 | mSyncMenu->insertSeparator(); | 105 | mSyncMenu->insertSeparator(); |
106 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 106 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
107 | config.setGroup("General"); | 107 | config.setGroup("General"); |
108 | QStringList prof = config.readListEntry("SyncProfileNames"); | 108 | QStringList prof = config.readListEntry("SyncProfileNames"); |
109 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 109 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
110 | if ( prof.count() < 2 ) { | 110 | if ( prof.count() < 2 ) { |
111 | prof.clear(); | 111 | prof.clear(); |
112 | QString externalName; | 112 | QString externalName; |
113 | #ifdef DESKTOP_VERSION | 113 | #ifdef DESKTOP_VERSION |
114 | #ifdef _WIN32_ | 114 | #ifdef _WIN32_ |
115 | externalName = "OutLook(not_implemented)"; | 115 | externalName = "OutLook(not_implemented)"; |
116 | #else | 116 | #else |
117 | externalName = "KDE_Desktop"; | 117 | externalName = "KDE_Desktop"; |
118 | #endif | 118 | #endif |
119 | #else | 119 | #else |
120 | externalName = "Sharp_DTM"; | 120 | externalName = "Sharp_DTM"; |
121 | #endif | 121 | #endif |
122 | prof << externalName; | 122 | prof << externalName; |
123 | prof << i18n("Local_file"); | 123 | prof << i18n("Local_file"); |
124 | prof << i18n("Last_file"); | 124 | prof << i18n("Last_file"); |
125 | KSyncProfile* temp = new KSyncProfile (); | 125 | KSyncProfile* temp = new KSyncProfile (); |
126 | temp->setName( prof[0] ); | 126 | temp->setName( prof[0] ); |
127 | temp->writeConfig(&config); | 127 | temp->writeConfig(&config); |
128 | temp->setName( prof[1] ); | 128 | temp->setName( prof[1] ); |
129 | temp->writeConfig(&config); | 129 | temp->writeConfig(&config); |
130 | temp->setName( prof[2] ); | 130 | temp->setName( prof[2] ); |
131 | temp->writeConfig(&config); | 131 | temp->writeConfig(&config); |
132 | config.setGroup("General"); | 132 | config.setGroup("General"); |
133 | config.writeEntry("SyncProfileNames",prof); | 133 | config.writeEntry("SyncProfileNames",prof); |
134 | config.writeEntry("ExternSyncProfiles",externalName); | 134 | config.writeEntry("ExternSyncProfiles",externalName); |
135 | config.sync(); | 135 | config.sync(); |
136 | delete temp; | 136 | delete temp; |
137 | } | 137 | } |
138 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 138 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
139 | mSyncProfileNames = prof; | 139 | mSyncProfileNames = prof; |
140 | unsigned int i; | 140 | unsigned int i; |
141 | for ( i = 0; i < prof.count(); ++i ) { | 141 | for ( i = 0; i < prof.count(); ++i ) { |
142 | QString insertText = prof[i]; | 142 | QString insertText = prof[i]; |
143 | if ( i == 0 ) { | 143 | if ( i == 0 ) { |
144 | #ifdef DESKTOP_VERSION | 144 | #ifdef DESKTOP_VERSION |
145 | #ifdef _WIN32_ | 145 | #ifdef _WIN32_ |
146 | insertText = "OutLook(not_implemented)"; | 146 | insertText = "OutLook(not_implemented)"; |
147 | #else | 147 | #else |
148 | insertText = "KDE_Desktop"; | 148 | insertText = "KDE_Desktop"; |
149 | #endif | 149 | #endif |
150 | #else | 150 | #else |
151 | insertText = "Sharp_DTM"; | 151 | insertText = "Sharp_DTM"; |
152 | #endif | 152 | #endif |
153 | } | 153 | } |
154 | mSyncMenu->insertItem( insertText, 1000+i ); | 154 | mSyncMenu->insertItem( insertText, 1000+i ); |
155 | clearMenu->insertItem( insertText, 1000+i ); | 155 | clearMenu->insertItem( insertText, 1000+i ); |
156 | if ( i == 2 ) | 156 | if ( i == 2 ) |
157 | mSyncMenu->insertSeparator(); | 157 | mSyncMenu->insertSeparator(); |
158 | } | 158 | } |
159 | QDir app_dir; | 159 | QDir app_dir; |
160 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 160 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
161 | if ( mTargetApp == PWMPI) { | 161 | if ( mTargetApp == PWMPI) { |
162 | mSyncMenu->removeItem( 1000 ); | 162 | mSyncMenu->removeItem( 1000 ); |
163 | clearMenu->removeItem( 1000 ); | 163 | clearMenu->removeItem( 1000 ); |
164 | } | 164 | } |
165 | #ifndef DESKTOP_VERSION | 165 | #ifndef DESKTOP_VERSION |
166 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 166 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
167 | mSyncMenu->removeItem( 1000 ); | 167 | mSyncMenu->removeItem( 1000 ); |
168 | clearMenu->removeItem( 1000 ); | 168 | clearMenu->removeItem( 1000 ); |
169 | } | 169 | } |
170 | #endif | 170 | #endif |
171 | mSyncMenu->removeItem( 1002 ); | 171 | mSyncMenu->removeItem( 1002 ); |
172 | clearMenu->removeItem( 1002 ); | 172 | clearMenu->removeItem( 1002 ); |
173 | } | 173 | } |
174 | void KSyncManager::slotClearMenu( int action ) | 174 | void KSyncManager::slotClearMenu( int action ) |
175 | { | 175 | { |
176 | QString syncDevice; | 176 | QString syncDevice; |
177 | if ( action > 999 ) { | 177 | if ( action > 999 ) { |
178 | syncDevice = mSyncProfileNames[action - 1000] ; | 178 | syncDevice = mSyncProfileNames[action - 1000] ; |
179 | } | 179 | } |
180 | 180 | ||
181 | 181 | ||
182 | 182 | ||
183 | int result = 0; | 183 | int result = 0; |
184 | QString sd; | 184 | QString sd; |
185 | if ( syncDevice.isEmpty() ) | 185 | if ( syncDevice.isEmpty() ) |
186 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); | 186 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); |
187 | else | 187 | else |
188 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); | 188 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); |
189 | 189 | ||
190 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, | 190 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, |
191 | 0, 1 ); | 191 | 0, 1 ); |
192 | if ( result ) | 192 | if ( result ) |
193 | return; | 193 | return; |
194 | mImplementation->removeSyncInfo( syncDevice ); | 194 | mImplementation->removeSyncInfo( syncDevice ); |
195 | } | 195 | } |
196 | void KSyncManager::slotSyncMenu( int action ) | 196 | void KSyncManager::slotSyncMenu( int action ) |
197 | { | 197 | { |
198 | qDebug("KSM::syncaction %d ", action); | 198 | qDebug("KSM::syncaction %d ", action); |
199 | mCurrentResourceLocal = ""; | 199 | mCurrentResourceLocal = ""; |
200 | emit multiResourceSyncStart( false ); | 200 | emit multiResourceSyncStart( false ); |
201 | if ( action == 5000 ) | 201 | if ( action == 5000 ) |
202 | return; | 202 | return; |
203 | mSyncWithDesktop = false; | 203 | mSyncWithDesktop = false; |
204 | if ( action == 0 ) { | 204 | if ( action == 0 ) { |
205 | 205 | ||
206 | // seems to be a Qt2 event handling bug | 206 | // seems to be a Qt2 event handling bug |
207 | // syncmenu.clear causes a segfault at first time | 207 | // syncmenu.clear causes a segfault at first time |
208 | // when we call it after the main event loop, it is ok | 208 | // when we call it after the main event loop, it is ok |
209 | // same behaviour when calling OM/Pi via QCOP for the first time | 209 | // same behaviour when calling OM/Pi via QCOP for the first time |
210 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 210 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
211 | //confSync(); | 211 | //confSync(); |
212 | 212 | ||
213 | return; | 213 | return; |
214 | } | 214 | } |
215 | if ( action == 1 ) { | 215 | if ( action == 1 ) { |
216 | multiSync( true ); | 216 | multiSync( true ); |
217 | return; | 217 | return; |
218 | } | 218 | } |
219 | if ( action == 2 ) { | 219 | if ( action == 2 ) { |
220 | enableQuick(); | 220 | enableQuick(); |
221 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 221 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
222 | return; | 222 | return; |
223 | } | 223 | } |
224 | if ( action == 3 ) { | 224 | if ( action == 3 ) { |
225 | delete mServerSocket; | 225 | delete mServerSocket; |
226 | mServerSocket = 0; | 226 | mServerSocket = 0; |
227 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 227 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
228 | return; | 228 | return; |
229 | } | 229 | } |
230 | 230 | ||
231 | if (blockSave()) | 231 | if (blockSave()) |
232 | return; | 232 | return; |
233 | 233 | ||
234 | setBlockSave(true); | 234 | setBlockSave(true); |
235 | bool silent = false; | 235 | bool silent = false; |
236 | if ( action == 999 ) { | 236 | if ( action == 999 ) { |
237 | //special mode for silent syncing | 237 | //special mode for silent syncing |
238 | action = 1000; | 238 | action = 1000; |
239 | silent = true; | 239 | silent = true; |
240 | } | 240 | } |
241 | 241 | ||
242 | mCurrentSyncProfile = action - 1000 ; | 242 | mCurrentSyncProfile = action - 1000 ; |
243 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; | 243 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
244 | mCurrentSyncName = mLocalMachineName ; | 244 | mCurrentSyncName = mLocalMachineName ; |
245 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 245 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
246 | KSyncProfile* temp = new KSyncProfile (); | 246 | KSyncProfile* temp = new KSyncProfile (); |
247 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); | 247 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
248 | temp->readConfig(&config); | 248 | temp->readConfig(&config); |
249 | if (silent) { | 249 | if (silent) { |
250 | mAskForPreferences = false; | 250 | mAskForPreferences = false; |
251 | mShowSyncSummary = false; | 251 | mShowSyncSummary = false; |
252 | mWriteBackFile = true; | 252 | mWriteBackFile = true; |
253 | mSyncAlgoPrefs = 2;// take newest | 253 | mSyncAlgoPrefs = 2;// take newest |
254 | } | 254 | } |
255 | else { | 255 | else { |
256 | mAskForPreferences = temp->getAskForPreferences(); | 256 | mAskForPreferences = temp->getAskForPreferences(); |
257 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 257 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
258 | mWriteBackFile = temp->getWriteBackFile(); | 258 | mWriteBackFile = temp->getWriteBackFile(); |
259 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 259 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
260 | } | 260 | } |
261 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 261 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
262 | mIsKapiFile = temp->getIsKapiFile(); | 262 | mIsKapiFile = temp->getIsKapiFile(); |
263 | mWriteBackInFuture = 0; | 263 | mWriteBackInFuture = 0; |
264 | if ( temp->getWriteBackFuture() ) { | 264 | if ( temp->getWriteBackFuture() ) { |
265 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 265 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
266 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 266 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
267 | } | 267 | } |
268 | mFilterInCal = temp->getFilterInCal(); | 268 | mFilterInCal = temp->getFilterInCal(); |
269 | mFilterOutCal = temp->getFilterOutCal(); | 269 | mFilterOutCal = temp->getFilterOutCal(); |
270 | mFilterInAB = temp->getFilterInAB(); | 270 | mFilterInAB = temp->getFilterInAB(); |
271 | mFilterOutAB = temp->getFilterOutAB(); | 271 | mFilterOutAB = temp->getFilterOutAB(); |
272 | 272 | ||
273 | if ( action == 1000 ) { | 273 | if ( action == 1000 ) { |
274 | mIsKapiFile = false; | 274 | mIsKapiFile = false; |
275 | #ifdef DESKTOP_VERSION | 275 | #ifdef DESKTOP_VERSION |
276 | syncKDE(); | 276 | syncKDE(); |
277 | #else | 277 | #else |
278 | syncSharp(); | 278 | syncSharp(); |
279 | #endif | 279 | #endif |
280 | 280 | ||
281 | } else if ( action == 1001 ) { | 281 | } else if ( action == 1001 ) { |
282 | syncLocalFile(); | 282 | syncLocalFile(); |
283 | 283 | ||
284 | } else if ( action == 1002 ) { | 284 | } else if ( action == 1002 ) { |
285 | mWriteBackFile = false; | 285 | mWriteBackFile = false; |
286 | mAskForPreferences = false; | 286 | mAskForPreferences = false; |
287 | mShowSyncSummary = false; | 287 | mShowSyncSummary = false; |
288 | mSyncAlgoPrefs = 3; | 288 | mSyncAlgoPrefs = 3; |
289 | quickSyncLocalFile(); | 289 | quickSyncLocalFile(); |
290 | 290 | ||
291 | } else if ( action >= 1003 ) { | 291 | } else if ( action >= 1003 ) { |
292 | if ( temp->getIsLocalFileSync() ) { | 292 | if ( temp->getIsLocalFileSync() ) { |
293 | switch(mTargetApp) | 293 | switch(mTargetApp) |
294 | { | 294 | { |
295 | case (KAPI): | 295 | case (KAPI): |
296 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 296 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
297 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 297 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
298 | break; | 298 | break; |
299 | case (KOPI): | 299 | case (KOPI): |
300 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 300 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
301 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 301 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
302 | break; | 302 | break; |
303 | case (PWMPI): | 303 | case (PWMPI): |
304 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 304 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
305 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 305 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
306 | break; | 306 | break; |
307 | default: | 307 | default: |
308 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); | 308 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); |
309 | break; | 309 | break; |
310 | 310 | ||
311 | } | 311 | } |
312 | } else { | 312 | } else { |
313 | if ( temp->getIsPhoneSync() ) { | 313 | if ( temp->getIsPhoneSync() ) { |
314 | mPhoneDevice = temp->getPhoneDevice( ) ; | 314 | mPhoneDevice = temp->getPhoneDevice( ) ; |
315 | mPhoneConnection = temp->getPhoneConnection( ); | 315 | mPhoneConnection = temp->getPhoneConnection( ); |
316 | mPhoneModel = temp->getPhoneModel( ); | 316 | mPhoneModel = temp->getPhoneModel( ); |
317 | syncPhone(); | 317 | syncPhone(); |
318 | } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) { | 318 | } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) { |
319 | mSpecificResources.clear(); | 319 | mSpecificResources.clear(); |
320 | if ( mTargetApp == KAPI ) { | 320 | if ( mTargetApp == KAPI ) { |
321 | if ( temp->getIsPiSyncSpec() ) | ||
322 | mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true ); | ||
321 | mPassWordPiSync = temp->getRemotePwAB(); | 323 | mPassWordPiSync = temp->getRemotePwAB(); |
322 | mActiveSyncPort = temp->getRemotePortAB(); | 324 | mActiveSyncPort = temp->getRemotePortAB(); |
323 | mActiveSyncIP = temp->getRemoteIPAB(); | 325 | mActiveSyncIP = temp->getRemoteIPAB(); |
324 | } else if ( mTargetApp == KOPI ) { | 326 | } else if ( mTargetApp == KOPI ) { |
325 | if ( temp->getIsPiSyncSpec() ) | 327 | if ( temp->getIsPiSyncSpec() ) |
326 | mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); | 328 | mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); |
327 | mPassWordPiSync = temp->getRemotePw(); | 329 | mPassWordPiSync = temp->getRemotePw(); |
328 | mActiveSyncPort = temp->getRemotePort(); | 330 | mActiveSyncPort = temp->getRemotePort(); |
329 | mActiveSyncIP = temp->getRemoteIP(); | 331 | mActiveSyncIP = temp->getRemoteIP(); |
330 | } else { | 332 | } else { |
331 | mPassWordPiSync = temp->getRemotePwPWM(); | 333 | mPassWordPiSync = temp->getRemotePwPWM(); |
332 | mActiveSyncPort = temp->getRemotePortPWM(); | 334 | mActiveSyncPort = temp->getRemotePortPWM(); |
333 | mActiveSyncIP = temp->getRemoteIPPWM(); | 335 | mActiveSyncIP = temp->getRemoteIPPWM(); |
334 | } | 336 | } |
335 | syncPi(); | 337 | syncPi(); |
336 | while ( !mPisyncFinished ) { | 338 | while ( !mPisyncFinished ) { |
337 | //qDebug("waiting "); | 339 | //qDebug("waiting "); |
338 | qApp->processEvents(); | 340 | qApp->processEvents(); |
339 | } | 341 | } |
340 | } else | 342 | } else |
341 | syncRemote( temp ); | 343 | syncRemote( temp ); |
342 | 344 | ||
343 | } | 345 | } |
344 | } | 346 | } |
345 | delete temp; | 347 | delete temp; |
346 | setBlockSave(false); | 348 | setBlockSave(false); |
347 | } | 349 | } |
348 | 350 | ||
349 | void KSyncManager::enableQuick( bool ask ) | 351 | void KSyncManager::enableQuick( bool ask ) |
350 | { | 352 | { |
351 | bool autoStart; | 353 | bool autoStart; |
352 | bool changed = false; | 354 | bool changed = false; |
353 | if ( ask ) { | 355 | if ( ask ) { |
354 | QDialog dia ( 0, "input-dialog", true ); | 356 | QDialog dia ( 0, "input-dialog", true ); |
355 | QLineEdit lab ( &dia ); | 357 | QLineEdit lab ( &dia ); |
356 | QVBoxLayout lay( &dia ); | 358 | QVBoxLayout lay( &dia ); |
357 | lab.setText( mPrefs->mPassiveSyncPort ); | 359 | lab.setText( mPrefs->mPassiveSyncPort ); |
358 | lay.setMargin(7); | 360 | lay.setMargin(7); |
359 | lay.setSpacing(7); | 361 | lay.setSpacing(7); |
360 | int po = 9197+mTargetApp; | 362 | int po = 9197+mTargetApp; |
361 | QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); | 363 | QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); |
362 | lay.addWidget( &label); | 364 | lay.addWidget( &label); |
363 | lay.addWidget( &lab); | 365 | lay.addWidget( &lab); |
364 | 366 | ||
365 | QLineEdit lepw ( &dia ); | 367 | QLineEdit lepw ( &dia ); |
366 | lepw.setText( mPrefs->mPassiveSyncPw ); | 368 | lepw.setText( mPrefs->mPassiveSyncPw ); |
367 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 369 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
368 | lay.addWidget( &label2); | 370 | lay.addWidget( &label2); |
369 | lay.addWidget( &lepw); | 371 | lay.addWidget( &lepw); |
370 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); | 372 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); |
371 | lay.addWidget( &autostart); | 373 | lay.addWidget( &autostart); |
372 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); | 374 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); |
373 | #ifdef DESKTOP_VERSION | 375 | #ifdef DESKTOP_VERSION |
374 | #ifdef _WIN32_ | 376 | #ifdef _WIN32_ |
375 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); | 377 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); |
376 | syncdesktop.hide();// not implemented! | 378 | syncdesktop.hide();// not implemented! |
377 | #else | 379 | #else |
378 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); | 380 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); |
379 | #endif | 381 | #endif |
380 | lay.addWidget( &syncdesktop); | 382 | lay.addWidget( &syncdesktop); |
381 | #else | 383 | #else |
382 | mPrefs->mPassiveSyncWithDesktop = false; | 384 | mPrefs->mPassiveSyncWithDesktop = false; |
383 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); | 385 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); |
384 | syncdesktop.hide(); | 386 | syncdesktop.hide(); |
385 | #endif | 387 | #endif |
386 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); | 388 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); |
387 | 389 | ||
388 | QPushButton pb ( "OK", &dia); | 390 | QPushButton pb ( "OK", &dia); |
389 | lay.addWidget( &pb ); | 391 | lay.addWidget( &pb ); |
390 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 392 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
391 | dia.resize( 230,120 ); | 393 | dia.resize( 230,120 ); |
392 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 394 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
393 | dia.show(); | 395 | dia.show(); |
394 | #ifndef DESKTOP_VERSION | 396 | #ifndef DESKTOP_VERSION |
395 | int dw = QApplication::desktop()->width(); | 397 | int dw = QApplication::desktop()->width(); |
396 | int dh = QApplication::desktop()->height(); | 398 | int dh = QApplication::desktop()->height(); |
397 | dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); | 399 | dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); |
398 | #endif | 400 | #endif |
399 | if ( ! dia.exec() ) | 401 | if ( ! dia.exec() ) |
400 | return; | 402 | return; |
401 | dia.hide(); | 403 | dia.hide(); |
402 | qApp->processEvents(); | 404 | qApp->processEvents(); |
403 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { | 405 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { |
404 | changed = true; | 406 | changed = true; |
405 | mPrefs->mPassiveSyncPw = lepw.text(); | 407 | mPrefs->mPassiveSyncPw = lepw.text(); |
406 | } | 408 | } |
407 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { | 409 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { |
408 | mPrefs->mPassiveSyncPort = lab.text(); | 410 | mPrefs->mPassiveSyncPort = lab.text(); |
409 | changed = true; | 411 | changed = true; |
410 | } | 412 | } |
411 | autoStart = autostart.isChecked(); | 413 | autoStart = autostart.isChecked(); |
412 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { | 414 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { |
413 | changed = true; | 415 | changed = true; |
414 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); | 416 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); |
415 | } | 417 | } |
416 | } | 418 | } |
417 | else | 419 | else |
418 | autoStart = mPrefs->mPassiveSyncAutoStart; | 420 | autoStart = mPrefs->mPassiveSyncAutoStart; |
419 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) | 421 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) |
420 | changed = true; | 422 | changed = true; |
421 | bool ok; | 423 | bool ok; |
422 | mPrefs->mPassiveSyncAutoStart = false; | 424 | mPrefs->mPassiveSyncAutoStart = false; |
423 | Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); | 425 | Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); |
424 | if ( ! ok || port_t > 65535 ) { | 426 | if ( ! ok || port_t > 65535 ) { |
425 | KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); | 427 | KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); |
426 | return; | 428 | return; |
427 | } | 429 | } |
428 | Q_UINT16 port = port_t; | 430 | Q_UINT16 port = port_t; |
429 | //qDebug("port %d ", port); | 431 | //qDebug("port %d ", port); |
430 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); | 432 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); |
431 | mServerSocket->setFileName( defaultFileName() );//bbb | 433 | mServerSocket->setFileName( defaultFileName() );//bbb |
432 | if ( !mServerSocket->ok() ) { | 434 | if ( !mServerSocket->ok() ) { |
433 | QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); | 435 | QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); |
434 | delete mServerSocket; | 436 | delete mServerSocket; |
435 | mServerSocket = 0; | 437 | mServerSocket = 0; |
436 | return; | 438 | return; |
437 | } | 439 | } |
438 | mPrefs->mPassiveSyncAutoStart = autoStart; | 440 | mPrefs->mPassiveSyncAutoStart = autoStart; |
439 | if ( changed ) { | 441 | if ( changed ) { |
440 | mPrefs->writeConfig(); | 442 | mPrefs->writeConfig(); |
441 | } | 443 | } |
442 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); | 444 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); |
443 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); | 445 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); |
444 | connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) ); | 446 | connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) ); |
445 | connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) ); | 447 | connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) ); |
446 | } | 448 | } |
447 | void KSyncManager::displayErrorPort() | 449 | void KSyncManager::displayErrorPort() |
448 | { | 450 | { |
449 | KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); | 451 | KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); |
450 | } | 452 | } |
451 | void KSyncManager::syncLocalFile() | 453 | void KSyncManager::syncLocalFile() |
452 | { | 454 | { |
453 | 455 | ||
454 | QString fn =mPrefs->mLastSyncedLocalFile; | 456 | QString fn =mPrefs->mLastSyncedLocalFile; |
455 | QString ext; | 457 | QString ext; |
456 | 458 | ||
457 | switch(mTargetApp) | 459 | switch(mTargetApp) |
458 | { | 460 | { |
459 | case (KAPI): | 461 | case (KAPI): |
460 | ext = "(*.vcf)"; | 462 | ext = "(*.vcf)"; |
461 | break; | 463 | break; |
462 | case (KOPI): | 464 | case (KOPI): |
463 | ext = "(*.ics/*.vcs)"; | 465 | ext = "(*.ics/*.vcs)"; |
464 | break; | 466 | break; |
465 | case (PWMPI): | 467 | case (PWMPI): |
466 | ext = "(*.pwm)"; | 468 | ext = "(*.pwm)"; |
467 | break; | 469 | break; |
468 | default: | 470 | default: |
469 | qDebug("KSM::syncLocalFile: invalid apptype selected"); | 471 | qDebug("KSM::syncLocalFile: invalid apptype selected"); |
470 | break; | 472 | break; |
471 | 473 | ||
472 | } | 474 | } |
473 | 475 | ||
474 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 476 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
475 | if ( fn == "" ) | 477 | if ( fn == "" ) |
476 | return; | 478 | return; |
477 | if ( syncWithFile( fn, false ) ) { | 479 | if ( syncWithFile( fn, false ) ) { |
478 | qDebug("KSM::syncLocalFile() successful "); | 480 | qDebug("KSM::syncLocalFile() successful "); |
479 | } | 481 | } |
480 | 482 | ||
481 | } | 483 | } |
482 | 484 | ||
483 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 485 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
484 | { | 486 | { |
485 | bool ret = false; | 487 | bool ret = false; |
486 | QFileInfo info; | 488 | QFileInfo info; |
487 | info.setFile( fn ); | 489 | info.setFile( fn ); |
488 | QString mess; | 490 | QString mess; |
489 | if ( !info. exists() ) { | 491 | if ( !info. exists() ) { |
490 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 492 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
491 | QMessageBox::warning( mParent, i18n("Warning!"), | 493 | QMessageBox::warning( mParent, i18n("Warning!"), |
492 | mess ); | 494 | mess ); |
493 | return ret; | 495 | return ret; |
494 | } | 496 | } |
495 | int result = 0; | 497 | int result = 0; |
496 | if ( !quick ) { | 498 | if ( !quick ) { |
497 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 499 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
498 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 500 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
499 | mess, | 501 | mess, |
500 | i18n("Sync"), i18n("Cancel"), 0, | 502 | i18n("Sync"), i18n("Cancel"), 0, |
501 | 0, 1 ); | 503 | 0, 1 ); |
502 | if ( result ) | 504 | if ( result ) |
503 | return false; | 505 | return false; |
504 | } | 506 | } |
505 | if ( mAskForPreferences ) | 507 | if ( mAskForPreferences ) |
506 | if ( !edit_sync_options()) { | 508 | if ( !edit_sync_options()) { |
507 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 509 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
508 | return false; | 510 | return false; |
509 | } | 511 | } |
510 | if ( result == 0 ) { | 512 | if ( result == 0 ) { |
511 | //qDebug("Now sycing ... "); | 513 | //qDebug("Now sycing ... "); |
512 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) ) | 514 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) ) |
513 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); | 515 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
514 | else | 516 | else |
515 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 517 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
516 | if ( ! quick ) | 518 | if ( ! quick ) |
517 | mPrefs->mLastSyncedLocalFile = fn; | 519 | mPrefs->mLastSyncedLocalFile = fn; |
518 | } | 520 | } |
519 | return ret; | 521 | return ret; |
520 | } | 522 | } |
521 | 523 | ||
522 | void KSyncManager::quickSyncLocalFile() | 524 | void KSyncManager::quickSyncLocalFile() |
523 | { | 525 | { |
524 | 526 | ||
525 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { | 527 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { |
526 | qDebug("KSM::quick syncLocalFile() successful "); | 528 | qDebug("KSM::quick syncLocalFile() successful "); |
527 | 529 | ||
528 | } | 530 | } |
529 | } | 531 | } |
530 | 532 | ||
531 | void KSyncManager::multiSync( bool askforPrefs ) | 533 | void KSyncManager::multiSync( bool askforPrefs ) |
532 | { | 534 | { |
533 | if (blockSave()) | 535 | if (blockSave()) |
534 | return; | 536 | return; |
535 | setBlockSave(true); | 537 | setBlockSave(true); |
536 | mCurrentResourceLocal = ""; | 538 | mCurrentResourceLocal = ""; |
537 | if ( askforPrefs ) { | 539 | if ( askforPrefs ) { |
538 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 540 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
539 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), | 541 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), |
540 | question, | 542 | question, |
541 | i18n("Yes"), i18n("No"), | 543 | i18n("Yes"), i18n("No"), |
542 | 0, 0 ) != 0 ) { | 544 | 0, 0 ) != 0 ) { |
543 | setBlockSave(false); | 545 | setBlockSave(false); |
544 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); | 546 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
545 | return; | 547 | return; |
546 | } | 548 | } |
547 | } | 549 | } |
548 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 550 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
549 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 551 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; |
550 | if ( askforPrefs ) { | 552 | if ( askforPrefs ) { |
551 | if ( !edit_sync_options()) { | 553 | if ( !edit_sync_options()) { |
552 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); | 554 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); |
553 | return; | 555 | return; |
554 | } | 556 | } |
555 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 557 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
556 | } | 558 | } |
557 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); | 559 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
558 | qApp->processEvents(); | 560 | qApp->processEvents(); |
559 | int num = ringSync() ; | 561 | int num = ringSync() ; |
560 | if ( num > 1 ) | 562 | if ( num > 1 ) |
561 | ringSync(); | 563 | ringSync(); |
562 | setBlockSave(false); | 564 | setBlockSave(false); |
563 | if ( num ) | 565 | if ( num ) |
564 | emit save(); | 566 | emit save(); |
565 | if ( num ) | 567 | if ( num ) |
566 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); | 568 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); |
567 | else | 569 | else |
568 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 570 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
569 | return; | 571 | return; |
570 | } | 572 | } |
571 | 573 | ||
572 | int KSyncManager::ringSync() | 574 | int KSyncManager::ringSync() |
573 | { | 575 | { |
574 | emit multiResourceSyncStart( false ); | 576 | emit multiResourceSyncStart( false ); |
575 | int syncedProfiles = 0; | 577 | int syncedProfiles = 0; |
576 | unsigned int i; | 578 | unsigned int i; |
577 | QTime timer; | 579 | QTime timer; |
578 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 580 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
579 | QStringList syncProfileNames = mSyncProfileNames; | 581 | QStringList syncProfileNames = mSyncProfileNames; |
580 | KSyncProfile* temp = new KSyncProfile (); | 582 | KSyncProfile* temp = new KSyncProfile (); |
581 | mAskForPreferences = false; | 583 | mAskForPreferences = false; |
582 | mCurrentResourceLocal = ""; | 584 | mCurrentResourceLocal = ""; |
583 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 585 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
584 | mCurrentSyncProfile = i; | 586 | mCurrentSyncProfile = i; |
585 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 587 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
586 | temp->readConfig(&config); | 588 | temp->readConfig(&config); |
587 | 589 | ||
588 | bool includeInRingSync = false; | 590 | bool includeInRingSync = false; |
589 | switch(mTargetApp) | 591 | switch(mTargetApp) |
590 | { | 592 | { |
591 | case (KAPI): | 593 | case (KAPI): |
592 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 594 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
593 | break; | 595 | break; |
594 | case (KOPI): | 596 | case (KOPI): |
595 | includeInRingSync = temp->getIncludeInRingSync(); | 597 | includeInRingSync = temp->getIncludeInRingSync(); |
596 | break; | 598 | break; |
597 | case (PWMPI): | 599 | case (PWMPI): |
598 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 600 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
599 | break; | 601 | break; |
600 | default: | 602 | default: |
601 | qDebug("KSM::ringSync: invalid apptype selected"); | 603 | qDebug("KSM::ringSync: invalid apptype selected"); |
602 | break; | 604 | break; |
603 | 605 | ||
604 | } | 606 | } |
605 | 607 | ||
606 | 608 | ||
607 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 609 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
608 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 610 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
609 | ++syncedProfiles; | 611 | ++syncedProfiles; |
610 | mSyncWithDesktop = false; | 612 | mSyncWithDesktop = false; |
611 | // mAskForPreferences = temp->getAskForPreferences(); | 613 | // mAskForPreferences = temp->getAskForPreferences(); |
612 | mWriteBackFile = temp->getWriteBackFile(); | 614 | mWriteBackFile = temp->getWriteBackFile(); |
613 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 615 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
614 | mIsKapiFile = temp->getIsKapiFile(); | 616 | mIsKapiFile = temp->getIsKapiFile(); |
615 | mWriteBackInFuture = 0; | 617 | mWriteBackInFuture = 0; |
616 | if ( temp->getWriteBackFuture() ) { | 618 | if ( temp->getWriteBackFuture() ) { |
617 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 619 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
618 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); | 620 | mWriteBackInPast = temp->getWriteBackPastWeeks( ); |
619 | } | 621 | } |
620 | mFilterInCal = temp->getFilterInCal(); | 622 | mFilterInCal = temp->getFilterInCal(); |
621 | mFilterOutCal = temp->getFilterOutCal(); | 623 | mFilterOutCal = temp->getFilterOutCal(); |
622 | mFilterInAB = temp->getFilterInAB(); | 624 | mFilterInAB = temp->getFilterInAB(); |
623 | mFilterOutAB = temp->getFilterOutAB(); | 625 | mFilterOutAB = temp->getFilterOutAB(); |
624 | mShowSyncSummary = false; | 626 | mShowSyncSummary = false; |
625 | mCurrentSyncDevice = syncProfileNames[i] ; | 627 | mCurrentSyncDevice = syncProfileNames[i] ; |
626 | mCurrentSyncName = mLocalMachineName; | 628 | mCurrentSyncName = mLocalMachineName; |
627 | if ( i == 0 ) { | 629 | if ( i == 0 ) { |
628 | mIsKapiFile = false; | 630 | mIsKapiFile = false; |
629 | #ifdef DESKTOP_VERSION | 631 | #ifdef DESKTOP_VERSION |
630 | syncKDE(); | 632 | syncKDE(); |
631 | #else | 633 | #else |
632 | syncSharp(); | 634 | syncSharp(); |
633 | #endif | 635 | #endif |
634 | } else { | 636 | } else { |
635 | if ( temp->getIsLocalFileSync() ) { | 637 | if ( temp->getIsLocalFileSync() ) { |
636 | switch(mTargetApp) | 638 | switch(mTargetApp) |
637 | { | 639 | { |
638 | case (KAPI): | 640 | case (KAPI): |
639 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 641 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
640 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 642 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
641 | break; | 643 | break; |
642 | case (KOPI): | 644 | case (KOPI): |
643 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 645 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
644 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 646 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
645 | break; | 647 | break; |
646 | case (PWMPI): | 648 | case (PWMPI): |
647 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 649 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
648 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 650 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
649 | break; | 651 | break; |
650 | default: | 652 | default: |
651 | qDebug("KSM: invalid apptype selected"); | 653 | qDebug("KSM: invalid apptype selected"); |
652 | break; | 654 | break; |
653 | } | 655 | } |
654 | } else { | 656 | } else { |
655 | if ( temp->getIsPhoneSync() ) { | 657 | if ( temp->getIsPhoneSync() ) { |
656 | mPhoneDevice = temp->getPhoneDevice( ) ; | 658 | mPhoneDevice = temp->getPhoneDevice( ) ; |
657 | mPhoneConnection = temp->getPhoneConnection( ); | 659 | mPhoneConnection = temp->getPhoneConnection( ); |
658 | mPhoneModel = temp->getPhoneModel( ); | 660 | mPhoneModel = temp->getPhoneModel( ); |
659 | syncPhone(); | 661 | syncPhone(); |
660 | } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) { | 662 | } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) { |
661 | mSpecificResources.clear(); | 663 | mSpecificResources.clear(); |
662 | if ( mTargetApp == KAPI ) { | 664 | if ( mTargetApp == KAPI ) { |
665 | if ( temp->getIsPiSyncSpec() ) | ||
666 | mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true ); | ||
663 | mPassWordPiSync = temp->getRemotePwAB(); | 667 | mPassWordPiSync = temp->getRemotePwAB(); |
664 | mActiveSyncPort = temp->getRemotePortAB(); | 668 | mActiveSyncPort = temp->getRemotePortAB(); |
665 | mActiveSyncIP = temp->getRemoteIPAB(); | 669 | mActiveSyncIP = temp->getRemoteIPAB(); |
666 | } else if ( mTargetApp == KOPI ) { | 670 | } else if ( mTargetApp == KOPI ) { |
667 | mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); | 671 | if ( temp->getIsPiSyncSpec() ) |
672 | mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); | ||
668 | mPassWordPiSync = temp->getRemotePw(); | 673 | mPassWordPiSync = temp->getRemotePw(); |
669 | mActiveSyncPort = temp->getRemotePort(); | 674 | mActiveSyncPort = temp->getRemotePort(); |
670 | mActiveSyncIP = temp->getRemoteIP(); | 675 | mActiveSyncIP = temp->getRemoteIP(); |
671 | } else { | 676 | } else { |
672 | mPassWordPiSync = temp->getRemotePwPWM(); | 677 | mPassWordPiSync = temp->getRemotePwPWM(); |
673 | mActiveSyncPort = temp->getRemotePortPWM(); | 678 | mActiveSyncPort = temp->getRemotePortPWM(); |
674 | mActiveSyncIP = temp->getRemoteIPPWM(); | 679 | mActiveSyncIP = temp->getRemoteIPPWM(); |
675 | } | 680 | } |
676 | syncPi(); | 681 | syncPi(); |
677 | while ( !mPisyncFinished ) { | 682 | while ( !mPisyncFinished ) { |
678 | //qDebug("waiting "); | 683 | //qDebug("waiting "); |
679 | qApp->processEvents(); | 684 | qApp->processEvents(); |
680 | } | 685 | } |
681 | timer.start(); | 686 | timer.start(); |
682 | while ( timer.elapsed () < 2000 ) { | 687 | while ( timer.elapsed () < 2000 ) { |
683 | qApp->processEvents(); | 688 | qApp->processEvents(); |
684 | } | 689 | } |
685 | } else | 690 | } else |
686 | syncRemote( temp, false ); | 691 | syncRemote( temp, false ); |
687 | 692 | ||
688 | } | 693 | } |
689 | } | 694 | } |
690 | timer.start(); | 695 | timer.start(); |
691 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 696 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
692 | while ( timer.elapsed () < 2000 ) { | 697 | while ( timer.elapsed () < 2000 ) { |
693 | qApp->processEvents(); | 698 | qApp->processEvents(); |
694 | #ifndef _WIN32_ | 699 | #ifndef _WIN32_ |
695 | sleep (1); | 700 | sleep (1); |
696 | #endif | 701 | #endif |
697 | } | 702 | } |
698 | 703 | ||
699 | } | 704 | } |
700 | 705 | ||
701 | } | 706 | } |
702 | delete temp; | 707 | delete temp; |
703 | return syncedProfiles; | 708 | return syncedProfiles; |
704 | } | 709 | } |
705 | 710 | ||
706 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | 711 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) |
707 | { | 712 | { |
708 | QString question; | 713 | QString question; |
709 | if ( ask ) { | 714 | if ( ask ) { |
710 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 715 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
711 | if ( QMessageBox::information( mParent, i18n("Sync"), | 716 | if ( QMessageBox::information( mParent, i18n("Sync"), |
712 | question, | 717 | question, |
713 | i18n("Yes"), i18n("No"), | 718 | i18n("Yes"), i18n("No"), |
714 | 0, 0 ) != 0 ) | 719 | 0, 0 ) != 0 ) |
715 | return; | 720 | return; |
716 | } | 721 | } |
717 | 722 | ||
718 | QString preCommand; | 723 | QString preCommand; |
719 | QString localTempFile; | 724 | QString localTempFile; |
720 | QString postCommand; | 725 | QString postCommand; |
721 | 726 | ||
722 | switch(mTargetApp) | 727 | switch(mTargetApp) |
723 | { | 728 | { |
724 | case (KAPI): | 729 | case (KAPI): |
725 | preCommand = prof->getPreSyncCommandAB(); | 730 | preCommand = prof->getPreSyncCommandAB(); |
726 | postCommand = prof->getPostSyncCommandAB(); | 731 | postCommand = prof->getPostSyncCommandAB(); |
727 | localTempFile = prof->getLocalTempFileAB(); | 732 | localTempFile = prof->getLocalTempFileAB(); |
728 | break; | 733 | break; |
729 | case (KOPI): | 734 | case (KOPI): |
730 | preCommand = prof->getPreSyncCommand(); | 735 | preCommand = prof->getPreSyncCommand(); |
731 | postCommand = prof->getPostSyncCommand(); | 736 | postCommand = prof->getPostSyncCommand(); |
732 | localTempFile = prof->getLocalTempFile(); | 737 | localTempFile = prof->getLocalTempFile(); |
733 | break; | 738 | break; |
734 | case (PWMPI): | 739 | case (PWMPI): |
735 | preCommand = prof->getPreSyncCommandPWM(); | 740 | preCommand = prof->getPreSyncCommandPWM(); |
736 | postCommand = prof->getPostSyncCommandPWM(); | 741 | postCommand = prof->getPostSyncCommandPWM(); |
737 | localTempFile = prof->getLocalTempFilePWM(); | 742 | localTempFile = prof->getLocalTempFilePWM(); |
738 | break; | 743 | break; |
739 | default: | 744 | default: |
740 | qDebug("KSM::syncRemote: invalid apptype selected"); | 745 | qDebug("KSM::syncRemote: invalid apptype selected"); |
741 | break; | 746 | break; |
742 | } | 747 | } |
743 | 748 | ||
744 | 749 | ||
745 | int fi; | 750 | int fi; |
746 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { | 751 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { |
747 | QString pwd = getPassword(); | 752 | QString pwd = getPassword(); |
748 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); | 753 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); |
749 | 754 | ||
750 | } | 755 | } |
751 | int maxlen = 30; | 756 | int maxlen = 30; |
752 | if ( QApplication::desktop()->width() > 320 ) | 757 | if ( QApplication::desktop()->width() > 320 ) |
753 | maxlen += 25; | 758 | maxlen += 25; |
754 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); | 759 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); |
755 | int result = system ( preCommand ); | 760 | int result = system ( preCommand ); |
756 | // 0 : okay | 761 | // 0 : okay |
757 | // 256: no such file or dir | 762 | // 256: no such file or dir |
758 | // | 763 | // |
759 | qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); | 764 | qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); |
760 | if ( result != 0 ) { | 765 | if ( result != 0 ) { |
761 | unsigned int len = maxlen; | 766 | unsigned int len = maxlen; |
762 | while ( len < preCommand.length() ) { | 767 | while ( len < preCommand.length() ) { |
763 | preCommand.insert( len , "\n" ); | 768 | preCommand.insert( len , "\n" ); |
764 | len += maxlen +2; | 769 | len += maxlen +2; |
765 | } | 770 | } |
766 | 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) ; | 771 | 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) ; |
767 | QMessageBox::information( mParent, i18n("Sync - ERROR"), | 772 | QMessageBox::information( mParent, i18n("Sync - ERROR"), |
768 | question, | 773 | question, |
769 | i18n("Okay!")) ; | 774 | i18n("Okay!")) ; |
770 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); | 775 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); |
771 | return; | 776 | return; |
772 | } | 777 | } |
773 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); | 778 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); |
774 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 779 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
775 | 780 | ||
776 | if ( syncWithFile( localTempFile, true ) ) { | 781 | if ( syncWithFile( localTempFile, true ) ) { |
777 | 782 | ||
778 | if ( mWriteBackFile ) { | 783 | if ( mWriteBackFile ) { |
779 | int fi; | 784 | int fi; |
780 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { | 785 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { |
781 | QString pwd = getPassword(); | 786 | QString pwd = getPassword(); |
782 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); | 787 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); |
783 | 788 | ||
784 | } | 789 | } |
785 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); | 790 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); |
786 | result = system ( postCommand ); | 791 | result = system ( postCommand ); |
787 | qDebug("KSM::Sync:Writing back file result: %d ", result); | 792 | qDebug("KSM::Sync:Writing back file result: %d ", result); |
788 | if ( result != 0 ) { | 793 | if ( result != 0 ) { |
789 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 794 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
790 | return; | 795 | return; |
791 | } else { | 796 | } else { |
792 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 797 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
793 | } | 798 | } |
794 | } | 799 | } |
795 | } | 800 | } |
796 | return; | 801 | return; |
797 | } | 802 | } |
798 | bool KSyncManager::edit_pisync_options() | 803 | bool KSyncManager::edit_pisync_options() |
799 | { | 804 | { |
800 | QDialog dia( mParent, "dia", true ); | 805 | QDialog dia( mParent, "dia", true ); |
801 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); | 806 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); |
802 | QVBoxLayout lay ( &dia ); | 807 | QVBoxLayout lay ( &dia ); |
803 | lay.setSpacing( 5 ); | 808 | lay.setSpacing( 5 ); |
804 | lay.setMargin( 3 ); | 809 | lay.setMargin( 3 ); |
805 | QLabel lab1 ( i18n("Password for remote access:"), &dia); | 810 | QLabel lab1 ( i18n("Password for remote access:"), &dia); |
806 | lay.addWidget( &lab1 ); | 811 | lay.addWidget( &lab1 ); |
807 | QLineEdit le1 (&dia ); | 812 | QLineEdit le1 (&dia ); |
808 | lay.addWidget( &le1 ); | 813 | lay.addWidget( &le1 ); |
809 | QLabel lab2 ( i18n("Remote IP address:"), &dia); | 814 | QLabel lab2 ( i18n("Remote IP address:"), &dia); |
810 | lay.addWidget( &lab2 ); | 815 | lay.addWidget( &lab2 ); |
811 | QLineEdit le2 (&dia ); | 816 | QLineEdit le2 (&dia ); |
812 | lay.addWidget( &le2 ); | 817 | lay.addWidget( &le2 ); |
813 | QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia); | 818 | QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia); |
814 | lay.addWidget( &lab3 ); | 819 | lay.addWidget( &lab3 ); |
815 | QLineEdit le3 (&dia ); | 820 | QLineEdit le3 (&dia ); |
816 | lay.addWidget( &le3 ); | 821 | lay.addWidget( &le3 ); |
817 | QPushButton pb ( "OK", &dia); | 822 | QPushButton pb ( "OK", &dia); |
818 | lay.addWidget( &pb ); | 823 | lay.addWidget( &pb ); |
819 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 824 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
820 | le1.setText( mPassWordPiSync ); | 825 | le1.setText( mPassWordPiSync ); |
821 | le2.setText( mActiveSyncIP ); | 826 | le2.setText( mActiveSyncIP ); |
822 | le3.setText( mActiveSyncPort ); | 827 | le3.setText( mActiveSyncPort ); |
823 | if ( dia.exec() ) { | 828 | if ( dia.exec() ) { |
824 | mPassWordPiSync = le1.text(); | 829 | mPassWordPiSync = le1.text(); |
825 | mActiveSyncPort = le3.text(); | 830 | mActiveSyncPort = le3.text(); |
826 | mActiveSyncIP = le2.text(); | 831 | mActiveSyncIP = le2.text(); |
827 | return true; | 832 | return true; |
828 | } | 833 | } |
829 | return false; | 834 | return false; |
830 | } | 835 | } |
831 | bool KSyncManager::edit_sync_options() | 836 | bool KSyncManager::edit_sync_options() |
832 | { | 837 | { |
833 | 838 | ||
834 | QDialog dia( mParent, "dia", true ); | 839 | QDialog dia( mParent, "dia", true ); |
835 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 840 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
836 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 841 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
837 | QVBoxLayout lay ( &dia ); | 842 | QVBoxLayout lay ( &dia ); |
838 | lay.setSpacing( 2 ); | 843 | lay.setSpacing( 2 ); |
839 | lay.setMargin( 3 ); | 844 | lay.setMargin( 3 ); |
840 | lay.addWidget(&gr); | 845 | lay.addWidget(&gr); |
841 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 846 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
842 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 847 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
843 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 848 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
844 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 849 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
845 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 850 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
846 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 851 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
847 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 852 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
848 | QPushButton pb ( "OK", &dia); | 853 | QPushButton pb ( "OK", &dia); |
849 | lay.addWidget( &pb ); | 854 | lay.addWidget( &pb ); |
850 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 855 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
851 | switch ( mSyncAlgoPrefs ) { | 856 | switch ( mSyncAlgoPrefs ) { |
852 | case 0: | 857 | case 0: |
853 | loc.setChecked( true); | 858 | loc.setChecked( true); |
854 | break; | 859 | break; |
855 | case 1: | 860 | case 1: |
856 | rem.setChecked( true ); | 861 | rem.setChecked( true ); |
857 | break; | 862 | break; |
858 | case 2: | 863 | case 2: |
859 | newest.setChecked( true); | 864 | newest.setChecked( true); |
860 | break; | 865 | break; |
861 | case 3: | 866 | case 3: |
862 | ask.setChecked( true); | 867 | ask.setChecked( true); |
863 | break; | 868 | break; |
864 | case 4: | 869 | case 4: |
865 | f_loc.setChecked( true); | 870 | f_loc.setChecked( true); |
866 | break; | 871 | break; |
867 | case 5: | 872 | case 5: |
868 | f_rem.setChecked( true); | 873 | f_rem.setChecked( true); |
869 | break; | 874 | break; |
870 | case 6: | 875 | case 6: |
871 | // both.setChecked( true); | 876 | // both.setChecked( true); |
872 | break; | 877 | break; |
873 | default: | 878 | default: |
874 | break; | 879 | break; |
875 | } | 880 | } |
876 | if ( dia.exec() ) { | 881 | if ( dia.exec() ) { |
877 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 882 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
878 | return true; | 883 | return true; |
879 | } | 884 | } |
880 | return false; | 885 | return false; |
881 | } | 886 | } |
882 | 887 | ||
883 | QString KSyncManager::getPassword( ) | 888 | QString KSyncManager::getPassword( ) |
884 | { | 889 | { |
885 | QString retfile = ""; | 890 | QString retfile = ""; |
886 | QDialog dia ( mParent, "input-dialog", true ); | 891 | QDialog dia ( mParent, "input-dialog", true ); |
887 | QLineEdit lab ( &dia ); | 892 | QLineEdit lab ( &dia ); |
888 | lab.setEchoMode( QLineEdit::Password ); | 893 | lab.setEchoMode( QLineEdit::Password ); |
889 | QVBoxLayout lay( &dia ); | 894 | QVBoxLayout lay( &dia ); |
890 | lay.setMargin(7); | 895 | lay.setMargin(7); |
891 | lay.setSpacing(7); | 896 | lay.setSpacing(7); |
892 | lay.addWidget( &lab); | 897 | lay.addWidget( &lab); |
893 | dia.setFixedSize( 230,50 ); | 898 | dia.setFixedSize( 230,50 ); |
894 | dia.setCaption( i18n("Enter password") ); | 899 | dia.setCaption( i18n("Enter password") ); |
895 | QPushButton pb ( "OK", &dia); | 900 | QPushButton pb ( "OK", &dia); |
896 | lay.addWidget( &pb ); | 901 | lay.addWidget( &pb ); |
897 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 902 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
898 | dia.show(); | 903 | dia.show(); |
899 | int res = dia.exec(); | 904 | int res = dia.exec(); |
900 | if ( res ) | 905 | if ( res ) |
901 | retfile = lab.text(); | 906 | retfile = lab.text(); |
902 | dia.hide(); | 907 | dia.hide(); |
903 | qApp->processEvents(); | 908 | qApp->processEvents(); |
904 | return retfile; | 909 | return retfile; |
905 | 910 | ||
906 | } | 911 | } |
907 | 912 | ||
908 | 913 | ||
909 | void KSyncManager::confSync() | 914 | void KSyncManager::confSync() |
910 | { | 915 | { |
911 | static KSyncPrefsDialog* sp = 0; | 916 | static KSyncPrefsDialog* sp = 0; |
912 | if ( ! sp ) { | 917 | if ( ! sp ) { |
913 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 918 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
914 | } | 919 | } |
915 | sp->usrReadConfig(); | 920 | sp->usrReadConfig(); |
916 | #ifndef DESKTOP_VERSION | 921 | #ifndef DESKTOP_VERSION |
917 | sp->showMaximized(); | 922 | sp->showMaximized(); |
918 | #else | 923 | #else |
919 | sp->show(); | 924 | sp->show(); |
920 | #endif | 925 | #endif |
921 | sp->exec(); | 926 | sp->exec(); |
922 | QStringList oldSyncProfileNames = mSyncProfileNames; | 927 | QStringList oldSyncProfileNames = mSyncProfileNames; |
923 | mSyncProfileNames = sp->getSyncProfileNames(); | 928 | mSyncProfileNames = sp->getSyncProfileNames(); |
924 | mLocalMachineName = sp->getLocalMachineName (); | 929 | mLocalMachineName = sp->getLocalMachineName (); |
925 | uint ii; | 930 | uint ii; |
926 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { | 931 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { |
927 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) | 932 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) |
928 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); | 933 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); |
929 | } | 934 | } |
930 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 935 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
931 | } | 936 | } |
932 | void KSyncManager::syncKDE() | 937 | void KSyncManager::syncKDE() |
933 | { | 938 | { |
934 | mSyncWithDesktop = true; | 939 | mSyncWithDesktop = true; |
935 | emit save(); | 940 | emit save(); |
936 | switch(mTargetApp) | 941 | switch(mTargetApp) |
937 | { | 942 | { |
938 | case (KAPI): | 943 | case (KAPI): |
939 | { | 944 | { |
940 | #ifdef DESKTOP_VERSION | 945 | #ifdef DESKTOP_VERSION |
941 | QString command = "kdeabdump33"; | 946 | QString command = "kdeabdump33"; |
942 | QString commandfile = "kdeabdump33"; | 947 | QString commandfile = "kdeabdump33"; |
943 | QString commandpath = qApp->applicationDirPath () + "/"; | 948 | QString commandpath = qApp->applicationDirPath () + "/"; |
944 | #else | 949 | #else |
945 | QString command = "kdeabdump33"; | 950 | QString command = "kdeabdump33"; |
946 | QString commandfile = "kdeabdump33"; | 951 | QString commandfile = "kdeabdump33"; |
947 | QString commandpath = QDir::homeDirPath ()+"/"; | 952 | QString commandpath = QDir::homeDirPath ()+"/"; |
948 | #endif | 953 | #endif |
949 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 954 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
950 | command = commandfile; | 955 | command = commandfile; |
951 | else | 956 | else |
952 | command = commandpath+commandfile; | 957 | command = commandpath+commandfile; |
953 | 958 | ||
954 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; | 959 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; |
955 | int result = system ( command.latin1()); | 960 | int result = system ( command.latin1()); |
956 | qDebug("AB dump 33 command call result: %d ", result); | 961 | qDebug("AB dump 33 command call result: %d ", result); |
957 | if ( result != 0 ) { | 962 | if ( result != 0 ) { |
958 | qDebug("Calling AB dump version 33 failed. Trying 34... "); | 963 | qDebug("Calling AB dump version 33 failed. Trying 34... "); |
959 | commandfile = "kdeabdump34"; | 964 | commandfile = "kdeabdump34"; |
960 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 965 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
961 | command = commandfile; | 966 | command = commandfile; |
962 | else | 967 | else |
963 | command = commandpath+commandfile; | 968 | command = commandpath+commandfile; |
964 | result = system ( command.latin1()); | 969 | result = system ( command.latin1()); |
965 | qDebug("AB dump 34 command call result: %d ", result); | 970 | qDebug("AB dump 34 command call result: %d ", result); |
966 | if ( result != 0 ) { | 971 | if ( result != 0 ) { |
967 | KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); | 972 | KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); |
968 | return; | 973 | return; |
969 | } | 974 | } |
970 | } | 975 | } |
971 | if ( syncWithFile( fileName,true ) ) { | 976 | if ( syncWithFile( fileName,true ) ) { |
972 | if ( mWriteBackFile ) { | 977 | if ( mWriteBackFile ) { |
973 | command += " --read"; | 978 | command += " --read"; |
974 | system ( command.latin1()); | 979 | system ( command.latin1()); |
975 | } | 980 | } |
976 | } | 981 | } |
977 | 982 | ||
978 | } | 983 | } |
979 | break; | 984 | break; |
980 | case (KOPI): | 985 | case (KOPI): |
981 | { | 986 | { |
982 | #ifdef DESKTOP_VERSION | 987 | #ifdef DESKTOP_VERSION |
983 | QString command = "kdecaldump33"; | 988 | QString command = "kdecaldump33"; |
984 | QString commandfile = "kdecaldump33"; | 989 | QString commandfile = "kdecaldump33"; |
985 | QString commandpath = qApp->applicationDirPath () + "/"; | 990 | QString commandpath = qApp->applicationDirPath () + "/"; |
986 | #else | 991 | #else |
987 | QString command = "kdecaldump33"; | 992 | QString command = "kdecaldump33"; |
988 | QString commandfile = "kdecaldump33"; | 993 | QString commandfile = "kdecaldump33"; |
989 | QString commandpath = QDir::homeDirPath ()+"/"; | 994 | QString commandpath = QDir::homeDirPath ()+"/"; |
990 | #endif | 995 | #endif |
991 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 996 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
992 | command = commandfile; | 997 | command = commandfile; |
993 | else | 998 | else |
994 | command = commandpath+commandfile; | 999 | command = commandpath+commandfile; |
995 | 1000 | ||
996 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | 1001 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; |
997 | int result = system ( command.latin1()); | 1002 | int result = system ( command.latin1()); |
998 | qDebug("Cal dump 33 command call result result: %d ", result); | 1003 | qDebug("Cal dump 33 command call result result: %d ", result); |
999 | if ( result != 0 ) { | 1004 | if ( result != 0 ) { |
1000 | qDebug("Calling CAL dump version 33 failed. Trying 34... "); | 1005 | qDebug("Calling CAL dump version 33 failed. Trying 34... "); |
1001 | commandfile = "kdecaldump34"; | 1006 | commandfile = "kdecaldump34"; |
1002 | if ( ! QFile::exists ( commandpath+commandfile ) ) | 1007 | if ( ! QFile::exists ( commandpath+commandfile ) ) |
1003 | command = commandfile; | 1008 | command = commandfile; |
1004 | else | 1009 | else |
1005 | command = commandpath+commandfile; | 1010 | command = commandpath+commandfile; |
1006 | result = system ( command.latin1()); | 1011 | result = system ( command.latin1()); |
1007 | qDebug("Cal dump 34 command call result result: %d ", result); | 1012 | qDebug("Cal dump 34 command call result result: %d ", result); |
1008 | if ( result != 0 ) { | 1013 | if ( result != 0 ) { |
1009 | KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); | 1014 | KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); |
1010 | return; | 1015 | return; |
1011 | } | 1016 | } |
1012 | } | 1017 | } |
1013 | if ( syncWithFile( fileName,true ) ) { | 1018 | if ( syncWithFile( fileName,true ) ) { |
1014 | if ( mWriteBackFile ) { | 1019 | if ( mWriteBackFile ) { |
1015 | command += " --read"; | 1020 | command += " --read"; |
1016 | system ( command.latin1()); | 1021 | system ( command.latin1()); |
1017 | } | 1022 | } |
1018 | } | 1023 | } |
1019 | 1024 | ||
1020 | } | 1025 | } |
1021 | break; | 1026 | break; |
1022 | case (PWMPI): | 1027 | case (PWMPI): |
1023 | 1028 | ||
1024 | break; | 1029 | break; |
1025 | default: | 1030 | default: |
1026 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); | 1031 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); |
1027 | break; | 1032 | break; |
1028 | 1033 | ||
1029 | } | 1034 | } |
1030 | } | 1035 | } |
1031 | 1036 | ||
1032 | void KSyncManager::syncSharp() | 1037 | void KSyncManager::syncSharp() |
1033 | { | 1038 | { |
1034 | 1039 | ||
1035 | if ( ! syncExternalApplication("sharp") ) | 1040 | if ( ! syncExternalApplication("sharp") ) |
1036 | qDebug("KSM::ERROR sync sharp "); | 1041 | qDebug("KSM::ERROR sync sharp "); |
1037 | } | 1042 | } |
1038 | 1043 | ||
1039 | bool KSyncManager::syncExternalApplication(QString resource) | 1044 | bool KSyncManager::syncExternalApplication(QString resource) |
1040 | { | 1045 | { |
1041 | 1046 | ||
1042 | emit save(); | 1047 | emit save(); |
1043 | 1048 | ||
1044 | if ( mAskForPreferences ) | 1049 | if ( mAskForPreferences ) |
1045 | if ( !edit_sync_options()) { | 1050 | if ( !edit_sync_options()) { |
1046 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 1051 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
1047 | return false; | 1052 | return false; |
1048 | } | 1053 | } |
1049 | 1054 | ||
1050 | qDebug("KSM::Sync extern %s", resource.latin1()); | 1055 | qDebug("KSM::Sync extern %s", resource.latin1()); |
1051 | 1056 | ||
1052 | bool syncOK = mImplementation->syncExternal(this, resource); | 1057 | bool syncOK = mImplementation->syncExternal(this, resource); |
1053 | 1058 | ||
1054 | return syncOK; | 1059 | return syncOK; |
1055 | 1060 | ||
1056 | } | 1061 | } |
1057 | 1062 | ||
1058 | void KSyncManager::syncPhone() | 1063 | void KSyncManager::syncPhone() |
1059 | { | 1064 | { |
1060 | 1065 | ||
1061 | syncExternalApplication("phone"); | 1066 | syncExternalApplication("phone"); |
1062 | 1067 | ||
1063 | } | 1068 | } |
1064 | 1069 | ||
1065 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 1070 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
1066 | { | 1071 | { |
1067 | if (!bar->isVisible()) | 1072 | if (!bar->isVisible()) |
1068 | { | 1073 | { |
1069 | int w = 300; | 1074 | int w = 300; |
1070 | if ( QApplication::desktop()->width() < 320 ) | 1075 | if ( QApplication::desktop()->width() < 320 ) |
1071 | w = 220; | 1076 | w = 220; |
1072 | int h = bar->sizeHint().height() ; | 1077 | int h = bar->sizeHint().height() ; |
1073 | int dw = QApplication::desktop()->width(); | 1078 | int dw = QApplication::desktop()->width(); |
1074 | int dh = QApplication::desktop()->height(); | 1079 | int dh = QApplication::desktop()->height(); |
1075 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1080 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1076 | bar->setCaption (caption); | 1081 | bar->setCaption (caption); |
1077 | bar->setTotalSteps ( total ) ; | 1082 | bar->setTotalSteps ( total ) ; |
1078 | bar->show(); | 1083 | bar->show(); |
1079 | } | 1084 | } |
1080 | bar->raise(); | 1085 | bar->raise(); |
1081 | bar->setProgress( percentage ); | 1086 | bar->setProgress( percentage ); |
1082 | qApp->processEvents(); | 1087 | qApp->processEvents(); |
1083 | } | 1088 | } |
1084 | 1089 | ||
1085 | void KSyncManager::hideProgressBar() | 1090 | void KSyncManager::hideProgressBar() |
1086 | { | 1091 | { |
1087 | bar->hide(); | 1092 | bar->hide(); |
1088 | qApp->processEvents(); | 1093 | qApp->processEvents(); |
1089 | } | 1094 | } |
1090 | 1095 | ||
1091 | bool KSyncManager::isProgressBarCanceled() | 1096 | bool KSyncManager::isProgressBarCanceled() |
1092 | { | 1097 | { |
1093 | return !bar->isVisible(); | 1098 | return !bar->isVisible(); |
1094 | } | 1099 | } |
1095 | 1100 | ||
1096 | QString KSyncManager::syncFileName() | 1101 | QString KSyncManager::syncFileName() |
1097 | { | 1102 | { |
1098 | 1103 | ||
1099 | QString fn = "tempfile"; | 1104 | QString fn = "tempfile"; |
1100 | switch(mTargetApp) | 1105 | switch(mTargetApp) |
1101 | { | 1106 | { |
1102 | case (KAPI): | 1107 | case (KAPI): |
1103 | fn = "tempsyncab.vcf"; | 1108 | fn = "tempsyncab.vcf"; |
1104 | break; | 1109 | break; |
1105 | case (KOPI): | 1110 | case (KOPI): |
1106 | fn = "tempsynccal.ics"; | 1111 | fn = "tempsynccal.ics"; |
1107 | break; | 1112 | break; |
1108 | case (PWMPI): | 1113 | case (PWMPI): |
1109 | fn = "tempsyncpw.pwm"; | 1114 | fn = "tempsyncpw.pwm"; |
1110 | break; | 1115 | break; |
1111 | default: | 1116 | default: |
1112 | break; | 1117 | break; |
1113 | } | 1118 | } |
1114 | #ifdef DESKTOP_VERSION | 1119 | #ifdef DESKTOP_VERSION |
1115 | return locateLocal( "tmp", fn ); | 1120 | return locateLocal( "tmp", fn ); |
1116 | #else | 1121 | #else |
1117 | return (QString( "/tmp/" )+ fn ); | 1122 | return (QString( "/tmp/" )+ fn ); |
1118 | #endif | 1123 | #endif |
1119 | } | 1124 | } |
1120 | 1125 | ||
1121 | void KSyncManager::syncPi() | 1126 | void KSyncManager::syncPi() |
1122 | { | 1127 | { |
1123 | mIsKapiFile = true; | 1128 | mIsKapiFile = true; |
1124 | mPisyncFinished = false; | 1129 | mPisyncFinished = false; |
1125 | qApp->processEvents(); | 1130 | qApp->processEvents(); |
1126 | if ( mAskForPreferences ) | 1131 | if ( mAskForPreferences ) |
1127 | if ( !edit_pisync_options()) { | 1132 | if ( !edit_pisync_options()) { |
1128 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 1133 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
1129 | mPisyncFinished = true; | 1134 | mPisyncFinished = true; |
1130 | return; | 1135 | return; |
1131 | } | 1136 | } |
1132 | bool ok; | 1137 | bool ok; |
1133 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 1138 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
1134 | if ( ! ok ) { | 1139 | if ( ! ok ) { |
1135 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 1140 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
1136 | mPisyncFinished = true; | 1141 | mPisyncFinished = true; |
1137 | return; | 1142 | return; |
1138 | } | 1143 | } |
1139 | mCurrentResourceLocal = ""; | 1144 | mCurrentResourceLocal = ""; |
1140 | mCurrentResourceRemote = ""; | 1145 | mCurrentResourceRemote = ""; |
1141 | if ( mSpecificResources.count() ) { | 1146 | if ( mSpecificResources.count() ) { |
1142 | uint lastSyncRes = mSpecificResources.count()/2; | 1147 | uint lastSyncRes = mSpecificResources.count()/2; |
1143 | int ccc = mSpecificResources.count()-1; | 1148 | int ccc = mSpecificResources.count()-1; |
1144 | while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) { | 1149 | while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) { |
1145 | --ccc; | 1150 | --ccc; |
1146 | --lastSyncRes; | 1151 | --lastSyncRes; |
1147 | //qDebug ( "KSM: sync pi %d",ccc ); | 1152 | //qDebug ( "KSM: sync pi %d",ccc ); |
1148 | } | 1153 | } |
1149 | uint startLocal = 0; | 1154 | uint startLocal = 0; |
1150 | uint startRemote = mSpecificResources.count()/2; | 1155 | uint startRemote = mSpecificResources.count()/2; |
1151 | emit multiResourceSyncStart( true ); | 1156 | emit multiResourceSyncStart( true ); |
1152 | while ( startLocal < mSpecificResources.count()/2 ) { | 1157 | while ( startLocal < mSpecificResources.count()/2 ) { |
1153 | if ( startLocal+1 >= lastSyncRes ) | 1158 | if ( startLocal+1 >= lastSyncRes ) |
1154 | emit multiResourceSyncStart( false ); | 1159 | emit multiResourceSyncStart( false ); |
1155 | mPisyncFinished = false; | 1160 | mPisyncFinished = false; |
1156 | mCurrentResourceLocal = mSpecificResources[ startLocal ]; | 1161 | mCurrentResourceLocal = mSpecificResources[ startLocal ]; |
1157 | mCurrentResourceRemote = mSpecificResources[ startRemote ]; | 1162 | mCurrentResourceRemote = mSpecificResources[ startRemote ]; |
1158 | //qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); | 1163 | //qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); |
1159 | if ( !mCurrentResourceRemote.isEmpty() ) { | 1164 | if ( !mCurrentResourceRemote.isEmpty() ) { |
1160 | qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); | 1165 | qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); |
1161 | 1166 | ||
1162 | KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); | 1167 | KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); |
1163 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 1168 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
1164 | commandSocket->readFile( syncFileName() ); | 1169 | commandSocket->readFile( syncFileName() ); |
1165 | mParent->topLevelWidget()->setCaption( i18n("Syncing %1 <-> %2").arg( mCurrentResourceLocal ).arg( mCurrentResourceRemote ) ); | 1170 | mParent->topLevelWidget()->setCaption( i18n("Syncing %1 <-> %2").arg( mCurrentResourceLocal ).arg( mCurrentResourceRemote ) ); |
1166 | while ( !mPisyncFinished ) { | 1171 | while ( !mPisyncFinished ) { |
1167 | //qDebug("waiting "); | 1172 | //qDebug("waiting "); |
1168 | qApp->processEvents(); | 1173 | qApp->processEvents(); |
1169 | } | 1174 | } |
1170 | if ( startLocal+1 < mSpecificResources.count()/2 ) { | 1175 | if ( startLocal+1 < mSpecificResources.count()/2 ) { |
1171 | mParent->topLevelWidget()->setCaption( i18n("Waiting 2 secs before syncing next resource...") ); | 1176 | mParent->topLevelWidget()->setCaption( i18n("Waiting a second before syncing next resource...") ); |
1172 | QTime timer; | 1177 | QTime timer; |
1173 | timer.start(); | 1178 | timer.start(); |
1174 | while ( timer.elapsed () < 2000 ) { | 1179 | while ( timer.elapsed () < 1000 ) { |
1175 | qApp->processEvents(); | 1180 | qApp->processEvents(); |
1176 | } | 1181 | } |
1177 | } | 1182 | } |
1178 | } | 1183 | } |
1179 | ++startRemote; | 1184 | ++startRemote; |
1180 | ++startLocal; | 1185 | ++startLocal; |
1181 | mAskForPreferences = false; | 1186 | mAskForPreferences = false; |
1182 | } | 1187 | } |
1183 | mPisyncFinished = true; | 1188 | mPisyncFinished = true; |
1184 | } else { | 1189 | } else { |
1185 | KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); | 1190 | KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); |
1186 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 1191 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
1187 | commandSocket->readFile( syncFileName() ); | 1192 | commandSocket->readFile( syncFileName() ); |
1188 | } | 1193 | } |
1189 | } | 1194 | } |
1190 | 1195 | ||
1191 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 1196 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
1192 | { | 1197 | { |
1193 | //enum { success, errorW, errorR, quiet }; | 1198 | //enum { success, errorW, errorR, quiet }; |
1194 | 1199 | ||
1195 | 1200 | ||
1196 | 1201 | ||
1197 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || | 1202 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || |
1198 | state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { | 1203 | state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { |
1199 | if ( state == KCommandSocket::errorPW ) | 1204 | if ( state == KCommandSocket::errorPW ) |
1200 | mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); | 1205 | mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); |
1201 | else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) | 1206 | else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) |
1202 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 1207 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
1203 | else if ( state == KCommandSocket::errorCA ) | 1208 | else if ( state == KCommandSocket::errorCA ) |
1204 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); | 1209 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); |
1205 | else if ( state == KCommandSocket::errorFI ) | 1210 | else if ( state == KCommandSocket::errorFI ) |
1206 | mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); | 1211 | mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); |
1207 | else if ( state == KCommandSocket::errorED ) | 1212 | else if ( state == KCommandSocket::errorED ) |
1208 | mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); | 1213 | mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); |
1209 | else if ( state == KCommandSocket::errorUN ) | 1214 | else if ( state == KCommandSocket::errorUN ) |
1210 | mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); | 1215 | mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); |
1211 | delete s; | 1216 | delete s; |
1212 | if ( state == KCommandSocket::errorR ) { | 1217 | if ( state == KCommandSocket::errorR ) { |
1213 | KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); | 1218 | KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); |
1214 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1219 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1215 | commandSocket->sendStop(); | 1220 | commandSocket->sendStop(); |
1216 | } | 1221 | } |
1217 | mPisyncFinished = true; | 1222 | mPisyncFinished = true; |
1218 | return; | 1223 | return; |
1219 | 1224 | ||
1220 | } else if ( state == KCommandSocket::errorW ) { | 1225 | } else if ( state == KCommandSocket::errorW ) { |
1221 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); | 1226 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); |
1222 | mPisyncFinished = true; | 1227 | mPisyncFinished = true; |
1223 | 1228 | ||
1224 | } else if ( state == KCommandSocket::successR ) { | 1229 | } else if ( state == KCommandSocket::successR ) { |
1225 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 1230 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
1226 | 1231 | ||
1227 | } else if ( state == KCommandSocket::successW ) { | 1232 | } else if ( state == KCommandSocket::successW ) { |
1228 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); | 1233 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); |
1229 | mPisyncFinished = true; | 1234 | mPisyncFinished = true; |
1230 | } else if ( state == KCommandSocket::quiet ){ | 1235 | } else if ( state == KCommandSocket::quiet ){ |
1231 | qDebug("KSS: quiet "); | 1236 | qDebug("KSS: quiet "); |
1232 | mPisyncFinished = true; | 1237 | mPisyncFinished = true; |
1233 | } else { | 1238 | } else { |
1234 | qDebug("KSS: Error: unknown state: %d ", state); | 1239 | qDebug("KSS: Error: unknown state: %d ", state); |
1235 | mPisyncFinished = true; | 1240 | mPisyncFinished = true; |
1236 | } | 1241 | } |
1237 | 1242 | ||
1238 | delete s; | 1243 | delete s; |
1239 | } | 1244 | } |
1240 | 1245 | ||
1241 | void KSyncManager::readFileFromSocket() | 1246 | void KSyncManager::readFileFromSocket() |
1242 | { | 1247 | { |
1243 | QString fileName = syncFileName(); | 1248 | QString fileName = syncFileName(); |
1244 | bool syncOK = true; | 1249 | bool syncOK = true; |
1245 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); | 1250 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); |
1246 | if ( ! syncWithFile( fileName , true ) ) { | 1251 | if ( ! syncWithFile( fileName , true ) ) { |
1247 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); | 1252 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); |
1248 | syncOK = false; | 1253 | syncOK = false; |
1249 | } | 1254 | } |
1250 | KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote,mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); | 1255 | KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote,mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); |
1251 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1256 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1252 | if ( mWriteBackFile && syncOK ) { | 1257 | if ( mWriteBackFile && syncOK ) { |
1253 | mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); | 1258 | mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); |
1254 | commandSocket->writeFile( fileName ); | 1259 | commandSocket->writeFile( fileName ); |
1255 | } | 1260 | } |
1256 | else { | 1261 | else { |
1257 | commandSocket->sendStop(); | 1262 | commandSocket->sendStop(); |
1258 | if ( syncOK ) | 1263 | if ( syncOK ) |
1259 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 1264 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
1260 | mPisyncFinished = true; | 1265 | mPisyncFinished = true; |
1261 | } | 1266 | } |
1262 | } | 1267 | } |
1263 | 1268 | ||
1264 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 1269 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
1265 | { | 1270 | { |
1266 | mPendingConnect = 0; | 1271 | mPendingConnect = 0; |
1267 | mPassWord = pw; | 1272 | mPassWord = pw; |
1268 | mSocket = 0; | 1273 | mSocket = 0; |
1269 | mSyncActionDialog = 0; | 1274 | mSyncActionDialog = 0; |
1270 | blockRC = false; | 1275 | blockRC = false; |
1271 | mErrorMessage = 0; | 1276 | mErrorMessage = 0; |
1272 | } | 1277 | } |
1273 | void KServerSocket::waitForSocketFinish() | 1278 | void KServerSocket::waitForSocketFinish() |
1274 | { | 1279 | { |
1275 | if ( mSocket ) { | 1280 | if ( mSocket ) { |
1276 | //qDebug("KSS:: waiting for finish operation"); | 1281 | //qDebug("KSS:: waiting for finish operation"); |
1277 | QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); | 1282 | QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); |
1278 | return; | 1283 | return; |
1279 | } | 1284 | } |
1280 | mSocket = new QSocket( this ); | 1285 | mSocket = new QSocket( this ); |
1281 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 1286 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
1282 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 1287 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
1283 | mSocket->setSocket( mPendingConnect ); | 1288 | mSocket->setSocket( mPendingConnect ); |
1284 | mPendingConnect = 0; | 1289 | mPendingConnect = 0; |
1285 | } | 1290 | } |
1286 | void KServerSocket::newConnection ( int socket ) | 1291 | void KServerSocket::newConnection ( int socket ) |
1287 | { | 1292 | { |
1288 | // qDebug("KServerSocket:New connection %d ", socket); | 1293 | // qDebug("KServerSocket:New connection %d ", socket); |
1289 | if ( mPendingConnect ) { | 1294 | if ( mPendingConnect ) { |
1290 | qDebug("KSS::Error : new Connection"); | 1295 | qDebug("KSS::Error : new Connection"); |
1291 | return; | 1296 | return; |
1292 | } | 1297 | } |
1293 | if ( mSocket ) { | 1298 | if ( mSocket ) { |
1294 | mPendingConnect = socket; | 1299 | mPendingConnect = socket; |
1295 | QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); | 1300 | QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); |
1296 | return; | 1301 | return; |
1297 | qDebug("KSS::newConnection Socket deleted! "); | 1302 | qDebug("KSS::newConnection Socket deleted! "); |
1298 | delete mSocket; | 1303 | delete mSocket; |
1299 | mSocket = 0; | 1304 | mSocket = 0; |
1300 | } | 1305 | } |
1301 | mPendingConnect = 0; | 1306 | mPendingConnect = 0; |
1302 | mSocket = new QSocket( this ); | 1307 | mSocket = new QSocket( this ); |
1303 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 1308 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
1304 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 1309 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
1305 | mSocket->setSocket( socket ); | 1310 | mSocket->setSocket( socket ); |
1306 | } | 1311 | } |
1307 | 1312 | ||
1308 | void KServerSocket::discardClient() | 1313 | void KServerSocket::discardClient() |
1309 | { | 1314 | { |
1310 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1315 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1311 | } | 1316 | } |
1312 | void KServerSocket::deleteSocket() | 1317 | void KServerSocket::deleteSocket() |
1313 | { | 1318 | { |
1314 | //qDebug("KSS::deleteSocket"); | 1319 | //qDebug("KSS::deleteSocket"); |
1315 | if ( mSocket ) { | 1320 | if ( mSocket ) { |
1316 | delete mSocket; | 1321 | delete mSocket; |
1317 | mSocket = 0; | 1322 | mSocket = 0; |
1318 | } | 1323 | } |
1319 | if ( mErrorMessage ) | 1324 | if ( mErrorMessage ) |
1320 | QTimer::singleShot( 10, this , SLOT ( displayErrorMessage())); | 1325 | QTimer::singleShot( 10, this , SLOT ( displayErrorMessage())); |
1321 | } | 1326 | } |
1322 | void KServerSocket::readClient() | 1327 | void KServerSocket::readClient() |
1323 | { | 1328 | { |
1324 | if ( blockRC ) | 1329 | if ( blockRC ) |
1325 | return; | 1330 | return; |
1326 | if ( mSocket == 0 ) { | 1331 | if ( mSocket == 0 ) { |
1327 | qDebug("ERROR::KSS::readClient(): mSocket == 0 "); | 1332 | qDebug("ERROR::KSS::readClient(): mSocket == 0 "); |
1328 | return; | 1333 | return; |
1329 | } | 1334 | } |
1330 | if ( mErrorMessage ) { | 1335 | if ( mErrorMessage ) { |
1331 | mErrorMessage = 999; | 1336 | mErrorMessage = 999; |
1332 | error_connect("ERROR_ED\r\n\r\n"); | 1337 | error_connect("ERROR_ED\r\n\r\n"); |
1333 | return; | 1338 | return; |
1334 | } | 1339 | } |
1335 | mResource = ""; | 1340 | mResource = ""; |
1336 | mErrorMessage = 0; | 1341 | mErrorMessage = 0; |
1337 | //qDebug("KServerSocket::readClient()"); | 1342 | //qDebug("KServerSocket::readClient()"); |
1338 | if ( mSocket->canReadLine() ) { | 1343 | if ( mSocket->canReadLine() ) { |
1339 | QString line = mSocket->readLine(); | 1344 | QString line = mSocket->readLine(); |
1340 | //qDebug("KServerSocket readline: %s ", line.latin1()); | 1345 | //qDebug("KServerSocket readline: %s ", line.latin1()); |
1341 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); | 1346 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); |
1342 | if ( tokens[0] == "GET" ) { | 1347 | if ( tokens[0] == "GET" ) { |
1343 | if ( tokens[1] == mPassWord ) { | 1348 | if ( tokens[1] == mPassWord ) { |
1344 | //emit sendFile( mSocket ); | 1349 | //emit sendFile( mSocket ); |
1345 | bool ok = false; | 1350 | bool ok = false; |
1346 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); | 1351 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); |
1347 | if ( ok ) { | 1352 | if ( ok ) { |
1348 | KSyncManager::mRequestedSyncEvent = dt; | 1353 | KSyncManager::mRequestedSyncEvent = dt; |
1349 | } | 1354 | } |
1350 | else | 1355 | else |
1351 | KSyncManager::mRequestedSyncEvent = QDateTime(); | 1356 | KSyncManager::mRequestedSyncEvent = QDateTime(); |
1352 | mResource =tokens[3]; | 1357 | mResource =tokens[3]; |
1353 | send_file(); | 1358 | send_file(); |
1354 | } | 1359 | } |
1355 | else { | 1360 | else { |
1356 | mErrorMessage = 1; | 1361 | mErrorMessage = 1; |
1357 | error_connect("ERROR_PW\r\n\r\n"); | 1362 | error_connect("ERROR_PW\r\n\r\n"); |
1358 | } | 1363 | } |
1359 | } | 1364 | } |
1360 | if ( tokens[0] == "PUT" ) { | 1365 | if ( tokens[0] == "PUT" ) { |
1361 | if ( tokens[1] == mPassWord ) { | 1366 | if ( tokens[1] == mPassWord ) { |
1362 | //emit getFile( mSocket ); | 1367 | //emit getFile( mSocket ); |
1363 | blockRC = true; | 1368 | blockRC = true; |
1364 | mResource =tokens[2]; | 1369 | mResource =tokens[2]; |
1365 | get_file(); | 1370 | get_file(); |
1366 | } | 1371 | } |
1367 | else { | 1372 | else { |
1368 | mErrorMessage = 2; | 1373 | mErrorMessage = 2; |
1369 | error_connect("ERROR_PW\r\n\r\n"); | 1374 | error_connect("ERROR_PW\r\n\r\n"); |
1370 | end_connect(); | 1375 | end_connect(); |
1371 | } | 1376 | } |
1372 | } | 1377 | } |
1373 | if ( tokens[0] == "STOP" ) { | 1378 | if ( tokens[0] == "STOP" ) { |
1374 | //emit endConnect(); | 1379 | //emit endConnect(); |
1375 | end_connect(); | 1380 | end_connect(); |
1376 | } | 1381 | } |
1377 | } | 1382 | } |
1378 | } | 1383 | } |
1379 | void KServerSocket::displayErrorMessage() | 1384 | void KServerSocket::displayErrorMessage() |
1380 | { | 1385 | { |
1381 | if ( mErrorMessage == 1 ) { | 1386 | if ( mErrorMessage == 1 ) { |
1382 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error")); | 1387 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error")); |
1383 | mErrorMessage = 0; | 1388 | mErrorMessage = 0; |
1384 | } | 1389 | } |
1385 | else if ( mErrorMessage == 2 ) { | 1390 | else if ( mErrorMessage == 2 ) { |
1386 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); | 1391 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); |
1387 | mErrorMessage = 0; | 1392 | mErrorMessage = 0; |
1388 | } | 1393 | } |
1389 | } | 1394 | } |
1390 | void KServerSocket::error_connect( QString errmess ) | 1395 | void KServerSocket::error_connect( QString errmess ) |
1391 | { | 1396 | { |
1392 | QTextStream os( mSocket ); | 1397 | QTextStream os( mSocket ); |
1393 | os.setEncoding( QTextStream::Latin1 ); | 1398 | os.setEncoding( QTextStream::Latin1 ); |
1394 | os << errmess ; | 1399 | os << errmess ; |
1395 | mSocket->close(); | 1400 | mSocket->close(); |
1396 | if ( mSocket->state() == QSocket::Idle ) { | 1401 | if ( mSocket->state() == QSocket::Idle ) { |
1397 | QTimer::singleShot( 0, this , SLOT ( discardClient())); | 1402 | QTimer::singleShot( 0, this , SLOT ( discardClient())); |
1398 | } | 1403 | } |
1399 | } | 1404 | } |
1400 | void KServerSocket::end_connect() | 1405 | void KServerSocket::end_connect() |
1401 | { | 1406 | { |
1402 | delete mSyncActionDialog; | 1407 | delete mSyncActionDialog; |
1403 | mSyncActionDialog = 0; | 1408 | mSyncActionDialog = 0; |
1404 | } | 1409 | } |
1405 | void KServerSocket::send_file() | 1410 | void KServerSocket::send_file() |
1406 | { | 1411 | { |
1407 | //qDebug("MainWindow::sendFile(QSocket* s) "); | 1412 | //qDebug("MainWindow::sendFile(QSocket* s) "); |
1408 | if ( mSyncActionDialog ) | 1413 | if ( mSyncActionDialog ) |
1409 | delete mSyncActionDialog; | 1414 | delete mSyncActionDialog; |
1410 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | 1415 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); |
1411 | mSyncActionDialog->setCaption(i18n("Received sync request")); | 1416 | mSyncActionDialog->setCaption(i18n("Received sync request")); |
1412 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); | 1417 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); |
1413 | label->setAlignment ( Qt::AlignHCenter ); | 1418 | label->setAlignment ( Qt::AlignHCenter ); |
1414 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 1419 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
1415 | lay->addWidget( label); | 1420 | lay->addWidget( label); |
1416 | lay->setMargin(7); | 1421 | lay->setMargin(7); |
1417 | lay->setSpacing(7); | 1422 | lay->setSpacing(7); |
1418 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1423 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1419 | int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); | 1424 | int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); |
1420 | //secs = 333; | 1425 | //secs = 333; |
1421 | if ( secs < 0 ) | 1426 | if ( secs < 0 ) |
1422 | secs = secs * (-1); | 1427 | secs = secs * (-1); |
1423 | if ( secs > 30 ) | 1428 | if ( secs > 30 ) |
1424 | //if ( true ) | 1429 | //if ( true ) |
1425 | { | 1430 | { |
1426 | QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); | 1431 | QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); |
1427 | QLabel* label = new QLabel( warning, mSyncActionDialog ); | 1432 | QLabel* label = new QLabel( warning, mSyncActionDialog ); |
1428 | label->setAlignment ( Qt::AlignHCenter ); | 1433 | label->setAlignment ( Qt::AlignHCenter ); |
1429 | lay->addWidget( label); | 1434 | lay->addWidget( label); |
1430 | if ( secs > 180 ) | 1435 | if ( secs > 180 ) |