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