author | zautrix <zautrix> | 2004-10-06 20:51:01 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-06 20:51:01 (UTC) |
commit | 0afcfa29ace7bc5e42a11fae44301e1e8230a376 (patch) (unidiff) | |
tree | b54f85b19ace24219be1b845469444089cacc94f /libkdepim | |
parent | ed4675de07d947f55d2672c721599e3a0af1e24b (diff) | |
download | kdepimpi-0afcfa29ace7bc5e42a11fae44301e1e8230a376.zip kdepimpi-0afcfa29ace7bc5e42a11fae44301e1e8230a376.tar.gz kdepimpi-0afcfa29ace7bc5e42a11fae44301e1e8230a376.tar.bz2 |
some prefs cleanups
-rw-r--r-- | libkdepim/kpimprefs.h | 18 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 100 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 20 |
3 files changed, 69 insertions, 69 deletions
diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h index 01c57a3..6f92919 100644 --- a/libkdepim/kpimprefs.h +++ b/libkdepim/kpimprefs.h | |||
@@ -51,33 +51,17 @@ class KPimPrefs : public KPrefs | |||
51 | 51 | ||
52 | /** Write preferences to config file */ | 52 | /** Write preferences to config file */ |
53 | void usrWriteConfig(); | 53 | void usrWriteConfig(); |
54 | 54 | ||
55 | 55 | ||
56 | public: | 56 | public: |
57 | QStringList mCustomCategories; | 57 | QStringList mCustomCategories; |
58 | 58 | ||
59 | // sync stuff | 59 | |
60 | QString mLocalMachineName; | ||
61 | QStringList mExternSyncProfiles; | ||
62 | QStringList mSyncProfileNames; | ||
63 | bool mAskForPreferences; | ||
64 | bool mShowSyncSummary; | ||
65 | bool mShowSyncEvents; | ||
66 | bool mShowTodoInAgenda; | ||
67 | bool mWriteBackExistingOnly; | ||
68 | int mSyncAlgoPrefs; | ||
69 | int mRingSyncAlgoPrefs; | ||
70 | bool mWriteBackFile; | ||
71 | int mWriteBackInFuture; | ||
72 | QString mPhoneDevice; | ||
73 | QString mPhoneConnection; | ||
74 | QString mPhoneModel; | ||
75 | QString mLastSyncedLocalFile; // save! | ||
76 | 60 | ||
77 | 61 | ||
78 | protected: | 62 | protected: |
79 | virtual void setCategoryDefaults(); | 63 | virtual void setCategoryDefaults(); |
80 | 64 | ||
81 | 65 | ||
82 | 66 | ||
83 | }; | 67 | }; |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 07e6761..c0cc840 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -47,17 +47,17 @@ | |||
47 | #include <qlayout.h> | 47 | #include <qlayout.h> |
48 | 48 | ||
49 | #include <klocale.h> | 49 | #include <klocale.h> |
50 | #include <kglobal.h> | 50 | #include <kglobal.h> |
51 | #include <kconfig.h> | 51 | #include <kconfig.h> |
52 | #include <kfiledialog.h> | 52 | #include <kfiledialog.h> |
53 | 53 | ||
54 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) | 54 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) |
55 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs), mSyncMenu(syncmenu) | 55 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) |
56 | { | 56 | { |
57 | bar = new QProgressBar ( 1, 0 ); | 57 | bar = new QProgressBar ( 1, 0 ); |
58 | bar->setCaption (""); | 58 | bar->setCaption (""); |
59 | 59 | ||
60 | int w = 300; | 60 | int w = 300; |
61 | if ( QApplication::desktop()->width() < 320 ) | 61 | if ( QApplication::desktop()->width() < 320 ) |
62 | w = 220; | 62 | w = 220; |
63 | int h = bar->sizeHint().height() ; | 63 | int h = bar->sizeHint().height() ; |
@@ -81,17 +81,17 @@ void KSyncManager::fillSyncMenu() | |||
81 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 81 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
82 | mSyncMenu->insertSeparator(); | 82 | mSyncMenu->insertSeparator(); |
83 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); | 83 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); |
84 | mSyncMenu->insertSeparator(); | 84 | mSyncMenu->insertSeparator(); |
85 | 85 | ||
86 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 86 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
87 | config.setGroup("General"); | 87 | config.setGroup("General"); |
88 | QStringList prof = config.readListEntry("SyncProfileNames"); | 88 | QStringList prof = config.readListEntry("SyncProfileNames"); |
89 | mPrefs->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 89 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
90 | if ( prof.count() < 3 ) { | 90 | if ( prof.count() < 3 ) { |
91 | prof.clear(); | 91 | prof.clear(); |
92 | prof << i18n("Sharp_DTM"); | 92 | prof << i18n("Sharp_DTM"); |
93 | prof << i18n("Local_file"); | 93 | prof << i18n("Local_file"); |
94 | prof << i18n("Last_file"); | 94 | prof << i18n("Last_file"); |
95 | KSyncProfile* temp = new KSyncProfile (); | 95 | KSyncProfile* temp = new KSyncProfile (); |
96 | temp->setName( prof[0] ); | 96 | temp->setName( prof[0] ); |
97 | temp->writeConfig(&config); | 97 | temp->writeConfig(&config); |
@@ -100,34 +100,32 @@ void KSyncManager::fillSyncMenu() | |||
100 | temp->setName( prof[2] ); | 100 | temp->setName( prof[2] ); |
101 | temp->writeConfig(&config); | 101 | temp->writeConfig(&config); |
102 | config.setGroup("General"); | 102 | config.setGroup("General"); |
103 | config.writeEntry("SyncProfileNames",prof); | 103 | config.writeEntry("SyncProfileNames",prof); |
104 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 104 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
105 | config.sync(); | 105 | config.sync(); |
106 | delete temp; | 106 | delete temp; |
107 | } | 107 | } |
108 | mPrefs->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 108 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
109 | mPrefs->mSyncProfileNames = prof; | 109 | mSyncProfileNames = prof; |
110 | unsigned int i; | 110 | unsigned int i; |
111 | for ( i = 0; i < prof.count(); ++i ) { | 111 | for ( i = 0; i < prof.count(); ++i ) { |
112 | mSyncMenu->insertItem( prof[i], 1000+i ); | 112 | mSyncMenu->insertItem( prof[i], 1000+i ); |
113 | if ( i == 2 ) | 113 | if ( i == 2 ) |
114 | mSyncMenu->insertSeparator(); | 114 | mSyncMenu->insertSeparator(); |
115 | } | 115 | } |
116 | QDir app_dir; | 116 | QDir app_dir; |
117 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 117 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
118 | if ( mTargetApp == PWMPI) { | 118 | if ( mTargetApp == PWMPI) { |
119 | mSyncMenu->removeItem( 1000 ); | 119 | mSyncMenu->removeItem( 1000 ); |
120 | } | 120 | } |
121 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 121 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
122 | mSyncMenu->setItemEnabled( 1000, false ); | 122 | mSyncMenu->setItemEnabled( 1000, false ); |
123 | } | 123 | } |
124 | //probaly useless | ||
125 | //mView->setupExternSyncProfiles(); | ||
126 | } | 124 | } |
127 | 125 | ||
128 | void KSyncManager::slotSyncMenu( int action ) | 126 | void KSyncManager::slotSyncMenu( int action ) |
129 | { | 127 | { |
130 | //qDebug("syncaction %d ", action); | 128 | //qDebug("syncaction %d ", action); |
131 | if ( action == 0 ) { | 129 | if ( action == 0 ) { |
132 | 130 | ||
133 | // seems to be a Qt2 event handling bug | 131 | // seems to be a Qt2 event handling bug |
@@ -145,79 +143,79 @@ void KSyncManager::slotSyncMenu( int action ) | |||
145 | } | 143 | } |
146 | 144 | ||
147 | if (blockSave()) | 145 | if (blockSave()) |
148 | return; | 146 | return; |
149 | 147 | ||
150 | setBlockSave(true); | 148 | setBlockSave(true); |
151 | 149 | ||
152 | mCurrentSyncProfile = action - 1000 ; | 150 | mCurrentSyncProfile = action - 1000 ; |
153 | mCurrentSyncDevice = mPrefs->mSyncProfileNames[mCurrentSyncProfile] ; | 151 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
154 | mCurrentSyncName = mPrefs->mLocalMachineName ; | 152 | mCurrentSyncName = mLocalMachineName ; |
155 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 153 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
156 | KSyncProfile* temp = new KSyncProfile (); | 154 | KSyncProfile* temp = new KSyncProfile (); |
157 | temp->setName(mPrefs->mSyncProfileNames[mCurrentSyncProfile]); | 155 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
158 | temp->readConfig(&config); | 156 | temp->readConfig(&config); |
159 | mPrefs->mAskForPreferences = temp->getAskForPreferences(); | 157 | mAskForPreferences = temp->getAskForPreferences(); |
160 | mPrefs->mSyncAlgoPrefs = temp->getSyncPrefs(); | 158 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
161 | mPrefs->mWriteBackFile = temp->getWriteBackFile(); | 159 | mWriteBackFile = temp->getWriteBackFile(); |
162 | mPrefs->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 160 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
163 | mPrefs->mWriteBackInFuture = 0; | 161 | mWriteBackInFuture = 0; |
164 | if ( temp->getWriteBackFuture() ) | 162 | if ( temp->getWriteBackFuture() ) |
165 | mPrefs->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 163 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
166 | mPrefs->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 164 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
167 | if ( action == 1000 ) { | 165 | if ( action == 1000 ) { |
168 | syncSharp(); | 166 | syncSharp(); |
169 | 167 | ||
170 | } else if ( action == 1001 ) { | 168 | } else if ( action == 1001 ) { |
171 | syncLocalFile(); | 169 | syncLocalFile(); |
172 | 170 | ||
173 | } else if ( action == 1002 ) { | 171 | } else if ( action == 1002 ) { |
174 | quickSyncLocalFile(); | 172 | quickSyncLocalFile(); |
175 | 173 | ||
176 | } else if ( action >= 1003 ) { | 174 | } else if ( action >= 1003 ) { |
177 | if ( temp->getIsLocalFileSync() ) { | 175 | if ( temp->getIsLocalFileSync() ) { |
178 | switch(mTargetApp) | 176 | switch(mTargetApp) |
179 | { | 177 | { |
180 | case (KAPI): | 178 | case (KAPI): |
181 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 179 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
182 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 180 | mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
183 | break; | 181 | break; |
184 | case (KOPI): | 182 | case (KOPI): |
185 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 183 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
186 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 184 | mLastSyncedLocalFile = temp->getRemoteFileName(); |
187 | break; | 185 | break; |
188 | case (PWMPI): | 186 | case (PWMPI): |
189 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 187 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
190 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 188 | mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
191 | break; | 189 | break; |
192 | default: | 190 | default: |
193 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 191 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
194 | break; | 192 | break; |
195 | 193 | ||
196 | } | 194 | } |
197 | } else { | 195 | } else { |
198 | if ( temp->getIsPhoneSync() ) { | 196 | if ( temp->getIsPhoneSync() ) { |
199 | mPrefs->mPhoneDevice = temp->getPhoneDevice( ) ; | 197 | mPhoneDevice = temp->getPhoneDevice( ) ; |
200 | mPrefs->mPhoneConnection = temp->getPhoneConnection( ); | 198 | mPhoneConnection = temp->getPhoneConnection( ); |
201 | mPrefs->mPhoneModel = temp->getPhoneModel( ); | 199 | mPhoneModel = temp->getPhoneModel( ); |
202 | syncPhone(); | 200 | syncPhone(); |
203 | } else | 201 | } else |
204 | syncRemote( temp ); | 202 | syncRemote( temp ); |
205 | 203 | ||
206 | } | 204 | } |
207 | } | 205 | } |
208 | delete temp; | 206 | delete temp; |
209 | setBlockSave(false); | 207 | setBlockSave(false); |
210 | } | 208 | } |
211 | 209 | ||
212 | void KSyncManager::syncLocalFile() | 210 | void KSyncManager::syncLocalFile() |
213 | { | 211 | { |
214 | 212 | ||
215 | QString fn =mPrefs->mLastSyncedLocalFile; | 213 | QString fn =mLastSyncedLocalFile; |
216 | QString ext; | 214 | QString ext; |
217 | 215 | ||
218 | switch(mTargetApp) | 216 | switch(mTargetApp) |
219 | { | 217 | { |
220 | case (KAPI): | 218 | case (KAPI): |
221 | ext = "(*.vcf)"; | 219 | ext = "(*.vcf)"; |
222 | break; | 220 | break; |
223 | case (KOPI): | 221 | case (KOPI): |
@@ -258,34 +256,34 @@ bool KSyncManager::syncWithFile( QString fn , bool quick ) | |||
258 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 256 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
259 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 257 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
260 | mess, | 258 | mess, |
261 | i18n("Sync"), i18n("Cancel"), 0, | 259 | i18n("Sync"), i18n("Cancel"), 0, |
262 | 0, 1 ); | 260 | 0, 1 ); |
263 | if ( result ) | 261 | if ( result ) |
264 | return false; | 262 | return false; |
265 | } | 263 | } |
266 | if ( mPrefs->mAskForPreferences ) | 264 | if ( mAskForPreferences ) |
267 | edit_sync_options(); | 265 | edit_sync_options(); |
268 | if ( result == 0 ) { | 266 | if ( result == 0 ) { |
269 | //qDebug("Now sycing ... "); | 267 | //qDebug("Now sycing ... "); |
270 | if ( ret = mImplementation->sync( this, fn, mPrefs->mSyncAlgoPrefs ) ) | 268 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
271 | mParent->setCaption( i18n("Synchronization successful") ); | 269 | mParent->setCaption( i18n("Synchronization successful") ); |
272 | else | 270 | else |
273 | mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 271 | mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
274 | if ( ! quick ) | 272 | if ( ! quick ) |
275 | mPrefs->mLastSyncedLocalFile = fn; | 273 | mLastSyncedLocalFile = fn; |
276 | mImplementation->sync_setModified(); | 274 | mImplementation->sync_setModified(); |
277 | } | 275 | } |
278 | return ret; | 276 | return ret; |
279 | } | 277 | } |
280 | void KSyncManager::quickSyncLocalFile() | 278 | void KSyncManager::quickSyncLocalFile() |
281 | { | 279 | { |
282 | 280 | ||
283 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, false ) ) { | 281 | if ( syncWithFile( mLastSyncedLocalFile, false ) ) { |
284 | qDebug("quick syncLocalFile() successful "); | 282 | qDebug("quick syncLocalFile() successful "); |
285 | 283 | ||
286 | } | 284 | } |
287 | } | 285 | } |
288 | void KSyncManager::multiSync( bool askforPrefs ) | 286 | void KSyncManager::multiSync( bool askforPrefs ) |
289 | { | 287 | { |
290 | if (blockSave()) | 288 | if (blockSave()) |
291 | return; | 289 | return; |
@@ -295,20 +293,20 @@ void KSyncManager::multiSync( bool askforPrefs ) | |||
295 | question, | 293 | question, |
296 | i18n("Yes"), i18n("No"), | 294 | i18n("Yes"), i18n("No"), |
297 | 0, 0 ) != 0 ) { | 295 | 0, 0 ) != 0 ) { |
298 | setBlockSave(false); | 296 | setBlockSave(false); |
299 | mParent->setCaption(i18n("Aborted! Nothing synced!")); | 297 | mParent->setCaption(i18n("Aborted! Nothing synced!")); |
300 | return; | 298 | return; |
301 | } | 299 | } |
302 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 300 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
303 | mPrefs->mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 301 | mSyncAlgoPrefs = mRingSyncAlgoPrefs; |
304 | if ( askforPrefs ) { | 302 | if ( askforPrefs ) { |
305 | edit_sync_options(); | 303 | edit_sync_options(); |
306 | mPrefs->mRingSyncAlgoPrefs = mPrefs->mSyncAlgoPrefs; | 304 | mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
307 | } | 305 | } |
308 | mParent->setCaption(i18n("Multiple sync started.") ); | 306 | mParent->setCaption(i18n("Multiple sync started.") ); |
309 | qApp->processEvents(); | 307 | qApp->processEvents(); |
310 | int num = ringSync() ; | 308 | int num = ringSync() ; |
311 | if ( num > 1 ) | 309 | if ( num > 1 ) |
312 | ringSync(); | 310 | ringSync(); |
313 | setBlockSave(false); | 311 | setBlockSave(false); |
314 | if ( num ) | 312 | if ( num ) |
@@ -320,19 +318,19 @@ void KSyncManager::multiSync( bool askforPrefs ) | |||
320 | return; | 318 | return; |
321 | } | 319 | } |
322 | int KSyncManager::ringSync() | 320 | int KSyncManager::ringSync() |
323 | { | 321 | { |
324 | int syncedProfiles = 0; | 322 | int syncedProfiles = 0; |
325 | unsigned int i; | 323 | unsigned int i; |
326 | QTime timer; | 324 | QTime timer; |
327 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 325 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
328 | QStringList syncProfileNames = mPrefs->mSyncProfileNames; | 326 | QStringList syncProfileNames = mSyncProfileNames; |
329 | KSyncProfile* temp = new KSyncProfile (); | 327 | KSyncProfile* temp = new KSyncProfile (); |
330 | mPrefs->mAskForPreferences = false; | 328 | mAskForPreferences = false; |
331 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 329 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
332 | mCurrentSyncProfile = i; | 330 | mCurrentSyncProfile = i; |
333 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 331 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
334 | temp->readConfig(&config); | 332 | temp->readConfig(&config); |
335 | 333 | ||
336 | QString includeInRingSync; | 334 | QString includeInRingSync; |
337 | switch(mTargetApp) | 335 | switch(mTargetApp) |
338 | { | 336 | { |
@@ -350,52 +348,52 @@ int KSyncManager::ringSync() | |||
350 | break; | 348 | break; |
351 | 349 | ||
352 | } | 350 | } |
353 | 351 | ||
354 | 352 | ||
355 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 353 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
356 | mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 354 | mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
357 | ++syncedProfiles; | 355 | ++syncedProfiles; |
358 | // mPrefs->mAskForPreferences = temp->getAskForPreferences(); | 356 | // mAskForPreferences = temp->getAskForPreferences(); |
359 | mPrefs->mWriteBackFile = temp->getWriteBackFile(); | 357 | mWriteBackFile = temp->getWriteBackFile(); |
360 | mPrefs->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 358 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
361 | mPrefs->mWriteBackInFuture = 0; | 359 | mWriteBackInFuture = 0; |
362 | if ( temp->getWriteBackFuture() ) | 360 | if ( temp->getWriteBackFuture() ) |
363 | mPrefs->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 361 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
364 | mPrefs->mShowSyncSummary = false; | 362 | mShowSyncSummary = false; |
365 | mCurrentSyncDevice = syncProfileNames[i] ; | 363 | mCurrentSyncDevice = syncProfileNames[i] ; |
366 | mCurrentSyncName = mPrefs->mLocalMachineName; | 364 | mCurrentSyncName = mLocalMachineName; |
367 | if ( i == 0 ) { | 365 | if ( i == 0 ) { |
368 | syncSharp(); | 366 | syncSharp(); |
369 | } else { | 367 | } else { |
370 | if ( temp->getIsLocalFileSync() ) { | 368 | if ( temp->getIsLocalFileSync() ) { |
371 | switch(mTargetApp) | 369 | switch(mTargetApp) |
372 | { | 370 | { |
373 | case (KAPI): | 371 | case (KAPI): |
374 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 372 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
375 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 373 | mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
376 | break; | 374 | break; |
377 | case (KOPI): | 375 | case (KOPI): |
378 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 376 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
379 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 377 | mLastSyncedLocalFile = temp->getRemoteFileName(); |
380 | break; | 378 | break; |
381 | case (PWMPI): | 379 | case (PWMPI): |
382 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 380 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
383 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 381 | mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
384 | break; | 382 | break; |
385 | default: | 383 | default: |
386 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 384 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
387 | break; | 385 | break; |
388 | } | 386 | } |
389 | } else { | 387 | } else { |
390 | if ( temp->getIsPhoneSync() ) { | 388 | if ( temp->getIsPhoneSync() ) { |
391 | mPrefs->mPhoneDevice = temp->getPhoneDevice( ) ; | 389 | mPhoneDevice = temp->getPhoneDevice( ) ; |
392 | mPrefs->mPhoneConnection = temp->getPhoneConnection( ); | 390 | mPhoneConnection = temp->getPhoneConnection( ); |
393 | mPrefs->mPhoneModel = temp->getPhoneModel( ); | 391 | mPhoneModel = temp->getPhoneModel( ); |
394 | syncPhone(); | 392 | syncPhone(); |
395 | } else | 393 | } else |
396 | syncRemote( temp, false ); | 394 | syncRemote( temp, false ); |
397 | 395 | ||
398 | } | 396 | } |
399 | } | 397 | } |
400 | timer.start(); | 398 | timer.start(); |
401 | mParent->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 399 | mParent->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
@@ -486,17 +484,17 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | |||
486 | 484 | ||
487 | 485 | ||
488 | 486 | ||
489 | if ( syncWithFile( localTempFile, true ) ) { | 487 | if ( syncWithFile( localTempFile, true ) ) { |
490 | // Event* e = mView->getLastSyncEvent(); | 488 | // Event* e = mView->getLastSyncEvent(); |
491 | // e->setReadOnly( false ); | 489 | // e->setReadOnly( false ); |
492 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 490 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
493 | // e->setReadOnly( true ); | 491 | // e->setReadOnly( true ); |
494 | if ( mPrefs->mWriteBackFile ) { | 492 | if ( mWriteBackFile ) { |
495 | int fi; | 493 | int fi; |
496 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { | 494 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { |
497 | QString pwd = getPassword(); | 495 | QString pwd = getPassword(); |
498 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); | 496 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); |
499 | 497 | ||
500 | } | 498 | } |
501 | mParent->setCaption ( i18n( "Writing back file ..." ) ); | 499 | mParent->setCaption ( i18n( "Writing back file ..." ) ); |
502 | result = system ( postCommand ); | 500 | result = system ( postCommand ); |
@@ -510,17 +508,17 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | |||
510 | } | 508 | } |
511 | } | 509 | } |
512 | return; | 510 | return; |
513 | } | 511 | } |
514 | 512 | ||
515 | void KSyncManager::edit_sync_options() | 513 | void KSyncManager::edit_sync_options() |
516 | { | 514 | { |
517 | //mDialogManager->showSyncOptions(); | 515 | //mDialogManager->showSyncOptions(); |
518 | //mPrefs->mSyncAlgoPrefs | 516 | //mSyncAlgoPrefs |
519 | QDialog dia( mParent, "dia", true ); | 517 | QDialog dia( mParent, "dia", true ); |
520 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 518 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
521 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 519 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
522 | QVBoxLayout lay ( &dia ); | 520 | QVBoxLayout lay ( &dia ); |
523 | lay.setSpacing( 2 ); | 521 | lay.setSpacing( 2 ); |
524 | lay.setMargin( 3 ); | 522 | lay.setMargin( 3 ); |
525 | lay.addWidget(&gr); | 523 | lay.addWidget(&gr); |
526 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 524 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
@@ -528,17 +526,17 @@ void KSyncManager::edit_sync_options() | |||
528 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 526 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
529 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 527 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
530 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 528 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
531 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 529 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
532 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 530 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
533 | QPushButton pb ( "OK", &dia); | 531 | QPushButton pb ( "OK", &dia); |
534 | lay.addWidget( &pb ); | 532 | lay.addWidget( &pb ); |
535 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 533 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
536 | switch ( mPrefs->mSyncAlgoPrefs ) { | 534 | switch ( mSyncAlgoPrefs ) { |
537 | case 0: | 535 | case 0: |
538 | loc.setChecked( true); | 536 | loc.setChecked( true); |
539 | break; | 537 | break; |
540 | case 1: | 538 | case 1: |
541 | rem.setChecked( true ); | 539 | rem.setChecked( true ); |
542 | break; | 540 | break; |
543 | case 2: | 541 | case 2: |
544 | newest.setChecked( true); | 542 | newest.setChecked( true); |
@@ -554,17 +552,17 @@ void KSyncManager::edit_sync_options() | |||
554 | break; | 552 | break; |
555 | case 6: | 553 | case 6: |
556 | // both.setChecked( true); | 554 | // both.setChecked( true); |
557 | break; | 555 | break; |
558 | default: | 556 | default: |
559 | break; | 557 | break; |
560 | } | 558 | } |
561 | if ( dia.exec() ) { | 559 | if ( dia.exec() ) { |
562 | mPrefs->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 560 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
563 | } | 561 | } |
564 | 562 | ||
565 | 563 | ||
566 | } | 564 | } |
567 | QString KSyncManager::getPassword( ) | 565 | QString KSyncManager::getPassword( ) |
568 | { | 566 | { |
569 | QString retfile = ""; | 567 | QString retfile = ""; |
570 | QDialog dia ( mParent, "input-dialog", true ); | 568 | QDialog dia ( mParent, "input-dialog", true ); |
@@ -598,33 +596,33 @@ void KSyncManager::confSync() | |||
598 | } | 596 | } |
599 | sp->usrReadConfig(); | 597 | sp->usrReadConfig(); |
600 | #ifndef DESKTOP_VERSION | 598 | #ifndef DESKTOP_VERSION |
601 | sp->showMaximized(); | 599 | sp->showMaximized(); |
602 | #else | 600 | #else |
603 | sp->show(); | 601 | sp->show(); |
604 | #endif | 602 | #endif |
605 | sp->exec(); | 603 | sp->exec(); |
606 | mPrefs->mSyncProfileNames = sp->getSyncProfileNames(); | 604 | mSyncProfileNames = sp->getSyncProfileNames(); |
607 | mPrefs->mLocalMachineName = sp->getLocalMachineName (); | 605 | mLocalMachineName = sp->getLocalMachineName (); |
608 | fillSyncMenu(); | 606 | fillSyncMenu(); |
609 | } | 607 | } |
610 | 608 | ||
611 | void KSyncManager::syncSharp() | 609 | void KSyncManager::syncSharp() |
612 | { | 610 | { |
613 | if ( ! syncExternalApplication("sharp") ) | 611 | if ( ! syncExternalApplication("sharp") ) |
614 | qDebug("ERROR sync sharp ");; | 612 | qDebug("ERROR sync sharp ");; |
615 | } | 613 | } |
616 | 614 | ||
617 | bool KSyncManager::syncExternalApplication(QString resource) | 615 | bool KSyncManager::syncExternalApplication(QString resource) |
618 | { | 616 | { |
619 | if ( mImplementation->sync_isModified() ) | 617 | if ( mImplementation->sync_isModified() ) |
620 | mImplementation->sync_save(); | 618 | mImplementation->sync_save(); |
621 | 619 | ||
622 | if ( mPrefs->mAskForPreferences ) | 620 | if ( mAskForPreferences ) |
623 | edit_sync_options(); | 621 | edit_sync_options(); |
624 | 622 | ||
625 | qDebug("sync %s", resource.latin1()); | 623 | qDebug("sync %s", resource.latin1()); |
626 | 624 | ||
627 | bool syncOK = mImplementation->syncExternal(this, resource); | 625 | bool syncOK = mImplementation->syncExternal(this, resource); |
628 | 626 | ||
629 | return syncOK; | 627 | return syncOK; |
630 | 628 | ||
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 9761107..6b10016 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h | |||
@@ -54,16 +54,35 @@ class KSyncManager : public QObject | |||
54 | 54 | ||
55 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } | 55 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } |
56 | QString getCurrentSyncName() { return mCurrentSyncName; } | 56 | QString getCurrentSyncName() { return mCurrentSyncName; } |
57 | 57 | ||
58 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); | 58 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); |
59 | void hideProgressBar(); | 59 | void hideProgressBar(); |
60 | bool isProgressBarCanceled(); | 60 | bool isProgressBarCanceled(); |
61 | 61 | ||
62 | // sync stuff | ||
63 | QString mLocalMachineName; | ||
64 | QStringList mExternSyncProfiles; | ||
65 | QStringList mSyncProfileNames; | ||
66 | bool mAskForPreferences; | ||
67 | bool mShowSyncSummary; | ||
68 | bool mShowSyncEvents; | ||
69 | bool mShowTodoInAgenda; | ||
70 | bool mWriteBackExistingOnly; | ||
71 | int mSyncAlgoPrefs; | ||
72 | int mRingSyncAlgoPrefs; | ||
73 | bool mWriteBackFile; | ||
74 | int mWriteBackInFuture; | ||
75 | QString mPhoneDevice; | ||
76 | QString mPhoneConnection; | ||
77 | QString mPhoneModel; | ||
78 | QString mLastSyncedLocalFile; // save! | ||
79 | |||
80 | |||
62 | 81 | ||
63 | public slots: | 82 | public slots: |
64 | void slotSyncMenu( int ); | 83 | void slotSyncMenu( int ); |
65 | 84 | ||
66 | private: | 85 | private: |
67 | // LR ******************************* | 86 | // LR ******************************* |
68 | // sync stuff! | 87 | // sync stuff! |
69 | QString mCurrentSyncDevice; | 88 | QString mCurrentSyncDevice; |
@@ -87,17 +106,16 @@ class KSyncManager : public QObject | |||
87 | 106 | ||
88 | private: | 107 | private: |
89 | bool mBlockSaveFlag; | 108 | bool mBlockSaveFlag; |
90 | 109 | ||
91 | 110 | ||
92 | QWidget* mParent; | 111 | QWidget* mParent; |
93 | KSyncInterface* mImplementation; | 112 | KSyncInterface* mImplementation; |
94 | TargetApp mTargetApp; | 113 | TargetApp mTargetApp; |
95 | KPimPrefs* mPrefs; | ||
96 | QPopupMenu* mSyncMenu; | 114 | QPopupMenu* mSyncMenu; |
97 | 115 | ||
98 | QProgressBar* bar; | 116 | QProgressBar* bar; |
99 | 117 | ||
100 | 118 | ||
101 | 119 | ||
102 | 120 | ||
103 | 121 | ||