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