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