-rw-r--r-- | libkdepim/ksyncmanager.cpp | 15 | ||||
-rw-r--r-- | libkdepim/ksyncprefsdialog.cpp | 1 |
2 files changed, 10 insertions, 6 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 4d859ce..f80c2a6 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1,1558 +1,1563 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | // $Id$ | 21 | // $Id$ |
22 | 22 | ||
23 | #include "ksyncmanager.h" | 23 | #include "ksyncmanager.h" |
24 | 24 | ||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | 31 | ||
32 | #include "ksyncprofile.h" | 32 | #include "ksyncprofile.h" |
33 | #include "ksyncprefsdialog.h" | 33 | #include "ksyncprefsdialog.h" |
34 | #include "kpimprefs.h" | 34 | #include "kpimprefs.h" |
35 | #include <kmessagebox.h> | 35 | #include <kmessagebox.h> |
36 | 36 | ||
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
39 | #include <qpopupmenu.h> | 39 | #include <qpopupmenu.h> |
40 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
41 | #include <qradiobutton.h> | 41 | #include <qradiobutton.h> |
42 | #include <qbuttongroup.h> | 42 | #include <qbuttongroup.h> |
43 | #include <qtimer.h> | 43 | #include <qtimer.h> |
44 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
45 | #include <qapplication.h> | 45 | #include <qapplication.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #include <qlabel.h> | 50 | #include <qlabel.h> |
51 | #include <qcheckbox.h> | 51 | #include <qcheckbox.h> |
52 | #include <qapplication.h> | 52 | #include <qapplication.h> |
53 | 53 | ||
54 | #include <klocale.h> | 54 | #include <klocale.h> |
55 | #include <kglobal.h> | 55 | #include <kglobal.h> |
56 | #include <kconfig.h> | 56 | #include <kconfig.h> |
57 | #include <kfiledialog.h> | 57 | #include <kfiledialog.h> |
58 | 58 | ||
59 | QDateTime KSyncManager::mRequestedSyncEvent; | 59 | QDateTime KSyncManager::mRequestedSyncEvent; |
60 | 60 | ||
61 | 61 | ||
62 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) | 62 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) |
63 | : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) | 63 | : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) |
64 | { | 64 | { |
65 | mServerSocket = 0; | 65 | mServerSocket = 0; |
66 | bar = new QProgressBar ( 1, 0 ); | 66 | bar = new QProgressBar ( 1, 0 ); |
67 | bar->setCaption (""); | 67 | bar->setCaption (""); |
68 | mWriteBackInPast = 2; | 68 | mWriteBackInPast = 2; |
69 | 69 | ||
70 | 70 | ||
71 | } | 71 | } |
72 | 72 | ||
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 ) |
1431 | { | 1436 | { |
1432 | if ( secs > 300 ) { | 1437 | if ( secs > 300 ) { |
1433 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { | 1438 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { |
1434 | qDebug("KSS::Sync cancelled ,cs"); | 1439 | qDebug("KSS::Sync cancelled ,cs"); |
1435 | mErrorMessage = 0; | 1440 | mErrorMessage = 0; |
1436 | end_connect(); | 1441 | end_connect(); |
1437 | error_connect("ERROR_CA\r\n\r\n"); | 1442 | error_connect("ERROR_CA\r\n\r\n"); |
1438 | return ; | 1443 | return ; |
1439 | } | 1444 | } |
1440 | } | 1445 | } |
1441 | QFont f = label->font(); | 1446 | QFont f = label->font(); |
1442 | f.setPointSize ( f.pointSize() *2 ); | 1447 | f.setPointSize ( f.pointSize() *2 ); |
1443 | f. setBold (true ); | 1448 | f. setBold (true ); |
1444 | QLabel* label = new QLabel( warning, mSyncActionDialog ); | 1449 | QLabel* label = new QLabel( warning, mSyncActionDialog ); |
1445 | label->setFont( f ); | 1450 | label->setFont( f ); |
1446 | warning = i18n("ADJUST\nYOUR\nCLOCKS!"); | 1451 | warning = i18n("ADJUST\nYOUR\nCLOCKS!"); |
1447 | label->setText( warning ); | 1452 | label->setText( warning ); |
1448 | label->setAlignment ( Qt::AlignHCenter ); | 1453 | label->setAlignment ( Qt::AlignHCenter ); |
1449 | lay->addWidget( label); | 1454 | lay->addWidget( label); |
1450 | mSyncActionDialog->setFixedSize( 230, 300); | 1455 | mSyncActionDialog->setFixedSize( 230, 300); |
1451 | } else { | 1456 | } else { |
1452 | mSyncActionDialog->setFixedSize( 230, 200); | 1457 | mSyncActionDialog->setFixedSize( 230, 200); |
1453 | } | 1458 | } |
1454 | } else { | 1459 | } else { |
1455 | mSyncActionDialog->setFixedSize( 230, 120); | 1460 | mSyncActionDialog->setFixedSize( 230, 120); |
1456 | } | 1461 | } |
1457 | } else | 1462 | } else |
1458 | mSyncActionDialog->setFixedSize( 230, 120); | 1463 | mSyncActionDialog->setFixedSize( 230, 120); |
1459 | mSyncActionDialog->show(); | 1464 | mSyncActionDialog->show(); |
1460 | mSyncActionDialog->raise(); | 1465 | mSyncActionDialog->raise(); |
1461 | emit request_file(mResource); | 1466 | emit request_file(mResource); |
1462 | emit request_file(); | 1467 | emit request_file(); |
1463 | qApp->processEvents(); | 1468 | qApp->processEvents(); |
1464 | QString fileName = mFileName; | 1469 | QString fileName = mFileName; |
1465 | QFile file( fileName ); | 1470 | QFile file( fileName ); |
1466 | if (!file.open( IO_ReadOnly ) ) { | 1471 | if (!file.open( IO_ReadOnly ) ) { |
1467 | mErrorMessage = 0; | 1472 | mErrorMessage = 0; |
1468 | end_connect(); | 1473 | end_connect(); |
1469 | error_connect("ERROR_FI\r\n\r\n"); | 1474 | error_connect("ERROR_FI\r\n\r\n"); |
1470 | return ; | 1475 | return ; |
1471 | } | 1476 | } |
1472 | mSyncActionDialog->setCaption( i18n("Sending file...") ); | 1477 | mSyncActionDialog->setCaption( i18n("Sending file...") ); |
1473 | QTextStream ts( &file ); | 1478 | QTextStream ts( &file ); |
1474 | ts.setEncoding( QTextStream::Latin1 ); | 1479 | ts.setEncoding( QTextStream::Latin1 ); |
1475 | 1480 | ||
1476 | QTextStream os( mSocket ); | 1481 | QTextStream os( mSocket ); |
1477 | os.setEncoding( QTextStream::Latin1 ); | 1482 | os.setEncoding( QTextStream::Latin1 ); |
1478 | while ( ! ts.atEnd() ) { | 1483 | while ( ! ts.atEnd() ) { |
1479 | os << ts.readLine() << "\r\n"; | 1484 | os << ts.readLine() << "\r\n"; |
1480 | } | 1485 | } |
1481 | os << "\r\n"; | 1486 | os << "\r\n"; |
1482 | //os << ts.read(); | 1487 | //os << ts.read(); |
1483 | file.close(); | 1488 | file.close(); |
1484 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | 1489 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); |
1485 | mSocket->close(); | 1490 | mSocket->close(); |
1486 | if ( mSocket->state() == QSocket::Idle ) | 1491 | if ( mSocket->state() == QSocket::Idle ) |
1487 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1492 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1488 | } | 1493 | } |
1489 | void KServerSocket::get_file() | 1494 | void KServerSocket::get_file() |
1490 | { | 1495 | { |
1491 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | 1496 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); |
1492 | 1497 | ||
1493 | piTime.start(); | 1498 | piTime.start(); |
1494 | piFileString = ""; | 1499 | piFileString = ""; |
1495 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | 1500 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); |
1496 | } | 1501 | } |
1497 | 1502 | ||
1498 | 1503 | ||
1499 | void KServerSocket::readBackFileFromSocket() | 1504 | void KServerSocket::readBackFileFromSocket() |
1500 | { | 1505 | { |
1501 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | 1506 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); |
1502 | while ( mSocket->canReadLine () ) { | 1507 | while ( mSocket->canReadLine () ) { |
1503 | piTime.restart(); | 1508 | piTime.restart(); |
1504 | QString line = mSocket->readLine (); | 1509 | QString line = mSocket->readLine (); |
1505 | piFileString += line; | 1510 | piFileString += line; |
1506 | //qDebug("readline: %s ", line.latin1()); | 1511 | //qDebug("readline: %s ", line.latin1()); |
1507 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | 1512 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); |
1508 | 1513 | ||
1509 | } | 1514 | } |
1510 | if ( piTime.elapsed () < 3000 ) { | 1515 | if ( piTime.elapsed () < 3000 ) { |
1511 | // wait for more | 1516 | // wait for more |
1512 | //qDebug("waitformore "); | 1517 | //qDebug("waitformore "); |
1513 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | 1518 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); |
1514 | return; | 1519 | return; |
1515 | } | 1520 | } |
1516 | QString fileName = mFileName; | 1521 | QString fileName = mFileName; |
1517 | QFile file ( fileName ); | 1522 | QFile file ( fileName ); |
1518 | if (!file.open( IO_WriteOnly ) ) { | 1523 | if (!file.open( IO_WriteOnly ) ) { |
1519 | delete mSyncActionDialog; | 1524 | delete mSyncActionDialog; |
1520 | mSyncActionDialog = 0; | 1525 | mSyncActionDialog = 0; |
1521 | qDebug("KSS:Error open read back file "); | 1526 | qDebug("KSS:Error open read back file "); |
1522 | piFileString = ""; | 1527 | piFileString = ""; |
1523 | emit file_received( false, mResource); | 1528 | emit file_received( false, mResource); |
1524 | emit file_received( false); | 1529 | emit file_received( false); |
1525 | blockRC = false; | 1530 | blockRC = false; |
1526 | return ; | 1531 | return ; |
1527 | 1532 | ||
1528 | } | 1533 | } |
1529 | 1534 | ||
1530 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1535 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1531 | QTextStream ts ( &file ); | 1536 | QTextStream ts ( &file ); |
1532 | ts.setEncoding( QTextStream::Latin1 ); | 1537 | ts.setEncoding( QTextStream::Latin1 ); |
1533 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | 1538 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); |
1534 | ts << piFileString; | 1539 | ts << piFileString; |
1535 | mSocket->close(); | 1540 | mSocket->close(); |
1536 | if ( mSocket->state() == QSocket::Idle ) | 1541 | if ( mSocket->state() == QSocket::Idle ) |
1537 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1542 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1538 | file.close(); | 1543 | file.close(); |
1539 | piFileString = ""; | 1544 | piFileString = ""; |
1540 | emit file_received( true, mResource ); | 1545 | emit file_received( true, mResource ); |
1541 | emit file_received( true); | 1546 | emit file_received( true); |
1542 | delete mSyncActionDialog; | 1547 | delete mSyncActionDialog; |
1543 | mSyncActionDialog = 0; | 1548 | mSyncActionDialog = 0; |
1544 | blockRC = false; | 1549 | blockRC = false; |
1545 | 1550 | ||
1546 | } | 1551 | } |
1547 | 1552 | ||
1548 | KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) | 1553 | KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) |
1549 | { | 1554 | { |
1550 | mRemoteResource = remres; | 1555 | mRemoteResource = remres; |
1551 | if ( mRemoteResource.isEmpty() ) | 1556 | if ( mRemoteResource.isEmpty() ) |
1552 | mRemoteResource = "ALL"; | 1557 | mRemoteResource = "ALL"; |
1553 | else | 1558 | else |
1554 | mRemoteResource.replace (QRegExp (" "),"_" ); | 1559 | mRemoteResource.replace (QRegExp (" "),"_" ); |
1555 | mPassWord = password; | 1560 | mPassWord = password; |
1556 | mSocket = 0; | 1561 | mSocket = 0; |
1557 | mFirst = false; | 1562 | mFirst = false; |
1558 | mFirstLine = true; | 1563 | mFirstLine = true; |
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp index 6f46d19..2b87298 100644 --- a/libkdepim/ksyncprefsdialog.cpp +++ b/libkdepim/ksyncprefsdialog.cpp | |||
@@ -122,769 +122,768 @@ void KSyncPrefsDialog::setupSyncAlgTab() | |||
122 | 122 | ||
123 | QHBox* buttonbox = new QHBox( topFrame); | 123 | QHBox* buttonbox = new QHBox( topFrame); |
124 | topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); | 124 | topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); |
125 | ++iii; | 125 | ++iii; |
126 | button = new QPushButton( i18n("New profile"), buttonbox ); | 126 | button = new QPushButton( i18n("New profile"), buttonbox ); |
127 | connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); | 127 | connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); |
128 | 128 | ||
129 | button = new QPushButton( i18n("Clone profile"), buttonbox ); | 129 | button = new QPushButton( i18n("Clone profile"), buttonbox ); |
130 | connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); | 130 | connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); |
131 | 131 | ||
132 | button = new QPushButton( i18n("Delete profile"), buttonbox ); | 132 | button = new QPushButton( i18n("Delete profile"), buttonbox ); |
133 | connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); | 133 | connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); |
134 | 134 | ||
135 | mProfileBox = new QComboBox(topFrame); | 135 | mProfileBox = new QComboBox(topFrame); |
136 | mProfileBox->setEditable ( true ); | 136 | mProfileBox->setEditable ( true ); |
137 | mProfileBox->setInsertionPolicy(QComboBox::NoInsertion); | 137 | mProfileBox->setInsertionPolicy(QComboBox::NoInsertion); |
138 | connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); | 138 | connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); |
139 | connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); | 139 | connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); |
140 | 140 | ||
141 | lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); | 141 | lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); |
142 | topLayout->addWidget(lab ,iii,0); | 142 | topLayout->addWidget(lab ,iii,0); |
143 | topLayout->addWidget(mProfileBox, iii,1); | 143 | topLayout->addWidget(mProfileBox, iii,1); |
144 | ++iii; | 144 | ++iii; |
145 | 145 | ||
146 | 146 | ||
147 | 147 | ||
148 | QHGroupBox *iims = new QHGroupBox( i18n("Multiple Sync options"), topFrame); | 148 | QHGroupBox *iims = new QHGroupBox( i18n("Multiple Sync options"), topFrame); |
149 | new QLabel( i18n("Include in multiple "), iims ); | 149 | new QLabel( i18n("Include in multiple "), iims ); |
150 | mIncludeInRing = new QCheckBox( i18n("calendar "), iims ); | 150 | mIncludeInRing = new QCheckBox( i18n("calendar "), iims ); |
151 | mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims ); | 151 | mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims ); |
152 | mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims ); | 152 | mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims ); |
153 | new QLabel( i18n(" sync"), iims ); | 153 | new QLabel( i18n(" sync"), iims ); |
154 | topLayout->addMultiCellWidget(iims, iii,iii,0,1); | 154 | topLayout->addMultiCellWidget(iims, iii,iii,0,1); |
155 | ++iii; | 155 | ++iii; |
156 | QVGroupBox* gb0 = new QVGroupBox( i18n("Sync algo options"), topFrame); | 156 | QVGroupBox* gb0 = new QVGroupBox( i18n("Sync algo options"), topFrame); |
157 | topLayout->addMultiCellWidget(gb0, iii,iii,0,1); | 157 | topLayout->addMultiCellWidget(gb0, iii,iii,0,1); |
158 | ++iii; | 158 | ++iii; |
159 | QButtonGroup* gr; | 159 | QButtonGroup* gr; |
160 | { | 160 | { |
161 | QVGroupBox* topFrame = gb0; | 161 | QVGroupBox* topFrame = gb0; |
162 | 162 | ||
163 | 163 | ||
164 | 164 | ||
165 | mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); | 165 | mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); |
166 | //topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); | 166 | //topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); |
167 | //++iii; | 167 | //++iii; |
168 | gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); | 168 | gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); |
169 | //topLayout->addMultiCellWidget(gr, iii,iii,0,1); | 169 | //topLayout->addMultiCellWidget(gr, iii,iii,0,1); |
170 | //++iii; | 170 | //++iii; |
171 | loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); | 171 | loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); |
172 | rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); | 172 | rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); |
173 | newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); | 173 | newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); |
174 | ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); | 174 | ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); |
175 | f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); | 175 | f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); |
176 | f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); | 176 | f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); |
177 | // both = new QRadioButton ( i18n("Take both on conflict"), gr ); | 177 | // both = new QRadioButton ( i18n("Take both on conflict"), gr ); |
178 | 178 | ||
179 | mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); | 179 | mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); |
180 | //topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); | 180 | //topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); |
181 | //++iii; | 181 | //++iii; |
182 | 182 | ||
183 | #if 0 | 183 | #if 0 |
184 | QHGroupBox* gb51 = new QHGroupBox( i18n("Local resources to sync with:"), topFrame); | 184 | QHGroupBox* gb51 = new QHGroupBox( i18n("Local resources to sync with:"), topFrame); |
185 | { | 185 | { |
186 | QVBox * fibo2 = new QVBox ( gb51 ); | 186 | QVBox * fibo2 = new QVBox ( gb51 ); |
187 | new QLabel ( i18n("Calendar resources:"), fibo2 ); | 187 | new QLabel ( i18n("Calendar resources:"), fibo2 ); |
188 | //mFilterInCal = new QComboBox( fibo2 ); | 188 | //mFilterInCal = new QComboBox( fibo2 ); |
189 | fibo2 = new QVBox ( gb51 ); | 189 | fibo2 = new QVBox ( gb51 ); |
190 | new QLabel ( i18n("Addressbook resources:"), fibo2 ); | 190 | new QLabel ( i18n("Addressbook resources:"), fibo2 ); |
191 | //mFilterInAB = new QComboBox( fibo2 ); | 191 | //mFilterInAB = new QComboBox( fibo2 ); |
192 | } | 192 | } |
193 | #endif | 193 | #endif |
194 | QHGroupBox* gb5 = new QHGroupBox( i18n("Apply filter when adding data to local:"), topFrame); | 194 | QHGroupBox* gb5 = new QHGroupBox( i18n("Apply filter when adding data to local:"), topFrame); |
195 | QVBox * fibo2 = new QVBox ( gb5 ); | 195 | QVBox * fibo2 = new QVBox ( gb5 ); |
196 | new QLabel ( i18n("Incoming calendar filter:"), fibo2 ); | 196 | new QLabel ( i18n("Incoming calendar filter:"), fibo2 ); |
197 | mFilterInCal = new QComboBox( fibo2 ); | 197 | mFilterInCal = new QComboBox( fibo2 ); |
198 | fibo2 = new QVBox ( gb5 ); | 198 | fibo2 = new QVBox ( gb5 ); |
199 | new QLabel ( i18n("Incoming addressbook filter:"), fibo2 ); | 199 | new QLabel ( i18n("Incoming addressbook filter:"), fibo2 ); |
200 | mFilterInAB = new QComboBox( fibo2 ); | 200 | mFilterInAB = new QComboBox( fibo2 ); |
201 | 201 | ||
202 | mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame ); | 202 | mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame ); |
203 | // topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); | 203 | // topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); |
204 | // ++iii; | 204 | // ++iii; |
205 | 205 | ||
206 | QVGroupBox* gb2 = new QVGroupBox( i18n("Write back options"), topFrame); | 206 | QVGroupBox* gb2 = new QVGroupBox( i18n("Write back options"), topFrame); |
207 | //topLayout->addMultiCellWidget(gb2, iii,iii,0,1); | 207 | //topLayout->addMultiCellWidget(gb2, iii,iii,0,1); |
208 | //++iii; | 208 | //++iii; |
209 | { | 209 | { |
210 | QVGroupBox*topFrame = gb2; | 210 | QVGroupBox*topFrame = gb2; |
211 | mWriteBackExisting= new QCheckBox( i18n("Write back (on remote) existing entries only"), topFrame ); | 211 | mWriteBackExisting= new QCheckBox( i18n("Write back (on remote) existing entries only"), topFrame ); |
212 | QHGroupBox* gb4 = new QHGroupBox( i18n("Apply filter when adding data to remote:"), topFrame); | 212 | QHGroupBox* gb4 = new QHGroupBox( i18n("Apply filter when adding data to remote:"), topFrame); |
213 | QVBox * fibo = new QVBox ( gb4 ); | 213 | QVBox * fibo = new QVBox ( gb4 ); |
214 | new QLabel ( i18n("Outgoing calendar filter:"), fibo ); | 214 | new QLabel ( i18n("Outgoing calendar filter:"), fibo ); |
215 | mFilterOutCal = new QComboBox( fibo ); | 215 | mFilterOutCal = new QComboBox( fibo ); |
216 | fibo = new QVBox ( gb4 ); | 216 | fibo = new QVBox ( gb4 ); |
217 | new QLabel ( i18n("Outgoing addressbook filter:"), fibo ); | 217 | new QLabel ( i18n("Outgoing addressbook filter:"), fibo ); |
218 | mFilterOutAB = new QComboBox( fibo ); | 218 | mFilterOutAB = new QComboBox( fibo ); |
219 | //topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); | 219 | //topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); |
220 | //++iii; | 220 | //++iii; |
221 | mWriteBackFuture= new QCheckBox( i18n("Write back (calendar) entries for time period only"), topFrame ); | 221 | mWriteBackFuture= new QCheckBox( i18n("Write back (calendar) entries for time period only"), topFrame ); |
222 | //topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1); | 222 | //topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1); |
223 | //++iii; | 223 | //++iii; |
224 | QVGroupBox* gb3 = new QVGroupBox( i18n("Time period"), topFrame); | 224 | QVGroupBox* gb3 = new QVGroupBox( i18n("Time period"), topFrame); |
225 | connect ( mWriteBackFuture, SIGNAL( toggled ( bool ) ), gb3, SLOT ( setEnabled ( bool ) ) ); | 225 | connect ( mWriteBackFuture, SIGNAL( toggled ( bool ) ), gb3, SLOT ( setEnabled ( bool ) ) ); |
226 | 226 | ||
227 | new QLabel( i18n("From ") , gb3 ); | 227 | new QLabel( i18n("From ") , gb3 ); |
228 | QHBox * tf1 = new QHBox ( gb3 ); | 228 | QHBox * tf1 = new QHBox ( gb3 ); |
229 | mWriteBackPastWeeks= new QSpinBox(1,104, 1, tf1 ); | 229 | mWriteBackPastWeeks= new QSpinBox(1,104, 1, tf1 ); |
230 | mWriteBackPastWeeks->setMaximumWidth( 100 ); | 230 | mWriteBackPastWeeks->setMaximumWidth( 100 ); |
231 | new QLabel( i18n(" weeks in the past to ") ,tf1 ); | 231 | new QLabel( i18n(" weeks in the past to ") ,tf1 ); |
232 | QHBox * tf2 = new QHBox ( gb3 ); | 232 | QHBox * tf2 = new QHBox ( gb3 ); |
233 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, tf2); | 233 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, tf2); |
234 | mWriteBackFutureWeeks->setMaximumWidth( 100 ); | 234 | mWriteBackFutureWeeks->setMaximumWidth( 100 ); |
235 | new QLabel( i18n(" weeks in the future ") , tf2 ); | 235 | new QLabel( i18n(" weeks in the future ") , tf2 ); |
236 | //topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1); | 236 | //topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1); |
237 | //++iii; | 237 | //++iii; |
238 | gb3->setEnabled( false ); | 238 | gb3->setEnabled( false ); |
239 | connect ( mWriteBackExisting, SIGNAL( toggled ( bool ) ), gb4, SLOT ( setDisabled ( bool ) ) ); | 239 | connect ( mWriteBackExisting, SIGNAL( toggled ( bool ) ), gb4, SLOT ( setDisabled ( bool ) ) ); |
240 | } | 240 | } |
241 | connect ( mWriteBackFile, SIGNAL( toggled ( bool ) ), gb2, SLOT ( setEnabled ( bool ) ) ); | 241 | connect ( mWriteBackFile, SIGNAL( toggled ( bool ) ), gb2, SLOT ( setEnabled ( bool ) ) ); |
242 | 242 | ||
243 | } | 243 | } |
244 | proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); | 244 | proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); |
245 | gr = proGr; | 245 | gr = proGr; |
246 | topLayout->addMultiCellWidget(gr, iii,iii,0,1); | 246 | topLayout->addMultiCellWidget(gr, iii,iii,0,1); |
247 | ++iii; | 247 | ++iii; |
248 | mIsLocal = new QRadioButton ( i18n("Local file"), gr ); | 248 | mIsLocal = new QRadioButton ( i18n("Local file"), gr ); |
249 | mIsPi = new QRadioButton ( i18n("Pi-Sync - all calendars ( direct Kx/Pi to Kx/Pi sync )"), gr ); | 249 | mIsPi = new QRadioButton ( i18n("Pi-Sync - all calendars ( direct Kx/Pi to Kx/Pi sync )"), gr ); |
250 | connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); | 250 | connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); |
251 | mIsPiSpecific = new QRadioButton ( i18n("Pi-Sync - selected calendars ( direct Kx/Pi to Kx/Pi sync )"), gr ); | 251 | mIsPiSpecific = new QRadioButton ( i18n("Pi-Sync - selected calendars ( direct Kx/Pi to Kx/Pi sync )"), gr ); |
252 | connect (mIsPiSpecific, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); | 252 | connect (mIsPiSpecific, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); |
253 | mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); | 253 | mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); |
254 | connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); | 254 | connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); |
255 | mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr ); | 255 | mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr ); |
256 | connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); | 256 | connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); |
257 | 257 | ||
258 | QVGroupBox* gb1 = new QVGroupBox( i18n("Profile kind specific settings"), topFrame); | 258 | QVGroupBox* gb1 = new QVGroupBox( i18n("Profile kind specific settings"), topFrame); |
259 | topLayout->addMultiCellWidget(gb1, iii,iii,0,1); | 259 | topLayout->addMultiCellWidget(gb1, iii,iii,0,1); |
260 | ++iii; | 260 | ++iii; |
261 | 261 | ||
262 | // ****************************************** | 262 | // ****************************************** |
263 | // Profile kind specific settings | 263 | // Profile kind specific settings |
264 | { | 264 | { |
265 | // *** phone ******************************* | 265 | // *** phone ******************************* |
266 | QVGroupBox* topFrame = gb1; | 266 | QVGroupBox* topFrame = gb1; |
267 | phoneWidget = new QVBox( topFrame); | 267 | phoneWidget = new QVBox( topFrame); |
268 | //topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1); | 268 | //topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1); |
269 | //++iii; | 269 | //++iii; |
270 | mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget ); | 270 | mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget ); |
271 | QHBox* temphb = new QHBox( phoneWidget ); | 271 | QHBox* temphb = new QHBox( phoneWidget ); |
272 | new QLabel( i18n("I/O device: "), temphb ); | 272 | new QLabel( i18n("I/O device: "), temphb ); |
273 | mPhoneDevice = new QLineEdit( temphb); | 273 | mPhoneDevice = new QLineEdit( temphb); |
274 | button = new QPushButton( i18n("Help..."), temphb ); | 274 | button = new QPushButton( i18n("Help..."), temphb ); |
275 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) ); | 275 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) ); |
276 | 276 | ||
277 | 277 | ||
278 | temphb = new QHBox( phoneWidget ); | 278 | temphb = new QHBox( phoneWidget ); |
279 | new QLabel( i18n("Connection: "), temphb ); | 279 | new QLabel( i18n("Connection: "), temphb ); |
280 | mPhoneConnection = new QLineEdit( temphb); | 280 | mPhoneConnection = new QLineEdit( temphb); |
281 | button = new QPushButton( i18n("Help..."), temphb ); | 281 | button = new QPushButton( i18n("Help..."), temphb ); |
282 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) ); | 282 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) ); |
283 | 283 | ||
284 | 284 | ||
285 | temphb = new QHBox( phoneWidget ); | 285 | temphb = new QHBox( phoneWidget ); |
286 | new QLabel( i18n("Model(opt.): "), temphb ); | 286 | new QLabel( i18n("Model(opt.): "), temphb ); |
287 | mPhoneModel = new QLineEdit( temphb); | 287 | mPhoneModel = new QLineEdit( temphb); |
288 | button = new QPushButton( i18n("Help..."), temphb ); | 288 | button = new QPushButton( i18n("Help..."), temphb ); |
289 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) ); | 289 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) ); |
290 | 290 | ||
291 | // *** local******************************* | 291 | // *** local******************************* |
292 | localFileWidget = new QVBox( topFrame); | 292 | localFileWidget = new QVBox( topFrame); |
293 | //topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); | 293 | //topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); |
294 | //++iii; | 294 | //++iii; |
295 | temphb = new QHBox( localFileWidget ); | 295 | temphb = new QHBox( localFileWidget ); |
296 | 296 | ||
297 | lab = new QLabel( i18n("Local file Cal:"), temphb ); | 297 | lab = new QLabel( i18n("Local file Cal:"), temphb ); |
298 | lab = new QLabel( i18n("Local file ABook:"), temphb ); | 298 | lab = new QLabel( i18n("Local file ABook:"), temphb ); |
299 | lab = new QLabel( i18n("Local file PWMgr:"), temphb ); | 299 | lab = new QLabel( i18n("Local file PWMgr:"), temphb ); |
300 | temphb = new QHBox( localFileWidget ); | 300 | temphb = new QHBox( localFileWidget ); |
301 | button = new QPushButton( i18n("Choose..."), temphb ); | 301 | button = new QPushButton( i18n("Choose..."), temphb ); |
302 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); | 302 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); |
303 | button = new QPushButton( i18n("Choose..."), temphb ); | 303 | button = new QPushButton( i18n("Choose..."), temphb ); |
304 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) ); | 304 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) ); |
305 | button = new QPushButton( i18n("Choose..."), temphb ); | 305 | button = new QPushButton( i18n("Choose..."), temphb ); |
306 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) ); | 306 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) ); |
307 | temphb = new QHBox( localFileWidget ); | 307 | temphb = new QHBox( localFileWidget ); |
308 | 308 | ||
309 | mRemoteFile = new QLineEdit( temphb); | 309 | mRemoteFile = new QLineEdit( temphb); |
310 | mRemoteFileAB = new QLineEdit( temphb); | 310 | mRemoteFileAB = new QLineEdit( temphb); |
311 | mRemoteFilePWM = new QLineEdit( temphb); | 311 | mRemoteFilePWM = new QLineEdit( temphb); |
312 | mIsKapiFileL = new QCheckBox( i18n("Addressbook file (*.vcf) is used by KA/Pi"), localFileWidget ); | 312 | mIsKapiFileL = new QCheckBox( i18n("Addressbook file (*.vcf) is used by KA/Pi"), localFileWidget ); |
313 | 313 | ||
314 | 314 | ||
315 | // *** remote******************************* | 315 | // *** remote******************************* |
316 | remoteFileWidget = new QVBox( topFrame); | 316 | remoteFileWidget = new QVBox( topFrame); |
317 | //topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); | 317 | //topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); |
318 | //++iii; | 318 | //++iii; |
319 | temphb = new QHBox( remoteFileWidget ); | 319 | temphb = new QHBox( remoteFileWidget ); |
320 | new QLabel( i18n("Calendar:"), temphb); | 320 | new QLabel( i18n("Calendar:"), temphb); |
321 | new QLabel( i18n("AddressBook:"), temphb); | 321 | new QLabel( i18n("AddressBook:"), temphb); |
322 | new QLabel( i18n("PWManager:"), temphb); | 322 | new QLabel( i18n("PWManager:"), temphb); |
323 | 323 | ||
324 | lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); | 324 | lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); |
325 | temphb = new QHBox( remoteFileWidget ); | 325 | temphb = new QHBox( remoteFileWidget ); |
326 | mRemotePrecommand = new QLineEdit(temphb); | 326 | mRemotePrecommand = new QLineEdit(temphb); |
327 | mRemotePrecommandAB = new QLineEdit(temphb); | 327 | mRemotePrecommandAB = new QLineEdit(temphb); |
328 | mRemotePrecommandPWM = new QLineEdit(temphb); | 328 | mRemotePrecommandPWM = new QLineEdit(temphb); |
329 | 329 | ||
330 | lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); | 330 | lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); |
331 | temphb = new QHBox( remoteFileWidget ); | 331 | temphb = new QHBox( remoteFileWidget ); |
332 | mLocalTempFile = new QLineEdit(temphb); | 332 | mLocalTempFile = new QLineEdit(temphb); |
333 | mLocalTempFileAB = new QLineEdit(temphb); | 333 | mLocalTempFileAB = new QLineEdit(temphb); |
334 | mLocalTempFilePWM = new QLineEdit(temphb); | 334 | mLocalTempFilePWM = new QLineEdit(temphb); |
335 | 335 | ||
336 | lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); | 336 | lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); |
337 | temphb = new QHBox( remoteFileWidget ); | 337 | temphb = new QHBox( remoteFileWidget ); |
338 | mRemotePostcommand = new QLineEdit(temphb ); | 338 | mRemotePostcommand = new QLineEdit(temphb ); |
339 | mRemotePostcommandAB = new QLineEdit(temphb ); | 339 | mRemotePostcommandAB = new QLineEdit(temphb ); |
340 | mRemotePostcommandPWM = new QLineEdit(temphb ); | 340 | mRemotePostcommandPWM = new QLineEdit(temphb ); |
341 | mIsKapiFileR = new QCheckBox( i18n("Addressbook file is used by KA/Pi"), remoteFileWidget ); | 341 | mIsKapiFileR = new QCheckBox( i18n("Addressbook file is used by KA/Pi"), remoteFileWidget ); |
342 | lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); | 342 | lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); |
343 | temphb = new QHBox( remoteFileWidget ); | 343 | temphb = new QHBox( remoteFileWidget ); |
344 | button = new QPushButton( i18n("ssh/scp"), temphb ); | 344 | button = new QPushButton( i18n("ssh/scp"), temphb ); |
345 | connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); | 345 | connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); |
346 | button = new QPushButton( i18n("ftp"), temphb ); | 346 | button = new QPushButton( i18n("ftp"), temphb ); |
347 | connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); | 347 | connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); |
348 | lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); | 348 | lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); |
349 | 349 | ||
350 | // *** pi-sync******************************* | 350 | // *** pi-sync******************************* |
351 | piWidget = new QVBox( topFrame); | 351 | piWidget = new QVBox( topFrame); |
352 | //topLayout->addMultiCellWidget(piWidget, iii,iii,0,1); | 352 | //topLayout->addMultiCellWidget(piWidget, iii,iii,0,1); |
353 | //++iii; | 353 | //++iii; |
354 | temphb = new QHBox( piWidget ); | 354 | temphb = new QHBox( piWidget ); |
355 | new QLabel( i18n("Calendar:"), temphb); | 355 | new QLabel( i18n("Calendar:"), temphb); |
356 | new QLabel( i18n("AddressBook:"), temphb); | 356 | new QLabel( i18n("AddressBook:"), temphb); |
357 | new QLabel( i18n("PWManager:"), temphb); | 357 | new QLabel( i18n("PWManager:"), temphb); |
358 | 358 | ||
359 | lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget); | 359 | lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget); |
360 | temphb = new QHBox( piWidget ); | 360 | temphb = new QHBox( piWidget ); |
361 | mRemotePw = new QLineEdit(temphb); | 361 | mRemotePw = new QLineEdit(temphb); |
362 | mRemotePwAB = new QLineEdit(temphb); | 362 | mRemotePwAB = new QLineEdit(temphb); |
363 | mRemotePwPWM = new QLineEdit(temphb); | 363 | mRemotePwPWM = new QLineEdit(temphb); |
364 | 364 | ||
365 | lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget); | 365 | lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget); |
366 | temphb = new QHBox( piWidget ); | 366 | temphb = new QHBox( piWidget ); |
367 | mRemoteIP = new QLineEdit(temphb); | 367 | mRemoteIP = new QLineEdit(temphb); |
368 | mRemoteIPAB = new QLineEdit(temphb); | 368 | mRemoteIPAB = new QLineEdit(temphb); |
369 | mRemoteIPPWM = new QLineEdit(temphb); | 369 | mRemoteIPPWM = new QLineEdit(temphb); |
370 | 370 | ||
371 | lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget); | 371 | lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget); |
372 | temphb = new QHBox( piWidget ); | 372 | temphb = new QHBox( piWidget ); |
373 | mRemotePort = new QLineEdit(temphb); | 373 | mRemotePort = new QLineEdit(temphb); |
374 | mRemotePortAB = new QLineEdit(temphb); | 374 | mRemotePortAB = new QLineEdit(temphb); |
375 | mRemotePortPWM = new QLineEdit(temphb); | 375 | mRemotePortPWM = new QLineEdit(temphb); |
376 | 376 | ||
377 | lab = new QLabel( i18n("Local/remote Resource sync partners (Leave empty to not sync)"), piWidget); | 377 | lab = new QLabel( i18n("Local/remote Resource sync partners (Leave empty to not sync)"), piWidget); |
378 | mTableBox = new QHBox( piWidget ); | 378 | mTableBox = new QHBox( piWidget ); |
379 | mResTableKopi = new QTable( 1, 1, mTableBox ); | 379 | mResTableKopi = new QTable( 1, 1, mTableBox ); |
380 | mResTableKapi = new QTable( 1, 1, mTableBox ); | 380 | mResTableKapi = new QTable( 1, 1, mTableBox ); |
381 | mResTablePwmpi = new QTable( 1, 1, mTableBox ); | 381 | mResTablePwmpi = new QTable( 1, 1, mTableBox ); |
382 | mResTableKopi->horizontalHeader()->setLabel( 0, i18n("Remote") ); | 382 | mResTableKopi->horizontalHeader()->setLabel( 0, i18n("Remote") ); |
383 | mResTableKapi->horizontalHeader()->setLabel( 0, i18n("Remote") ); | 383 | mResTableKapi->horizontalHeader()->setLabel( 0, i18n("Remote") ); |
384 | mResTablePwmpi->horizontalHeader()->setLabel( 0, i18n("Remote") ); | 384 | mResTablePwmpi->horizontalHeader()->setLabel( 0, i18n("Remote") ); |
385 | mResTableKopi->setLeftMargin( 80 ); | 385 | mResTableKopi->setLeftMargin( 80 ); |
386 | mResTableKapi->setLeftMargin( 80 ); | 386 | mResTableKapi->setLeftMargin( 80 ); |
387 | } | 387 | } |
388 | // ****************************************** | 388 | // ****************************************** |
389 | // Profile kind specific settings END | 389 | // Profile kind specific settings END |
390 | 390 | ||
391 | } | 391 | } |
392 | 392 | ||
393 | void KSyncPrefsDialog::readResources() | 393 | void KSyncPrefsDialog::readResources() |
394 | { | 394 | { |
395 | mResourcesKopi.clear(); | 395 | mResourcesKopi.clear(); |
396 | KConfig fc(locateLocal("config","kopicalendarrc")); | 396 | KConfig fc(locateLocal("config","kopicalendarrc")); |
397 | fc.setGroup("CC"); | 397 | fc.setGroup("CC"); |
398 | int numCals = fc.readNumEntry("NumberCalendars",0 ); | 398 | int numCals = fc.readNumEntry("NumberCalendars",0 ); |
399 | int curCal = 1; | 399 | int curCal = 1; |
400 | while ( curCal <= numCals ) { | 400 | while ( curCal <= numCals ) { |
401 | QString prefix = "Cal_" +QString::number( curCal ); | 401 | QString prefix = "Cal_" +QString::number( curCal ); |
402 | QString name = fc.readEntry( prefix+"_Name", "Calendar"); | 402 | QString name = fc.readEntry( prefix+"_Name", "Calendar"); |
403 | mResourcesKopi.append( name ); | 403 | mResourcesKopi.append( name ); |
404 | ++curCal; | 404 | ++curCal; |
405 | } | 405 | } |
406 | mResTableKopi->setNumRows( mResourcesKopi.count() ); | 406 | mResTableKopi->setNumRows( mResourcesKopi.count() ); |
407 | int i; | 407 | int i; |
408 | for ( i = 0;i < mResourcesKopi.count(); ++i ) { | 408 | for ( i = 0;i < mResourcesKopi.count(); ++i ) { |
409 | mResTableKopi->verticalHeader ()->setLabel( i, mResourcesKopi[i] ); | 409 | mResTableKopi->verticalHeader ()->setLabel( i, mResourcesKopi[i] ); |
410 | } | 410 | } |
411 | 411 | ||
412 | mResourcesKapi.clear(); | 412 | mResourcesKapi.clear(); |
413 | 413 | ||
414 | KConfig conf ( locateLocal("config", "kabcrc") ); | 414 | KConfig conf ( locateLocal("config", "kabcrc") ); |
415 | 415 | ||
416 | conf.setGroup( "General" ); | 416 | conf.setGroup( "General" ); |
417 | 417 | ||
418 | QStringList keys = conf.readListEntry( "ResourceKeys" ); | 418 | QStringList keys = conf.readListEntry( "ResourceKeys" ); |
419 | //keys += conf->readListEntry( "PassiveResourceKeys" ); | 419 | //keys += conf->readListEntry( "PassiveResourceKeys" ); |
420 | 420 | ||
421 | //QString standardKey = mConfig->readEntry( "Standard" ); | 421 | //QString standardKey = mConfig->readEntry( "Standard" ); |
422 | 422 | ||
423 | for ( QStringList::Iterator it = keys.begin(); it != keys.end(); ++it ) { | 423 | for ( QStringList::Iterator it = keys.begin(); it != keys.end(); ++it ) { |
424 | conf.setGroup("Resource_"+ (*it) ); | 424 | conf.setGroup("Resource_"+ (*it) ); |
425 | QString name = conf.readEntry( "ResourceName" ); | 425 | QString name = conf.readEntry( "ResourceName" ); |
426 | mResourcesKapi.append( name ); | 426 | mResourcesKapi.append( name ); |
427 | } | 427 | } |
428 | mResTableKapi->setNumRows( mResourcesKapi.count() ); | 428 | mResTableKapi->setNumRows( mResourcesKapi.count() ); |
429 | for ( i = 0;i < mResourcesKopi.count(); ++i ) { | 429 | for ( i = 0;i < mResourcesKopi.count(); ++i ) { |
430 | mResTableKapi->verticalHeader ()->setLabel( i, mResourcesKapi[i] ); | 430 | mResTableKapi->verticalHeader ()->setLabel( i, mResourcesKapi[i] ); |
431 | } | 431 | } |
432 | 432 | ||
433 | 433 | ||
434 | } | 434 | } |
435 | void KSyncPrefsDialog::readFilter() | 435 | void KSyncPrefsDialog::readFilter() |
436 | { | 436 | { |
437 | mFilterKapi.clear(); | 437 | mFilterKapi.clear(); |
438 | mFilterKopi.clear(); | 438 | mFilterKopi.clear(); |
439 | KConfig cfgko(locateLocal("config","korganizerrc")); | 439 | KConfig cfgko(locateLocal("config","korganizerrc")); |
440 | KConfig cfgka(locateLocal("config","kaddressbookrc")); | 440 | KConfig cfgka(locateLocal("config","kaddressbookrc")); |
441 | cfgko.setGroup("General"); | 441 | cfgko.setGroup("General"); |
442 | mFilterKopi = cfgko.readListEntry("CalendarFilters"); | 442 | mFilterKopi = cfgko.readListEntry("CalendarFilters"); |
443 | cfgka.setGroup("Filter"); | 443 | cfgka.setGroup("Filter"); |
444 | int count = cfgka.readNumEntry( "Count", 0 ); | 444 | int count = cfgka.readNumEntry( "Count", 0 ); |
445 | for ( int i = 0; i < count; i++ ) { | 445 | for ( int i = 0; i < count; i++ ) { |
446 | cfgka.setGroup("Filter_"+QString::number( i ) ); | 446 | cfgka.setGroup("Filter_"+QString::number( i ) ); |
447 | mFilterKapi.append( cfgka.readEntry("Name", "internal error") ); | 447 | mFilterKapi.append( cfgka.readEntry("Name", "internal error") ); |
448 | } | 448 | } |
449 | mFilterOutCal->clear(); | 449 | mFilterOutCal->clear(); |
450 | mFilterInCal->clear(); | 450 | mFilterInCal->clear(); |
451 | mFilterOutAB->clear(); | 451 | mFilterOutAB->clear(); |
452 | mFilterInAB->clear(); | 452 | mFilterInAB->clear(); |
453 | QStringList temp = mFilterKopi; | 453 | QStringList temp = mFilterKopi; |
454 | temp.prepend(i18n("No Filter") ); | 454 | temp.prepend(i18n("No Filter") ); |
455 | mFilterOutCal->insertStringList( temp ); | 455 | mFilterOutCal->insertStringList( temp ); |
456 | mFilterInCal->insertStringList( temp ); | 456 | mFilterInCal->insertStringList( temp ); |
457 | temp = mFilterKapi; | 457 | temp = mFilterKapi; |
458 | temp.prepend(i18n("No Filter") ); | 458 | temp.prepend(i18n("No Filter") ); |
459 | mFilterOutAB->insertStringList( temp ); | 459 | mFilterOutAB->insertStringList( temp ); |
460 | mFilterInAB->insertStringList( temp ); | 460 | mFilterInAB->insertStringList( temp ); |
461 | } | 461 | } |
462 | 462 | ||
463 | void KSyncPrefsDialog::slotOK() | 463 | void KSyncPrefsDialog::slotOK() |
464 | { | 464 | { |
465 | if ( mMyMachineName->text() == "undefined" ) { | 465 | if ( mMyMachineName->text() == "undefined" ) { |
466 | KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); | 466 | KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); |
467 | return; | 467 | return; |
468 | } | 468 | } |
469 | int i; | 469 | int i; |
470 | for (i = 0; i < mSyncProfileNames.count(); ++ i) { | 470 | for (i = 0; i < mSyncProfileNames.count(); ++ i) { |
471 | if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { | 471 | if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { |
472 | KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); | 472 | KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); |
473 | return; | 473 | return; |
474 | } | 474 | } |
475 | } | 475 | } |
476 | usrWriteConfig(); | 476 | usrWriteConfig(); |
477 | QDialog::accept(); | 477 | QDialog::accept(); |
478 | } | 478 | } |
479 | void KSyncPrefsDialog::accept() | 479 | void KSyncPrefsDialog::accept() |
480 | { | 480 | { |
481 | slotOK(); | 481 | slotOK(); |
482 | } | 482 | } |
483 | void KSyncPrefsDialog::chooseFile() | 483 | void KSyncPrefsDialog::chooseFile() |
484 | { | 484 | { |
485 | QString fn = QDir::homeDirPath(); | 485 | QString fn = QDir::homeDirPath(); |
486 | 486 | ||
487 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 487 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
488 | if ( fn == "" ) | 488 | if ( fn == "" ) |
489 | return; | 489 | return; |
490 | mRemoteFile->setText( fn ); | 490 | mRemoteFile->setText( fn ); |
491 | } | 491 | } |
492 | 492 | ||
493 | void KSyncPrefsDialog::chooseFileAB() | 493 | void KSyncPrefsDialog::chooseFileAB() |
494 | { | 494 | { |
495 | QString fn = QDir::homeDirPath(); | 495 | QString fn = QDir::homeDirPath(); |
496 | 496 | ||
497 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this ); | 497 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this ); |
498 | if ( fn == "" ) | 498 | if ( fn == "" ) |
499 | return; | 499 | return; |
500 | mRemoteFileAB->setText( fn ); | 500 | mRemoteFileAB->setText( fn ); |
501 | } | 501 | } |
502 | 502 | ||
503 | void KSyncPrefsDialog::chooseFilePWM() | 503 | void KSyncPrefsDialog::chooseFilePWM() |
504 | { | 504 | { |
505 | QString fn = QDir::homeDirPath(); | 505 | QString fn = QDir::homeDirPath(); |
506 | |||
507 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this ); | 506 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this ); |
508 | if ( fn == "" ) | 507 | if ( fn == "" ) |
509 | return; | 508 | return; |
510 | mRemoteFilePWM->setText( fn ); | 509 | mRemoteFilePWM->setText( fn ); |
511 | } | 510 | } |
512 | void KSyncPrefsDialog::updateMyCaption() | 511 | void KSyncPrefsDialog::updateMyCaption() |
513 | { | 512 | { |
514 | setCaption( mProfileBox->currentText() + " : " +i18n("Synchronization Preferences")); | 513 | setCaption( mProfileBox->currentText() + " : " +i18n("Synchronization Preferences")); |
515 | } | 514 | } |
516 | void KSyncPrefsDialog::textChanged( const QString & s ) | 515 | void KSyncPrefsDialog::textChanged( const QString & s ) |
517 | { | 516 | { |
518 | if ( mProfileBox->count() == 0 ) | 517 | if ( mProfileBox->count() == 0 ) |
519 | return; | 518 | return; |
520 | if ( currentSelection < 3 ) { | 519 | if ( currentSelection < 3 ) { |
521 | //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); | 520 | //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); |
522 | mProfileBox->blockSignals( true ); | 521 | mProfileBox->blockSignals( true ); |
523 | mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); | 522 | mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); |
524 | mProfileBox->blockSignals( false ); | 523 | mProfileBox->blockSignals( false ); |
525 | return; | 524 | return; |
526 | } | 525 | } |
527 | //qDebug("cur i %d ",mProfileBox-> currentItem () ); | 526 | //qDebug("cur i %d ",mProfileBox-> currentItem () ); |
528 | mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; | 527 | mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; |
529 | KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; | 528 | KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; |
530 | prof->setName( s ); | 529 | prof->setName( s ); |
531 | mSyncProfileNames[mProfileBox-> currentItem ()] = s; | 530 | mSyncProfileNames[mProfileBox-> currentItem ()] = s; |
532 | updateMyCaption(); | 531 | updateMyCaption(); |
533 | } | 532 | } |
534 | void KSyncPrefsDialog::profileChanged( int item ) | 533 | void KSyncPrefsDialog::profileChanged( int item ) |
535 | { | 534 | { |
536 | //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() ); | 535 | //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() ); |
537 | KSyncProfile* prof; | 536 | KSyncProfile* prof; |
538 | saveProfile(); | 537 | saveProfile(); |
539 | readFilter(); | 538 | readFilter(); |
540 | readResources(); | 539 | readResources(); |
541 | currentSelection = item; | 540 | currentSelection = item; |
542 | prof = mSyncProfiles.at(item) ; | 541 | prof = mSyncProfiles.at(item) ; |
543 | 542 | ||
544 | mRemotePw->setText(prof->getRemotePw()); | 543 | mRemotePw->setText(prof->getRemotePw()); |
545 | mRemoteIP->setText(prof->getRemoteIP()); | 544 | mRemoteIP->setText(prof->getRemoteIP()); |
546 | mRemotePort->setText(prof->getRemotePort()); | 545 | mRemotePort->setText(prof->getRemotePort()); |
547 | 546 | ||
548 | mRemotePwAB->setText(prof->getRemotePwAB()); | 547 | mRemotePwAB->setText(prof->getRemotePwAB()); |
549 | mRemoteIPAB->setText(prof->getRemoteIPAB()); | 548 | mRemoteIPAB->setText(prof->getRemoteIPAB()); |
550 | mRemotePortAB->setText(prof->getRemotePortAB()); | 549 | mRemotePortAB->setText(prof->getRemotePortAB()); |
551 | 550 | ||
552 | mRemotePwPWM->setText(prof->getRemotePwPWM()); | 551 | mRemotePwPWM->setText(prof->getRemotePwPWM()); |
553 | mRemoteIPPWM->setText(prof->getRemoteIPPWM()); | 552 | mRemoteIPPWM->setText(prof->getRemoteIPPWM()); |
554 | mRemotePortPWM->setText(prof->getRemotePortPWM()); | 553 | mRemotePortPWM->setText(prof->getRemotePortPWM()); |
555 | 554 | ||
556 | mRemotePrecommand->setText(prof->getPreSyncCommand()); | 555 | mRemotePrecommand->setText(prof->getPreSyncCommand()); |
557 | mRemotePostcommand->setText(prof->getPostSyncCommand()); | 556 | mRemotePostcommand->setText(prof->getPostSyncCommand()); |
558 | mLocalTempFile->setText(prof->getLocalTempFile()); | 557 | mLocalTempFile->setText(prof->getLocalTempFile()); |
559 | mRemoteFile->setText(prof->getRemoteFileName()) ; | 558 | mRemoteFile->setText(prof->getRemoteFileName()) ; |
560 | 559 | ||
561 | mRemotePrecommandAB->setText(prof->getPreSyncCommandAB()); | 560 | mRemotePrecommandAB->setText(prof->getPreSyncCommandAB()); |
562 | mRemotePostcommandAB->setText(prof->getPostSyncCommandAB()); | 561 | mRemotePostcommandAB->setText(prof->getPostSyncCommandAB()); |
563 | mLocalTempFileAB->setText(prof->getLocalTempFileAB()); | 562 | mLocalTempFileAB->setText(prof->getLocalTempFileAB()); |
564 | mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ; | 563 | mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ; |
565 | 564 | ||
566 | mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM()); | 565 | mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM()); |
567 | mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM()); | 566 | mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM()); |
568 | mLocalTempFilePWM->setText(prof->getLocalTempFilePWM()); | 567 | mLocalTempFilePWM->setText(prof->getLocalTempFilePWM()); |
569 | mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ; | 568 | mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ; |
570 | 569 | ||
571 | if ( mWriteContactToSIM ) | 570 | if ( mWriteContactToSIM ) |
572 | mWriteContactToSIM->setChecked( prof->getWriteContactToSIM()); | 571 | mWriteContactToSIM->setChecked( prof->getWriteContactToSIM()); |
573 | mPhoneDevice->setText(prof->getPhoneDevice()); | 572 | mPhoneDevice->setText(prof->getPhoneDevice()); |
574 | mPhoneConnection->setText(prof->getPhoneConnection()); | 573 | mPhoneConnection->setText(prof->getPhoneConnection()); |
575 | mPhoneModel->setText(prof->getPhoneModel()); | 574 | mPhoneModel->setText(prof->getPhoneModel()); |
576 | 575 | ||
577 | mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); | 576 | mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); |
578 | mAskForPreferences->setChecked( prof->getAskForPreferences()); | 577 | mAskForPreferences->setChecked( prof->getAskForPreferences()); |
579 | mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); | 578 | mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); |
580 | mWriteBackFile->setChecked( prof->getWriteBackFile()); | 579 | mWriteBackFile->setChecked( prof->getWriteBackFile()); |
581 | mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); | 580 | mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); |
582 | mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() ); | 581 | mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() ); |
583 | mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() ); | 582 | mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() ); |
584 | mWriteBackFuture->setChecked( prof->getWriteBackFuture()); | 583 | mWriteBackFuture->setChecked( prof->getWriteBackFuture()); |
585 | mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() ); | 584 | mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() ); |
586 | mWriteBackPastWeeks->setValue( prof->getWriteBackPastWeeks() ); | 585 | mWriteBackPastWeeks->setValue( prof->getWriteBackPastWeeks() ); |
587 | 586 | ||
588 | mFilterInCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterInCal () ) + 1 ); | 587 | mFilterInCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterInCal () ) + 1 ); |
589 | mFilterOutCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterOutCal () ) + 1 ); | 588 | mFilterOutCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterOutCal () ) + 1 ); |
590 | mFilterInAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterInAB () ) + 1 ); | 589 | mFilterInAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterInAB () ) + 1 ); |
591 | mFilterOutAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterOutAB () ) + 1 ); | 590 | mFilterOutAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterOutAB () ) + 1 ); |
592 | 591 | ||
593 | switch ( prof->getSyncPrefs() ) { | 592 | switch ( prof->getSyncPrefs() ) { |
594 | case 0: | 593 | case 0: |
595 | loc->setChecked( true); | 594 | loc->setChecked( true); |
596 | break; | 595 | break; |
597 | case 1: | 596 | case 1: |
598 | rem->setChecked( true ); | 597 | rem->setChecked( true ); |
599 | break; | 598 | break; |
600 | case 2: | 599 | case 2: |
601 | newest->setChecked( true); | 600 | newest->setChecked( true); |
602 | break; | 601 | break; |
603 | case 3: | 602 | case 3: |
604 | ask->setChecked( true); | 603 | ask->setChecked( true); |
605 | break; | 604 | break; |
606 | case 4: | 605 | case 4: |
607 | f_loc->setChecked( true); | 606 | f_loc->setChecked( true); |
608 | break; | 607 | break; |
609 | case 5: | 608 | case 5: |
610 | f_rem->setChecked( true); | 609 | f_rem->setChecked( true); |
611 | break; | 610 | break; |
612 | case 6: | 611 | case 6: |
613 | //both->setChecked( true); | 612 | //both->setChecked( true); |
614 | break; | 613 | break; |
615 | default: | 614 | default: |
616 | break; | 615 | break; |
617 | } | 616 | } |
618 | mIsLocal->setChecked(prof->getIsLocalFileSync()) ; | 617 | mIsLocal->setChecked(prof->getIsLocalFileSync()) ; |
619 | mIsPhone->setChecked(prof->getIsPhoneSync()) ; | 618 | mIsPhone->setChecked(prof->getIsPhoneSync()) ; |
620 | mIsPi->setChecked(prof->getIsPiSync()) ; | 619 | mIsPi->setChecked(prof->getIsPiSync()) ; |
621 | mIsPiSpecific->setChecked(prof->getIsPiSyncSpec()) ; | 620 | mIsPiSpecific->setChecked(prof->getIsPiSyncSpec()) ; |
622 | mIsKapiFileL->setChecked(prof->getIsKapiFile()) ; | 621 | mIsKapiFileL->setChecked(prof->getIsKapiFile()) ; |
623 | mIsKapiFileR->setChecked(prof->getIsKapiFile()) ; | 622 | mIsKapiFileR->setChecked(prof->getIsKapiFile()) ; |
624 | 623 | ||
625 | 624 | ||
626 | QStringList res = QStringList::split( ":",prof->getResSpecKopi(), true ); | 625 | QStringList res = QStringList::split( ":",prof->getResSpecKopi(), true ); |
627 | int add = res.count()/2; | 626 | int add = res.count()/2; |
628 | int i; | 627 | int i; |
629 | for ( i = 0;i < add ; ++i ) { | 628 | for ( i = 0;i < add ; ++i ) { |
630 | mResTableKopi->setText( i, 0, res[i+add] ); | 629 | mResTableKopi->setText( i, 0, res[i+add] ); |
631 | } | 630 | } |
632 | res = QStringList::split( ":",prof->getResSpecKapi(), true); | 631 | res = QStringList::split( ":",prof->getResSpecKapi(), true); |
633 | add = res.count()/2; | 632 | add = res.count()/2; |
634 | for ( i = 0;i < add; ++i ) { | 633 | for ( i = 0;i < add; ++i ) { |
635 | mResTableKapi->setText( i, 0, res[i+add] ); | 634 | mResTableKapi->setText( i, 0, res[i+add] ); |
636 | } | 635 | } |
637 | mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() &&!prof->getIsPiSyncSpec()); | 636 | mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() &&!prof->getIsPiSyncSpec()); |
638 | proGr->setEnabled( item > 2 ); | 637 | proGr->setEnabled( item > 2 ); |
639 | if ( item < 3 ) { | 638 | if ( item < 3 ) { |
640 | localFileWidget->hide(); | 639 | localFileWidget->hide(); |
641 | remoteFileWidget->hide(); | 640 | remoteFileWidget->hide(); |
642 | phoneWidget->hide(); | 641 | phoneWidget->hide(); |
643 | piWidget->hide(); | 642 | piWidget->hide(); |
644 | 643 | ||
645 | } else | 644 | } else |
646 | kindChanged( prof->getIsLocalFileSync() ); | 645 | kindChanged( prof->getIsLocalFileSync() ); |
647 | updateMyCaption(); | 646 | updateMyCaption(); |
648 | } | 647 | } |
649 | 648 | ||
650 | void KSyncPrefsDialog::fillSSH() | 649 | void KSyncPrefsDialog::fillSSH() |
651 | { | 650 | { |
652 | mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); | 651 | mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); |
653 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); | 652 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); |
654 | mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); | 653 | mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); |
655 | mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); | 654 | mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); |
656 | mLocalTempFileAB->setText("/tmp/std.vcf" ); | 655 | mLocalTempFileAB->setText("/tmp/std.vcf" ); |
657 | mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" ); | 656 | mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" ); |
658 | mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); | 657 | mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); |
659 | mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); | 658 | mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); |
660 | mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" ); | 659 | mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" ); |
661 | } | 660 | } |
662 | void KSyncPrefsDialog::fillFTP() | 661 | void KSyncPrefsDialog::fillFTP() |
663 | { | 662 | { |
664 | mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); | 663 | mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); |
665 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); | 664 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); |
666 | mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); | 665 | mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); |
667 | mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" ); | 666 | mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" ); |
668 | mLocalTempFileAB->setText("/tmp/std.vcf" ); | 667 | mLocalTempFileAB->setText("/tmp/std.vcf" ); |
669 | mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); | 668 | mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); |
670 | 669 | ||
671 | mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" ); | 670 | mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" ); |
672 | mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); | 671 | mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); |
673 | mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); | 672 | mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); |
674 | 673 | ||
675 | } | 674 | } |
676 | void KSyncPrefsDialog::kindChanged( bool b ) | 675 | void KSyncPrefsDialog::kindChanged( bool b ) |
677 | { | 676 | { |
678 | 677 | ||
679 | if ( mIsLocal->isChecked () ) { | 678 | if ( mIsLocal->isChecked () ) { |
680 | mIsKapiFileL->setChecked( mIsKapiFileR->isChecked() ); | 679 | mIsKapiFileL->setChecked( mIsKapiFileR->isChecked() ); |
681 | } else { | 680 | } else { |
682 | mIsKapiFileR->setChecked( mIsKapiFileL->isChecked() ); | 681 | mIsKapiFileR->setChecked( mIsKapiFileL->isChecked() ); |
683 | } | 682 | } |
684 | 683 | ||
685 | if ( mIsLocal->isChecked () ) | 684 | if ( mIsLocal->isChecked () ) |
686 | localFileWidget->show(); | 685 | localFileWidget->show(); |
687 | else | 686 | else |
688 | localFileWidget->hide(); | 687 | localFileWidget->hide(); |
689 | 688 | ||
690 | if ( mIsNotLocal->isChecked () ) | 689 | if ( mIsNotLocal->isChecked () ) |
691 | remoteFileWidget->show(); | 690 | remoteFileWidget->show(); |
692 | else | 691 | else |
693 | remoteFileWidget->hide(); | 692 | remoteFileWidget->hide(); |
694 | 693 | ||
695 | if ( mIsPhone->isChecked () ) { | 694 | if ( mIsPhone->isChecked () ) { |
696 | phoneWidget->show(); | 695 | phoneWidget->show(); |
697 | } | 696 | } |
698 | else { | 697 | else { |
699 | phoneWidget->hide(); | 698 | phoneWidget->hide(); |
700 | } | 699 | } |
701 | 700 | ||
702 | if ( mIsPi->isChecked () || mIsPiSpecific->isChecked () ) { | 701 | if ( mIsPi->isChecked () || mIsPiSpecific->isChecked () ) { |
703 | piWidget->show(); | 702 | piWidget->show(); |
704 | if (mIsPiSpecific->isChecked () ) { | 703 | if (mIsPiSpecific->isChecked () ) { |
705 | mTableBox->show(); | 704 | mTableBox->show(); |
706 | } | 705 | } |
707 | else { | 706 | else { |
708 | mTableBox->hide(); | 707 | mTableBox->hide(); |
709 | } | 708 | } |
710 | } | 709 | } |
711 | else { | 710 | else { |
712 | piWidget->hide(); | 711 | piWidget->hide(); |
713 | } | 712 | } |
714 | 713 | ||
715 | 714 | ||
716 | } | 715 | } |
717 | void KSyncPrefsDialog::deleteProfile() | 716 | void KSyncPrefsDialog::deleteProfile() |
718 | { | 717 | { |
719 | //qDebug("KSyncPrefsDialog::deleteProfile() "); | 718 | //qDebug("KSyncPrefsDialog::deleteProfile() "); |
720 | if ( currentSelection >= 0 ) { | 719 | if ( currentSelection >= 0 ) { |
721 | if ( currentSelection < 3 ) { | 720 | if ( currentSelection < 3 ) { |
722 | KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); | 721 | KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); |
723 | return; | 722 | return; |
724 | } | 723 | } |
725 | KSyncProfile* temp = mSyncProfiles.at(currentSelection); | 724 | KSyncProfile* temp = mSyncProfiles.at(currentSelection); |
726 | mSyncProfiles.remove( temp ); | 725 | mSyncProfiles.remove( temp ); |
727 | mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); | 726 | mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); |
728 | insertProfiles(); | 727 | insertProfiles(); |
729 | } | 728 | } |
730 | } | 729 | } |
731 | 730 | ||
732 | void KSyncPrefsDialog::saveProfile() | 731 | void KSyncPrefsDialog::saveProfile() |
733 | { | 732 | { |
734 | KSyncProfile* prof; | 733 | KSyncProfile* prof; |
735 | if ( currentSelection >= 0 ) { | 734 | if ( currentSelection >= 0 ) { |
736 | prof = mSyncProfiles.at(currentSelection) ; | 735 | prof = mSyncProfiles.at(currentSelection) ; |
737 | 736 | ||
738 | prof->setRemotePw( mRemotePw->text()); | 737 | prof->setRemotePw( mRemotePw->text()); |
739 | prof->setRemoteIP( mRemoteIP->text()); | 738 | prof->setRemoteIP( mRemoteIP->text()); |
740 | prof->setRemotePort( mRemotePort->text()); | 739 | prof->setRemotePort( mRemotePort->text()); |
741 | 740 | ||
742 | prof->setRemotePwAB( mRemotePwAB->text()); | 741 | prof->setRemotePwAB( mRemotePwAB->text()); |
743 | prof->setRemoteIPAB( mRemoteIPAB->text()); | 742 | prof->setRemoteIPAB( mRemoteIPAB->text()); |
744 | prof->setRemotePortAB( mRemotePortAB->text()); | 743 | prof->setRemotePortAB( mRemotePortAB->text()); |
745 | 744 | ||
746 | prof->setRemotePwPWM( mRemotePwPWM->text()); | 745 | prof->setRemotePwPWM( mRemotePwPWM->text()); |
747 | prof->setRemoteIPPWM( mRemoteIPPWM->text()); | 746 | prof->setRemoteIPPWM( mRemoteIPPWM->text()); |
748 | prof->setRemotePortPWM( mRemotePortPWM->text()); | 747 | prof->setRemotePortPWM( mRemotePortPWM->text()); |
749 | 748 | ||
750 | prof->setPreSyncCommand( mRemotePrecommand->text()); | 749 | prof->setPreSyncCommand( mRemotePrecommand->text()); |
751 | prof->setPostSyncCommand( mRemotePostcommand->text() ); | 750 | prof->setPostSyncCommand( mRemotePostcommand->text() ); |
752 | prof->setLocalTempFile( mLocalTempFile->text()); | 751 | prof->setLocalTempFile( mLocalTempFile->text()); |
753 | prof->setRemoteFileName( mRemoteFile->text() ); | 752 | prof->setRemoteFileName( mRemoteFile->text() ); |
754 | prof->setPreSyncCommandAB( mRemotePrecommandAB->text()); | 753 | prof->setPreSyncCommandAB( mRemotePrecommandAB->text()); |
755 | prof->setPostSyncCommandAB( mRemotePostcommandAB->text() ); | 754 | prof->setPostSyncCommandAB( mRemotePostcommandAB->text() ); |
756 | prof->setLocalTempFileAB( mLocalTempFileAB->text()); | 755 | prof->setLocalTempFileAB( mLocalTempFileAB->text()); |
757 | prof->setRemoteFileNameAB( mRemoteFileAB->text() ); | 756 | prof->setRemoteFileNameAB( mRemoteFileAB->text() ); |
758 | prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text()); | 757 | prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text()); |
759 | prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() ); | 758 | prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() ); |
760 | prof->setLocalTempFilePWM( mLocalTempFilePWM->text()); | 759 | prof->setLocalTempFilePWM( mLocalTempFilePWM->text()); |
761 | prof->setRemoteFileNamePWM( mRemoteFilePWM->text() ); | 760 | prof->setRemoteFileNamePWM( mRemoteFilePWM->text() ); |
762 | prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); | 761 | prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); |
763 | prof->setAskForPreferences( mAskForPreferences->isChecked()); | 762 | prof->setAskForPreferences( mAskForPreferences->isChecked()); |
764 | prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); | 763 | prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); |
765 | prof->setWriteBackFile( mWriteBackFile->isChecked()); | 764 | prof->setWriteBackFile( mWriteBackFile->isChecked()); |
766 | prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); | 765 | prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); |
767 | prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() ); | 766 | prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() ); |
768 | prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() ); | 767 | prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() ); |
769 | int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; | 768 | int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; |
770 | prof->setSyncPrefs( syncprefs); | 769 | prof->setSyncPrefs( syncprefs); |
771 | prof->setIsLocalFileSync( mIsLocal->isChecked() ); | 770 | prof->setIsLocalFileSync( mIsLocal->isChecked() ); |
772 | prof->setIsPhoneSync( mIsPhone->isChecked() ); | 771 | prof->setIsPhoneSync( mIsPhone->isChecked() ); |
773 | prof->setIsPiSync( mIsPi->isChecked() ); | 772 | prof->setIsPiSync( mIsPi->isChecked() ); |
774 | prof->setIsPiSyncSpec( mIsPiSpecific->isChecked() ); | 773 | prof->setIsPiSyncSpec( mIsPiSpecific->isChecked() ); |
775 | prof->setIsKapiFile( mIsKapiFileL->isChecked() ); | 774 | prof->setIsKapiFile( mIsKapiFileL->isChecked() ); |
776 | prof->setWriteBackFuture(mWriteBackFuture->isChecked()); | 775 | prof->setWriteBackFuture(mWriteBackFuture->isChecked()); |
777 | prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value()); | 776 | prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value()); |
778 | prof->setWriteBackPastWeeks(mWriteBackPastWeeks->value()); | 777 | prof->setWriteBackPastWeeks(mWriteBackPastWeeks->value()); |
779 | if ( mWriteContactToSIM ) | 778 | if ( mWriteContactToSIM ) |
780 | prof->setWriteContactToSIM(mWriteContactToSIM->isChecked()); | 779 | prof->setWriteContactToSIM(mWriteContactToSIM->isChecked()); |
781 | prof->setPhoneDevice( mPhoneDevice->text() ); | 780 | prof->setPhoneDevice( mPhoneDevice->text() ); |
782 | prof->setPhoneConnection( mPhoneConnection->text() ); | 781 | prof->setPhoneConnection( mPhoneConnection->text() ); |
783 | prof->setPhoneModel( mPhoneModel->text() ); | 782 | prof->setPhoneModel( mPhoneModel->text() ); |
784 | prof->setFilterInCal ( mFilterInCal->currentText ()); | 783 | prof->setFilterInCal ( mFilterInCal->currentText ()); |
785 | prof->setFilterOutCal ( mFilterOutCal ->currentText ()); | 784 | prof->setFilterOutCal ( mFilterOutCal ->currentText ()); |
786 | prof->setFilterInAB ( mFilterInAB ->currentText ()); | 785 | prof->setFilterInAB ( mFilterInAB ->currentText ()); |
787 | prof->setFilterOutAB ( mFilterOutAB ->currentText ()); | 786 | prof->setFilterOutAB ( mFilterOutAB ->currentText ()); |
788 | mProfileBox->setFocus(); | 787 | mProfileBox->setFocus(); |
789 | if ( mIsPiSpecific->isChecked() ) { | 788 | if ( mIsPiSpecific->isChecked() ) { |
790 | 789 | ||
791 | QStringList res = mResourcesKopi; | 790 | QStringList res = mResourcesKopi; |
792 | int i; | 791 | int i; |
793 | for ( i = 0;i < mResourcesKopi.count(); ++i ) { | 792 | for ( i = 0;i < mResourcesKopi.count(); ++i ) { |
794 | res.append( mResTableKopi->text( i, 0 )); | 793 | res.append( mResTableKopi->text( i, 0 )); |
795 | } | 794 | } |
796 | prof->setResSpecKopi( res.join(":")); | 795 | prof->setResSpecKopi( res.join(":")); |
797 | res = mResourcesKapi; | 796 | res = mResourcesKapi; |
798 | for ( i = 0;i < mResourcesKapi.count(); ++i ) { | 797 | for ( i = 0;i < mResourcesKapi.count(); ++i ) { |
799 | res.append( mResTableKapi->text( i, 0 )); | 798 | res.append( mResTableKapi->text( i, 0 )); |
800 | } | 799 | } |
801 | prof->setResSpecKapi( res.join(":")); | 800 | prof->setResSpecKapi( res.join(":")); |
802 | } | 801 | } |
803 | } | 802 | } |
804 | } | 803 | } |
805 | 804 | ||
806 | void KSyncPrefsDialog::insertProfiles() | 805 | void KSyncPrefsDialog::insertProfiles() |
807 | { | 806 | { |
808 | int curItem = mProfileBox->currentItem(); | 807 | int curItem = mProfileBox->currentItem(); |
809 | mProfileBox->blockSignals( true ); | 808 | mProfileBox->blockSignals( true ); |
810 | mProfileBox->clear(); | 809 | mProfileBox->clear(); |
811 | mProfileBox->insertStringList (mSyncProfileNames ); | 810 | mProfileBox->insertStringList (mSyncProfileNames ); |
812 | int item = mSyncProfileNames.count() -1; | 811 | int item = mSyncProfileNames.count() -1; |
813 | if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) | 812 | if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) |
814 | mProfileBox->setCurrentItem( curItem ); | 813 | mProfileBox->setCurrentItem( curItem ); |
815 | else if ( item >= 0 ) { | 814 | else if ( item >= 0 ) { |
816 | mProfileBox->setCurrentItem( item ); | 815 | mProfileBox->setCurrentItem( item ); |
817 | } | 816 | } |
818 | currentSelection = -1; | 817 | currentSelection = -1; |
819 | if ( mSyncProfileNames.count() > 0 ) { | 818 | if ( mSyncProfileNames.count() > 0 ) { |
820 | //qDebug(" profileChanged( mProfileBox->currentItem() "); | 819 | //qDebug(" profileChanged( mProfileBox->currentItem() "); |
821 | profileChanged( mProfileBox->currentItem() ); | 820 | profileChanged( mProfileBox->currentItem() ); |
822 | currentSelection = mProfileBox->currentItem(); | 821 | currentSelection = mProfileBox->currentItem(); |
823 | } | 822 | } |
824 | mProfileBox->blockSignals( false ); | 823 | mProfileBox->blockSignals( false ); |
825 | } | 824 | } |
826 | 825 | ||
827 | void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) | 826 | void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) |
828 | { | 827 | { |
829 | saveProfile(); | 828 | saveProfile(); |
830 | mSyncProfiles.append( temp ); | 829 | mSyncProfiles.append( temp ); |
831 | mSyncProfileNames << temp->getName(); | 830 | mSyncProfileNames << temp->getName(); |
832 | insertProfiles(); | 831 | insertProfiles(); |
833 | int last = mProfileBox->count() -1; | 832 | int last = mProfileBox->count() -1; |
834 | mProfileBox->blockSignals( true ); | 833 | mProfileBox->blockSignals( true ); |
835 | mProfileBox->setCurrentItem( last ); | 834 | mProfileBox->setCurrentItem( last ); |
836 | mProfileBox->blockSignals( false ); | 835 | mProfileBox->blockSignals( false ); |
837 | profileChanged(last); | 836 | profileChanged(last); |
838 | } | 837 | } |
839 | void KSyncPrefsDialog::newProfile() | 838 | void KSyncPrefsDialog::newProfile() |
840 | { | 839 | { |
841 | addProfile ( new KSyncProfile () ); | 840 | addProfile ( new KSyncProfile () ); |
842 | } | 841 | } |
843 | 842 | ||
844 | void KSyncPrefsDialog::cloneProfile() | 843 | void KSyncPrefsDialog::cloneProfile() |
845 | { | 844 | { |
846 | if ( currentSelection >= 0 ) | 845 | if ( currentSelection >= 0 ) |
847 | addProfile (mSyncProfiles.at(currentSelection)->clone()) ; | 846 | addProfile (mSyncProfiles.at(currentSelection)->clone()) ; |
848 | else | 847 | else |
849 | newProfile(); | 848 | newProfile(); |
850 | } | 849 | } |
851 | 850 | ||
852 | void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) | 851 | void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) |
853 | { | 852 | { |
854 | mMyMachineName->setText( name ); | 853 | mMyMachineName->setText( name ); |
855 | 854 | ||
856 | } | 855 | } |
857 | QString KSyncPrefsDialog::getLocalMachineName ( ) | 856 | QString KSyncPrefsDialog::getLocalMachineName ( ) |
858 | { | 857 | { |
859 | return mMyMachineName->text(); | 858 | return mMyMachineName->text(); |
860 | } | 859 | } |
861 | 860 | ||
862 | QStringList KSyncPrefsDialog::getSyncProfileNames() | 861 | QStringList KSyncPrefsDialog::getSyncProfileNames() |
863 | { | 862 | { |
864 | return mSyncProfileNames; | 863 | return mSyncProfileNames; |
865 | } | 864 | } |
866 | void KSyncPrefsDialog::usrReadConfig() | 865 | void KSyncPrefsDialog::usrReadConfig() |
867 | { | 866 | { |
868 | //KConfig *config = KOGlobals::config(); | 867 | //KConfig *config = KOGlobals::config(); |
869 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 868 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
870 | config.setGroup("General"); | 869 | config.setGroup("General"); |
871 | mSyncProfileNames =config.readListEntry("SyncProfileNames"); | 870 | mSyncProfileNames =config.readListEntry("SyncProfileNames"); |
872 | mMyMachineName->setText(config.readEntry("LocalMachineName","undefined")); | 871 | mMyMachineName->setText(config.readEntry("LocalMachineName","undefined")); |
873 | int i; | 872 | int i; |
874 | KSyncProfile* temp ; | 873 | KSyncProfile* temp ; |
875 | mSyncProfiles.clear(); | 874 | mSyncProfiles.clear(); |
876 | for ( i = 0; i < mSyncProfileNames.count();++i ) { | 875 | for ( i = 0; i < mSyncProfileNames.count();++i ) { |
877 | temp = new KSyncProfile (); | 876 | temp = new KSyncProfile (); |
878 | temp->setName( mSyncProfileNames[i] ); | 877 | temp->setName( mSyncProfileNames[i] ); |
879 | temp->readConfig( &config ); | 878 | temp->readConfig( &config ); |
880 | mSyncProfiles.append( temp ); | 879 | mSyncProfiles.append( temp ); |
881 | } | 880 | } |
882 | insertProfiles(); | 881 | insertProfiles(); |
883 | //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); | 882 | //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); |
884 | } | 883 | } |
885 | 884 | ||
886 | 885 | ||
887 | void KSyncPrefsDialog::usrWriteConfig() | 886 | void KSyncPrefsDialog::usrWriteConfig() |
888 | { | 887 | { |
889 | saveProfile(); | 888 | saveProfile(); |
890 | if ( currentSelection >= 0 ) | 889 | if ( currentSelection >= 0 ) |