author | zautrix <zautrix> | 2004-10-07 10:37:59 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-07 10:37:59 (UTC) |
commit | f0e8b8f36bccda952fa662e4faf2d58fcee67262 (patch) (unidiff) | |
tree | f1d26c6d9e8bdba9b15464682b8a64b1d3e04d8b /libkdepim/ksyncmanager.cpp | |
parent | 95508093d45aaf062813b7824884f964ee2d4d9a (diff) | |
download | kdepimpi-f0e8b8f36bccda952fa662e4faf2d58fcee67262.zip kdepimpi-f0e8b8f36bccda952fa662e4faf2d58fcee67262.tar.gz kdepimpi-f0e8b8f36bccda952fa662e4faf2d58fcee67262.tar.bz2 |
fix for different targets
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index ea543dd..b360644 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1,606 +1,616 @@ | |||
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 | //LR ok | 79 | //LR ok |
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 | prof << i18n("Sharp_DTM"); | 102 | prof << i18n("Sharp_DTM"); |
103 | prof << i18n("Local_file"); | 103 | prof << i18n("Local_file"); |
104 | KSyncProfile* temp = new KSyncProfile (); | 104 | KSyncProfile* temp = new KSyncProfile (); |
105 | temp->setName( prof[0] ); | 105 | temp->setName( prof[0] ); |
106 | temp->writeConfig(&config); | 106 | temp->writeConfig(&config); |
107 | temp->setName( prof[1] ); | 107 | temp->setName( prof[1] ); |
108 | temp->writeConfig(&config); | 108 | temp->writeConfig(&config); |
109 | config.setGroup("General"); | 109 | config.setGroup("General"); |
110 | config.writeEntry("SyncProfileNames",prof); | 110 | config.writeEntry("SyncProfileNames",prof); |
111 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 111 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
112 | config.sync(); | 112 | config.sync(); |
113 | delete temp; | 113 | delete temp; |
114 | } | 114 | } |
115 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 115 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
116 | mSyncProfileNames = prof; | 116 | mSyncProfileNames = prof; |
117 | unsigned int i; | 117 | unsigned int i; |
118 | for ( i = 0; i < prof.count(); ++i ) { | 118 | for ( i = 0; i < prof.count(); ++i ) { |
119 | mSyncMenu->insertItem( prof[i], 1000+i ); | 119 | mSyncMenu->insertItem( prof[i], 1000+i ); |
120 | if ( i == 2 ) | 120 | if ( i == 2 ) |
121 | mSyncMenu->insertSeparator(); | 121 | mSyncMenu->insertSeparator(); |
122 | } | 122 | } |
123 | QDir app_dir; | 123 | QDir app_dir; |
124 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 124 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
125 | if ( mTargetApp == PWMPI) { | 125 | if ( mTargetApp == PWMPI) { |
126 | mSyncMenu->removeItem( 1000 ); | 126 | mSyncMenu->removeItem( 1000 ); |
127 | } | 127 | } |
128 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 128 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
129 | mSyncMenu->setItemEnabled( 1000, false ); | 129 | mSyncMenu->setItemEnabled( 1000, false ); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | 132 | ||
133 | void KSyncManager::slotSyncMenu( int action ) | 133 | void KSyncManager::slotSyncMenu( int action ) |
134 | { | 134 | { |
135 | //qDebug("syncaction %d ", action); | 135 | //qDebug("syncaction %d ", action); |
136 | if ( action == 0 ) { | 136 | if ( action == 0 ) { |
137 | 137 | ||
138 | // seems to be a Qt2 event handling bug | 138 | // seems to be a Qt2 event handling bug |
139 | // syncmenu.clear causes a segfault at first time | 139 | // syncmenu.clear causes a segfault at first time |
140 | // when we call it after the main event loop, it is ok | 140 | // when we call it after the main event loop, it is ok |
141 | // same behaviour when calling OM/Pi via QCOP for the first time | 141 | // same behaviour when calling OM/Pi via QCOP for the first time |
142 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 142 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
143 | //confSync(); | 143 | //confSync(); |
144 | 144 | ||
145 | return; | 145 | return; |
146 | } | 146 | } |
147 | if ( action == 1 ) { | 147 | if ( action == 1 ) { |
148 | multiSync( true ); | 148 | multiSync( true ); |
149 | return; | 149 | return; |
150 | } | 150 | } |
151 | if ( action == 2 ) { | 151 | if ( action == 2 ) { |
152 | enableQuick(); | 152 | enableQuick(); |
153 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 153 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
154 | return; | 154 | return; |
155 | } | 155 | } |
156 | if ( action == 3 ) { | 156 | if ( action == 3 ) { |
157 | delete mServerSocket; | 157 | delete mServerSocket; |
158 | mServerSocket = 0; | 158 | mServerSocket = 0; |
159 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 159 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
160 | return; | 160 | return; |
161 | } | 161 | } |
162 | 162 | ||
163 | if (blockSave()) | 163 | if (blockSave()) |
164 | return; | 164 | return; |
165 | 165 | ||
166 | setBlockSave(true); | 166 | setBlockSave(true); |
167 | 167 | ||
168 | mCurrentSyncProfile = action - 1000 ; | 168 | mCurrentSyncProfile = action - 1000 ; |
169 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; | 169 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
170 | mCurrentSyncName = mLocalMachineName ; | 170 | mCurrentSyncName = mLocalMachineName ; |
171 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 171 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
172 | KSyncProfile* temp = new KSyncProfile (); | 172 | KSyncProfile* temp = new KSyncProfile (); |
173 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); | 173 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
174 | temp->readConfig(&config); | 174 | temp->readConfig(&config); |
175 | mAskForPreferences = temp->getAskForPreferences(); | 175 | mAskForPreferences = temp->getAskForPreferences(); |
176 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 176 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
177 | mWriteBackFile = temp->getWriteBackFile(); | 177 | mWriteBackFile = temp->getWriteBackFile(); |
178 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 178 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
179 | mWriteBackInFuture = 0; | 179 | mWriteBackInFuture = 0; |
180 | if ( temp->getWriteBackFuture() ) | 180 | if ( temp->getWriteBackFuture() ) |
181 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 181 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
182 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 182 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
183 | if ( action == 1000 ) { | 183 | if ( action == 1000 ) { |
184 | syncSharp(); | 184 | syncSharp(); |
185 | 185 | ||
186 | } else if ( action == 1001 ) { | 186 | } else if ( action == 1001 ) { |
187 | syncLocalFile(); | 187 | syncLocalFile(); |
188 | 188 | ||
189 | } else if ( action == 1002 ) { | 189 | } else if ( action == 1002 ) { |
190 | quickSyncLocalFile(); | 190 | quickSyncLocalFile(); |
191 | 191 | ||
192 | } else if ( action >= 1003 ) { | 192 | } else if ( action >= 1003 ) { |
193 | if ( temp->getIsLocalFileSync() ) { | 193 | if ( temp->getIsLocalFileSync() ) { |
194 | switch(mTargetApp) | 194 | switch(mTargetApp) |
195 | { | 195 | { |
196 | case (KAPI): | 196 | case (KAPI): |
197 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 197 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
198 | mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 198 | mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
199 | break; | 199 | break; |
200 | case (KOPI): | 200 | case (KOPI): |
201 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 201 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
202 | mLastSyncedLocalFile = temp->getRemoteFileName(); | 202 | mLastSyncedLocalFile = temp->getRemoteFileName(); |
203 | break; | 203 | break; |
204 | case (PWMPI): | 204 | case (PWMPI): |
205 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 205 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
206 | mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 206 | mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
207 | break; | 207 | break; |
208 | default: | 208 | default: |
209 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 209 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
210 | break; | 210 | break; |
211 | 211 | ||
212 | } | 212 | } |
213 | } else { | 213 | } else { |
214 | if ( temp->getIsPhoneSync() ) { | 214 | if ( temp->getIsPhoneSync() ) { |
215 | mPhoneDevice = temp->getPhoneDevice( ) ; | 215 | mPhoneDevice = temp->getPhoneDevice( ) ; |
216 | mPhoneConnection = temp->getPhoneConnection( ); | 216 | mPhoneConnection = temp->getPhoneConnection( ); |
217 | mPhoneModel = temp->getPhoneModel( ); | 217 | mPhoneModel = temp->getPhoneModel( ); |
218 | syncPhone(); | 218 | syncPhone(); |
219 | } else if ( temp->getIsPiSync() ) { | 219 | } else if ( temp->getIsPiSync() ) { |
220 | mPassWordPiSync = temp->getRemotePw(); | 220 | if ( mTargetApp == KAPI ) { |
221 | mActiveSyncPort = temp->getRemotePort(); | 221 | mPassWordPiSync = temp->getRemotePwAB(); |
222 | mActiveSyncIP = temp->getRemoteIP(); | 222 | mActiveSyncPort = temp->getRemotePortAB(); |
223 | mActiveSyncIP = temp->getRemoteIPAB(); | ||
224 | } else if ( mTargetApp == KOPI ) { | ||
225 | mPassWordPiSync = temp->getRemotePw(); | ||
226 | mActiveSyncPort = temp->getRemotePort(); | ||
227 | mActiveSyncIP = temp->getRemoteIP(); | ||
228 | } else { | ||
229 | mPassWordPiSync = temp->getRemotePwPWM(); | ||
230 | mActiveSyncPort = temp->getRemotePortPWM(); | ||
231 | mActiveSyncIP = temp->getRemoteIPPWM(); | ||
232 | } | ||
223 | syncPi(); | 233 | syncPi(); |
224 | } | 234 | } |
225 | syncRemote( temp ); | 235 | syncRemote( temp ); |
226 | 236 | ||
227 | } | 237 | } |
228 | } | 238 | } |
229 | delete temp; | 239 | delete temp; |
230 | setBlockSave(false); | 240 | setBlockSave(false); |
231 | } | 241 | } |
232 | void KSyncManager::enableQuick() | 242 | void KSyncManager::enableQuick() |
233 | { | 243 | { |
234 | QDialog dia ( 0, "input-dialog", true ); | 244 | QDialog dia ( 0, "input-dialog", true ); |
235 | QLineEdit lab ( &dia ); | 245 | QLineEdit lab ( &dia ); |
236 | QVBoxLayout lay( &dia ); | 246 | QVBoxLayout lay( &dia ); |
237 | lab.setText( mPrefs->mPassiveSyncPort ); | 247 | lab.setText( mPrefs->mPassiveSyncPort ); |
238 | lay.setMargin(7); | 248 | lay.setMargin(7); |
239 | lay.setSpacing(7); | 249 | lay.setSpacing(7); |
240 | int po = 9197+mTargetApp; | 250 | int po = 9197+mTargetApp; |
241 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); | 251 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); |
242 | lay.addWidget( &label); | 252 | lay.addWidget( &label); |
243 | lay.addWidget( &lab); | 253 | lay.addWidget( &lab); |
244 | 254 | ||
245 | QLineEdit lepw ( &dia ); | 255 | QLineEdit lepw ( &dia ); |
246 | lepw.setText( mPrefs->mPassiveSyncPw ); | 256 | lepw.setText( mPrefs->mPassiveSyncPw ); |
247 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 257 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
248 | lay.addWidget( &label2); | 258 | lay.addWidget( &label2); |
249 | lay.addWidget( &lepw); | 259 | lay.addWidget( &lepw); |
250 | dia.setFixedSize( 230,80 ); | 260 | dia.setFixedSize( 230,80 ); |
251 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 261 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
252 | QPushButton pb ( "OK", &dia); | 262 | QPushButton pb ( "OK", &dia); |
253 | lay.addWidget( &pb ); | 263 | lay.addWidget( &pb ); |
254 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 264 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
255 | dia.show(); | 265 | dia.show(); |
256 | if ( ! dia.exec() ) | 266 | if ( ! dia.exec() ) |
257 | return; | 267 | return; |
258 | dia.hide(); | 268 | dia.hide(); |
259 | qApp->processEvents(); | 269 | qApp->processEvents(); |
260 | mPrefs->mPassiveSyncPw = lepw.text(); | 270 | mPrefs->mPassiveSyncPw = lepw.text(); |
261 | mPrefs->mPassiveSyncPort = lab.text(); | 271 | mPrefs->mPassiveSyncPort = lab.text(); |
262 | bool ok; | 272 | bool ok; |
263 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); | 273 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); |
264 | if ( ! ok ) { | 274 | if ( ! ok ) { |
265 | KMessageBox::information( 0, i18n("No valid port")); | 275 | KMessageBox::information( 0, i18n("No valid port")); |
266 | return; | 276 | return; |
267 | } | 277 | } |
268 | //qDebug("port %d ", port); | 278 | //qDebug("port %d ", port); |
269 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); | 279 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); |
270 | mServerSocket->setFileName( defaultFileName() ); | 280 | mServerSocket->setFileName( defaultFileName() ); |
271 | //qDebug("connected "); | 281 | //qDebug("connected "); |
272 | if ( !mServerSocket->ok() ) { | 282 | if ( !mServerSocket->ok() ) { |
273 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); | 283 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); |
274 | delete mServerSocket; | 284 | delete mServerSocket; |
275 | mServerSocket = 0; | 285 | mServerSocket = 0; |
276 | return; | 286 | return; |
277 | } | 287 | } |
278 | //connect( mServerSocket, SIGNAL ( saveFile() ),this, SIGNAL ( save() ) ); | 288 | //connect( mServerSocket, SIGNAL ( saveFile() ),this, SIGNAL ( save() ) ); |
279 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); | 289 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); |
280 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); | 290 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); |
281 | } | 291 | } |
282 | 292 | ||
283 | void KSyncManager::syncLocalFile() | 293 | void KSyncManager::syncLocalFile() |
284 | { | 294 | { |
285 | 295 | ||
286 | QString fn =mLastSyncedLocalFile; | 296 | QString fn =mLastSyncedLocalFile; |
287 | QString ext; | 297 | QString ext; |
288 | 298 | ||
289 | switch(mTargetApp) | 299 | switch(mTargetApp) |
290 | { | 300 | { |
291 | case (KAPI): | 301 | case (KAPI): |
292 | ext = "(*.vcf)"; | 302 | ext = "(*.vcf)"; |
293 | break; | 303 | break; |
294 | case (KOPI): | 304 | case (KOPI): |
295 | ext = "(*.ics/*.vcs)"; | 305 | ext = "(*.ics/*.vcs)"; |
296 | break; | 306 | break; |
297 | case (PWMPI): | 307 | case (PWMPI): |
298 | ext = "(*.pwm)"; | 308 | ext = "(*.pwm)"; |
299 | break; | 309 | break; |
300 | default: | 310 | default: |
301 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); | 311 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); |
302 | break; | 312 | break; |
303 | 313 | ||
304 | } | 314 | } |
305 | 315 | ||
306 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 316 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
307 | if ( fn == "" ) | 317 | if ( fn == "" ) |
308 | return; | 318 | return; |
309 | if ( syncWithFile( fn, false ) ) { | 319 | if ( syncWithFile( fn, false ) ) { |
310 | qDebug("syncLocalFile() successful "); | 320 | qDebug("syncLocalFile() successful "); |
311 | } | 321 | } |
312 | 322 | ||
313 | } | 323 | } |
314 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 324 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
315 | { | 325 | { |
316 | bool ret = false; | 326 | bool ret = false; |
317 | QFileInfo info; | 327 | QFileInfo info; |
318 | info.setFile( fn ); | 328 | info.setFile( fn ); |
319 | QString mess; | 329 | QString mess; |
320 | bool loadbup = true; | 330 | bool loadbup = true; |
321 | if ( !info. exists() ) { | 331 | if ( !info. exists() ) { |
322 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 332 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
323 | int result = QMessageBox::warning( mParent, i18n("Warning!"), | 333 | int result = QMessageBox::warning( mParent, i18n("Warning!"), |
324 | mess ); | 334 | mess ); |
325 | return ret; | 335 | return ret; |
326 | } | 336 | } |
327 | int result = 0; | 337 | int result = 0; |
328 | if ( !quick ) { | 338 | if ( !quick ) { |
329 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 339 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
330 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 340 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
331 | mess, | 341 | mess, |
332 | i18n("Sync"), i18n("Cancel"), 0, | 342 | i18n("Sync"), i18n("Cancel"), 0, |
333 | 0, 1 ); | 343 | 0, 1 ); |
334 | if ( result ) | 344 | if ( result ) |
335 | return false; | 345 | return false; |
336 | } | 346 | } |
337 | if ( mAskForPreferences ) | 347 | if ( mAskForPreferences ) |
338 | edit_sync_options(); | 348 | edit_sync_options(); |
339 | if ( result == 0 ) { | 349 | if ( result == 0 ) { |
340 | //qDebug("Now sycing ... "); | 350 | //qDebug("Now sycing ... "); |
341 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) | 351 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
342 | mParent->setCaption( i18n("Synchronization successful") ); | 352 | mParent->setCaption( i18n("Synchronization successful") ); |
343 | else | 353 | else |
344 | mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 354 | mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
345 | if ( ! quick ) | 355 | if ( ! quick ) |
346 | mLastSyncedLocalFile = fn; | 356 | mLastSyncedLocalFile = fn; |
347 | } | 357 | } |
348 | return ret; | 358 | return ret; |
349 | } | 359 | } |
350 | void KSyncManager::quickSyncLocalFile() | 360 | void KSyncManager::quickSyncLocalFile() |
351 | { | 361 | { |
352 | 362 | ||
353 | if ( syncWithFile( mLastSyncedLocalFile, false ) ) { | 363 | if ( syncWithFile( mLastSyncedLocalFile, false ) ) { |
354 | qDebug("quick syncLocalFile() successful "); | 364 | qDebug("quick syncLocalFile() successful "); |
355 | 365 | ||
356 | } | 366 | } |
357 | } | 367 | } |
358 | void KSyncManager::multiSync( bool askforPrefs ) | 368 | void KSyncManager::multiSync( bool askforPrefs ) |
359 | { | 369 | { |
360 | if (blockSave()) | 370 | if (blockSave()) |
361 | return; | 371 | return; |
362 | setBlockSave(true); | 372 | setBlockSave(true); |
363 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 373 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
364 | if ( QMessageBox::information( mParent, i18n("Sync"), | 374 | if ( QMessageBox::information( mParent, i18n("Sync"), |
365 | question, | 375 | question, |
366 | i18n("Yes"), i18n("No"), | 376 | i18n("Yes"), i18n("No"), |
367 | 0, 0 ) != 0 ) { | 377 | 0, 0 ) != 0 ) { |
368 | setBlockSave(false); | 378 | setBlockSave(false); |
369 | mParent->setCaption(i18n("Aborted! Nothing synced!")); | 379 | mParent->setCaption(i18n("Aborted! Nothing synced!")); |
370 | return; | 380 | return; |
371 | } | 381 | } |
372 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 382 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
373 | mSyncAlgoPrefs = mRingSyncAlgoPrefs; | 383 | mSyncAlgoPrefs = mRingSyncAlgoPrefs; |
374 | if ( askforPrefs ) { | 384 | if ( askforPrefs ) { |
375 | edit_sync_options(); | 385 | edit_sync_options(); |
376 | mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 386 | mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
377 | } | 387 | } |
378 | mParent->setCaption(i18n("Multiple sync started.") ); | 388 | mParent->setCaption(i18n("Multiple sync started.") ); |
379 | qApp->processEvents(); | 389 | qApp->processEvents(); |
380 | int num = ringSync() ; | 390 | int num = ringSync() ; |
381 | if ( num > 1 ) | 391 | if ( num > 1 ) |
382 | ringSync(); | 392 | ringSync(); |
383 | setBlockSave(false); | 393 | setBlockSave(false); |
384 | if ( num ) | 394 | if ( num ) |
385 | emit save(); | 395 | emit save(); |
386 | if ( num ) | 396 | if ( num ) |
387 | mParent->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | 397 | mParent->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); |
388 | else | 398 | else |
389 | mParent->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 399 | mParent->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
390 | return; | 400 | return; |
391 | } | 401 | } |
392 | int KSyncManager::ringSync() | 402 | int KSyncManager::ringSync() |
393 | { | 403 | { |
394 | int syncedProfiles = 0; | 404 | int syncedProfiles = 0; |
395 | unsigned int i; | 405 | unsigned int i; |
396 | QTime timer; | 406 | QTime timer; |
397 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 407 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
398 | QStringList syncProfileNames = mSyncProfileNames; | 408 | QStringList syncProfileNames = mSyncProfileNames; |
399 | KSyncProfile* temp = new KSyncProfile (); | 409 | KSyncProfile* temp = new KSyncProfile (); |
400 | mAskForPreferences = false; | 410 | mAskForPreferences = false; |
401 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 411 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
402 | mCurrentSyncProfile = i; | 412 | mCurrentSyncProfile = i; |
403 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 413 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
404 | temp->readConfig(&config); | 414 | temp->readConfig(&config); |
405 | 415 | ||
406 | QString includeInRingSync; | 416 | QString includeInRingSync; |
407 | switch(mTargetApp) | 417 | switch(mTargetApp) |
408 | { | 418 | { |
409 | case (KAPI): | 419 | case (KAPI): |
410 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 420 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
411 | break; | 421 | break; |
412 | case (KOPI): | 422 | case (KOPI): |
413 | includeInRingSync = temp->getIncludeInRingSync(); | 423 | includeInRingSync = temp->getIncludeInRingSync(); |
414 | break; | 424 | break; |
415 | case (PWMPI): | 425 | case (PWMPI): |
416 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 426 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
417 | break; | 427 | break; |
418 | default: | 428 | default: |
419 | qDebug("KSyncManager::ringSync: invalid apptype selected"); | 429 | qDebug("KSyncManager::ringSync: invalid apptype selected"); |
420 | break; | 430 | break; |
421 | 431 | ||
422 | } | 432 | } |
423 | 433 | ||
424 | 434 | ||
425 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 435 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
426 | mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 436 | mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
427 | ++syncedProfiles; | 437 | ++syncedProfiles; |
428 | // mAskForPreferences = temp->getAskForPreferences(); | 438 | // mAskForPreferences = temp->getAskForPreferences(); |
429 | mWriteBackFile = temp->getWriteBackFile(); | 439 | mWriteBackFile = temp->getWriteBackFile(); |
430 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 440 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
431 | mWriteBackInFuture = 0; | 441 | mWriteBackInFuture = 0; |
432 | if ( temp->getWriteBackFuture() ) | 442 | if ( temp->getWriteBackFuture() ) |
433 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 443 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
434 | mShowSyncSummary = false; | 444 | mShowSyncSummary = false; |
435 | mCurrentSyncDevice = syncProfileNames[i] ; | 445 | mCurrentSyncDevice = syncProfileNames[i] ; |
436 | mCurrentSyncName = mLocalMachineName; | 446 | mCurrentSyncName = mLocalMachineName; |
437 | if ( i == 0 ) { | 447 | if ( i == 0 ) { |
438 | syncSharp(); | 448 | syncSharp(); |
439 | } else { | 449 | } else { |
440 | if ( temp->getIsLocalFileSync() ) { | 450 | if ( temp->getIsLocalFileSync() ) { |
441 | switch(mTargetApp) | 451 | switch(mTargetApp) |
442 | { | 452 | { |
443 | case (KAPI): | 453 | case (KAPI): |
444 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 454 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
445 | mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 455 | mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
446 | break; | 456 | break; |
447 | case (KOPI): | 457 | case (KOPI): |
448 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 458 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
449 | mLastSyncedLocalFile = temp->getRemoteFileName(); | 459 | mLastSyncedLocalFile = temp->getRemoteFileName(); |
450 | break; | 460 | break; |
451 | case (PWMPI): | 461 | case (PWMPI): |
452 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 462 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
453 | mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 463 | mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
454 | break; | 464 | break; |
455 | default: | 465 | default: |
456 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 466 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
457 | break; | 467 | break; |
458 | } | 468 | } |
459 | } else { | 469 | } else { |
460 | if ( temp->getIsPhoneSync() ) { | 470 | if ( temp->getIsPhoneSync() ) { |
461 | mPhoneDevice = temp->getPhoneDevice( ) ; | 471 | mPhoneDevice = temp->getPhoneDevice( ) ; |
462 | mPhoneConnection = temp->getPhoneConnection( ); | 472 | mPhoneConnection = temp->getPhoneConnection( ); |
463 | mPhoneModel = temp->getPhoneModel( ); | 473 | mPhoneModel = temp->getPhoneModel( ); |
464 | syncPhone(); | 474 | syncPhone(); |
465 | } else | 475 | } else |
466 | syncRemote( temp, false ); | 476 | syncRemote( temp, false ); |
467 | 477 | ||
468 | } | 478 | } |
469 | } | 479 | } |
470 | timer.start(); | 480 | timer.start(); |
471 | mParent->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 481 | mParent->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
472 | while ( timer.elapsed () < 2000 ) { | 482 | while ( timer.elapsed () < 2000 ) { |
473 | qApp->processEvents(); | 483 | qApp->processEvents(); |
474 | #ifndef _WIN32_ | 484 | #ifndef _WIN32_ |
475 | sleep (1); | 485 | sleep (1); |
476 | #endif | 486 | #endif |
477 | } | 487 | } |
478 | 488 | ||
479 | } | 489 | } |
480 | 490 | ||
481 | } | 491 | } |
482 | delete temp; | 492 | delete temp; |
483 | return syncedProfiles; | 493 | return syncedProfiles; |
484 | } | 494 | } |
485 | 495 | ||
486 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | 496 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) |
487 | { | 497 | { |
488 | QString question; | 498 | QString question; |
489 | if ( ask ) { | 499 | if ( ask ) { |
490 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 500 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
491 | if ( QMessageBox::information( mParent, i18n("Sync"), | 501 | if ( QMessageBox::information( mParent, i18n("Sync"), |
492 | question, | 502 | question, |
493 | i18n("Yes"), i18n("No"), | 503 | i18n("Yes"), i18n("No"), |
494 | 0, 0 ) != 0 ) | 504 | 0, 0 ) != 0 ) |
495 | return; | 505 | return; |
496 | } | 506 | } |
497 | 507 | ||
498 | QString preCommand; | 508 | QString preCommand; |
499 | QString localTempFile; | 509 | QString localTempFile; |
500 | QString postCommand; | 510 | QString postCommand; |
501 | 511 | ||
502 | switch(mTargetApp) | 512 | switch(mTargetApp) |
503 | { | 513 | { |
504 | case (KAPI): | 514 | case (KAPI): |
505 | preCommand = prof->getPreSyncCommandAB(); | 515 | preCommand = prof->getPreSyncCommandAB(); |
506 | postCommand = prof->getPostSyncCommandAB(); | 516 | postCommand = prof->getPostSyncCommandAB(); |
507 | localTempFile = prof->getLocalTempFileAB(); | 517 | localTempFile = prof->getLocalTempFileAB(); |
508 | break; | 518 | break; |
509 | case (KOPI): | 519 | case (KOPI): |
510 | preCommand = prof->getPreSyncCommand(); | 520 | preCommand = prof->getPreSyncCommand(); |
511 | postCommand = prof->getPostSyncCommand(); | 521 | postCommand = prof->getPostSyncCommand(); |
512 | localTempFile = prof->getLocalTempFile(); | 522 | localTempFile = prof->getLocalTempFile(); |
513 | break; | 523 | break; |
514 | case (PWMPI): | 524 | case (PWMPI): |
515 | preCommand = prof->getPreSyncCommandPWM(); | 525 | preCommand = prof->getPreSyncCommandPWM(); |
516 | postCommand = prof->getPostSyncCommandPWM(); | 526 | postCommand = prof->getPostSyncCommandPWM(); |
517 | localTempFile = prof->getLocalTempFilePWM(); | 527 | localTempFile = prof->getLocalTempFilePWM(); |
518 | break; | 528 | break; |
519 | default: | 529 | default: |
520 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); | 530 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); |
521 | break; | 531 | break; |
522 | } | 532 | } |
523 | 533 | ||
524 | 534 | ||
525 | int fi; | 535 | int fi; |
526 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { | 536 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { |
527 | QString pwd = getPassword(); | 537 | QString pwd = getPassword(); |
528 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); | 538 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); |
529 | 539 | ||
530 | } | 540 | } |
531 | int maxlen = 30; | 541 | int maxlen = 30; |
532 | if ( QApplication::desktop()->width() > 320 ) | 542 | if ( QApplication::desktop()->width() > 320 ) |
533 | maxlen += 25; | 543 | maxlen += 25; |
534 | mParent->setCaption ( i18n( "Copy remote file to local machine..." ) ); | 544 | mParent->setCaption ( i18n( "Copy remote file to local machine..." ) ); |
535 | int fileSize = 0; | 545 | int fileSize = 0; |
536 | int result = system ( preCommand ); | 546 | int result = system ( preCommand ); |
537 | // 0 : okay | 547 | // 0 : okay |
538 | // 256: no such file or dir | 548 | // 256: no such file or dir |
539 | // | 549 | // |
540 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 550 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
541 | if ( result != 0 ) { | 551 | if ( result != 0 ) { |
542 | unsigned int len = maxlen; | 552 | unsigned int len = maxlen; |
543 | while ( len < preCommand.length() ) { | 553 | while ( len < preCommand.length() ) { |
544 | preCommand.insert( len , "\n" ); | 554 | preCommand.insert( len , "\n" ); |
545 | len += maxlen +2; | 555 | len += maxlen +2; |
546 | } | 556 | } |
547 | 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) ; | 557 | 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) ; |
548 | QMessageBox::information( mParent, i18n("Sync - ERROR"), | 558 | QMessageBox::information( mParent, i18n("Sync - ERROR"), |
549 | question, | 559 | question, |
550 | i18n("Okay!")) ; | 560 | i18n("Okay!")) ; |
551 | mParent->setCaption (""); | 561 | mParent->setCaption (""); |
552 | return; | 562 | return; |
553 | } | 563 | } |
554 | mParent->setCaption ( i18n( "Copying succeed." ) ); | 564 | mParent->setCaption ( i18n( "Copying succeed." ) ); |
555 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 565 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
556 | 566 | ||
557 | 567 | ||
558 | 568 | ||
559 | if ( syncWithFile( localTempFile, true ) ) { | 569 | if ( syncWithFile( localTempFile, true ) ) { |
560 | // Event* e = mView->getLastSyncEvent(); | 570 | // Event* e = mView->getLastSyncEvent(); |
561 | // e->setReadOnly( false ); | 571 | // e->setReadOnly( false ); |
562 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 572 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
563 | // e->setReadOnly( true ); | 573 | // e->setReadOnly( true ); |
564 | if ( mWriteBackFile ) { | 574 | if ( mWriteBackFile ) { |
565 | int fi; | 575 | int fi; |
566 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { | 576 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { |
567 | QString pwd = getPassword(); | 577 | QString pwd = getPassword(); |
568 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); | 578 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); |
569 | 579 | ||
570 | } | 580 | } |
571 | mParent->setCaption ( i18n( "Writing back file ..." ) ); | 581 | mParent->setCaption ( i18n( "Writing back file ..." ) ); |
572 | result = system ( postCommand ); | 582 | result = system ( postCommand ); |
573 | qDebug("Writing back file result: %d ", result); | 583 | qDebug("Writing back file result: %d ", result); |
574 | if ( result != 0 ) { | 584 | if ( result != 0 ) { |
575 | mParent->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 585 | mParent->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
576 | return; | 586 | return; |
577 | } else { | 587 | } else { |
578 | mParent->setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 588 | mParent->setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
579 | } | 589 | } |
580 | } | 590 | } |
581 | } | 591 | } |
582 | return; | 592 | return; |
583 | } | 593 | } |
584 | 594 | ||
585 | void KSyncManager::edit_sync_options() | 595 | void KSyncManager::edit_sync_options() |
586 | { | 596 | { |
587 | //mDialogManager->showSyncOptions(); | 597 | //mDialogManager->showSyncOptions(); |
588 | //mSyncAlgoPrefs | 598 | //mSyncAlgoPrefs |
589 | QDialog dia( mParent, "dia", true ); | 599 | QDialog dia( mParent, "dia", true ); |
590 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 600 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
591 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 601 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
592 | QVBoxLayout lay ( &dia ); | 602 | QVBoxLayout lay ( &dia ); |
593 | lay.setSpacing( 2 ); | 603 | lay.setSpacing( 2 ); |
594 | lay.setMargin( 3 ); | 604 | lay.setMargin( 3 ); |
595 | lay.addWidget(&gr); | 605 | lay.addWidget(&gr); |
596 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 606 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
597 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 607 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
598 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 608 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
599 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 609 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
600 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 610 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
601 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 611 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
602 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 612 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
603 | QPushButton pb ( "OK", &dia); | 613 | QPushButton pb ( "OK", &dia); |
604 | lay.addWidget( &pb ); | 614 | lay.addWidget( &pb ); |
605 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 615 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
606 | switch ( mSyncAlgoPrefs ) { | 616 | switch ( mSyncAlgoPrefs ) { |