author | zautrix <zautrix> | 2004-10-13 03:05:35 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-13 03:05:35 (UTC) |
commit | 8f852fddc2dc5b63511d6ad1c85a1e74141969ff (patch) (unidiff) | |
tree | 123c7e845e1520a4dcd50dd2361252cc6ab7a76a /libkdepim | |
parent | e7833b80c28e38bfe6316ee5fce150635cdebe03 (diff) | |
download | kdepimpi-8f852fddc2dc5b63511d6ad1c85a1e74141969ff.zip kdepimpi-8f852fddc2dc5b63511d6ad1c85a1e74141969ff.tar.gz kdepimpi-8f852fddc2dc5b63511d6ad1c85a1e74141969ff.tar.bz2 |
fixed one syncing problem
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 1 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 1 | ||||
-rw-r--r-- | libkdepim/ksyncprefsdialog.cpp | 14 | ||||
-rw-r--r-- | libkdepim/ksyncprefsdialog.h | 2 | ||||
-rw-r--r-- | libkdepim/ksyncprofile.cpp | 4 | ||||
-rw-r--r-- | libkdepim/ksyncprofile.h | 3 |
6 files changed, 24 insertions, 1 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 6baa2ee..5175f94 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1,1206 +1,1207 @@ | |||
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 | prof << i18n("Sharp_DTM"); | 102 | prof << i18n("Sharp_DTM"); |
103 | prof << i18n("Local_file"); | 103 | prof << i18n("Local_file"); |
104 | prof << i18n("Last_file"); | 104 | prof << i18n("Last_file"); |
105 | KSyncProfile* temp = new KSyncProfile (); | 105 | KSyncProfile* temp = new KSyncProfile (); |
106 | temp->setName( prof[0] ); | 106 | temp->setName( prof[0] ); |
107 | temp->writeConfig(&config); | 107 | temp->writeConfig(&config); |
108 | temp->setName( prof[1] ); | 108 | temp->setName( prof[1] ); |
109 | temp->writeConfig(&config); | 109 | temp->writeConfig(&config); |
110 | temp->setName( prof[2] ); | 110 | temp->setName( prof[2] ); |
111 | temp->writeConfig(&config); | 111 | temp->writeConfig(&config); |
112 | config.setGroup("General"); | 112 | config.setGroup("General"); |
113 | config.writeEntry("SyncProfileNames",prof); | 113 | config.writeEntry("SyncProfileNames",prof); |
114 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 114 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
115 | config.sync(); | 115 | config.sync(); |
116 | delete temp; | 116 | delete temp; |
117 | } | 117 | } |
118 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 118 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
119 | mSyncProfileNames = prof; | 119 | mSyncProfileNames = prof; |
120 | unsigned int i; | 120 | unsigned int i; |
121 | for ( i = 0; i < prof.count(); ++i ) { | 121 | for ( i = 0; i < prof.count(); ++i ) { |
122 | mSyncMenu->insertItem( prof[i], 1000+i ); | 122 | mSyncMenu->insertItem( prof[i], 1000+i ); |
123 | if ( i == 2 ) | 123 | if ( i == 2 ) |
124 | mSyncMenu->insertSeparator(); | 124 | mSyncMenu->insertSeparator(); |
125 | } | 125 | } |
126 | QDir app_dir; | 126 | QDir app_dir; |
127 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 127 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
128 | if ( mTargetApp == PWMPI) { | 128 | if ( mTargetApp == PWMPI) { |
129 | mSyncMenu->removeItem( 1000 ); | 129 | mSyncMenu->removeItem( 1000 ); |
130 | } | 130 | } |
131 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 131 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
132 | mSyncMenu->removeItem( 1000 ); | 132 | mSyncMenu->removeItem( 1000 ); |
133 | } | 133 | } |
134 | mSyncMenu->removeItem( 1002 ); | 134 | mSyncMenu->removeItem( 1002 ); |
135 | } | 135 | } |
136 | 136 | ||
137 | void KSyncManager::slotSyncMenu( int action ) | 137 | void KSyncManager::slotSyncMenu( int action ) |
138 | { | 138 | { |
139 | //qDebug("syncaction %d ", action); | 139 | //qDebug("syncaction %d ", action); |
140 | if ( action == 0 ) { | 140 | if ( action == 0 ) { |
141 | 141 | ||
142 | // seems to be a Qt2 event handling bug | 142 | // seems to be a Qt2 event handling bug |
143 | // syncmenu.clear causes a segfault at first time | 143 | // syncmenu.clear causes a segfault at first time |
144 | // when we call it after the main event loop, it is ok | 144 | // when we call it after the main event loop, it is ok |
145 | // same behaviour when calling OM/Pi via QCOP for the first time | 145 | // same behaviour when calling OM/Pi via QCOP for the first time |
146 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 146 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
147 | //confSync(); | 147 | //confSync(); |
148 | 148 | ||
149 | return; | 149 | return; |
150 | } | 150 | } |
151 | if ( action == 1 ) { | 151 | if ( action == 1 ) { |
152 | multiSync( true ); | 152 | multiSync( true ); |
153 | return; | 153 | return; |
154 | } | 154 | } |
155 | if ( action == 2 ) { | 155 | if ( action == 2 ) { |
156 | enableQuick(); | 156 | enableQuick(); |
157 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 157 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
158 | return; | 158 | return; |
159 | } | 159 | } |
160 | if ( action == 3 ) { | 160 | if ( action == 3 ) { |
161 | delete mServerSocket; | 161 | delete mServerSocket; |
162 | mServerSocket = 0; | 162 | mServerSocket = 0; |
163 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 163 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
164 | return; | 164 | return; |
165 | } | 165 | } |
166 | 166 | ||
167 | if (blockSave()) | 167 | if (blockSave()) |
168 | return; | 168 | return; |
169 | 169 | ||
170 | setBlockSave(true); | 170 | setBlockSave(true); |
171 | 171 | ||
172 | mCurrentSyncProfile = action - 1000 ; | 172 | mCurrentSyncProfile = action - 1000 ; |
173 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; | 173 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
174 | mCurrentSyncName = mLocalMachineName ; | 174 | mCurrentSyncName = mLocalMachineName ; |
175 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 175 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
176 | KSyncProfile* temp = new KSyncProfile (); | 176 | KSyncProfile* temp = new KSyncProfile (); |
177 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); | 177 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
178 | temp->readConfig(&config); | 178 | temp->readConfig(&config); |
179 | mAskForPreferences = temp->getAskForPreferences(); | 179 | mAskForPreferences = temp->getAskForPreferences(); |
180 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 180 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
181 | mWriteBackFile = temp->getWriteBackFile(); | 181 | mWriteBackFile = temp->getWriteBackFile(); |
182 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 182 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
183 | mIsKapiFile = temp->getIsKapiFile(); | ||
183 | mWriteBackInFuture = 0; | 184 | mWriteBackInFuture = 0; |
184 | if ( temp->getWriteBackFuture() ) | 185 | if ( temp->getWriteBackFuture() ) |
185 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 186 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
186 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 187 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
187 | if ( action == 1000 ) { | 188 | if ( action == 1000 ) { |
188 | syncSharp(); | 189 | syncSharp(); |
189 | 190 | ||
190 | } else if ( action == 1001 ) { | 191 | } else if ( action == 1001 ) { |
191 | syncLocalFile(); | 192 | syncLocalFile(); |
192 | 193 | ||
193 | } else if ( action == 1002 ) { | 194 | } else if ( action == 1002 ) { |
194 | mWriteBackFile = false; | 195 | mWriteBackFile = false; |
195 | mAskForPreferences = false; | 196 | mAskForPreferences = false; |
196 | mShowSyncSummary = false; | 197 | mShowSyncSummary = false; |
197 | mSyncAlgoPrefs = 3; | 198 | mSyncAlgoPrefs = 3; |
198 | quickSyncLocalFile(); | 199 | quickSyncLocalFile(); |
199 | 200 | ||
200 | } else if ( action >= 1003 ) { | 201 | } else if ( action >= 1003 ) { |
201 | if ( temp->getIsLocalFileSync() ) { | 202 | if ( temp->getIsLocalFileSync() ) { |
202 | switch(mTargetApp) | 203 | switch(mTargetApp) |
203 | { | 204 | { |
204 | case (KAPI): | 205 | case (KAPI): |
205 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 206 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
206 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 207 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
207 | break; | 208 | break; |
208 | case (KOPI): | 209 | case (KOPI): |
209 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 210 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
210 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 211 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
211 | break; | 212 | break; |
212 | case (PWMPI): | 213 | case (PWMPI): |
213 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 214 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
214 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 215 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
215 | break; | 216 | break; |
216 | default: | 217 | default: |
217 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 218 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
218 | break; | 219 | break; |
219 | 220 | ||
220 | } | 221 | } |
221 | } else { | 222 | } else { |
222 | if ( temp->getIsPhoneSync() ) { | 223 | if ( temp->getIsPhoneSync() ) { |
223 | mPhoneDevice = temp->getPhoneDevice( ) ; | 224 | mPhoneDevice = temp->getPhoneDevice( ) ; |
224 | mPhoneConnection = temp->getPhoneConnection( ); | 225 | mPhoneConnection = temp->getPhoneConnection( ); |
225 | mPhoneModel = temp->getPhoneModel( ); | 226 | mPhoneModel = temp->getPhoneModel( ); |
226 | syncPhone(); | 227 | syncPhone(); |
227 | } else if ( temp->getIsPiSync() ) { | 228 | } else if ( temp->getIsPiSync() ) { |
228 | if ( mTargetApp == KAPI ) { | 229 | if ( mTargetApp == KAPI ) { |
229 | mPassWordPiSync = temp->getRemotePwAB(); | 230 | mPassWordPiSync = temp->getRemotePwAB(); |
230 | mActiveSyncPort = temp->getRemotePortAB(); | 231 | mActiveSyncPort = temp->getRemotePortAB(); |
231 | mActiveSyncIP = temp->getRemoteIPAB(); | 232 | mActiveSyncIP = temp->getRemoteIPAB(); |
232 | } else if ( mTargetApp == KOPI ) { | 233 | } else if ( mTargetApp == KOPI ) { |
233 | mPassWordPiSync = temp->getRemotePw(); | 234 | mPassWordPiSync = temp->getRemotePw(); |
234 | mActiveSyncPort = temp->getRemotePort(); | 235 | mActiveSyncPort = temp->getRemotePort(); |
235 | mActiveSyncIP = temp->getRemoteIP(); | 236 | mActiveSyncIP = temp->getRemoteIP(); |
236 | } else { | 237 | } else { |
237 | mPassWordPiSync = temp->getRemotePwPWM(); | 238 | mPassWordPiSync = temp->getRemotePwPWM(); |
238 | mActiveSyncPort = temp->getRemotePortPWM(); | 239 | mActiveSyncPort = temp->getRemotePortPWM(); |
239 | mActiveSyncIP = temp->getRemoteIPPWM(); | 240 | mActiveSyncIP = temp->getRemoteIPPWM(); |
240 | } | 241 | } |
241 | syncPi(); | 242 | syncPi(); |
242 | } else | 243 | } else |
243 | syncRemote( temp ); | 244 | syncRemote( temp ); |
244 | 245 | ||
245 | } | 246 | } |
246 | } | 247 | } |
247 | delete temp; | 248 | delete temp; |
248 | setBlockSave(false); | 249 | setBlockSave(false); |
249 | } | 250 | } |
250 | 251 | ||
251 | void KSyncManager::enableQuick() | 252 | void KSyncManager::enableQuick() |
252 | { | 253 | { |
253 | QDialog dia ( 0, "input-dialog", true ); | 254 | QDialog dia ( 0, "input-dialog", true ); |
254 | QLineEdit lab ( &dia ); | 255 | QLineEdit lab ( &dia ); |
255 | QVBoxLayout lay( &dia ); | 256 | QVBoxLayout lay( &dia ); |
256 | lab.setText( mPrefs->mPassiveSyncPort ); | 257 | lab.setText( mPrefs->mPassiveSyncPort ); |
257 | lay.setMargin(7); | 258 | lay.setMargin(7); |
258 | lay.setSpacing(7); | 259 | lay.setSpacing(7); |
259 | int po = 9197+mTargetApp; | 260 | int po = 9197+mTargetApp; |
260 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); | 261 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); |
261 | lay.addWidget( &label); | 262 | lay.addWidget( &label); |
262 | lay.addWidget( &lab); | 263 | lay.addWidget( &lab); |
263 | 264 | ||
264 | QLineEdit lepw ( &dia ); | 265 | QLineEdit lepw ( &dia ); |
265 | lepw.setText( mPrefs->mPassiveSyncPw ); | 266 | lepw.setText( mPrefs->mPassiveSyncPw ); |
266 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 267 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
267 | lay.addWidget( &label2); | 268 | lay.addWidget( &label2); |
268 | lay.addWidget( &lepw); | 269 | lay.addWidget( &lepw); |
269 | dia.setFixedSize( 230,80 ); | 270 | dia.setFixedSize( 230,80 ); |
270 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 271 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
271 | QPushButton pb ( "OK", &dia); | 272 | QPushButton pb ( "OK", &dia); |
272 | lay.addWidget( &pb ); | 273 | lay.addWidget( &pb ); |
273 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 274 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
274 | dia.show(); | 275 | dia.show(); |
275 | if ( ! dia.exec() ) | 276 | if ( ! dia.exec() ) |
276 | return; | 277 | return; |
277 | dia.hide(); | 278 | dia.hide(); |
278 | qApp->processEvents(); | 279 | qApp->processEvents(); |
279 | mPrefs->mPassiveSyncPw = lepw.text(); | 280 | mPrefs->mPassiveSyncPw = lepw.text(); |
280 | mPrefs->mPassiveSyncPort = lab.text(); | 281 | mPrefs->mPassiveSyncPort = lab.text(); |
281 | bool ok; | 282 | bool ok; |
282 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); | 283 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); |
283 | if ( ! ok ) { | 284 | if ( ! ok ) { |
284 | KMessageBox::information( 0, i18n("No valid port")); | 285 | KMessageBox::information( 0, i18n("No valid port")); |
285 | return; | 286 | return; |
286 | } | 287 | } |
287 | //qDebug("port %d ", port); | 288 | //qDebug("port %d ", port); |
288 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); | 289 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); |
289 | mServerSocket->setFileName( defaultFileName() ); | 290 | mServerSocket->setFileName( defaultFileName() ); |
290 | //qDebug("connected "); | 291 | //qDebug("connected "); |
291 | if ( !mServerSocket->ok() ) { | 292 | if ( !mServerSocket->ok() ) { |
292 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); | 293 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); |
293 | delete mServerSocket; | 294 | delete mServerSocket; |
294 | mServerSocket = 0; | 295 | mServerSocket = 0; |
295 | return; | 296 | return; |
296 | } | 297 | } |
297 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); | 298 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); |
298 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); | 299 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); |
299 | } | 300 | } |
300 | 301 | ||
301 | void KSyncManager::syncLocalFile() | 302 | void KSyncManager::syncLocalFile() |
302 | { | 303 | { |
303 | 304 | ||
304 | QString fn =mPrefs->mLastSyncedLocalFile; | 305 | QString fn =mPrefs->mLastSyncedLocalFile; |
305 | QString ext; | 306 | QString ext; |
306 | 307 | ||
307 | switch(mTargetApp) | 308 | switch(mTargetApp) |
308 | { | 309 | { |
309 | case (KAPI): | 310 | case (KAPI): |
310 | ext = "(*.vcf)"; | 311 | ext = "(*.vcf)"; |
311 | break; | 312 | break; |
312 | case (KOPI): | 313 | case (KOPI): |
313 | ext = "(*.ics/*.vcs)"; | 314 | ext = "(*.ics/*.vcs)"; |
314 | break; | 315 | break; |
315 | case (PWMPI): | 316 | case (PWMPI): |
316 | ext = "(*.pwm)"; | 317 | ext = "(*.pwm)"; |
317 | break; | 318 | break; |
318 | default: | 319 | default: |
319 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); | 320 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); |
320 | break; | 321 | break; |
321 | 322 | ||
322 | } | 323 | } |
323 | 324 | ||
324 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 325 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
325 | if ( fn == "" ) | 326 | if ( fn == "" ) |
326 | return; | 327 | return; |
327 | if ( syncWithFile( fn, false ) ) { | 328 | if ( syncWithFile( fn, false ) ) { |
328 | qDebug("syncLocalFile() successful "); | 329 | qDebug("syncLocalFile() successful "); |
329 | } | 330 | } |
330 | 331 | ||
331 | } | 332 | } |
332 | 333 | ||
333 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 334 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
334 | { | 335 | { |
335 | bool ret = false; | 336 | bool ret = false; |
336 | QFileInfo info; | 337 | QFileInfo info; |
337 | info.setFile( fn ); | 338 | info.setFile( fn ); |
338 | QString mess; | 339 | QString mess; |
339 | bool loadbup = true; | 340 | bool loadbup = true; |
340 | if ( !info. exists() ) { | 341 | if ( !info. exists() ) { |
341 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 342 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
342 | int result = QMessageBox::warning( mParent, i18n("Warning!"), | 343 | int result = QMessageBox::warning( mParent, i18n("Warning!"), |
343 | mess ); | 344 | mess ); |
344 | return ret; | 345 | return ret; |
345 | } | 346 | } |
346 | int result = 0; | 347 | int result = 0; |
347 | if ( !quick ) { | 348 | if ( !quick ) { |
348 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 349 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
349 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 350 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
350 | mess, | 351 | mess, |
351 | i18n("Sync"), i18n("Cancel"), 0, | 352 | i18n("Sync"), i18n("Cancel"), 0, |
352 | 0, 1 ); | 353 | 0, 1 ); |
353 | if ( result ) | 354 | if ( result ) |
354 | return false; | 355 | return false; |
355 | } | 356 | } |
356 | if ( mAskForPreferences ) | 357 | if ( mAskForPreferences ) |
357 | edit_sync_options(); | 358 | edit_sync_options(); |
358 | if ( result == 0 ) { | 359 | if ( result == 0 ) { |
359 | //qDebug("Now sycing ... "); | 360 | //qDebug("Now sycing ... "); |
360 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) | 361 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
361 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); | 362 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
362 | else | 363 | else |
363 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 364 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
364 | if ( ! quick ) | 365 | if ( ! quick ) |
365 | mPrefs->mLastSyncedLocalFile = fn; | 366 | mPrefs->mLastSyncedLocalFile = fn; |
366 | } | 367 | } |
367 | return ret; | 368 | return ret; |
368 | } | 369 | } |
369 | 370 | ||
370 | void KSyncManager::quickSyncLocalFile() | 371 | void KSyncManager::quickSyncLocalFile() |
371 | { | 372 | { |
372 | 373 | ||
373 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { | 374 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { |
374 | qDebug("quick syncLocalFile() successful "); | 375 | qDebug("quick syncLocalFile() successful "); |
375 | 376 | ||
376 | } | 377 | } |
377 | } | 378 | } |
378 | 379 | ||
379 | void KSyncManager::multiSync( bool askforPrefs ) | 380 | void KSyncManager::multiSync( bool askforPrefs ) |
380 | { | 381 | { |
381 | if (blockSave()) | 382 | if (blockSave()) |
382 | return; | 383 | return; |
383 | setBlockSave(true); | 384 | setBlockSave(true); |
384 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 385 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
385 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), | 386 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), |
386 | question, | 387 | question, |
387 | i18n("Yes"), i18n("No"), | 388 | i18n("Yes"), i18n("No"), |
388 | 0, 0 ) != 0 ) { | 389 | 0, 0 ) != 0 ) { |
389 | setBlockSave(false); | 390 | setBlockSave(false); |
390 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); | 391 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
391 | return; | 392 | return; |
392 | } | 393 | } |
393 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 394 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
394 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 395 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; |
395 | if ( askforPrefs ) { | 396 | if ( askforPrefs ) { |
396 | edit_sync_options(); | 397 | edit_sync_options(); |
397 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 398 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
398 | } | 399 | } |
399 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); | 400 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
400 | qApp->processEvents(); | 401 | qApp->processEvents(); |
401 | int num = ringSync() ; | 402 | int num = ringSync() ; |
402 | if ( num > 1 ) | 403 | if ( num > 1 ) |
403 | ringSync(); | 404 | ringSync(); |
404 | setBlockSave(false); | 405 | setBlockSave(false); |
405 | if ( num ) | 406 | if ( num ) |
406 | emit save(); | 407 | emit save(); |
407 | if ( num ) | 408 | if ( num ) |
408 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); | 409 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); |
409 | else | 410 | else |
410 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 411 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
411 | return; | 412 | return; |
412 | } | 413 | } |
413 | 414 | ||
414 | int KSyncManager::ringSync() | 415 | int KSyncManager::ringSync() |
415 | { | 416 | { |
416 | int syncedProfiles = 0; | 417 | int syncedProfiles = 0; |
417 | unsigned int i; | 418 | unsigned int i; |
418 | QTime timer; | 419 | QTime timer; |
419 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 420 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
420 | QStringList syncProfileNames = mSyncProfileNames; | 421 | QStringList syncProfileNames = mSyncProfileNames; |
421 | KSyncProfile* temp = new KSyncProfile (); | 422 | KSyncProfile* temp = new KSyncProfile (); |
422 | mAskForPreferences = false; | 423 | mAskForPreferences = false; |
423 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 424 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
424 | mCurrentSyncProfile = i; | 425 | mCurrentSyncProfile = i; |
425 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 426 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
426 | temp->readConfig(&config); | 427 | temp->readConfig(&config); |
427 | 428 | ||
428 | bool includeInRingSync; | 429 | bool includeInRingSync; |
429 | switch(mTargetApp) | 430 | switch(mTargetApp) |
430 | { | 431 | { |
431 | case (KAPI): | 432 | case (KAPI): |
432 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 433 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
433 | break; | 434 | break; |
434 | case (KOPI): | 435 | case (KOPI): |
435 | includeInRingSync = temp->getIncludeInRingSync(); | 436 | includeInRingSync = temp->getIncludeInRingSync(); |
436 | break; | 437 | break; |
437 | case (PWMPI): | 438 | case (PWMPI): |
438 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 439 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
439 | break; | 440 | break; |
440 | default: | 441 | default: |
441 | qDebug("KSyncManager::ringSync: invalid apptype selected"); | 442 | qDebug("KSyncManager::ringSync: invalid apptype selected"); |
442 | break; | 443 | break; |
443 | 444 | ||
444 | } | 445 | } |
445 | 446 | ||
446 | 447 | ||
447 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 448 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
448 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 449 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
449 | ++syncedProfiles; | 450 | ++syncedProfiles; |
450 | // mAskForPreferences = temp->getAskForPreferences(); | 451 | // mAskForPreferences = temp->getAskForPreferences(); |
451 | mWriteBackFile = temp->getWriteBackFile(); | 452 | mWriteBackFile = temp->getWriteBackFile(); |
452 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 453 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
453 | mWriteBackInFuture = 0; | 454 | mWriteBackInFuture = 0; |
454 | if ( temp->getWriteBackFuture() ) | 455 | if ( temp->getWriteBackFuture() ) |
455 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 456 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
456 | mShowSyncSummary = false; | 457 | mShowSyncSummary = false; |
457 | mCurrentSyncDevice = syncProfileNames[i] ; | 458 | mCurrentSyncDevice = syncProfileNames[i] ; |
458 | mCurrentSyncName = mLocalMachineName; | 459 | mCurrentSyncName = mLocalMachineName; |
459 | if ( i == 0 ) { | 460 | if ( i == 0 ) { |
460 | syncSharp(); | 461 | syncSharp(); |
461 | } else { | 462 | } else { |
462 | if ( temp->getIsLocalFileSync() ) { | 463 | if ( temp->getIsLocalFileSync() ) { |
463 | switch(mTargetApp) | 464 | switch(mTargetApp) |
464 | { | 465 | { |
465 | case (KAPI): | 466 | case (KAPI): |
466 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 467 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
467 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 468 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
468 | break; | 469 | break; |
469 | case (KOPI): | 470 | case (KOPI): |
470 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 471 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
471 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 472 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
472 | break; | 473 | break; |
473 | case (PWMPI): | 474 | case (PWMPI): |
474 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 475 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
475 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 476 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
476 | break; | 477 | break; |
477 | default: | 478 | default: |
478 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 479 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
479 | break; | 480 | break; |
480 | } | 481 | } |
481 | } else { | 482 | } else { |
482 | if ( temp->getIsPhoneSync() ) { | 483 | if ( temp->getIsPhoneSync() ) { |
483 | mPhoneDevice = temp->getPhoneDevice( ) ; | 484 | mPhoneDevice = temp->getPhoneDevice( ) ; |
484 | mPhoneConnection = temp->getPhoneConnection( ); | 485 | mPhoneConnection = temp->getPhoneConnection( ); |
485 | mPhoneModel = temp->getPhoneModel( ); | 486 | mPhoneModel = temp->getPhoneModel( ); |
486 | syncPhone(); | 487 | syncPhone(); |
487 | } else if ( temp->getIsPiSync() ) { | 488 | } else if ( temp->getIsPiSync() ) { |
488 | if ( mTargetApp == KAPI ) { | 489 | if ( mTargetApp == KAPI ) { |
489 | mPassWordPiSync = temp->getRemotePwAB(); | 490 | mPassWordPiSync = temp->getRemotePwAB(); |
490 | mActiveSyncPort = temp->getRemotePortAB(); | 491 | mActiveSyncPort = temp->getRemotePortAB(); |
491 | mActiveSyncIP = temp->getRemoteIPAB(); | 492 | mActiveSyncIP = temp->getRemoteIPAB(); |
492 | } else if ( mTargetApp == KOPI ) { | 493 | } else if ( mTargetApp == KOPI ) { |
493 | mPassWordPiSync = temp->getRemotePw(); | 494 | mPassWordPiSync = temp->getRemotePw(); |
494 | mActiveSyncPort = temp->getRemotePort(); | 495 | mActiveSyncPort = temp->getRemotePort(); |
495 | mActiveSyncIP = temp->getRemoteIP(); | 496 | mActiveSyncIP = temp->getRemoteIP(); |
496 | } else { | 497 | } else { |
497 | mPassWordPiSync = temp->getRemotePwPWM(); | 498 | mPassWordPiSync = temp->getRemotePwPWM(); |
498 | mActiveSyncPort = temp->getRemotePortPWM(); | 499 | mActiveSyncPort = temp->getRemotePortPWM(); |
499 | mActiveSyncIP = temp->getRemoteIPPWM(); | 500 | mActiveSyncIP = temp->getRemoteIPPWM(); |
500 | } | 501 | } |
501 | syncPi(); | 502 | syncPi(); |
502 | } else | 503 | } else |
503 | syncRemote( temp, false ); | 504 | syncRemote( temp, false ); |
504 | 505 | ||
505 | } | 506 | } |
506 | } | 507 | } |
507 | timer.start(); | 508 | timer.start(); |
508 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 509 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
509 | while ( timer.elapsed () < 2000 ) { | 510 | while ( timer.elapsed () < 2000 ) { |
510 | qApp->processEvents(); | 511 | qApp->processEvents(); |
511 | #ifndef _WIN32_ | 512 | #ifndef _WIN32_ |
512 | sleep (1); | 513 | sleep (1); |
513 | #endif | 514 | #endif |
514 | } | 515 | } |
515 | 516 | ||
516 | } | 517 | } |
517 | 518 | ||
518 | } | 519 | } |
519 | delete temp; | 520 | delete temp; |
520 | return syncedProfiles; | 521 | return syncedProfiles; |
521 | } | 522 | } |
522 | 523 | ||
523 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | 524 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) |
524 | { | 525 | { |
525 | QString question; | 526 | QString question; |
526 | if ( ask ) { | 527 | if ( ask ) { |
527 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 528 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
528 | if ( QMessageBox::information( mParent, i18n("Sync"), | 529 | if ( QMessageBox::information( mParent, i18n("Sync"), |
529 | question, | 530 | question, |
530 | i18n("Yes"), i18n("No"), | 531 | i18n("Yes"), i18n("No"), |
531 | 0, 0 ) != 0 ) | 532 | 0, 0 ) != 0 ) |
532 | return; | 533 | return; |
533 | } | 534 | } |
534 | 535 | ||
535 | QString preCommand; | 536 | QString preCommand; |
536 | QString localTempFile; | 537 | QString localTempFile; |
537 | QString postCommand; | 538 | QString postCommand; |
538 | 539 | ||
539 | switch(mTargetApp) | 540 | switch(mTargetApp) |
540 | { | 541 | { |
541 | case (KAPI): | 542 | case (KAPI): |
542 | preCommand = prof->getPreSyncCommandAB(); | 543 | preCommand = prof->getPreSyncCommandAB(); |
543 | postCommand = prof->getPostSyncCommandAB(); | 544 | postCommand = prof->getPostSyncCommandAB(); |
544 | localTempFile = prof->getLocalTempFileAB(); | 545 | localTempFile = prof->getLocalTempFileAB(); |
545 | break; | 546 | break; |
546 | case (KOPI): | 547 | case (KOPI): |
547 | preCommand = prof->getPreSyncCommand(); | 548 | preCommand = prof->getPreSyncCommand(); |
548 | postCommand = prof->getPostSyncCommand(); | 549 | postCommand = prof->getPostSyncCommand(); |
549 | localTempFile = prof->getLocalTempFile(); | 550 | localTempFile = prof->getLocalTempFile(); |
550 | break; | 551 | break; |
551 | case (PWMPI): | 552 | case (PWMPI): |
552 | preCommand = prof->getPreSyncCommandPWM(); | 553 | preCommand = prof->getPreSyncCommandPWM(); |
553 | postCommand = prof->getPostSyncCommandPWM(); | 554 | postCommand = prof->getPostSyncCommandPWM(); |
554 | localTempFile = prof->getLocalTempFilePWM(); | 555 | localTempFile = prof->getLocalTempFilePWM(); |
555 | break; | 556 | break; |
556 | default: | 557 | default: |
557 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); | 558 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); |
558 | break; | 559 | break; |
559 | } | 560 | } |
560 | 561 | ||
561 | 562 | ||
562 | int fi; | 563 | int fi; |
563 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { | 564 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { |
564 | QString pwd = getPassword(); | 565 | QString pwd = getPassword(); |
565 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); | 566 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); |
566 | 567 | ||
567 | } | 568 | } |
568 | int maxlen = 30; | 569 | int maxlen = 30; |
569 | if ( QApplication::desktop()->width() > 320 ) | 570 | if ( QApplication::desktop()->width() > 320 ) |
570 | maxlen += 25; | 571 | maxlen += 25; |
571 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); | 572 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); |
572 | int fileSize = 0; | 573 | int fileSize = 0; |
573 | int result = system ( preCommand ); | 574 | int result = system ( preCommand ); |
574 | // 0 : okay | 575 | // 0 : okay |
575 | // 256: no such file or dir | 576 | // 256: no such file or dir |
576 | // | 577 | // |
577 | qDebug("Sync: Remote copy result(0 = okay): %d ",result ); | 578 | qDebug("Sync: Remote copy result(0 = okay): %d ",result ); |
578 | if ( result != 0 ) { | 579 | if ( result != 0 ) { |
579 | unsigned int len = maxlen; | 580 | unsigned int len = maxlen; |
580 | while ( len < preCommand.length() ) { | 581 | while ( len < preCommand.length() ) { |
581 | preCommand.insert( len , "\n" ); | 582 | preCommand.insert( len , "\n" ); |
582 | len += maxlen +2; | 583 | len += maxlen +2; |
583 | } | 584 | } |
584 | 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) ; | 585 | 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) ; |
585 | QMessageBox::information( mParent, i18n("Sync - ERROR"), | 586 | QMessageBox::information( mParent, i18n("Sync - ERROR"), |
586 | question, | 587 | question, |
587 | i18n("Okay!")) ; | 588 | i18n("Okay!")) ; |
588 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); | 589 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); |
589 | return; | 590 | return; |
590 | } | 591 | } |
591 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); | 592 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); |
592 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 593 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
593 | 594 | ||
594 | if ( syncWithFile( localTempFile, true ) ) { | 595 | if ( syncWithFile( localTempFile, true ) ) { |
595 | 596 | ||
596 | if ( mWriteBackFile ) { | 597 | if ( mWriteBackFile ) { |
597 | int fi; | 598 | int fi; |
598 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { | 599 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { |
599 | QString pwd = getPassword(); | 600 | QString pwd = getPassword(); |
600 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); | 601 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); |
601 | 602 | ||
602 | } | 603 | } |
603 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); | 604 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); |
604 | result = system ( postCommand ); | 605 | result = system ( postCommand ); |
605 | qDebug("Sync:Writing back file result: %d ", result); | 606 | qDebug("Sync:Writing back file result: %d ", result); |
606 | if ( result != 0 ) { | 607 | if ( result != 0 ) { |
607 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 608 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
608 | return; | 609 | return; |
609 | } else { | 610 | } else { |
610 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 611 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
611 | } | 612 | } |
612 | } | 613 | } |
613 | } | 614 | } |
614 | return; | 615 | return; |
615 | } | 616 | } |
616 | void KSyncManager::edit_pisync_options() | 617 | void KSyncManager::edit_pisync_options() |
617 | { | 618 | { |
618 | QDialog dia( mParent, "dia", true ); | 619 | QDialog dia( mParent, "dia", true ); |
619 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); | 620 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); |
620 | QVBoxLayout lay ( &dia ); | 621 | QVBoxLayout lay ( &dia ); |
621 | lay.setSpacing( 5 ); | 622 | lay.setSpacing( 5 ); |
622 | lay.setMargin( 3 ); | 623 | lay.setMargin( 3 ); |
623 | QLabel lab1 ( i18n("Password for remote access:"), &dia); | 624 | QLabel lab1 ( i18n("Password for remote access:"), &dia); |
624 | lay.addWidget( &lab1 ); | 625 | lay.addWidget( &lab1 ); |
625 | QLineEdit le1 (&dia ); | 626 | QLineEdit le1 (&dia ); |
626 | lay.addWidget( &le1 ); | 627 | lay.addWidget( &le1 ); |
627 | QLabel lab2 ( i18n("Remote IP address:"), &dia); | 628 | QLabel lab2 ( i18n("Remote IP address:"), &dia); |
628 | lay.addWidget( &lab2 ); | 629 | lay.addWidget( &lab2 ); |
629 | QLineEdit le2 (&dia ); | 630 | QLineEdit le2 (&dia ); |
630 | lay.addWidget( &le2 ); | 631 | lay.addWidget( &le2 ); |
631 | QLabel lab3 ( i18n("Remote port number:"), &dia); | 632 | QLabel lab3 ( i18n("Remote port number:"), &dia); |
632 | lay.addWidget( &lab3 ); | 633 | lay.addWidget( &lab3 ); |
633 | QLineEdit le3 (&dia ); | 634 | QLineEdit le3 (&dia ); |
634 | lay.addWidget( &le3 ); | 635 | lay.addWidget( &le3 ); |
635 | QPushButton pb ( "OK", &dia); | 636 | QPushButton pb ( "OK", &dia); |
636 | lay.addWidget( &pb ); | 637 | lay.addWidget( &pb ); |
637 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 638 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
638 | le1.setText( mPassWordPiSync ); | 639 | le1.setText( mPassWordPiSync ); |
639 | le2.setText( mActiveSyncIP ); | 640 | le2.setText( mActiveSyncIP ); |
640 | le3.setText( mActiveSyncPort ); | 641 | le3.setText( mActiveSyncPort ); |
641 | if ( dia.exec() ) { | 642 | if ( dia.exec() ) { |
642 | mPassWordPiSync = le1.text(); | 643 | mPassWordPiSync = le1.text(); |
643 | mActiveSyncPort = le3.text(); | 644 | mActiveSyncPort = le3.text(); |
644 | mActiveSyncIP = le2.text(); | 645 | mActiveSyncIP = le2.text(); |
645 | } | 646 | } |
646 | 647 | ||
647 | } | 648 | } |
648 | void KSyncManager::edit_sync_options() | 649 | void KSyncManager::edit_sync_options() |
649 | { | 650 | { |
650 | 651 | ||
651 | QDialog dia( mParent, "dia", true ); | 652 | QDialog dia( mParent, "dia", true ); |
652 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 653 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
653 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 654 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
654 | QVBoxLayout lay ( &dia ); | 655 | QVBoxLayout lay ( &dia ); |
655 | lay.setSpacing( 2 ); | 656 | lay.setSpacing( 2 ); |
656 | lay.setMargin( 3 ); | 657 | lay.setMargin( 3 ); |
657 | lay.addWidget(&gr); | 658 | lay.addWidget(&gr); |
658 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 659 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
659 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 660 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
660 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 661 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
661 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 662 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
662 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 663 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
663 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 664 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
664 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 665 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
665 | QPushButton pb ( "OK", &dia); | 666 | QPushButton pb ( "OK", &dia); |
666 | lay.addWidget( &pb ); | 667 | lay.addWidget( &pb ); |
667 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 668 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
668 | switch ( mSyncAlgoPrefs ) { | 669 | switch ( mSyncAlgoPrefs ) { |
669 | case 0: | 670 | case 0: |
670 | loc.setChecked( true); | 671 | loc.setChecked( true); |
671 | break; | 672 | break; |
672 | case 1: | 673 | case 1: |
673 | rem.setChecked( true ); | 674 | rem.setChecked( true ); |
674 | break; | 675 | break; |
675 | case 2: | 676 | case 2: |
676 | newest.setChecked( true); | 677 | newest.setChecked( true); |
677 | break; | 678 | break; |
678 | case 3: | 679 | case 3: |
679 | ask.setChecked( true); | 680 | ask.setChecked( true); |
680 | break; | 681 | break; |
681 | case 4: | 682 | case 4: |
682 | f_loc.setChecked( true); | 683 | f_loc.setChecked( true); |
683 | break; | 684 | break; |
684 | case 5: | 685 | case 5: |
685 | f_rem.setChecked( true); | 686 | f_rem.setChecked( true); |
686 | break; | 687 | break; |
687 | case 6: | 688 | case 6: |
688 | // both.setChecked( true); | 689 | // both.setChecked( true); |
689 | break; | 690 | break; |
690 | default: | 691 | default: |
691 | break; | 692 | break; |
692 | } | 693 | } |
693 | if ( dia.exec() ) { | 694 | if ( dia.exec() ) { |
694 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 695 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
695 | } | 696 | } |
696 | 697 | ||
697 | 698 | ||
698 | } | 699 | } |
699 | 700 | ||
700 | QString KSyncManager::getPassword( ) | 701 | QString KSyncManager::getPassword( ) |
701 | { | 702 | { |
702 | QString retfile = ""; | 703 | QString retfile = ""; |
703 | QDialog dia ( mParent, "input-dialog", true ); | 704 | QDialog dia ( mParent, "input-dialog", true ); |
704 | QLineEdit lab ( &dia ); | 705 | QLineEdit lab ( &dia ); |
705 | lab.setEchoMode( QLineEdit::Password ); | 706 | lab.setEchoMode( QLineEdit::Password ); |
706 | QVBoxLayout lay( &dia ); | 707 | QVBoxLayout lay( &dia ); |
707 | lay.setMargin(7); | 708 | lay.setMargin(7); |
708 | lay.setSpacing(7); | 709 | lay.setSpacing(7); |
709 | lay.addWidget( &lab); | 710 | lay.addWidget( &lab); |
710 | dia.setFixedSize( 230,50 ); | 711 | dia.setFixedSize( 230,50 ); |
711 | dia.setCaption( i18n("Enter password") ); | 712 | dia.setCaption( i18n("Enter password") ); |
712 | QPushButton pb ( "OK", &dia); | 713 | QPushButton pb ( "OK", &dia); |
713 | lay.addWidget( &pb ); | 714 | lay.addWidget( &pb ); |
714 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 715 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
715 | dia.show(); | 716 | dia.show(); |
716 | int res = dia.exec(); | 717 | int res = dia.exec(); |
717 | if ( res ) | 718 | if ( res ) |
718 | retfile = lab.text(); | 719 | retfile = lab.text(); |
719 | dia.hide(); | 720 | dia.hide(); |
720 | qApp->processEvents(); | 721 | qApp->processEvents(); |
721 | return retfile; | 722 | return retfile; |
722 | 723 | ||
723 | } | 724 | } |
724 | 725 | ||
725 | 726 | ||
726 | void KSyncManager::confSync() | 727 | void KSyncManager::confSync() |
727 | { | 728 | { |
728 | static KSyncPrefsDialog* sp = 0; | 729 | static KSyncPrefsDialog* sp = 0; |
729 | if ( ! sp ) { | 730 | if ( ! sp ) { |
730 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 731 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
731 | } | 732 | } |
732 | sp->usrReadConfig(); | 733 | sp->usrReadConfig(); |
733 | #ifndef DESKTOP_VERSION | 734 | #ifndef DESKTOP_VERSION |
734 | sp->showMaximized(); | 735 | sp->showMaximized(); |
735 | #else | 736 | #else |
736 | sp->show(); | 737 | sp->show(); |
737 | #endif | 738 | #endif |
738 | sp->exec(); | 739 | sp->exec(); |
739 | mSyncProfileNames = sp->getSyncProfileNames(); | 740 | mSyncProfileNames = sp->getSyncProfileNames(); |
740 | mLocalMachineName = sp->getLocalMachineName (); | 741 | mLocalMachineName = sp->getLocalMachineName (); |
741 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 742 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
742 | } | 743 | } |
743 | 744 | ||
744 | void KSyncManager::syncSharp() | 745 | void KSyncManager::syncSharp() |
745 | { | 746 | { |
746 | 747 | ||
747 | if ( ! syncExternalApplication("sharp") ) | 748 | if ( ! syncExternalApplication("sharp") ) |
748 | qDebug("ERROR sync sharp "); | 749 | qDebug("ERROR sync sharp "); |
749 | } | 750 | } |
750 | 751 | ||
751 | bool KSyncManager::syncExternalApplication(QString resource) | 752 | bool KSyncManager::syncExternalApplication(QString resource) |
752 | { | 753 | { |
753 | 754 | ||
754 | emit save(); | 755 | emit save(); |
755 | 756 | ||
756 | if ( mAskForPreferences ) | 757 | if ( mAskForPreferences ) |
757 | edit_sync_options(); | 758 | edit_sync_options(); |
758 | 759 | ||
759 | qDebug("Sync extern %s", resource.latin1()); | 760 | qDebug("Sync extern %s", resource.latin1()); |
760 | 761 | ||
761 | bool syncOK = mImplementation->syncExternal(this, resource); | 762 | bool syncOK = mImplementation->syncExternal(this, resource); |
762 | 763 | ||
763 | return syncOK; | 764 | return syncOK; |
764 | 765 | ||
765 | } | 766 | } |
766 | 767 | ||
767 | void KSyncManager::syncPhone() | 768 | void KSyncManager::syncPhone() |
768 | { | 769 | { |
769 | 770 | ||
770 | syncExternalApplication("phone"); | 771 | syncExternalApplication("phone"); |
771 | 772 | ||
772 | } | 773 | } |
773 | 774 | ||
774 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 775 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
775 | { | 776 | { |
776 | if (!bar->isVisible()) | 777 | if (!bar->isVisible()) |
777 | { | 778 | { |
778 | bar->setCaption (caption); | 779 | bar->setCaption (caption); |
779 | bar->setTotalSteps ( total ) ; | 780 | bar->setTotalSteps ( total ) ; |
780 | 781 | ||
781 | bar->show(); | 782 | bar->show(); |
782 | } | 783 | } |
783 | 784 | ||
784 | bar->setProgress( percentage ); | 785 | bar->setProgress( percentage ); |
785 | } | 786 | } |
786 | 787 | ||
787 | void KSyncManager::hideProgressBar() | 788 | void KSyncManager::hideProgressBar() |
788 | { | 789 | { |
789 | bar->hide(); | 790 | bar->hide(); |
790 | } | 791 | } |
791 | 792 | ||
792 | bool KSyncManager::isProgressBarCanceled() | 793 | bool KSyncManager::isProgressBarCanceled() |
793 | { | 794 | { |
794 | return !bar->isVisible(); | 795 | return !bar->isVisible(); |
795 | } | 796 | } |
796 | 797 | ||
797 | QString KSyncManager::syncFileName() | 798 | QString KSyncManager::syncFileName() |
798 | { | 799 | { |
799 | 800 | ||
800 | QString fn = "tempfile"; | 801 | QString fn = "tempfile"; |
801 | switch(mTargetApp) | 802 | switch(mTargetApp) |
802 | { | 803 | { |
803 | case (KAPI): | 804 | case (KAPI): |
804 | fn = "tempsyncab.vcf"; | 805 | fn = "tempsyncab.vcf"; |
805 | break; | 806 | break; |
806 | case (KOPI): | 807 | case (KOPI): |
807 | fn = "tempsynccal.ics"; | 808 | fn = "tempsynccal.ics"; |
808 | break; | 809 | break; |
809 | case (PWMPI): | 810 | case (PWMPI): |
810 | fn = "tempsyncpw.pwm"; | 811 | fn = "tempsyncpw.pwm"; |
811 | break; | 812 | break; |
812 | default: | 813 | default: |
813 | break; | 814 | break; |
814 | } | 815 | } |
815 | #ifdef _WIN32_ | 816 | #ifdef _WIN32_ |
816 | return locateLocal( "tmp", fn ); | 817 | return locateLocal( "tmp", fn ); |
817 | #else | 818 | #else |
818 | return (QString( "/tmp/" )+ fn ); | 819 | return (QString( "/tmp/" )+ fn ); |
819 | #endif | 820 | #endif |
820 | } | 821 | } |
821 | 822 | ||
822 | void KSyncManager::syncPi() | 823 | void KSyncManager::syncPi() |
823 | { | 824 | { |
824 | qApp->processEvents(); | 825 | qApp->processEvents(); |
825 | if ( mAskForPreferences ) | 826 | if ( mAskForPreferences ) |
826 | edit_pisync_options(); | 827 | edit_pisync_options(); |
827 | bool ok; | 828 | bool ok; |
828 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 829 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
829 | if ( ! ok ) { | 830 | if ( ! ok ) { |
830 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 831 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
831 | return; | 832 | return; |
832 | } | 833 | } |
833 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); | 834 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); |
834 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 835 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
835 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); | 836 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); |
836 | commandSocket->readFile( syncFileName() ); | 837 | commandSocket->readFile( syncFileName() ); |
837 | } | 838 | } |
838 | 839 | ||
839 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 840 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
840 | { | 841 | { |
841 | //enum { success, errorW, errorR, quiet }; | 842 | //enum { success, errorW, errorR, quiet }; |
842 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { | 843 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { |
843 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 844 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
844 | delete s; | 845 | delete s; |
845 | if ( state == KCommandSocket::errorR ) { | 846 | if ( state == KCommandSocket::errorR ) { |
846 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 847 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
847 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 848 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
848 | commandSocket->sendStop(); | 849 | commandSocket->sendStop(); |
849 | } | 850 | } |
850 | return; | 851 | return; |
851 | 852 | ||
852 | } else if ( state == KCommandSocket::errorW ) { | 853 | } else if ( state == KCommandSocket::errorW ) { |
853 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); | 854 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); |
854 | 855 | ||
855 | } else if ( state == KCommandSocket::successR ) { | 856 | } else if ( state == KCommandSocket::successR ) { |
856 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 857 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
857 | 858 | ||
858 | } else if ( state == KCommandSocket::successW ) { | 859 | } else if ( state == KCommandSocket::successW ) { |
859 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 860 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
860 | } | 861 | } |
861 | 862 | ||
862 | delete s; | 863 | delete s; |
863 | } | 864 | } |
864 | 865 | ||
865 | void KSyncManager::readFileFromSocket() | 866 | void KSyncManager::readFileFromSocket() |
866 | { | 867 | { |
867 | QString fileName = syncFileName(); | 868 | QString fileName = syncFileName(); |
868 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); | 869 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); |
869 | if ( ! syncWithFile( fileName , true ) ) { | 870 | if ( ! syncWithFile( fileName , true ) ) { |
870 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); | 871 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); |
871 | return; | 872 | return; |
872 | } | 873 | } |
873 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 874 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
874 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 875 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
875 | if ( mWriteBackFile ) | 876 | if ( mWriteBackFile ) |
876 | commandSocket->writeFile( fileName ); | 877 | commandSocket->writeFile( fileName ); |
877 | else { | 878 | else { |
878 | commandSocket->sendStop(); | 879 | commandSocket->sendStop(); |
879 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 880 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
880 | } | 881 | } |
881 | } | 882 | } |
882 | 883 | ||
883 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 884 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
884 | { | 885 | { |
885 | mPassWord = pw; | 886 | mPassWord = pw; |
886 | mSocket = 0; | 887 | mSocket = 0; |
887 | mSyncActionDialog = 0; | 888 | mSyncActionDialog = 0; |
888 | blockRC = false; | 889 | blockRC = false; |
889 | }; | 890 | }; |
890 | 891 | ||
891 | void KServerSocket::newConnection ( int socket ) | 892 | void KServerSocket::newConnection ( int socket ) |
892 | { | 893 | { |
893 | // qDebug("KServerSocket:New connection %d ", socket); | 894 | // qDebug("KServerSocket:New connection %d ", socket); |
894 | if ( mSocket ) { | 895 | if ( mSocket ) { |
895 | qDebug("KServerSocket::newConnection Socket deleted! "); | 896 | qDebug("KServerSocket::newConnection Socket deleted! "); |
896 | delete mSocket; | 897 | delete mSocket; |
897 | mSocket = 0; | 898 | mSocket = 0; |
898 | } | 899 | } |
899 | mSocket = new QSocket( this ); | 900 | mSocket = new QSocket( this ); |
900 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 901 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
901 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 902 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
902 | mSocket->setSocket( socket ); | 903 | mSocket->setSocket( socket ); |
903 | } | 904 | } |
904 | 905 | ||
905 | void KServerSocket::discardClient() | 906 | void KServerSocket::discardClient() |
906 | { | 907 | { |
907 | //qDebug(" KServerSocket::discardClient()"); | 908 | //qDebug(" KServerSocket::discardClient()"); |
908 | if ( mSocket ) { | 909 | if ( mSocket ) { |
909 | delete mSocket; | 910 | delete mSocket; |
910 | mSocket = 0; | 911 | mSocket = 0; |
911 | } | 912 | } |
912 | //emit endConnect(); | 913 | //emit endConnect(); |
913 | } | 914 | } |
914 | void KServerSocket::readClient() | 915 | void KServerSocket::readClient() |
915 | { | 916 | { |
916 | if ( blockRC ) | 917 | if ( blockRC ) |
917 | return; | 918 | return; |
918 | if ( mSocket == 0 ) { | 919 | if ( mSocket == 0 ) { |
919 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); | 920 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); |
920 | return; | 921 | return; |
921 | } | 922 | } |
922 | //qDebug("KServerSocket::readClient()"); | 923 | //qDebug("KServerSocket::readClient()"); |
923 | if ( mSocket->canReadLine() ) { | 924 | if ( mSocket->canReadLine() ) { |
924 | QString line = mSocket->readLine(); | 925 | QString line = mSocket->readLine(); |
925 | //qDebug("KServerSocket readline: %s ", line.latin1()); | 926 | //qDebug("KServerSocket readline: %s ", line.latin1()); |
926 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); | 927 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); |
927 | if ( tokens[0] == "GET" ) { | 928 | if ( tokens[0] == "GET" ) { |
928 | if ( tokens[1] == mPassWord ) | 929 | if ( tokens[1] == mPassWord ) |
929 | //emit sendFile( mSocket ); | 930 | //emit sendFile( mSocket ); |
930 | send_file(); | 931 | send_file(); |
931 | else { | 932 | else { |
932 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); | 933 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); |
933 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 934 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
934 | } | 935 | } |
935 | } | 936 | } |
936 | if ( tokens[0] == "PUT" ) { | 937 | if ( tokens[0] == "PUT" ) { |
937 | if ( tokens[1] == mPassWord ) { | 938 | if ( tokens[1] == mPassWord ) { |
938 | //emit getFile( mSocket ); | 939 | //emit getFile( mSocket ); |
939 | blockRC = true; | 940 | blockRC = true; |
940 | get_file(); | 941 | get_file(); |
941 | } | 942 | } |
942 | else { | 943 | else { |
943 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); | 944 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); |
944 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 945 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
945 | } | 946 | } |
946 | } | 947 | } |
947 | if ( tokens[0] == "STOP" ) { | 948 | if ( tokens[0] == "STOP" ) { |
948 | //emit endConnect(); | 949 | //emit endConnect(); |
949 | end_connect(); | 950 | end_connect(); |
950 | } | 951 | } |
951 | } | 952 | } |
952 | } | 953 | } |
953 | void KServerSocket::end_connect() | 954 | void KServerSocket::end_connect() |
954 | { | 955 | { |
955 | delete mSyncActionDialog; | 956 | delete mSyncActionDialog; |
956 | mSyncActionDialog = 0; | 957 | mSyncActionDialog = 0; |
957 | } | 958 | } |
958 | void KServerSocket::send_file() | 959 | void KServerSocket::send_file() |
959 | { | 960 | { |
960 | //qDebug("MainWindow::sendFile(QSocket* s) "); | 961 | //qDebug("MainWindow::sendFile(QSocket* s) "); |
961 | if ( mSyncActionDialog ) | 962 | if ( mSyncActionDialog ) |
962 | delete mSyncActionDialog; | 963 | delete mSyncActionDialog; |
963 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | 964 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); |
964 | mSyncActionDialog->setCaption(i18n("Received sync request")); | 965 | mSyncActionDialog->setCaption(i18n("Received sync request")); |
965 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); | 966 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); |
966 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 967 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
967 | lay->addWidget( label); | 968 | lay->addWidget( label); |
968 | lay->setMargin(7); | 969 | lay->setMargin(7); |
969 | lay->setSpacing(7); | 970 | lay->setSpacing(7); |
970 | mSyncActionDialog->setFixedSize( 230, 120); | 971 | mSyncActionDialog->setFixedSize( 230, 120); |
971 | mSyncActionDialog->show(); | 972 | mSyncActionDialog->show(); |
972 | mSyncActionDialog->raise(); | 973 | mSyncActionDialog->raise(); |
973 | emit request_file(); | 974 | emit request_file(); |
974 | qApp->processEvents(); | 975 | qApp->processEvents(); |
975 | QString fileName = mFileName; | 976 | QString fileName = mFileName; |
976 | QFile file( fileName ); | 977 | QFile file( fileName ); |
977 | if (!file.open( IO_ReadOnly ) ) { | 978 | if (!file.open( IO_ReadOnly ) ) { |
978 | delete mSyncActionDialog; | 979 | delete mSyncActionDialog; |
979 | mSyncActionDialog = 0; | 980 | mSyncActionDialog = 0; |
980 | qDebug("KSS::error open file "); | 981 | qDebug("KSS::error open file "); |
981 | mSocket->close(); | 982 | mSocket->close(); |
982 | if ( mSocket->state() == QSocket::Idle ) | 983 | if ( mSocket->state() == QSocket::Idle ) |
983 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 984 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
984 | return ; | 985 | return ; |
985 | 986 | ||
986 | } | 987 | } |
987 | mSyncActionDialog->setCaption( i18n("Sending file...") ); | 988 | mSyncActionDialog->setCaption( i18n("Sending file...") ); |
988 | QTextStream ts( &file ); | 989 | QTextStream ts( &file ); |
989 | ts.setEncoding( QTextStream::Latin1 ); | 990 | ts.setEncoding( QTextStream::Latin1 ); |
990 | 991 | ||
991 | QTextStream os( mSocket ); | 992 | QTextStream os( mSocket ); |
992 | os.setEncoding( QTextStream::Latin1 ); | 993 | os.setEncoding( QTextStream::Latin1 ); |
993 | while ( ! ts.atEnd() ) { | 994 | while ( ! ts.atEnd() ) { |
994 | os << ts.readLine() << "\r\n"; | 995 | os << ts.readLine() << "\r\n"; |
995 | } | 996 | } |
996 | //os << ts.read(); | 997 | //os << ts.read(); |
997 | file.close(); | 998 | file.close(); |
998 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | 999 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); |
999 | mSocket->close(); | 1000 | mSocket->close(); |
1000 | if ( mSocket->state() == QSocket::Idle ) | 1001 | if ( mSocket->state() == QSocket::Idle ) |
1001 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1002 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1002 | } | 1003 | } |
1003 | void KServerSocket::get_file() | 1004 | void KServerSocket::get_file() |
1004 | { | 1005 | { |
1005 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | 1006 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); |
1006 | 1007 | ||
1007 | piTime.start(); | 1008 | piTime.start(); |
1008 | piFileString = ""; | 1009 | piFileString = ""; |
1009 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | 1010 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); |
1010 | } | 1011 | } |
1011 | 1012 | ||
1012 | 1013 | ||
1013 | void KServerSocket::readBackFileFromSocket() | 1014 | void KServerSocket::readBackFileFromSocket() |
1014 | { | 1015 | { |
1015 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | 1016 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); |
1016 | while ( mSocket->canReadLine () ) { | 1017 | while ( mSocket->canReadLine () ) { |
1017 | piTime.restart(); | 1018 | piTime.restart(); |
1018 | QString line = mSocket->readLine (); | 1019 | QString line = mSocket->readLine (); |
1019 | piFileString += line; | 1020 | piFileString += line; |
1020 | //qDebug("readline: %s ", line.latin1()); | 1021 | //qDebug("readline: %s ", line.latin1()); |
1021 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | 1022 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); |
1022 | 1023 | ||
1023 | } | 1024 | } |
1024 | if ( piTime.elapsed () < 3000 ) { | 1025 | if ( piTime.elapsed () < 3000 ) { |
1025 | // wait for more | 1026 | // wait for more |
1026 | //qDebug("waitformore "); | 1027 | //qDebug("waitformore "); |
1027 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | 1028 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); |
1028 | return; | 1029 | return; |
1029 | } | 1030 | } |
1030 | QString fileName = mFileName; | 1031 | QString fileName = mFileName; |
1031 | QFile file ( fileName ); | 1032 | QFile file ( fileName ); |
1032 | if (!file.open( IO_WriteOnly ) ) { | 1033 | if (!file.open( IO_WriteOnly ) ) { |
1033 | delete mSyncActionDialog; | 1034 | delete mSyncActionDialog; |
1034 | mSyncActionDialog = 0; | 1035 | mSyncActionDialog = 0; |
1035 | qDebug("KSS:Error open read back file "); | 1036 | qDebug("KSS:Error open read back file "); |
1036 | piFileString = ""; | 1037 | piFileString = ""; |
1037 | emit file_received( false ); | 1038 | emit file_received( false ); |
1038 | blockRC = false; | 1039 | blockRC = false; |
1039 | return ; | 1040 | return ; |
1040 | 1041 | ||
1041 | } | 1042 | } |
1042 | 1043 | ||
1043 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1044 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1044 | QTextStream ts ( &file ); | 1045 | QTextStream ts ( &file ); |
1045 | ts.setEncoding( QTextStream::Latin1 ); | 1046 | ts.setEncoding( QTextStream::Latin1 ); |
1046 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | 1047 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); |
1047 | ts << piFileString; | 1048 | ts << piFileString; |
1048 | mSocket->close(); | 1049 | mSocket->close(); |
1049 | if ( mSocket->state() == QSocket::Idle ) | 1050 | if ( mSocket->state() == QSocket::Idle ) |
1050 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1051 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1051 | file.close(); | 1052 | file.close(); |
1052 | delete mSyncActionDialog; | 1053 | delete mSyncActionDialog; |
1053 | mSyncActionDialog = 0; | 1054 | mSyncActionDialog = 0; |
1054 | piFileString = ""; | 1055 | piFileString = ""; |
1055 | blockRC = false; | 1056 | blockRC = false; |
1056 | emit file_received( true ); | 1057 | emit file_received( true ); |
1057 | 1058 | ||
1058 | } | 1059 | } |
1059 | 1060 | ||
1060 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) | 1061 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) |
1061 | { | 1062 | { |
1062 | mPassWord = password; | 1063 | mPassWord = password; |
1063 | mSocket = 0; | 1064 | mSocket = 0; |
1064 | mPort = port; | 1065 | mPort = port; |
1065 | mHost = host; | 1066 | mHost = host; |
1066 | 1067 | ||
1067 | mRetVal = quiet; | 1068 | mRetVal = quiet; |
1068 | mTimerSocket = new QTimer ( this ); | 1069 | mTimerSocket = new QTimer ( this ); |
1069 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); | 1070 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); |
1070 | } | 1071 | } |
1071 | void KCommandSocket::readFile( QString fn ) | 1072 | void KCommandSocket::readFile( QString fn ) |
1072 | { | 1073 | { |
1073 | if ( !mSocket ) { | 1074 | if ( !mSocket ) { |
1074 | mSocket = new QSocket( this ); | 1075 | mSocket = new QSocket( this ); |
1075 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | 1076 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); |
1076 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1077 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1077 | } | 1078 | } |
1078 | mFileString = ""; | 1079 | mFileString = ""; |
1079 | mFileName = fn; | 1080 | mFileName = fn; |
1080 | mFirst = true; | 1081 | mFirst = true; |
1081 | mSocket->connectToHost( mHost, mPort ); | 1082 | mSocket->connectToHost( mHost, mPort ); |
1082 | QTextStream os( mSocket ); | 1083 | QTextStream os( mSocket ); |
1083 | os.setEncoding( QTextStream::Latin1 ); | 1084 | os.setEncoding( QTextStream::Latin1 ); |
1084 | os << "GET " << mPassWord << "\r\n"; | 1085 | os << "GET " << mPassWord << "\r\n"; |
1085 | mTimerSocket->start( 10000 ); | 1086 | mTimerSocket->start( 10000 ); |
1086 | } | 1087 | } |
1087 | 1088 | ||
1088 | void KCommandSocket::writeFile( QString fileName ) | 1089 | void KCommandSocket::writeFile( QString fileName ) |
1089 | { | 1090 | { |
1090 | if ( !mSocket ) { | 1091 | if ( !mSocket ) { |
1091 | mSocket = new QSocket( this ); | 1092 | mSocket = new QSocket( this ); |
1092 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1093 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1093 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); | 1094 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); |
1094 | } | 1095 | } |
1095 | mFileName = fileName ; | 1096 | mFileName = fileName ; |
1096 | mSocket->connectToHost( mHost, mPort ); | 1097 | mSocket->connectToHost( mHost, mPort ); |
1097 | } | 1098 | } |
1098 | void KCommandSocket::writeFileToSocket() | 1099 | void KCommandSocket::writeFileToSocket() |
1099 | { | 1100 | { |
1100 | QFile file2( mFileName ); | 1101 | QFile file2( mFileName ); |
1101 | if (!file2.open( IO_ReadOnly ) ) { | 1102 | if (!file2.open( IO_ReadOnly ) ) { |
1102 | mRetVal= errorW; | 1103 | mRetVal= errorW; |
1103 | mSocket->close(); | 1104 | mSocket->close(); |
1104 | if ( mSocket->state() == QSocket::Idle ) | 1105 | if ( mSocket->state() == QSocket::Idle ) |
1105 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1106 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1106 | return ; | 1107 | return ; |
1107 | } | 1108 | } |
1108 | QTextStream ts2( &file2 ); | 1109 | QTextStream ts2( &file2 ); |
1109 | ts2.setEncoding( QTextStream::Latin1 ); | 1110 | ts2.setEncoding( QTextStream::Latin1 ); |
1110 | QTextStream os2( mSocket ); | 1111 | QTextStream os2( mSocket ); |
1111 | os2.setEncoding( QTextStream::Latin1 ); | 1112 | os2.setEncoding( QTextStream::Latin1 ); |
1112 | os2 << "PUT " << mPassWord << "\r\n";; | 1113 | os2 << "PUT " << mPassWord << "\r\n";; |
1113 | while ( ! ts2.atEnd() ) { | 1114 | while ( ! ts2.atEnd() ) { |
1114 | os2 << ts2.readLine() << "\r\n"; | 1115 | os2 << ts2.readLine() << "\r\n"; |
1115 | } | 1116 | } |
1116 | mRetVal= successW; | 1117 | mRetVal= successW; |
1117 | file2.close(); | 1118 | file2.close(); |
1118 | mSocket->close(); | 1119 | mSocket->close(); |
1119 | if ( mSocket->state() == QSocket::Idle ) | 1120 | if ( mSocket->state() == QSocket::Idle ) |
1120 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1121 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1121 | } | 1122 | } |
1122 | void KCommandSocket::sendStop() | 1123 | void KCommandSocket::sendStop() |
1123 | { | 1124 | { |
1124 | if ( !mSocket ) { | 1125 | if ( !mSocket ) { |
1125 | mSocket = new QSocket( this ); | 1126 | mSocket = new QSocket( this ); |
1126 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1127 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1127 | } | 1128 | } |
1128 | mSocket->connectToHost( mHost, mPort ); | 1129 | mSocket->connectToHost( mHost, mPort ); |
1129 | QTextStream os2( mSocket ); | 1130 | QTextStream os2( mSocket ); |
1130 | os2.setEncoding( QTextStream::Latin1 ); | 1131 | os2.setEncoding( QTextStream::Latin1 ); |
1131 | os2 << "STOP\r\n"; | 1132 | os2 << "STOP\r\n"; |
1132 | mSocket->close(); | 1133 | mSocket->close(); |
1133 | if ( mSocket->state() == QSocket::Idle ) | 1134 | if ( mSocket->state() == QSocket::Idle ) |
1134 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1135 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1135 | } | 1136 | } |
1136 | 1137 | ||
1137 | void KCommandSocket::startReadFileFromSocket() | 1138 | void KCommandSocket::startReadFileFromSocket() |
1138 | { | 1139 | { |
1139 | if ( ! mFirst ) | 1140 | if ( ! mFirst ) |
1140 | return; | 1141 | return; |
1141 | mFirst = false; | 1142 | mFirst = false; |
1142 | mTimerSocket->stop(); | 1143 | mTimerSocket->stop(); |
1143 | mFileString = ""; | 1144 | mFileString = ""; |
1144 | mTime.start(); | 1145 | mTime.start(); |
1145 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | 1146 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); |
1146 | 1147 | ||
1147 | } | 1148 | } |
1148 | void KCommandSocket::readFileFromSocket() | 1149 | void KCommandSocket::readFileFromSocket() |
1149 | { | 1150 | { |
1150 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | 1151 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); |
1151 | while ( mSocket->canReadLine () ) { | 1152 | while ( mSocket->canReadLine () ) { |
1152 | mTime.restart(); | 1153 | mTime.restart(); |
1153 | QString line = mSocket->readLine (); | 1154 | QString line = mSocket->readLine (); |
1154 | mFileString += line; | 1155 | mFileString += line; |
1155 | //qDebug("readline: %s ", line.latin1()); | 1156 | //qDebug("readline: %s ", line.latin1()); |
1156 | } | 1157 | } |
1157 | if ( mTime.elapsed () < 3000 ) { | 1158 | if ( mTime.elapsed () < 3000 ) { |
1158 | // wait for more | 1159 | // wait for more |
1159 | //qDebug("waitformore "); | 1160 | //qDebug("waitformore "); |
1160 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); | 1161 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); |
1161 | return; | 1162 | return; |
1162 | } | 1163 | } |
1163 | QString fileName = mFileName; | 1164 | QString fileName = mFileName; |
1164 | QFile file ( fileName ); | 1165 | QFile file ( fileName ); |
1165 | if (!file.open( IO_WriteOnly ) ) { | 1166 | if (!file.open( IO_WriteOnly ) ) { |
1166 | mFileString = ""; | 1167 | mFileString = ""; |
1167 | mRetVal = errorR; | 1168 | mRetVal = errorR; |
1168 | qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); | 1169 | qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); |
1169 | deleteSocket(); | 1170 | deleteSocket(); |
1170 | return ; | 1171 | return ; |
1171 | 1172 | ||
1172 | } | 1173 | } |
1173 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1174 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1174 | QTextStream ts ( &file ); | 1175 | QTextStream ts ( &file ); |
1175 | ts.setEncoding( QTextStream::Latin1 ); | 1176 | ts.setEncoding( QTextStream::Latin1 ); |
1176 | ts << mFileString; | 1177 | ts << mFileString; |
1177 | file.close(); | 1178 | file.close(); |
1178 | mFileString = ""; | 1179 | mFileString = ""; |
1179 | mRetVal = successR; | 1180 | mRetVal = successR; |
1180 | mSocket->close(); | 1181 | mSocket->close(); |
1181 | // if state is not idle, deleteSocket(); is called via | 1182 | // if state is not idle, deleteSocket(); is called via |
1182 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1183 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1183 | if ( mSocket->state() == QSocket::Idle ) | 1184 | if ( mSocket->state() == QSocket::Idle ) |
1184 | deleteSocket(); | 1185 | deleteSocket(); |
1185 | } | 1186 | } |
1186 | 1187 | ||
1187 | void KCommandSocket::deleteSocket() | 1188 | void KCommandSocket::deleteSocket() |
1188 | { | 1189 | { |
1189 | //qDebug("KCommandSocket::deleteSocket() "); | 1190 | //qDebug("KCommandSocket::deleteSocket() "); |
1190 | if ( mTimerSocket->isActive () ) { | 1191 | if ( mTimerSocket->isActive () ) { |
1191 | mTimerSocket->stop(); | 1192 | mTimerSocket->stop(); |
1192 | mRetVal = errorTO; | 1193 | mRetVal = errorTO; |
1193 | qDebug("Connection to remote host timed out"); | 1194 | qDebug("Connection to remote host timed out"); |
1194 | if ( mSocket ) { | 1195 | if ( mSocket ) { |
1195 | mSocket->close(); | 1196 | mSocket->close(); |
1196 | //if ( mSocket->state() == QSocket::Idle ) | 1197 | //if ( mSocket->state() == QSocket::Idle ) |
1197 | // deleteSocket(); | 1198 | // deleteSocket(); |
1198 | delete mSocket; | 1199 | delete mSocket; |
1199 | mSocket = 0; | 1200 | mSocket = 0; |
1200 | } | 1201 | } |
1201 | KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | 1202 | KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); |
1202 | emit commandFinished( this, mRetVal ); | 1203 | emit commandFinished( this, mRetVal ); |
1203 | return; | 1204 | return; |
1204 | } | 1205 | } |
1205 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); | 1206 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); |
1206 | if ( mSocket) | 1207 | if ( mSocket) |
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 5b05383..9094aac 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h | |||
@@ -1,208 +1,209 @@ | |||
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 mWriteBackExistingOnly; | 138 | bool mWriteBackExistingOnly; |
138 | int mSyncAlgoPrefs; | 139 | int mSyncAlgoPrefs; |
139 | bool mWriteBackFile; | 140 | bool mWriteBackFile; |
140 | int mWriteBackInFuture; | 141 | int mWriteBackInFuture; |
141 | QString mPhoneDevice; | 142 | QString mPhoneDevice; |
142 | QString mPhoneConnection; | 143 | QString mPhoneConnection; |
143 | QString mPhoneModel; | 144 | QString mPhoneModel; |
144 | QString mPassWordPiSync; | 145 | QString mPassWordPiSync; |
145 | QString mActiveSyncPort; | 146 | QString mActiveSyncPort; |
146 | QString mActiveSyncIP ; | 147 | QString mActiveSyncIP ; |
147 | 148 | ||
148 | signals: | 149 | signals: |
149 | void save(); | 150 | void save(); |
150 | void request_file(); | 151 | void request_file(); |
151 | void getFile( bool ); | 152 | void getFile( bool ); |
152 | 153 | ||
153 | public slots: | 154 | public slots: |
154 | void slotSyncMenu( int ); | 155 | void slotSyncMenu( int ); |
155 | void deleteCommandSocket(KCommandSocket*s, int state); | 156 | void deleteCommandSocket(KCommandSocket*s, int state); |
156 | void readFileFromSocket(); | 157 | void readFileFromSocket(); |
157 | void fillSyncMenu(); | 158 | void fillSyncMenu(); |
158 | 159 | ||
159 | private: | 160 | private: |
160 | void syncPi(); | 161 | void syncPi(); |
161 | KServerSocket * mServerSocket; | 162 | KServerSocket * mServerSocket; |
162 | void enableQuick(); | 163 | void enableQuick(); |
163 | KPimPrefs* mPrefs; | 164 | KPimPrefs* mPrefs; |
164 | QString mDefFileName; | 165 | QString mDefFileName; |
165 | QString mCurrentSyncDevice; | 166 | QString mCurrentSyncDevice; |
166 | QString mCurrentSyncName; | 167 | QString mCurrentSyncName; |
167 | void quickSyncLocalFile(); | 168 | void quickSyncLocalFile(); |
168 | bool syncWithFile( QString fn , bool quick ); | 169 | bool syncWithFile( QString fn , bool quick ); |
169 | void syncLocalFile(); | 170 | void syncLocalFile(); |
170 | void syncPhone(); | 171 | void syncPhone(); |
171 | void syncSharp(); | 172 | void syncSharp(); |
172 | bool syncExternalApplication(QString); | 173 | bool syncExternalApplication(QString); |
173 | int mCurrentSyncProfile ; | 174 | int mCurrentSyncProfile ; |
174 | void syncRemote( KSyncProfile* prof, bool ask = true); | 175 | void syncRemote( KSyncProfile* prof, bool ask = true); |
175 | void edit_sync_options(); | 176 | void edit_sync_options(); |
176 | void edit_pisync_options(); | 177 | void edit_pisync_options(); |
177 | int ringSync(); | 178 | int ringSync(); |
178 | QString getPassword( ); | 179 | QString getPassword( ); |
179 | 180 | ||
180 | private slots: | 181 | private slots: |
181 | void confSync(); | 182 | void confSync(); |
182 | private: | 183 | private: |
183 | bool mBlockSaveFlag; | 184 | bool mBlockSaveFlag; |
184 | QWidget* mParent; | 185 | QWidget* mParent; |
185 | KSyncInterface* mImplementation; | 186 | KSyncInterface* mImplementation; |
186 | TargetApp mTargetApp; | 187 | TargetApp mTargetApp; |
187 | QPopupMenu* mSyncMenu; | 188 | QPopupMenu* mSyncMenu; |
188 | QProgressBar* bar; | 189 | QProgressBar* bar; |
189 | 190 | ||
190 | }; | 191 | }; |
191 | 192 | ||
192 | 193 | ||
193 | class KSyncInterface | 194 | class KSyncInterface |
194 | { | 195 | { |
195 | public : | 196 | public : |
196 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; | 197 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; |
197 | virtual bool syncExternal(KSyncManager* manager, QString resource) | 198 | virtual bool syncExternal(KSyncManager* manager, QString resource) |
198 | { | 199 | { |
199 | // empty implementation, because some syncable applications do not | 200 | // empty implementation, because some syncable applications do not |
200 | // have an external(sharpdtm) syncmode, like pwmanager. | 201 | // have an external(sharpdtm) syncmode, like pwmanager. |
201 | return false; | 202 | return false; |
202 | } | 203 | } |
203 | 204 | ||
204 | 205 | ||
205 | }; | 206 | }; |
206 | 207 | ||
207 | 208 | ||
208 | #endif | 209 | #endif |
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp index cf8f996..03265d2 100644 --- a/libkdepim/ksyncprefsdialog.cpp +++ b/libkdepim/ksyncprefsdialog.cpp | |||
@@ -1,732 +1,744 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | 3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program 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 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qlabel.h> | 25 | #include <qlabel.h> |
26 | #include <qgroupbox.h> | 26 | #include <qgroupbox.h> |
27 | #include <qbuttongroup.h> | 27 | #include <qbuttongroup.h> |
28 | #include <qlineedit.h> | 28 | #include <qlineedit.h> |
29 | #include <qfont.h> | 29 | #include <qfont.h> |
30 | #include <qslider.h> | 30 | #include <qslider.h> |
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qdir.h> | 32 | #include <qdir.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
35 | #include <qvbox.h> | 35 | #include <qvbox.h> |
36 | #include <qhbox.h> | 36 | #include <qhbox.h> |
37 | #include <qspinbox.h> | 37 | #include <qspinbox.h> |
38 | #include <qdatetime.h> | 38 | #include <qdatetime.h> |
39 | #include <qcheckbox.h> | 39 | #include <qcheckbox.h> |
40 | #include <qradiobutton.h> | 40 | #include <qradiobutton.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qstrlist.h> | 42 | #include <qstrlist.h> |
43 | #include <qapplication.h> | 43 | #include <qapplication.h> |
44 | #include <qlayout.h> | 44 | #include <qlayout.h> |
45 | #include <qscrollview.h> | 45 | #include <qscrollview.h> |
46 | 46 | ||
47 | #include <kcolorbutton.h> | 47 | #include <kcolorbutton.h> |
48 | #include <kdebug.h> | 48 | #include <kdebug.h> |
49 | #include <klocale.h> | 49 | #include <klocale.h> |
50 | #include <kglobal.h> | 50 | #include <kglobal.h> |
51 | #include <kfontdialog.h> | 51 | #include <kfontdialog.h> |
52 | #include <kmessagebox.h> | 52 | #include <kmessagebox.h> |
53 | #include <kcolordialog.h> | 53 | #include <kcolordialog.h> |
54 | #include <kiconloader.h> | 54 | #include <kiconloader.h> |
55 | #include <kemailsettings.h> | 55 | #include <kemailsettings.h> |
56 | #include <kstandarddirs.h> | 56 | #include <kstandarddirs.h> |
57 | #include <kfiledialog.h> | 57 | #include <kfiledialog.h> |
58 | #include <kmessagebox.h> | 58 | #include <kmessagebox.h> |
59 | 59 | ||
60 | //#include <kurlrequester.h> | 60 | //#include <kurlrequester.h> |
61 | #include <klineedit.h> | 61 | #include <klineedit.h> |
62 | #include "ksyncprofile.h" | 62 | #include "ksyncprofile.h" |
63 | 63 | ||
64 | 64 | ||
65 | //#include "koprefs.h" | 65 | //#include "koprefs.h" |
66 | 66 | ||
67 | #include "ksyncprefsdialog.h" | 67 | #include "ksyncprefsdialog.h" |
68 | //#include "koglobals.h" | 68 | //#include "koglobals.h" |
69 | 69 | ||
70 | 70 | ||
71 | KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) : | 71 | KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) : |
72 | KDialog(parent,name,true) | 72 | KDialog(parent,name,true) |
73 | { | 73 | { |
74 | 74 | ||
75 | setCaption( i18n("Synchronization Preferences")); | 75 | setCaption( i18n("Synchronization Preferences")); |
76 | 76 | ||
77 | mSyncProfiles.setAutoDelete( true ); | 77 | mSyncProfiles.setAutoDelete( true ); |
78 | setupSyncAlgTab(); | 78 | setupSyncAlgTab(); |
79 | } | 79 | } |
80 | 80 | ||
81 | 81 | ||
82 | KSyncPrefsDialog::~KSyncPrefsDialog() | 82 | KSyncPrefsDialog::~KSyncPrefsDialog() |
83 | { | 83 | { |
84 | } | 84 | } |
85 | 85 | ||
86 | void KSyncPrefsDialog::setupSyncAlgTab() | 86 | void KSyncPrefsDialog::setupSyncAlgTab() |
87 | { | 87 | { |
88 | QLabel * lab; | 88 | QLabel * lab; |
89 | //QFrame *page = addPage(i18n("Sync Prefs"),0,0); | 89 | //QFrame *page = addPage(i18n("Sync Prefs"),0,0); |
90 | QVBox * mainbox = new QVBox( this ); | 90 | QVBox * mainbox = new QVBox( this ); |
91 | QScrollView* sv = new QScrollView( mainbox ); | 91 | QScrollView* sv = new QScrollView( mainbox ); |
92 | QHBoxLayout * lay = new QHBoxLayout( this ); | 92 | QHBoxLayout * lay = new QHBoxLayout( this ); |
93 | lay->addWidget( mainbox ); | 93 | lay->addWidget( mainbox ); |
94 | QHBox * b_box = new QHBox( mainbox ); | 94 | QHBox * b_box = new QHBox( mainbox ); |
95 | 95 | ||
96 | QPushButton* button = new QPushButton( i18n("Ok"), b_box ); | 96 | QPushButton* button = new QPushButton( i18n("Ok"), b_box ); |
97 | connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); | 97 | connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); |
98 | button = new QPushButton( i18n("Cancel"), b_box ); | 98 | button = new QPushButton( i18n("Cancel"), b_box ); |
99 | connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); | 99 | connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); |
100 | //QBoxLayout * sl = new QVBoxLayout(this ); | 100 | //QBoxLayout * sl = new QVBoxLayout(this ); |
101 | //sl->addWidget ( sv ); | 101 | //sl->addWidget ( sv ); |
102 | sv->setResizePolicy ( QScrollView::AutoOneFit ); | 102 | sv->setResizePolicy ( QScrollView::AutoOneFit ); |
103 | QFrame *topFrame = new QFrame ( sv ); | 103 | QFrame *topFrame = new QFrame ( sv ); |
104 | sv->addChild( topFrame ); | 104 | sv->addChild( topFrame ); |
105 | mSetupSyncAlgTab = topFrame; | 105 | mSetupSyncAlgTab = topFrame; |
106 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); | 106 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); |
107 | topLayout->setSpacing(spacingHint()); | 107 | topLayout->setSpacing(spacingHint()); |
108 | topLayout->setMargin(marginHint()); | 108 | topLayout->setMargin(marginHint()); |
109 | 109 | ||
110 | //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); | 110 | //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); |
111 | int iii = 0; | 111 | int iii = 0; |
112 | //topLayout->addMultiCellWidget(lab , iii,iii,0,1); | 112 | //topLayout->addMultiCellWidget(lab , iii,iii,0,1); |
113 | //++iii; | 113 | //++iii; |
114 | 114 | ||
115 | mMyMachineName = new QLineEdit(topFrame); | 115 | mMyMachineName = new QLineEdit(topFrame); |
116 | lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); | 116 | lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); |
117 | topLayout->addWidget(lab ,iii,0); | 117 | topLayout->addWidget(lab ,iii,0); |
118 | topLayout->addWidget(mMyMachineName,iii,1); | 118 | topLayout->addWidget(mMyMachineName,iii,1); |
119 | ++iii; | 119 | ++iii; |
120 | 120 | ||
121 | QHBox* buttonbox = new QHBox( topFrame); | 121 | QHBox* buttonbox = new QHBox( topFrame); |
122 | topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); | 122 | topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); |
123 | ++iii; | 123 | ++iii; |
124 | button = new QPushButton( i18n("New profile"), buttonbox ); | 124 | button = new QPushButton( i18n("New profile"), buttonbox ); |
125 | connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); | 125 | connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); |
126 | 126 | ||
127 | button = new QPushButton( i18n("Clone profile"), buttonbox ); | 127 | button = new QPushButton( i18n("Clone profile"), buttonbox ); |
128 | connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); | 128 | connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); |
129 | 129 | ||
130 | button = new QPushButton( i18n("Delete profile"), buttonbox ); | 130 | button = new QPushButton( i18n("Delete profile"), buttonbox ); |
131 | connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); | 131 | connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); |
132 | 132 | ||
133 | mProfileBox = new QComboBox(topFrame); | 133 | mProfileBox = new QComboBox(topFrame); |
134 | mProfileBox->setEditable ( true ); | 134 | mProfileBox->setEditable ( true ); |
135 | mProfileBox->setInsertionPolicy(QComboBox::NoInsertion); | 135 | mProfileBox->setInsertionPolicy(QComboBox::NoInsertion); |
136 | connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); | 136 | connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); |
137 | connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); | 137 | connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); |
138 | 138 | ||
139 | lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); | 139 | lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); |
140 | topLayout->addWidget(lab ,iii,0); | 140 | topLayout->addWidget(lab ,iii,0); |
141 | topLayout->addWidget(mProfileBox, iii,1); | 141 | topLayout->addWidget(mProfileBox, iii,1); |
142 | ++iii; | 142 | ++iii; |
143 | 143 | ||
144 | QHBox *iims = new QHBox( topFrame ); | 144 | QHBox *iims = new QHBox( topFrame ); |
145 | new QLabel( i18n("Include in multiple "), iims ); | 145 | new QLabel( i18n("Include in multiple "), iims ); |
146 | mIncludeInRing = new QCheckBox( i18n("calendar "), iims ); | 146 | mIncludeInRing = new QCheckBox( i18n("calendar "), iims ); |
147 | mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims ); | 147 | mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims ); |
148 | mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims ); | 148 | mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims ); |
149 | new QLabel( i18n(" sync"), iims ); | 149 | new QLabel( i18n(" sync"), iims ); |
150 | topLayout->addMultiCellWidget(iims, iii,iii,0,1); | 150 | topLayout->addMultiCellWidget(iims, iii,iii,0,1); |
151 | ++iii; | 151 | ++iii; |
152 | 152 | ||
153 | mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); | 153 | mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); |
154 | topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); | 154 | topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); |
155 | ++iii; | 155 | ++iii; |
156 | QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); | 156 | QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); |
157 | topLayout->addMultiCellWidget(gr, iii,iii,0,1); | 157 | topLayout->addMultiCellWidget(gr, iii,iii,0,1); |
158 | ++iii; | 158 | ++iii; |
159 | loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); | 159 | loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); |
160 | rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); | 160 | rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); |
161 | newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); | 161 | newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); |
162 | ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); | 162 | ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); |
163 | f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); | 163 | f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); |
164 | f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); | 164 | f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); |
165 | // both = new QRadioButton ( i18n("Take both on conflict"), gr ); | 165 | // both = new QRadioButton ( i18n("Take both on conflict"), gr ); |
166 | 166 | ||
167 | mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); | 167 | mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); |
168 | topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); | 168 | topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); |
169 | ++iii; | 169 | ++iii; |
170 | 170 | ||
171 | mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame ); | 171 | mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame ); |
172 | topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); | 172 | topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); |
173 | ++iii; | 173 | ++iii; |
174 | 174 | ||
175 | mWriteBackExisting= new QCheckBox( i18n("-- Write back (on remote) existing entries only"), topFrame ); | 175 | mWriteBackExisting= new QCheckBox( i18n("-- Write back (on remote) existing entries only"), topFrame ); |
176 | topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); | 176 | topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); |
177 | ++iii; | 177 | ++iii; |
178 | 178 | ||
179 | mWriteBackFuture= new QCheckBox( i18n("-- Write back (calendar) entries in future only"), topFrame ); | 179 | mWriteBackFuture= new QCheckBox( i18n("-- Write back (calendar) entries in future only"), topFrame ); |
180 | topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1); | 180 | topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1); |
181 | ++iii; | 181 | ++iii; |
182 | topLayout->addMultiCellWidget(new QLabel( i18n("---- Max. weeks in future: ") , topFrame ), iii,iii,0,0); | 182 | topLayout->addMultiCellWidget(new QLabel( i18n("---- Max. weeks in future: ") , topFrame ), iii,iii,0,0); |
183 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, topFrame); | 183 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, topFrame); |
184 | topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1); | 184 | topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1); |
185 | ++iii; | 185 | ++iii; |
186 | 186 | ||
187 | proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); | 187 | proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); |
188 | gr = proGr; | 188 | gr = proGr; |
189 | topLayout->addMultiCellWidget(gr, iii,iii,0,1); | 189 | topLayout->addMultiCellWidget(gr, iii,iii,0,1); |
190 | ++iii; | 190 | ++iii; |
191 | mIsLocal = new QRadioButton ( i18n("Local file"), gr ); | 191 | mIsLocal = new QRadioButton ( i18n("Local file"), gr ); |
192 | mIsPi = new QRadioButton ( i18n("Pi-Sync ( direct Kx/Pi to Kx/Pi sync )"), gr ); | 192 | mIsPi = new QRadioButton ( i18n("Pi-Sync ( direct Kx/Pi to Kx/Pi sync )"), gr ); |
193 | connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); | 193 | connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); |
194 | mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); | 194 | mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); |
195 | connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); | 195 | connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); |
196 | mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr ); | 196 | mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr ); |
197 | connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); | 197 | connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); |
198 | 198 | ||
199 | 199 | ||
200 | phoneWidget = new QVBox( topFrame); | 200 | phoneWidget = new QVBox( topFrame); |
201 | topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1); | 201 | topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1); |
202 | ++iii; | 202 | ++iii; |
203 | mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget ); | 203 | mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget ); |
204 | QHBox* temphb = new QHBox( phoneWidget ); | 204 | QHBox* temphb = new QHBox( phoneWidget ); |
205 | new QLabel( i18n("I/O device: "), temphb ); | 205 | new QLabel( i18n("I/O device: "), temphb ); |
206 | mPhoneDevice = new QLineEdit( temphb); | 206 | mPhoneDevice = new QLineEdit( temphb); |
207 | button = new QPushButton( i18n("Help..."), temphb ); | 207 | button = new QPushButton( i18n("Help..."), temphb ); |
208 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) ); | 208 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) ); |
209 | 209 | ||
210 | 210 | ||
211 | temphb = new QHBox( phoneWidget ); | 211 | temphb = new QHBox( phoneWidget ); |
212 | new QLabel( i18n("Connection: "), temphb ); | 212 | new QLabel( i18n("Connection: "), temphb ); |
213 | mPhoneConnection = new QLineEdit( temphb); | 213 | mPhoneConnection = new QLineEdit( temphb); |
214 | button = new QPushButton( i18n("Help..."), temphb ); | 214 | button = new QPushButton( i18n("Help..."), temphb ); |
215 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) ); | 215 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) ); |
216 | 216 | ||
217 | 217 | ||
218 | temphb = new QHBox( phoneWidget ); | 218 | temphb = new QHBox( phoneWidget ); |
219 | new QLabel( i18n("Model(opt.): "), temphb ); | 219 | new QLabel( i18n("Model(opt.): "), temphb ); |
220 | mPhoneModel = new QLineEdit( temphb); | 220 | mPhoneModel = new QLineEdit( temphb); |
221 | button = new QPushButton( i18n("Help..."), temphb ); | 221 | button = new QPushButton( i18n("Help..."), temphb ); |
222 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) ); | 222 | connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) ); |
223 | 223 | ||
224 | // *** local | 224 | // *** local |
225 | localFileWidget = new QVBox( topFrame); | 225 | localFileWidget = new QVBox( topFrame); |
226 | topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); | 226 | topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); |
227 | ++iii; | 227 | ++iii; |
228 | temphb = new QHBox( localFileWidget ); | 228 | temphb = new QHBox( localFileWidget ); |
229 | 229 | ||
230 | lab = new QLabel( i18n("Local file Cal:"), temphb ); | 230 | lab = new QLabel( i18n("Local file Cal:"), temphb ); |
231 | lab = new QLabel( i18n("Local file ABook:"), temphb ); | 231 | lab = new QLabel( i18n("Local file ABook:"), temphb ); |
232 | lab = new QLabel( i18n("Local file PWMgr:"), temphb ); | 232 | lab = new QLabel( i18n("Local file PWMgr:"), temphb ); |
233 | temphb = new QHBox( localFileWidget ); | 233 | temphb = new QHBox( localFileWidget ); |
234 | button = new QPushButton( i18n("Choose..."), temphb ); | 234 | button = new QPushButton( i18n("Choose..."), temphb ); |
235 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); | 235 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); |
236 | button = new QPushButton( i18n("Choose..."), temphb ); | 236 | button = new QPushButton( i18n("Choose..."), temphb ); |
237 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) ); | 237 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) ); |
238 | button = new QPushButton( i18n("Choose..."), temphb ); | 238 | button = new QPushButton( i18n("Choose..."), temphb ); |
239 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) ); | 239 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) ); |
240 | temphb = new QHBox( localFileWidget ); | 240 | temphb = new QHBox( localFileWidget ); |
241 | 241 | ||
242 | mRemoteFile = new QLineEdit( temphb); | 242 | mRemoteFile = new QLineEdit( temphb); |
243 | mRemoteFileAB = new QLineEdit( temphb); | 243 | mRemoteFileAB = new QLineEdit( temphb); |
244 | mRemoteFilePWM = new QLineEdit( temphb); | 244 | mRemoteFilePWM = new QLineEdit( temphb); |
245 | mIsKapiFileL = new QCheckBox( i18n("Addressbook file (*.vcf) is used by KA/Pi"), localFileWidget ); | ||
246 | |||
245 | 247 | ||
246 | // *** remote | 248 | // *** remote |
247 | remoteFileWidget = new QVBox( topFrame); | 249 | remoteFileWidget = new QVBox( topFrame); |
248 | topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); | 250 | topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); |
249 | ++iii; | 251 | ++iii; |
250 | temphb = new QHBox( remoteFileWidget ); | 252 | temphb = new QHBox( remoteFileWidget ); |
251 | new QLabel( i18n("Calendar:"), temphb); | 253 | new QLabel( i18n("Calendar:"), temphb); |
252 | new QLabel( i18n("AddressBook:"), temphb); | 254 | new QLabel( i18n("AddressBook:"), temphb); |
253 | new QLabel( i18n("PWManager:"), temphb); | 255 | new QLabel( i18n("PWManager:"), temphb); |
254 | 256 | ||
255 | lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); | 257 | lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); |
256 | temphb = new QHBox( remoteFileWidget ); | 258 | temphb = new QHBox( remoteFileWidget ); |
257 | mRemotePrecommand = new QLineEdit(temphb); | 259 | mRemotePrecommand = new QLineEdit(temphb); |
258 | mRemotePrecommandAB = new QLineEdit(temphb); | 260 | mRemotePrecommandAB = new QLineEdit(temphb); |
259 | mRemotePrecommandPWM = new QLineEdit(temphb); | 261 | mRemotePrecommandPWM = new QLineEdit(temphb); |
260 | 262 | ||
261 | lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); | 263 | lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); |
262 | temphb = new QHBox( remoteFileWidget ); | 264 | temphb = new QHBox( remoteFileWidget ); |
263 | mLocalTempFile = new QLineEdit(temphb); | 265 | mLocalTempFile = new QLineEdit(temphb); |
264 | mLocalTempFileAB = new QLineEdit(temphb); | 266 | mLocalTempFileAB = new QLineEdit(temphb); |
265 | mLocalTempFilePWM = new QLineEdit(temphb); | 267 | mLocalTempFilePWM = new QLineEdit(temphb); |
266 | 268 | ||
267 | lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); | 269 | lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); |
268 | temphb = new QHBox( remoteFileWidget ); | 270 | temphb = new QHBox( remoteFileWidget ); |
269 | mRemotePostcommand = new QLineEdit(temphb ); | 271 | mRemotePostcommand = new QLineEdit(temphb ); |
270 | mRemotePostcommandAB = new QLineEdit(temphb ); | 272 | mRemotePostcommandAB = new QLineEdit(temphb ); |
271 | mRemotePostcommandPWM = new QLineEdit(temphb ); | 273 | mRemotePostcommandPWM = new QLineEdit(temphb ); |
272 | 274 | mIsKapiFileR = new QCheckBox( i18n("Addressbook file is used by KA/Pi"), remoteFileWidget ); | |
273 | lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); | 275 | lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); |
274 | temphb = new QHBox( remoteFileWidget ); | 276 | temphb = new QHBox( remoteFileWidget ); |
275 | button = new QPushButton( i18n("ssh/scp"), temphb ); | 277 | button = new QPushButton( i18n("ssh/scp"), temphb ); |
276 | connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); | 278 | connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); |
277 | button = new QPushButton( i18n("ftp"), temphb ); | 279 | button = new QPushButton( i18n("ftp"), temphb ); |
278 | connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); | 280 | connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); |
279 | lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); | 281 | lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); |
280 | 282 | ||
281 | // *** pi-sync | 283 | // *** pi-sync |
282 | piWidget = new QVBox( topFrame); | 284 | piWidget = new QVBox( topFrame); |
283 | topLayout->addMultiCellWidget(piWidget, iii,iii,0,1); | 285 | topLayout->addMultiCellWidget(piWidget, iii,iii,0,1); |
284 | ++iii; | 286 | ++iii; |
285 | temphb = new QHBox( piWidget ); | 287 | temphb = new QHBox( piWidget ); |
286 | new QLabel( i18n("Calendar:"), temphb); | 288 | new QLabel( i18n("Calendar:"), temphb); |
287 | new QLabel( i18n("AddressBook:"), temphb); | 289 | new QLabel( i18n("AddressBook:"), temphb); |
288 | new QLabel( i18n("PWManager:"), temphb); | 290 | new QLabel( i18n("PWManager:"), temphb); |
289 | 291 | ||
290 | lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget); | 292 | lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget); |
291 | temphb = new QHBox( piWidget ); | 293 | temphb = new QHBox( piWidget ); |
292 | mRemotePw = new QLineEdit(temphb); | 294 | mRemotePw = new QLineEdit(temphb); |
293 | mRemotePwAB = new QLineEdit(temphb); | 295 | mRemotePwAB = new QLineEdit(temphb); |
294 | mRemotePwPWM = new QLineEdit(temphb); | 296 | mRemotePwPWM = new QLineEdit(temphb); |
295 | 297 | ||
296 | lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget); | 298 | lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget); |
297 | temphb = new QHBox( piWidget ); | 299 | temphb = new QHBox( piWidget ); |
298 | mRemoteIP = new QLineEdit(temphb); | 300 | mRemoteIP = new QLineEdit(temphb); |
299 | mRemoteIPAB = new QLineEdit(temphb); | 301 | mRemoteIPAB = new QLineEdit(temphb); |
300 | mRemoteIPPWM = new QLineEdit(temphb); | 302 | mRemoteIPPWM = new QLineEdit(temphb); |
301 | 303 | ||
302 | lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget); | 304 | lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget); |
303 | temphb = new QHBox( piWidget ); | 305 | temphb = new QHBox( piWidget ); |
304 | mRemotePort = new QLineEdit(temphb); | 306 | mRemotePort = new QLineEdit(temphb); |
305 | mRemotePortAB = new QLineEdit(temphb); | 307 | mRemotePortAB = new QLineEdit(temphb); |
306 | mRemotePortPWM = new QLineEdit(temphb); | 308 | mRemotePortPWM = new QLineEdit(temphb); |
307 | 309 | ||
308 | } | 310 | } |
309 | 311 | ||
310 | 312 | ||
311 | 313 | ||
312 | 314 | ||
313 | 315 | ||
314 | void KSyncPrefsDialog::slotOK() | 316 | void KSyncPrefsDialog::slotOK() |
315 | { | 317 | { |
316 | if ( mMyMachineName->text() == "undefined" ) { | 318 | if ( mMyMachineName->text() == "undefined" ) { |
317 | KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); | 319 | KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); |
318 | return; | 320 | return; |
319 | } | 321 | } |
320 | int i; | 322 | int i; |
321 | for (i = 0; i < mSyncProfileNames.count(); ++ i) { | 323 | for (i = 0; i < mSyncProfileNames.count(); ++ i) { |
322 | if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { | 324 | if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { |
323 | KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); | 325 | KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); |
324 | return; | 326 | return; |
325 | } | 327 | } |
326 | } | 328 | } |
327 | usrWriteConfig(); | 329 | usrWriteConfig(); |
328 | QDialog::accept(); | 330 | QDialog::accept(); |
329 | } | 331 | } |
330 | void KSyncPrefsDialog::accept() | 332 | void KSyncPrefsDialog::accept() |
331 | { | 333 | { |
332 | slotOK(); | 334 | slotOK(); |
333 | } | 335 | } |
334 | void KSyncPrefsDialog::chooseFile() | 336 | void KSyncPrefsDialog::chooseFile() |
335 | { | 337 | { |
336 | QString fn = QDir::homeDirPath(); | 338 | QString fn = QDir::homeDirPath(); |
337 | 339 | ||
338 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 340 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
339 | if ( fn == "" ) | 341 | if ( fn == "" ) |
340 | return; | 342 | return; |
341 | mRemoteFile->setText( fn ); | 343 | mRemoteFile->setText( fn ); |
342 | } | 344 | } |
343 | 345 | ||
344 | void KSyncPrefsDialog::chooseFileAB() | 346 | void KSyncPrefsDialog::chooseFileAB() |
345 | { | 347 | { |
346 | QString fn = QDir::homeDirPath(); | 348 | QString fn = QDir::homeDirPath(); |
347 | 349 | ||
348 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this ); | 350 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this ); |
349 | if ( fn == "" ) | 351 | if ( fn == "" ) |
350 | return; | 352 | return; |
351 | mRemoteFileAB->setText( fn ); | 353 | mRemoteFileAB->setText( fn ); |
352 | } | 354 | } |
353 | 355 | ||
354 | void KSyncPrefsDialog::chooseFilePWM() | 356 | void KSyncPrefsDialog::chooseFilePWM() |
355 | { | 357 | { |
356 | QString fn = QDir::homeDirPath(); | 358 | QString fn = QDir::homeDirPath(); |
357 | 359 | ||
358 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this ); | 360 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this ); |
359 | if ( fn == "" ) | 361 | if ( fn == "" ) |
360 | return; | 362 | return; |
361 | mRemoteFilePWM->setText( fn ); | 363 | mRemoteFilePWM->setText( fn ); |
362 | } | 364 | } |
363 | 365 | ||
364 | void KSyncPrefsDialog::textChanged( const QString & s ) | 366 | void KSyncPrefsDialog::textChanged( const QString & s ) |
365 | { | 367 | { |
366 | if ( mProfileBox->count() == 0 ) | 368 | if ( mProfileBox->count() == 0 ) |
367 | return; | 369 | return; |
368 | if ( currentSelection < 3 ) { | 370 | if ( currentSelection < 3 ) { |
369 | //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); | 371 | //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); |
370 | mProfileBox->blockSignals( true ); | 372 | mProfileBox->blockSignals( true ); |
371 | mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); | 373 | mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); |
372 | mProfileBox->blockSignals( false ); | 374 | mProfileBox->blockSignals( false ); |
373 | return; | 375 | return; |
374 | } | 376 | } |
375 | //qDebug("cur i %d ",mProfileBox-> currentItem () ); | 377 | //qDebug("cur i %d ",mProfileBox-> currentItem () ); |
376 | mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; | 378 | mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; |
377 | KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; | 379 | KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; |
378 | prof->setName( s ); | 380 | prof->setName( s ); |
379 | mSyncProfileNames[mProfileBox-> currentItem ()] = s; | 381 | mSyncProfileNames[mProfileBox-> currentItem ()] = s; |
380 | } | 382 | } |
381 | void KSyncPrefsDialog::profileChanged( int item ) | 383 | void KSyncPrefsDialog::profileChanged( int item ) |
382 | { | 384 | { |
383 | //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() ); | 385 | //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() ); |
384 | KSyncProfile* prof; | 386 | KSyncProfile* prof; |
385 | saveProfile(); | 387 | saveProfile(); |
386 | currentSelection = item; | 388 | currentSelection = item; |
387 | prof = mSyncProfiles.at(item) ; | 389 | prof = mSyncProfiles.at(item) ; |
388 | 390 | ||
389 | mRemotePw->setText(prof->getRemotePw()); | 391 | mRemotePw->setText(prof->getRemotePw()); |
390 | mRemoteIP->setText(prof->getRemoteIP()); | 392 | mRemoteIP->setText(prof->getRemoteIP()); |
391 | mRemotePort->setText(prof->getRemotePort()); | 393 | mRemotePort->setText(prof->getRemotePort()); |
392 | 394 | ||
393 | mRemotePwAB->setText(prof->getRemotePwAB()); | 395 | mRemotePwAB->setText(prof->getRemotePwAB()); |
394 | mRemoteIPAB->setText(prof->getRemoteIPAB()); | 396 | mRemoteIPAB->setText(prof->getRemoteIPAB()); |
395 | mRemotePortAB->setText(prof->getRemotePortAB()); | 397 | mRemotePortAB->setText(prof->getRemotePortAB()); |
396 | 398 | ||
397 | mRemotePwPWM->setText(prof->getRemotePwPWM()); | 399 | mRemotePwPWM->setText(prof->getRemotePwPWM()); |
398 | mRemoteIPPWM->setText(prof->getRemoteIPPWM()); | 400 | mRemoteIPPWM->setText(prof->getRemoteIPPWM()); |
399 | mRemotePortPWM->setText(prof->getRemotePortPWM()); | 401 | mRemotePortPWM->setText(prof->getRemotePortPWM()); |
400 | 402 | ||
401 | mRemotePrecommand->setText(prof->getPreSyncCommand()); | 403 | mRemotePrecommand->setText(prof->getPreSyncCommand()); |
402 | mRemotePostcommand->setText(prof->getPostSyncCommand()); | 404 | mRemotePostcommand->setText(prof->getPostSyncCommand()); |
403 | mLocalTempFile->setText(prof->getLocalTempFile()); | 405 | mLocalTempFile->setText(prof->getLocalTempFile()); |
404 | mRemoteFile->setText(prof->getRemoteFileName()) ; | 406 | mRemoteFile->setText(prof->getRemoteFileName()) ; |
405 | 407 | ||
406 | mRemotePrecommandAB->setText(prof->getPreSyncCommandAB()); | 408 | mRemotePrecommandAB->setText(prof->getPreSyncCommandAB()); |
407 | mRemotePostcommandAB->setText(prof->getPostSyncCommandAB()); | 409 | mRemotePostcommandAB->setText(prof->getPostSyncCommandAB()); |
408 | mLocalTempFileAB->setText(prof->getLocalTempFileAB()); | 410 | mLocalTempFileAB->setText(prof->getLocalTempFileAB()); |
409 | mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ; | 411 | mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ; |
410 | 412 | ||
411 | mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM()); | 413 | mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM()); |
412 | mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM()); | 414 | mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM()); |
413 | mLocalTempFilePWM->setText(prof->getLocalTempFilePWM()); | 415 | mLocalTempFilePWM->setText(prof->getLocalTempFilePWM()); |
414 | mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ; | 416 | mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ; |
415 | 417 | ||
416 | if ( mWriteContactToSIM ) | 418 | if ( mWriteContactToSIM ) |
417 | mWriteContactToSIM->setChecked( prof->getWriteContactToSIM()); | 419 | mWriteContactToSIM->setChecked( prof->getWriteContactToSIM()); |
418 | mPhoneDevice->setText(prof->getPhoneDevice()); | 420 | mPhoneDevice->setText(prof->getPhoneDevice()); |
419 | mPhoneConnection->setText(prof->getPhoneConnection()); | 421 | mPhoneConnection->setText(prof->getPhoneConnection()); |
420 | mPhoneModel->setText(prof->getPhoneModel()); | 422 | mPhoneModel->setText(prof->getPhoneModel()); |
421 | 423 | ||
422 | mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); | 424 | mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); |
423 | mAskForPreferences->setChecked( prof->getAskForPreferences()); | 425 | mAskForPreferences->setChecked( prof->getAskForPreferences()); |
424 | mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); | 426 | mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); |
425 | mWriteBackFile->setChecked( prof->getWriteBackFile()); | 427 | mWriteBackFile->setChecked( prof->getWriteBackFile()); |
426 | mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); | 428 | mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); |
427 | mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() ); | 429 | mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() ); |
428 | mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() ); | 430 | mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() ); |
429 | mWriteBackFuture->setChecked( prof->getWriteBackFuture()); | 431 | mWriteBackFuture->setChecked( prof->getWriteBackFuture()); |
430 | mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() ); | 432 | mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() ); |
431 | 433 | ||
432 | switch ( prof->getSyncPrefs() ) { | 434 | switch ( prof->getSyncPrefs() ) { |
433 | case 0: | 435 | case 0: |
434 | loc->setChecked( true); | 436 | loc->setChecked( true); |
435 | break; | 437 | break; |
436 | case 1: | 438 | case 1: |
437 | rem->setChecked( true ); | 439 | rem->setChecked( true ); |
438 | break; | 440 | break; |
439 | case 2: | 441 | case 2: |
440 | newest->setChecked( true); | 442 | newest->setChecked( true); |
441 | break; | 443 | break; |
442 | case 3: | 444 | case 3: |
443 | ask->setChecked( true); | 445 | ask->setChecked( true); |
444 | break; | 446 | break; |
445 | case 4: | 447 | case 4: |
446 | f_loc->setChecked( true); | 448 | f_loc->setChecked( true); |
447 | break; | 449 | break; |
448 | case 5: | 450 | case 5: |
449 | f_rem->setChecked( true); | 451 | f_rem->setChecked( true); |
450 | break; | 452 | break; |
451 | case 6: | 453 | case 6: |
452 | //both->setChecked( true); | 454 | //both->setChecked( true); |
453 | break; | 455 | break; |
454 | default: | 456 | default: |
455 | break; | 457 | break; |
456 | } | 458 | } |
457 | mIsLocal->setChecked(prof->getIsLocalFileSync()) ; | 459 | mIsLocal->setChecked(prof->getIsLocalFileSync()) ; |
458 | mIsPhone->setChecked(prof->getIsPhoneSync()) ; | 460 | mIsPhone->setChecked(prof->getIsPhoneSync()) ; |
459 | mIsPi->setChecked(prof->getIsPiSync()) ; | 461 | mIsPi->setChecked(prof->getIsPiSync()) ; |
462 | mIsKapiFileL->setChecked(prof->getIsKapiFile()) ; | ||
463 | mIsKapiFileR->setChecked(prof->getIsKapiFile()) ; | ||
464 | |||
460 | mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() ); | 465 | mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() ); |
461 | proGr->setEnabled( item > 2 ); | 466 | proGr->setEnabled( item > 2 ); |
462 | if ( item < 3 ) { | 467 | if ( item < 3 ) { |
463 | localFileWidget->hide(); | 468 | localFileWidget->hide(); |
464 | remoteFileWidget->hide(); | 469 | remoteFileWidget->hide(); |
465 | phoneWidget->hide(); | 470 | phoneWidget->hide(); |
466 | piWidget->hide(); | 471 | piWidget->hide(); |
467 | 472 | ||
468 | } else | 473 | } else |
469 | kindChanged( prof->getIsLocalFileSync() ); | 474 | kindChanged( prof->getIsLocalFileSync() ); |
470 | } | 475 | } |
471 | 476 | ||
472 | void KSyncPrefsDialog::fillSSH() | 477 | void KSyncPrefsDialog::fillSSH() |
473 | { | 478 | { |
474 | mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); | 479 | mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); |
475 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); | 480 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); |
476 | mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); | 481 | mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); |
477 | mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); | 482 | mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); |
478 | mLocalTempFileAB->setText("/tmp/std.vcf" ); | 483 | mLocalTempFileAB->setText("/tmp/std.vcf" ); |
479 | mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" ); | 484 | mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" ); |
480 | mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); | 485 | mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); |
481 | mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); | 486 | mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); |
482 | mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" ); | 487 | mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" ); |
483 | } | 488 | } |
484 | void KSyncPrefsDialog::fillFTP() | 489 | void KSyncPrefsDialog::fillFTP() |
485 | { | 490 | { |
486 | mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); | 491 | mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); |
487 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); | 492 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); |
488 | mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); | 493 | mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); |
489 | mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" ); | 494 | mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" ); |
490 | mLocalTempFileAB->setText("/tmp/std.vcf" ); | 495 | mLocalTempFileAB->setText("/tmp/std.vcf" ); |
491 | mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); | 496 | mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); |
492 | 497 | ||
493 | mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" ); | 498 | mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" ); |
494 | mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); | 499 | mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); |
495 | mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); | 500 | mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); |
496 | 501 | ||
497 | } | 502 | } |
498 | void KSyncPrefsDialog::kindChanged( bool b ) | 503 | void KSyncPrefsDialog::kindChanged( bool b ) |
499 | { | 504 | { |
505 | |||
506 | if ( mIsLocal->isChecked () ) { | ||
507 | mIsKapiFileL->setChecked( mIsKapiFileR->isChecked() ); | ||
508 | } else { | ||
509 | mIsKapiFileR->setChecked( mIsKapiFileL->isChecked() ); | ||
510 | } | ||
500 | 511 | ||
501 | if ( mIsLocal->isChecked () ) | 512 | if ( mIsLocal->isChecked () ) |
502 | localFileWidget->show(); | 513 | localFileWidget->show(); |
503 | else | 514 | else |
504 | localFileWidget->hide(); | 515 | localFileWidget->hide(); |
505 | 516 | ||
506 | if ( mIsNotLocal->isChecked () ) | 517 | if ( mIsNotLocal->isChecked () ) |
507 | remoteFileWidget->show(); | 518 | remoteFileWidget->show(); |
508 | else | 519 | else |
509 | remoteFileWidget->hide(); | 520 | remoteFileWidget->hide(); |
510 | 521 | ||
511 | if ( mIsPhone->isChecked () ) { | 522 | if ( mIsPhone->isChecked () ) { |
512 | phoneWidget->show(); | 523 | phoneWidget->show(); |
513 | } | 524 | } |
514 | else { | 525 | else { |
515 | phoneWidget->hide(); | 526 | phoneWidget->hide(); |
516 | } | 527 | } |
517 | if ( mIsPi->isChecked () ) { | 528 | if ( mIsPi->isChecked () ) { |
518 | piWidget->show(); | 529 | piWidget->show(); |
519 | } | 530 | } |
520 | else { | 531 | else { |
521 | piWidget->hide(); | 532 | piWidget->hide(); |
522 | } | 533 | } |
523 | 534 | ||
524 | } | 535 | } |
525 | void KSyncPrefsDialog::deleteProfile() | 536 | void KSyncPrefsDialog::deleteProfile() |
526 | { | 537 | { |
527 | //qDebug("KSyncPrefsDialog::deleteProfile() "); | 538 | //qDebug("KSyncPrefsDialog::deleteProfile() "); |
528 | if ( currentSelection >= 0 ) { | 539 | if ( currentSelection >= 0 ) { |
529 | if ( currentSelection < 3 ) { | 540 | if ( currentSelection < 3 ) { |
530 | KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); | 541 | KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); |
531 | return; | 542 | return; |
532 | } | 543 | } |
533 | KSyncProfile* temp = mSyncProfiles.at(currentSelection); | 544 | KSyncProfile* temp = mSyncProfiles.at(currentSelection); |
534 | mSyncProfiles.remove( temp ); | 545 | mSyncProfiles.remove( temp ); |
535 | mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); | 546 | mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); |
536 | insertProfiles(); | 547 | insertProfiles(); |
537 | } | 548 | } |
538 | } | 549 | } |
539 | 550 | ||
540 | void KSyncPrefsDialog::saveProfile() | 551 | void KSyncPrefsDialog::saveProfile() |
541 | { | 552 | { |
542 | KSyncProfile* prof; | 553 | KSyncProfile* prof; |
543 | if ( currentSelection >= 0 ) { | 554 | if ( currentSelection >= 0 ) { |
544 | prof = mSyncProfiles.at(currentSelection) ; | 555 | prof = mSyncProfiles.at(currentSelection) ; |
545 | 556 | ||
546 | prof->setRemotePw( mRemotePw->text()); | 557 | prof->setRemotePw( mRemotePw->text()); |
547 | prof->setRemoteIP( mRemoteIP->text()); | 558 | prof->setRemoteIP( mRemoteIP->text()); |
548 | prof->setRemotePort( mRemotePort->text()); | 559 | prof->setRemotePort( mRemotePort->text()); |
549 | 560 | ||
550 | prof->setRemotePwAB( mRemotePwAB->text()); | 561 | prof->setRemotePwAB( mRemotePwAB->text()); |
551 | prof->setRemoteIPAB( mRemoteIPAB->text()); | 562 | prof->setRemoteIPAB( mRemoteIPAB->text()); |
552 | prof->setRemotePortAB( mRemotePortAB->text()); | 563 | prof->setRemotePortAB( mRemotePortAB->text()); |
553 | 564 | ||
554 | prof->setRemotePwPWM( mRemotePwPWM->text()); | 565 | prof->setRemotePwPWM( mRemotePwPWM->text()); |
555 | prof->setRemoteIPPWM( mRemoteIPPWM->text()); | 566 | prof->setRemoteIPPWM( mRemoteIPPWM->text()); |
556 | prof->setRemotePortPWM( mRemotePortPWM->text()); | 567 | prof->setRemotePortPWM( mRemotePortPWM->text()); |
557 | 568 | ||
558 | prof->setPreSyncCommand( mRemotePrecommand->text()); | 569 | prof->setPreSyncCommand( mRemotePrecommand->text()); |
559 | prof->setPostSyncCommand( mRemotePostcommand->text() ); | 570 | prof->setPostSyncCommand( mRemotePostcommand->text() ); |
560 | prof->setLocalTempFile( mLocalTempFile->text()); | 571 | prof->setLocalTempFile( mLocalTempFile->text()); |
561 | prof->setRemoteFileName( mRemoteFile->text() ); | 572 | prof->setRemoteFileName( mRemoteFile->text() ); |
562 | prof->setPreSyncCommandAB( mRemotePrecommandAB->text()); | 573 | prof->setPreSyncCommandAB( mRemotePrecommandAB->text()); |
563 | prof->setPostSyncCommandAB( mRemotePostcommandAB->text() ); | 574 | prof->setPostSyncCommandAB( mRemotePostcommandAB->text() ); |
564 | prof->setLocalTempFileAB( mLocalTempFileAB->text()); | 575 | prof->setLocalTempFileAB( mLocalTempFileAB->text()); |
565 | prof->setRemoteFileNameAB( mRemoteFileAB->text() ); | 576 | prof->setRemoteFileNameAB( mRemoteFileAB->text() ); |
566 | prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text()); | 577 | prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text()); |
567 | prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() ); | 578 | prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() ); |
568 | prof->setLocalTempFilePWM( mLocalTempFilePWM->text()); | 579 | prof->setLocalTempFilePWM( mLocalTempFilePWM->text()); |
569 | prof->setRemoteFileNamePWM( mRemoteFilePWM->text() ); | 580 | prof->setRemoteFileNamePWM( mRemoteFilePWM->text() ); |
570 | prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); | 581 | prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); |
571 | prof->setAskForPreferences( mAskForPreferences->isChecked()); | 582 | prof->setAskForPreferences( mAskForPreferences->isChecked()); |
572 | prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); | 583 | prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); |
573 | prof->setWriteBackFile( mWriteBackFile->isChecked()); | 584 | prof->setWriteBackFile( mWriteBackFile->isChecked()); |
574 | prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); | 585 | prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); |
575 | prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() ); | 586 | prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() ); |
576 | prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() ); | 587 | prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() ); |
577 | int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; | 588 | int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; |
578 | prof->setSyncPrefs( syncprefs); | 589 | prof->setSyncPrefs( syncprefs); |
579 | prof->setIsLocalFileSync( mIsLocal->isChecked() ); | 590 | prof->setIsLocalFileSync( mIsLocal->isChecked() ); |
580 | prof->setIsPhoneSync( mIsPhone->isChecked() ); | 591 | prof->setIsPhoneSync( mIsPhone->isChecked() ); |
581 | prof->setIsPiSync( mIsPi->isChecked() ); | 592 | prof->setIsPiSync( mIsPi->isChecked() ); |
593 | prof->setIsKapiFile( mIsKapiFileL->isChecked() ); | ||
582 | prof->setWriteBackFuture(mWriteBackFuture->isChecked()); | 594 | prof->setWriteBackFuture(mWriteBackFuture->isChecked()); |
583 | prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value()); | 595 | prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value()); |
584 | if ( mWriteContactToSIM ) | 596 | if ( mWriteContactToSIM ) |
585 | prof->setWriteContactToSIM(mWriteContactToSIM->isChecked()); | 597 | prof->setWriteContactToSIM(mWriteContactToSIM->isChecked()); |
586 | prof->setPhoneDevice( mPhoneDevice->text() ); | 598 | prof->setPhoneDevice( mPhoneDevice->text() ); |
587 | prof->setPhoneConnection( mPhoneConnection->text() ); | 599 | prof->setPhoneConnection( mPhoneConnection->text() ); |
588 | prof->setPhoneModel( mPhoneModel->text() ); | 600 | prof->setPhoneModel( mPhoneModel->text() ); |
589 | 601 | ||
590 | } | 602 | } |
591 | 603 | ||
592 | } | 604 | } |
593 | 605 | ||
594 | void KSyncPrefsDialog::insertProfiles() | 606 | void KSyncPrefsDialog::insertProfiles() |
595 | { | 607 | { |
596 | int curItem = mProfileBox->currentItem(); | 608 | int curItem = mProfileBox->currentItem(); |
597 | mProfileBox->blockSignals( true ); | 609 | mProfileBox->blockSignals( true ); |
598 | mProfileBox->clear(); | 610 | mProfileBox->clear(); |
599 | mProfileBox->insertStringList (mSyncProfileNames ); | 611 | mProfileBox->insertStringList (mSyncProfileNames ); |
600 | int item = mSyncProfileNames.count() -1; | 612 | int item = mSyncProfileNames.count() -1; |
601 | if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) | 613 | if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) |
602 | mProfileBox->setCurrentItem( curItem ); | 614 | mProfileBox->setCurrentItem( curItem ); |
603 | else if ( item >= 0 ) { | 615 | else if ( item >= 0 ) { |
604 | mProfileBox->setCurrentItem( item ); | 616 | mProfileBox->setCurrentItem( item ); |
605 | } | 617 | } |
606 | currentSelection = -1; | 618 | currentSelection = -1; |
607 | if ( mSyncProfileNames.count() > 0 ) { | 619 | if ( mSyncProfileNames.count() > 0 ) { |
608 | //qDebug(" profileChanged( mProfileBox->currentItem() "); | 620 | //qDebug(" profileChanged( mProfileBox->currentItem() "); |
609 | profileChanged( mProfileBox->currentItem() ); | 621 | profileChanged( mProfileBox->currentItem() ); |
610 | currentSelection = mProfileBox->currentItem(); | 622 | currentSelection = mProfileBox->currentItem(); |
611 | } | 623 | } |
612 | mProfileBox->blockSignals( false ); | 624 | mProfileBox->blockSignals( false ); |
613 | } | 625 | } |
614 | 626 | ||
615 | void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) | 627 | void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) |
616 | { | 628 | { |
617 | saveProfile(); | 629 | saveProfile(); |
618 | mSyncProfiles.append( temp ); | 630 | mSyncProfiles.append( temp ); |
619 | mSyncProfileNames << temp->getName(); | 631 | mSyncProfileNames << temp->getName(); |
620 | insertProfiles(); | 632 | insertProfiles(); |
621 | int last = mProfileBox->count() -1; | 633 | int last = mProfileBox->count() -1; |
622 | mProfileBox->blockSignals( true ); | 634 | mProfileBox->blockSignals( true ); |
623 | mProfileBox->setCurrentItem( last ); | 635 | mProfileBox->setCurrentItem( last ); |
624 | mProfileBox->blockSignals( false ); | 636 | mProfileBox->blockSignals( false ); |
625 | profileChanged(last); | 637 | profileChanged(last); |
626 | } | 638 | } |
627 | void KSyncPrefsDialog::newProfile() | 639 | void KSyncPrefsDialog::newProfile() |
628 | { | 640 | { |
629 | addProfile ( new KSyncProfile () ); | 641 | addProfile ( new KSyncProfile () ); |
630 | } | 642 | } |
631 | 643 | ||
632 | void KSyncPrefsDialog::cloneProfile() | 644 | void KSyncPrefsDialog::cloneProfile() |
633 | { | 645 | { |
634 | if ( currentSelection >= 0 ) | 646 | if ( currentSelection >= 0 ) |
635 | addProfile (mSyncProfiles.at(currentSelection)->clone()) ; | 647 | addProfile (mSyncProfiles.at(currentSelection)->clone()) ; |
636 | else | 648 | else |
637 | newProfile(); | 649 | newProfile(); |
638 | } | 650 | } |
639 | 651 | ||
640 | void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) | 652 | void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) |
641 | { | 653 | { |
642 | mMyMachineName->setText( name ); | 654 | mMyMachineName->setText( name ); |
643 | 655 | ||
644 | } | 656 | } |
645 | QString KSyncPrefsDialog::getLocalMachineName ( ) | 657 | QString KSyncPrefsDialog::getLocalMachineName ( ) |
646 | { | 658 | { |
647 | return mMyMachineName->text(); | 659 | return mMyMachineName->text(); |
648 | } | 660 | } |
649 | 661 | ||
650 | QStringList KSyncPrefsDialog::getSyncProfileNames() | 662 | QStringList KSyncPrefsDialog::getSyncProfileNames() |
651 | { | 663 | { |
652 | return mSyncProfileNames; | 664 | return mSyncProfileNames; |
653 | } | 665 | } |
654 | void KSyncPrefsDialog::usrReadConfig() | 666 | void KSyncPrefsDialog::usrReadConfig() |
655 | { | 667 | { |
656 | //KConfig *config = KOGlobals::config(); | 668 | //KConfig *config = KOGlobals::config(); |
657 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 669 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
658 | config.setGroup("General"); | 670 | config.setGroup("General"); |
659 | mSyncProfileNames =config.readListEntry("SyncProfileNames"); | 671 | mSyncProfileNames =config.readListEntry("SyncProfileNames"); |
660 | mMyMachineName->setText(config.readEntry("LocalMachineName","undefined")); | 672 | mMyMachineName->setText(config.readEntry("LocalMachineName","undefined")); |
661 | int i; | 673 | int i; |
662 | KSyncProfile* temp ; | 674 | KSyncProfile* temp ; |
663 | mSyncProfiles.clear(); | 675 | mSyncProfiles.clear(); |
664 | for ( i = 0; i < mSyncProfileNames.count();++i ) { | 676 | for ( i = 0; i < mSyncProfileNames.count();++i ) { |
665 | temp = new KSyncProfile (); | 677 | temp = new KSyncProfile (); |
666 | temp->setName( mSyncProfileNames[i] ); | 678 | temp->setName( mSyncProfileNames[i] ); |
667 | temp->readConfig( &config ); | 679 | temp->readConfig( &config ); |
668 | mSyncProfiles.append( temp ); | 680 | mSyncProfiles.append( temp ); |
669 | } | 681 | } |
670 | insertProfiles(); | 682 | insertProfiles(); |
671 | //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); | 683 | //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); |
672 | } | 684 | } |
673 | 685 | ||
674 | 686 | ||
675 | void KSyncPrefsDialog::usrWriteConfig() | 687 | void KSyncPrefsDialog::usrWriteConfig() |
676 | { | 688 | { |
677 | saveProfile(); | 689 | saveProfile(); |
678 | if ( currentSelection >= 0 ) | 690 | if ( currentSelection >= 0 ) |
679 | profileChanged(currentSelection); | 691 | profileChanged(currentSelection); |
680 | //KConfig *config = KOGlobals::config(); | 692 | //KConfig *config = KOGlobals::config(); |
681 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 693 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
682 | KSyncProfile* prof = mSyncProfiles.first(); | 694 | KSyncProfile* prof = mSyncProfiles.first(); |
683 | QStringList externalSyncProfileNames; | 695 | QStringList externalSyncProfileNames; |
684 | externalSyncProfileNames.append("Sharp_DTM");; | 696 | externalSyncProfileNames.append("Sharp_DTM");; |
685 | while ( prof ) { | 697 | while ( prof ) { |
686 | prof->writeConfig(&config); | 698 | prof->writeConfig(&config); |
687 | if ( prof->getIsPhoneSync( ) ) | 699 | if ( prof->getIsPhoneSync( ) ) |
688 | externalSyncProfileNames.append(prof->getName( ) ); | 700 | externalSyncProfileNames.append(prof->getName( ) ); |
689 | prof = mSyncProfiles.next(); | 701 | prof = mSyncProfiles.next(); |
690 | } | 702 | } |
691 | //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; | 703 | //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; |
692 | //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); | 704 | //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); |
693 | config.setGroup("General"); | 705 | config.setGroup("General"); |
694 | config.writeEntry("SyncProfileNames",mSyncProfileNames); | 706 | config.writeEntry("SyncProfileNames",mSyncProfileNames); |
695 | config.writeEntry("ExternSyncProfiles",externalSyncProfileNames); | 707 | config.writeEntry("ExternSyncProfiles",externalSyncProfileNames); |
696 | config.writeEntry("LocalMachineName",mMyMachineName->text()); | 708 | config.writeEntry("LocalMachineName",mMyMachineName->text()); |
697 | config.sync(); | 709 | config.sync(); |
698 | } | 710 | } |
699 | 711 | ||
700 | void KSyncPrefsDialog::helpDevice() | 712 | void KSyncPrefsDialog::helpDevice() |
701 | { | 713 | { |
702 | QString hint = i18n("Insert device where\nphone is connected. E.g.:\n"); | 714 | QString hint = i18n("Insert device where\nphone is connected. E.g.:\n"); |
703 | #ifdef _WIN32_ | 715 | #ifdef _WIN32_ |
704 | hint += "Leave empty for Irda.\n" | 716 | hint += "Leave empty for Irda.\n" |
705 | "com1:\n(first serial port)\n" | 717 | "com1:\n(first serial port)\n" |
706 | "usb not supported\n" | 718 | "usb not supported\n" |
707 | "???\n(bluetooth device address)\n"; | 719 | "???\n(bluetooth device address)\n"; |
708 | 720 | ||
709 | #else | 721 | #else |
710 | hint += "/dev/ircomm\n(Irda)\n" | 722 | hint += "/dev/ircomm\n(Irda)\n" |
711 | "/dev/ttyS0\n(first serial port)\n" | 723 | "/dev/ttyS0\n(first serial port)\n" |
712 | "/dev/ttyUSB0\n(first device usb port)\n" | 724 | "/dev/ttyUSB0\n(first device usb port)\n" |
713 | "???\n(bluetooth device address)\n"; | 725 | "???\n(bluetooth device address)\n"; |
714 | #endif | 726 | #endif |
715 | KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); | 727 | KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); |
716 | } | 728 | } |
717 | void KSyncPrefsDialog::helpModel() | 729 | void KSyncPrefsDialog::helpModel() |
718 | { | 730 | { |
719 | QString hint = i18n("Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n"); | 731 | QString hint = i18n("Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n"); |
720 | hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection"; | 732 | hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection"; |
721 | KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); | 733 | KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); |
722 | 734 | ||
723 | } | 735 | } |
724 | void KSyncPrefsDialog::helpConnection() | 736 | void KSyncPrefsDialog::helpConnection() |
725 | { | 737 | { |
726 | QString hint = i18n("Insert kind of connection,e.g.:\n"); | 738 | QString hint = i18n("Insert kind of connection,e.g.:\n"); |
727 | hint += "irda | Nokia FBUS over infrared\n" | 739 | hint += "irda | Nokia FBUS over infrared\n" |
728 | "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n" | 740 | "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n" |
729 | "irdaobex | set also model as obex\n" | 741 | "irdaobex | set also model as obex\n" |
730 | "fbus | Nokia FBUS2 serial\n"; | 742 | "fbus | Nokia FBUS2 serial\n"; |
731 | KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); | 743 | KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); |
732 | } | 744 | } |
diff --git a/libkdepim/ksyncprefsdialog.h b/libkdepim/ksyncprefsdialog.h index d3f8f4c..c601a58 100644 --- a/libkdepim/ksyncprefsdialog.h +++ b/libkdepim/ksyncprefsdialog.h | |||
@@ -1,151 +1,153 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program 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 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef _KSYNCPREFSDIALOG_H | 23 | #ifndef _KSYNCPREFSDIALOG_H |
24 | #define _KSYNCPREFSDIALOG_H | 24 | #define _KSYNCPREFSDIALOG_H |
25 | 25 | ||
26 | 26 | ||
27 | #include <kdialogbase.h> | 27 | #include <kdialogbase.h> |
28 | #include <qptrlist.h> | 28 | #include <qptrlist.h> |
29 | 29 | ||
30 | //#include <libkdepim/kprefsdialog.h> | 30 | //#include <libkdepim/kprefsdialog.h> |
31 | 31 | ||
32 | class KColorButton; | 32 | class KColorButton; |
33 | class QSpinBox;; | 33 | class QSpinBox;; |
34 | class QRadioButton; | 34 | class QRadioButton; |
35 | class QCheckBox; | 35 | class QCheckBox; |
36 | class QSlider; | 36 | class QSlider; |
37 | class KURLRequester; | 37 | class KURLRequester; |
38 | class QComboBox; | 38 | class QComboBox; |
39 | class QButtonGroup; | 39 | class QButtonGroup; |
40 | class QLineEdit; | 40 | class QLineEdit; |
41 | class QVBox; | 41 | class QVBox; |
42 | class QStringList; | 42 | class QStringList; |
43 | class KSyncProfile; | 43 | class KSyncProfile; |
44 | 44 | ||
45 | /** Dialog to change the korganizer configuration. | 45 | /** Dialog to change the korganizer configuration. |
46 | */ | 46 | */ |
47 | class KSyncPrefsDialog : public KDialog | 47 | class KSyncPrefsDialog : public KDialog |
48 | { | 48 | { |
49 | Q_OBJECT | 49 | Q_OBJECT |
50 | public: | 50 | public: |
51 | /** Initialize dialog and pages */ | 51 | /** Initialize dialog and pages */ |
52 | KSyncPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false); | 52 | KSyncPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false); |
53 | ~KSyncPrefsDialog(); | 53 | ~KSyncPrefsDialog(); |
54 | void usrReadConfig(); | 54 | void usrReadConfig(); |
55 | void setLocalMachineName ( const QString& name ); | 55 | void setLocalMachineName ( const QString& name ); |
56 | QString getLocalMachineName ( ); | 56 | QString getLocalMachineName ( ); |
57 | 57 | ||
58 | QStringList getSyncProfileNames(); | 58 | QStringList getSyncProfileNames(); |
59 | 59 | ||
60 | public slots: | 60 | public slots: |
61 | protected slots: | 61 | protected slots: |
62 | void accept(); | 62 | void accept(); |
63 | void deleteProfile(); | 63 | void deleteProfile(); |
64 | void newProfile(); | 64 | void newProfile(); |
65 | void cloneProfile(); | 65 | void cloneProfile(); |
66 | void kindChanged(bool); | 66 | void kindChanged(bool); |
67 | void fillSSH(); | 67 | void fillSSH(); |
68 | void fillFTP(); | 68 | void fillFTP(); |
69 | void textChanged( const QString & ); | 69 | void textChanged( const QString & ); |
70 | void profileChanged( int ); | 70 | void profileChanged( int ); |
71 | void chooseFile(); | 71 | void chooseFile(); |
72 | void chooseFileAB(); | 72 | void chooseFileAB(); |
73 | void chooseFilePWM(); | 73 | void chooseFilePWM(); |
74 | void slotOK(); | 74 | void slotOK(); |
75 | void helpDevice(); | 75 | void helpDevice(); |
76 | void helpModel(); | 76 | void helpModel(); |
77 | void helpConnection(); | 77 | void helpConnection(); |
78 | 78 | ||
79 | protected: | 79 | protected: |
80 | void usrWriteConfig(); | 80 | void usrWriteConfig(); |
81 | 81 | ||
82 | void setupSyncAlgTab(); | 82 | void setupSyncAlgTab(); |
83 | 83 | ||
84 | private: | 84 | private: |
85 | int currentSelection; | 85 | int currentSelection; |
86 | QPtrList<KSyncProfile> mSyncProfiles; | 86 | QPtrList<KSyncProfile> mSyncProfiles; |
87 | QStringList mSyncProfileNames; | 87 | QStringList mSyncProfileNames; |
88 | QLineEdit * mMyMachineName; | 88 | QLineEdit * mMyMachineName; |
89 | QComboBox * mProfileBox; | 89 | QComboBox * mProfileBox; |
90 | QRadioButton* mIsLocal; | 90 | QRadioButton* mIsLocal; |
91 | QRadioButton* mIsNotLocal; | 91 | QRadioButton* mIsNotLocal; |
92 | QRadioButton* mIsPhone; | 92 | QRadioButton* mIsPhone; |
93 | QRadioButton* mIsPi; | 93 | QRadioButton* mIsPi; |
94 | QCheckBox* mIncludeInRing; | 94 | QCheckBox* mIncludeInRing; |
95 | QCheckBox* mIncludeInRingAB; | 95 | QCheckBox* mIncludeInRingAB; |
96 | QCheckBox* mIncludeInRingPWM; | 96 | QCheckBox* mIncludeInRingPWM; |
97 | void addProfile ( KSyncProfile* ); | 97 | void addProfile ( KSyncProfile* ); |
98 | void insertProfiles(); | 98 | void insertProfiles(); |
99 | void saveProfile(); | 99 | void saveProfile(); |
100 | QButtonGroup* proGr; | 100 | QButtonGroup* proGr; |
101 | 101 | ||
102 | QRadioButton* loc, *rem, *newest, *ask, *f_loc,* f_rem, *both; | 102 | QRadioButton* loc, *rem, *newest, *ask, *f_loc,* f_rem, *both; |
103 | 103 | ||
104 | 104 | ||
105 | QLineEdit * mRemotePostcommand; | 105 | QLineEdit * mRemotePostcommand; |
106 | QLineEdit * mRemotePrecommand; | 106 | QLineEdit * mRemotePrecommand; |
107 | QLineEdit * mRemoteFile; | 107 | QLineEdit * mRemoteFile; |
108 | QLineEdit * mLocalTempFile; | 108 | QLineEdit * mLocalTempFile; |
109 | 109 | ||
110 | QLineEdit * mRemotePostcommandAB; | 110 | QLineEdit * mRemotePostcommandAB; |
111 | QLineEdit * mRemotePrecommandAB; | 111 | QLineEdit * mRemotePrecommandAB; |
112 | QLineEdit * mRemoteFileAB; | 112 | QLineEdit * mRemoteFileAB; |
113 | QLineEdit * mLocalTempFileAB; | 113 | QLineEdit * mLocalTempFileAB; |
114 | 114 | ||
115 | QLineEdit * mRemotePostcommandPWM; | 115 | QLineEdit * mRemotePostcommandPWM; |
116 | QLineEdit * mRemotePrecommandPWM; | 116 | QLineEdit * mRemotePrecommandPWM; |
117 | QLineEdit * mRemoteFilePWM; | 117 | QLineEdit * mRemoteFilePWM; |
118 | QLineEdit * mLocalTempFilePWM; | 118 | QLineEdit * mLocalTempFilePWM; |
119 | 119 | ||
120 | 120 | ||
121 | QLineEdit * mRemotePw; | 121 | QLineEdit * mRemotePw; |
122 | QLineEdit * mRemoteIP; | 122 | QLineEdit * mRemoteIP; |
123 | QLineEdit * mRemotePort; | 123 | QLineEdit * mRemotePort; |
124 | 124 | ||
125 | QLineEdit * mRemotePwAB; | 125 | QLineEdit * mRemotePwAB; |
126 | QLineEdit * mRemoteIPAB; | 126 | QLineEdit * mRemoteIPAB; |
127 | QLineEdit * mRemotePortAB; | 127 | QLineEdit * mRemotePortAB; |
128 | 128 | ||
129 | QLineEdit * mRemotePwPWM; | 129 | QLineEdit * mRemotePwPWM; |
130 | QLineEdit * mRemoteIPPWM; | 130 | QLineEdit * mRemoteIPPWM; |
131 | QLineEdit * mRemotePortPWM; | 131 | QLineEdit * mRemotePortPWM; |
132 | 132 | ||
133 | QLineEdit * mPhoneDevice; | 133 | QLineEdit * mPhoneDevice; |
134 | QLineEdit * mPhoneConnection; | 134 | QLineEdit * mPhoneConnection; |
135 | QLineEdit * mPhoneModel; | 135 | QLineEdit * mPhoneModel; |
136 | 136 | ||
137 | QWidget* mSetupSyncAlgTab; | 137 | QWidget* mSetupSyncAlgTab; |
138 | QVBox* localFileWidget; | 138 | QVBox* localFileWidget; |
139 | QVBox* remoteFileWidget; | 139 | QVBox* remoteFileWidget; |
140 | QVBox* phoneWidget; | 140 | QVBox* phoneWidget; |
141 | QVBox* piWidget; | 141 | QVBox* piWidget; |
142 | QCheckBox* mWriteBackFile; | 142 | QCheckBox* mWriteBackFile; |
143 | QCheckBox* mWriteBackFuture; | 143 | QCheckBox* mWriteBackFuture; |
144 | QSpinBox* mWriteBackFutureWeeks; | 144 | QSpinBox* mWriteBackFutureWeeks; |
145 | QCheckBox* mWriteBackExisting; | 145 | QCheckBox* mWriteBackExisting; |
146 | QCheckBox* mAskForPreferences; | 146 | QCheckBox* mAskForPreferences; |
147 | QCheckBox* mShowSummaryAfterSync; | 147 | QCheckBox* mShowSummaryAfterSync; |
148 | QCheckBox* mWriteContactToSIM; | 148 | QCheckBox* mWriteContactToSIM; |
149 | QCheckBox* mIsKapiFileL; | ||
150 | QCheckBox* mIsKapiFileR; | ||
149 | }; | 151 | }; |
150 | 152 | ||
151 | #endif | 153 | #endif |
diff --git a/libkdepim/ksyncprofile.cpp b/libkdepim/ksyncprofile.cpp index 76dfe00..029b70b 100644 --- a/libkdepim/ksyncprofile.cpp +++ b/libkdepim/ksyncprofile.cpp | |||
@@ -1,248 +1,252 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | 3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> |
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 <qcolor.h> | 23 | #include <qcolor.h> |
24 | 24 | ||
25 | #include <kconfig.h> | 25 | #include <kconfig.h> |
26 | #include <kstandarddirs.h> | 26 | #include <kstandarddirs.h> |
27 | #include <kglobal.h> | 27 | #include <kglobal.h> |
28 | #include <kdebug.h> | 28 | #include <kdebug.h> |
29 | 29 | ||
30 | #include "ksyncprofile.h" | 30 | #include "ksyncprofile.h" |
31 | 31 | ||
32 | 32 | ||
33 | KSyncProfile::KSyncProfile(): QObject () | 33 | KSyncProfile::KSyncProfile(): QObject () |
34 | { | 34 | { |
35 | setDefault(); | 35 | setDefault(); |
36 | } | 36 | } |
37 | KSyncProfile::~KSyncProfile() | 37 | KSyncProfile::~KSyncProfile() |
38 | { | 38 | { |
39 | 39 | ||
40 | } | 40 | } |
41 | 41 | ||
42 | 42 | ||
43 | KSyncProfile* KSyncProfile::clone() | 43 | KSyncProfile* KSyncProfile::clone() |
44 | { | 44 | { |
45 | KSyncProfile* myClone = new KSyncProfile(); | 45 | KSyncProfile* myClone = new KSyncProfile(); |
46 | myClone->setRemotePw(mRemotePw); | 46 | myClone->setRemotePw(mRemotePw); |
47 | myClone->setRemoteIP(mRemoteIP); | 47 | myClone->setRemoteIP(mRemoteIP); |
48 | myClone->setRemotePort(mRemotePort); | 48 | myClone->setRemotePort(mRemotePort); |
49 | myClone->setRemotePwAB(mRemotePwAB); | 49 | myClone->setRemotePwAB(mRemotePwAB); |
50 | myClone->setRemoteIPAB(mRemoteIPAB); | 50 | myClone->setRemoteIPAB(mRemoteIPAB); |
51 | myClone->setRemotePortAB(mRemotePortAB); | 51 | myClone->setRemotePortAB(mRemotePortAB); |
52 | myClone->setRemotePwPWM(mRemotePwPWM); | 52 | myClone->setRemotePwPWM(mRemotePwPWM); |
53 | myClone->setRemoteIPPWM(mRemoteIPPWM); | 53 | myClone->setRemoteIPPWM(mRemoteIPPWM); |
54 | myClone->setRemotePortPWM (mRemotePortPWM); | 54 | myClone->setRemotePortPWM (mRemotePortPWM); |
55 | myClone->setPreSyncCommand( mPreSyncCommand ); | 55 | myClone->setPreSyncCommand( mPreSyncCommand ); |
56 | myClone->setPostSyncCommand( mPostSyncCommand ); | 56 | myClone->setPostSyncCommand( mPostSyncCommand ); |
57 | myClone->setLocalTempFile( mLocalTempFile); | 57 | myClone->setLocalTempFile( mLocalTempFile); |
58 | myClone->setRemoteFileName( mRemoteFileName ); | 58 | myClone->setRemoteFileName( mRemoteFileName ); |
59 | myClone->setPreSyncCommandAB( mPreSyncCommandAB ); | 59 | myClone->setPreSyncCommandAB( mPreSyncCommandAB ); |
60 | myClone->setPostSyncCommandAB( mPostSyncCommandAB ); | 60 | myClone->setPostSyncCommandAB( mPostSyncCommandAB ); |
61 | myClone->setLocalTempFileAB( mLocalTempFileAB); | 61 | myClone->setLocalTempFileAB( mLocalTempFileAB); |
62 | myClone->setRemoteFileNameAB( mRemoteFileNameAB ); | 62 | myClone->setRemoteFileNameAB( mRemoteFileNameAB ); |
63 | myClone->setPreSyncCommandPWM( mPreSyncCommandPWM ); | 63 | myClone->setPreSyncCommandPWM( mPreSyncCommandPWM ); |
64 | myClone->setPostSyncCommandPWM( mPostSyncCommandPWM ); | 64 | myClone->setPostSyncCommandPWM( mPostSyncCommandPWM ); |
65 | myClone->setLocalTempFilePWM( mLocalTempFilePWM); | 65 | myClone->setLocalTempFilePWM( mLocalTempFilePWM); |
66 | myClone->setRemoteFileNamePWM( mRemoteFileNamePWM ); | 66 | myClone->setRemoteFileNamePWM( mRemoteFileNamePWM ); |
67 | myClone->setShowSummaryAfterSync( mShowSummaryAfterSync ); | 67 | myClone->setShowSummaryAfterSync( mShowSummaryAfterSync ); |
68 | myClone->setAskForPreferences( mAskForPreferences); | 68 | myClone->setAskForPreferences( mAskForPreferences); |
69 | myClone->setWriteBackExisting(mWriteBackExisting ); | 69 | myClone->setWriteBackExisting(mWriteBackExisting ); |
70 | myClone->setWriteBackFile( mWriteBackFile); | 70 | myClone->setWriteBackFile( mWriteBackFile); |
71 | myClone->setWriteBackFuture( mWriteBackFuture ); | 71 | myClone->setWriteBackFuture( mWriteBackFuture ); |
72 | myClone->setWriteBackFutureWeeks( mWriteBackFutureWeeks ); | 72 | myClone->setWriteBackFutureWeeks( mWriteBackFutureWeeks ); |
73 | myClone->setIncludeInRingSync( mIncludeInRingSync ); | 73 | myClone->setIncludeInRingSync( mIncludeInRingSync ); |
74 | myClone->setIncludeInRingSyncAB( mIncludeInRingSyncAB ); | 74 | myClone->setIncludeInRingSyncAB( mIncludeInRingSyncAB ); |
75 | myClone->setIncludeInRingSyncPWM( mIncludeInRingSyncPWM ); | 75 | myClone->setIncludeInRingSyncPWM( mIncludeInRingSyncPWM ); |
76 | myClone->setSyncPrefs( mSyncPrefs); | 76 | myClone->setSyncPrefs( mSyncPrefs); |
77 | myClone->setIsLocalFileSync( mIsLocalFileSync ); | 77 | myClone->setIsLocalFileSync( mIsLocalFileSync ); |
78 | myClone->setIsPhoneSync( mIsPhoneSync ); | 78 | myClone->setIsPhoneSync( mIsPhoneSync ); |
79 | myClone->setIsKapiFile( mIsKapiFile ); | ||
79 | myClone->setIsPiSync( mIsPiSync ); | 80 | myClone->setIsPiSync( mIsPiSync ); |
80 | myClone->setWriteContactToSIM( mWriteContactToSIM ); | 81 | myClone->setWriteContactToSIM( mWriteContactToSIM ); |
81 | myClone->setName( "noName" ); | 82 | myClone->setName( "noName" ); |
82 | //myClone->setIdentifier( "noID" ); | 83 | //myClone->setIdentifier( "noID" ); |
83 | return myClone; | 84 | return myClone; |
84 | } | 85 | } |
85 | 86 | ||
86 | 87 | ||
87 | void KSyncProfile::setDefault() | 88 | void KSyncProfile::setDefault() |
88 | { | 89 | { |
89 | mPreSyncCommand = i18n("command for downloading remote file to local device"); | 90 | mPreSyncCommand = i18n("command for downloading remote file to local device"); |
90 | mPostSyncCommand = i18n("command for uploading local temp file to remote device"); | 91 | mPostSyncCommand = i18n("command for uploading local temp file to remote device"); |
91 | mLocalTempFile = "/tmp/mycalendar.ics"; | 92 | mLocalTempFile = "/tmp/mycalendar.ics"; |
92 | mRemoteFileName = "/home/polo/kdepim/apps/korganizer/localfile.ics"; | 93 | mRemoteFileName = "/home/polo/kdepim/apps/korganizer/localfile.ics"; |
93 | mPreSyncCommandAB = i18n("command for downloading remote file to local device"); | 94 | mPreSyncCommandAB = i18n("command for downloading remote file to local device"); |
94 | mPostSyncCommandAB = i18n("command for uploading local temp file to remote device"); | 95 | mPostSyncCommandAB = i18n("command for uploading local temp file to remote device"); |
95 | mLocalTempFileAB = "/tmp/std.vcf"; | 96 | mLocalTempFileAB = "/tmp/std.vcf"; |
96 | mRemoteFileNameAB = "/home/polo/kdepim/apps/kabc/localfile.vcf"; | 97 | mRemoteFileNameAB = "/home/polo/kdepim/apps/kabc/localfile.vcf"; |
97 | mPreSyncCommandPWM = i18n("command for downloading remote file to local device"); | 98 | mPreSyncCommandPWM = i18n("command for downloading remote file to local device"); |
98 | mPostSyncCommandPWM = i18n("command for uploading local temp file to remote device"); | 99 | mPostSyncCommandPWM = i18n("command for uploading local temp file to remote device"); |
99 | mLocalTempFilePWM = "/tmp/passwords.pwm"; | 100 | mLocalTempFilePWM = "/tmp/passwords.pwm"; |
100 | mRemoteFileNamePWM = "/home/polo/kdepim/apps/pwmanager/localfile.pwm"; | 101 | mRemoteFileNamePWM = "/home/polo/kdepim/apps/pwmanager/localfile.pwm"; |
101 | 102 | ||
102 | mRemotePw = "abc"; | 103 | mRemotePw = "abc"; |
103 | mRemoteIP = "192.168.0.99"; | 104 | mRemoteIP = "192.168.0.99"; |
104 | mRemotePort = "9197"; | 105 | mRemotePort = "9197"; |
105 | 106 | ||
106 | mRemotePwAB = "abc"; | 107 | mRemotePwAB = "abc"; |
107 | mRemoteIPAB = "192.168.0.99"; | 108 | mRemoteIPAB = "192.168.0.99"; |
108 | mRemotePortAB = "9198"; | 109 | mRemotePortAB = "9198"; |
109 | 110 | ||
110 | mRemotePwPWM = "abc"; | 111 | mRemotePwPWM = "abc"; |
111 | mRemoteIPPWM = "192.168.0.99"; | 112 | mRemoteIPPWM = "192.168.0.99"; |
112 | mRemotePortPWM = "9199"; | 113 | mRemotePortPWM = "9199"; |
113 | 114 | ||
114 | mShowSummaryAfterSync = true; | 115 | mShowSummaryAfterSync = true; |
115 | mAskForPreferences = true; | 116 | mAskForPreferences = true; |
116 | mWriteBackExisting = false; | 117 | mWriteBackExisting = false; |
117 | mWriteBackFuture = false; | 118 | mWriteBackFuture = false; |
118 | mWriteBackFutureWeeks = 12; | 119 | mWriteBackFutureWeeks = 12; |
119 | mWriteBackFile = true; | 120 | mWriteBackFile = true; |
120 | mIncludeInRingSync = false; | 121 | mIncludeInRingSync = false; |
121 | mIncludeInRingSyncAB = false; | 122 | mIncludeInRingSyncAB = false; |
122 | mIncludeInRingSyncPWM = false; | 123 | mIncludeInRingSyncPWM = false; |
123 | mSyncPrefs = SYNC_PREF_ASK; | 124 | mSyncPrefs = SYNC_PREF_ASK; |
124 | mIsLocalFileSync = true; | 125 | mIsLocalFileSync = true; |
125 | mName = "noName"; | 126 | mName = "noName"; |
126 | mIsPhoneSync = false; | 127 | mIsPhoneSync = false; |
127 | mIsPiSync = false; | 128 | mIsPiSync = false; |
129 | mIsKapiFile = false; | ||
128 | mWriteContactToSIM = false; | 130 | mWriteContactToSIM = false; |
129 | mPhoneDevice = "/dev/ircomm"; | 131 | mPhoneDevice = "/dev/ircomm"; |
130 | mPhoneConnection = "irda"; | 132 | mPhoneConnection = "irda"; |
131 | mPhoneModel = "6310i"; | 133 | mPhoneModel = "6310i"; |
132 | } | 134 | } |
133 | void KSyncProfile::readConfig(KConfig *config ) | 135 | void KSyncProfile::readConfig(KConfig *config ) |
134 | { | 136 | { |
135 | if (config) | 137 | if (config) |
136 | { | 138 | { |
137 | 139 | ||
138 | config->setGroup( mName ); | 140 | config->setGroup( mName ); |
139 | 141 | ||
140 | mName = config->readEntry( "Name", mName ); | 142 | mName = config->readEntry( "Name", mName ); |
141 | 143 | ||
142 | mRemotePw = config->readEntry( "RemotePw",mRemotePw ); | 144 | mRemotePw = config->readEntry( "RemotePw",mRemotePw ); |
143 | mRemoteIP = config->readEntry( "RemoteIP",mRemoteIP ); | 145 | mRemoteIP = config->readEntry( "RemoteIP",mRemoteIP ); |
144 | mRemotePort = config->readEntry( "RemotePort", mRemotePort ); | 146 | mRemotePort = config->readEntry( "RemotePort", mRemotePort ); |
145 | mRemotePwAB = config->readEntry( "RemotePwAB", mRemotePwAB ); | 147 | mRemotePwAB = config->readEntry( "RemotePwAB", mRemotePwAB ); |
146 | mRemoteIPAB = config->readEntry( "RemoteIPAB", mRemoteIPAB ); | 148 | mRemoteIPAB = config->readEntry( "RemoteIPAB", mRemoteIPAB ); |
147 | mRemotePortAB = config->readEntry( "RemotePortAB", mRemotePortAB ); | 149 | mRemotePortAB = config->readEntry( "RemotePortAB", mRemotePortAB ); |
148 | mRemotePwPWM = config->readEntry( "RemotePwPWM", mRemotePwPWM ); | 150 | mRemotePwPWM = config->readEntry( "RemotePwPWM", mRemotePwPWM ); |
149 | mRemoteIPPWM = config->readEntry( "RemoteIPPWM", mRemoteIPPWM ); | 151 | mRemoteIPPWM = config->readEntry( "RemoteIPPWM", mRemoteIPPWM ); |
150 | mRemotePortPWM = config->readEntry( "RemotePortPWM", mRemotePortPWM ); | 152 | mRemotePortPWM = config->readEntry( "RemotePortPWM", mRemotePortPWM ); |
151 | 153 | ||
152 | mPreSyncCommand = config->readEntry( "PreSyncCommand",mPreSyncCommand ); | 154 | mPreSyncCommand = config->readEntry( "PreSyncCommand",mPreSyncCommand ); |
153 | mPostSyncCommand = config->readEntry( "PostSyncCommand", mPostSyncCommand ); | 155 | mPostSyncCommand = config->readEntry( "PostSyncCommand", mPostSyncCommand ); |
154 | mLocalTempFile = config->readEntry( "LocalTempFile", mLocalTempFile ); | 156 | mLocalTempFile = config->readEntry( "LocalTempFile", mLocalTempFile ); |
155 | mRemoteFileName = config->readEntry( "RemoteFileName", mRemoteFileName ); | 157 | mRemoteFileName = config->readEntry( "RemoteFileName", mRemoteFileName ); |
156 | 158 | ||
157 | mPreSyncCommandAB = config->readEntry( "PreSyncCommandAB",mPreSyncCommandAB ); | 159 | mPreSyncCommandAB = config->readEntry( "PreSyncCommandAB",mPreSyncCommandAB ); |
158 | mPostSyncCommandAB = config->readEntry( "PostSyncCommandAB", mPostSyncCommandAB ); | 160 | mPostSyncCommandAB = config->readEntry( "PostSyncCommandAB", mPostSyncCommandAB ); |
159 | mLocalTempFileAB = config->readEntry( "LocalTempFileAB", mLocalTempFileAB ); | 161 | mLocalTempFileAB = config->readEntry( "LocalTempFileAB", mLocalTempFileAB ); |
160 | mRemoteFileNameAB = config->readEntry( "RemoteFileNameAB", mRemoteFileNameAB ); | 162 | mRemoteFileNameAB = config->readEntry( "RemoteFileNameAB", mRemoteFileNameAB ); |
161 | 163 | ||
162 | mPreSyncCommandPWM = config->readEntry( "PreSyncCommandPWM",mPreSyncCommandPWM ); | 164 | mPreSyncCommandPWM = config->readEntry( "PreSyncCommandPWM",mPreSyncCommandPWM ); |
163 | mPostSyncCommandPWM = config->readEntry( "PostSyncCommandPWM", mPostSyncCommandPWM ); | 165 | mPostSyncCommandPWM = config->readEntry( "PostSyncCommandPWM", mPostSyncCommandPWM ); |
164 | mLocalTempFilePWM = config->readEntry( "LocalTempFilePWM", mLocalTempFilePWM ); | 166 | mLocalTempFilePWM = config->readEntry( "LocalTempFilePWM", mLocalTempFilePWM ); |
165 | mRemoteFileNamePWM = config->readEntry( "RemoteFileNamePWM", mRemoteFileNamePWM ); | 167 | mRemoteFileNamePWM = config->readEntry( "RemoteFileNamePWM", mRemoteFileNamePWM ); |
166 | 168 | ||
167 | mPhoneDevice = config->readEntry( "PhoneDevice", mPhoneDevice ); | 169 | mPhoneDevice = config->readEntry( "PhoneDevice", mPhoneDevice ); |
168 | mPhoneConnection = config->readEntry( "PhoneConnection", mPhoneConnection ); | 170 | mPhoneConnection = config->readEntry( "PhoneConnection", mPhoneConnection ); |
169 | mPhoneModel = config->readEntry( "PhoneModel", mPhoneModel ); | 171 | mPhoneModel = config->readEntry( "PhoneModel", mPhoneModel ); |
170 | 172 | ||
171 | mIncludeInRingSync = config->readBoolEntry( "IncludeInRingSync",mIncludeInRingSync ); | 173 | mIncludeInRingSync = config->readBoolEntry( "IncludeInRingSync",mIncludeInRingSync ); |
172 | mIncludeInRingSyncAB = config->readBoolEntry( "IncludeInRingSyncAB",mIncludeInRingSyncAB ); | 174 | mIncludeInRingSyncAB = config->readBoolEntry( "IncludeInRingSyncAB",mIncludeInRingSyncAB ); |
173 | mIncludeInRingSyncPWM = config->readBoolEntry( "IncludeInRingSyncPWM",mIncludeInRingSyncPWM ); | 175 | mIncludeInRingSyncPWM = config->readBoolEntry( "IncludeInRingSyncPWM",mIncludeInRingSyncPWM ); |
174 | mShowSummaryAfterSync = config->readBoolEntry( "ShowSummaryAfterSync", mShowSummaryAfterSync ); | 176 | mShowSummaryAfterSync = config->readBoolEntry( "ShowSummaryAfterSync", mShowSummaryAfterSync ); |
175 | mAskForPreferences = config->readBoolEntry( "AskForPreferences",mAskForPreferences ); | 177 | mAskForPreferences = config->readBoolEntry( "AskForPreferences",mAskForPreferences ); |
176 | mWriteBackExisting = config->readBoolEntry( "WriteBackExisting",mWriteBackExisting ); | 178 | mWriteBackExisting = config->readBoolEntry( "WriteBackExisting",mWriteBackExisting ); |
177 | mWriteBackFuture = config->readBoolEntry( "WriteBackFuture",mWriteBackFuture ); | 179 | mWriteBackFuture = config->readBoolEntry( "WriteBackFuture",mWriteBackFuture ); |
178 | mWriteBackFile = config->readBoolEntry( "WriteBackFile",mWriteBackFile ); | 180 | mWriteBackFile = config->readBoolEntry( "WriteBackFile",mWriteBackFile ); |
179 | mWriteContactToSIM = config->readBoolEntry( "WriteContactToSIM",mWriteContactToSIM ); | 181 | mWriteContactToSIM = config->readBoolEntry( "WriteContactToSIM",mWriteContactToSIM ); |
180 | mSyncPrefs = config->readNumEntry( "SyncPrefs", mSyncPrefs ); | 182 | mSyncPrefs = config->readNumEntry( "SyncPrefs", mSyncPrefs ); |
181 | mWriteBackFutureWeeks = config->readNumEntry( "WriteBackFutureWeeks", mWriteBackFutureWeeks ); | 183 | mWriteBackFutureWeeks = config->readNumEntry( "WriteBackFutureWeeks", mWriteBackFutureWeeks ); |
182 | mIsLocalFileSync= config->readBoolEntry( "IsLocalFileSync", mIsLocalFileSync ); | 184 | mIsLocalFileSync= config->readBoolEntry( "IsLocalFileSync", mIsLocalFileSync ); |
183 | mIsPhoneSync= config->readBoolEntry( "IsPhoneSync", mIsPhoneSync ); | 185 | mIsPhoneSync= config->readBoolEntry( "IsPhoneSync", mIsPhoneSync ); |
184 | mIsPiSync= config->readBoolEntry( "IsPiSync", mIsPiSync ); | 186 | mIsPiSync= config->readBoolEntry( "IsPiSync", mIsPiSync ); |
187 | mIsKapiFile = config->readBoolEntry( "IsKapiFile", mIsKapiFile ); | ||
185 | } | 188 | } |
186 | else | 189 | else |
187 | { | 190 | { |
188 | setDefault(); | 191 | setDefault(); |
189 | } | 192 | } |
190 | } | 193 | } |
191 | 194 | ||
192 | void KSyncProfile::deleteConfig(KConfig *config ) | 195 | void KSyncProfile::deleteConfig(KConfig *config ) |
193 | { | 196 | { |
194 | config->deleteGroup( mName ); | 197 | config->deleteGroup( mName ); |
195 | } | 198 | } |
196 | 199 | ||
197 | void KSyncProfile::writeConfig( KConfig * config ) | 200 | void KSyncProfile::writeConfig( KConfig * config ) |
198 | { | 201 | { |
199 | config->setGroup(mName); | 202 | config->setGroup(mName); |
200 | 203 | ||
201 | config->writeEntry( "RemotePw", mRemotePw); | 204 | config->writeEntry( "RemotePw", mRemotePw); |
202 | config->writeEntry( "RemoteIP", mRemoteIP); | 205 | config->writeEntry( "RemoteIP", mRemoteIP); |
203 | config->writeEntry( "RemotePort", mRemotePort); | 206 | config->writeEntry( "RemotePort", mRemotePort); |
204 | 207 | ||
205 | config->writeEntry( "RemotePwAB", mRemotePwAB); | 208 | config->writeEntry( "RemotePwAB", mRemotePwAB); |
206 | config->writeEntry( "RemoteIPAB", mRemoteIPAB); | 209 | config->writeEntry( "RemoteIPAB", mRemoteIPAB); |
207 | config->writeEntry( "RemotePortAB", mRemotePortAB); | 210 | config->writeEntry( "RemotePortAB", mRemotePortAB); |
208 | 211 | ||
209 | config->writeEntry( "RemotePwPWM", mRemotePwPWM); | 212 | config->writeEntry( "RemotePwPWM", mRemotePwPWM); |
210 | config->writeEntry( "RemoteIPPWM", mRemoteIPPWM); | 213 | config->writeEntry( "RemoteIPPWM", mRemoteIPPWM); |
211 | config->writeEntry( "RemotePortPWM", mRemotePortPWM); | 214 | config->writeEntry( "RemotePortPWM", mRemotePortPWM); |
212 | 215 | ||
213 | config->writeEntry( "Name", mName ); | 216 | config->writeEntry( "Name", mName ); |
214 | config->writeEntry( "PreSyncCommand",mPreSyncCommand ); | 217 | config->writeEntry( "PreSyncCommand",mPreSyncCommand ); |
215 | config->writeEntry( "PostSyncCommand", mPostSyncCommand ); | 218 | config->writeEntry( "PostSyncCommand", mPostSyncCommand ); |
216 | config->writeEntry( "LocalTempFile", mLocalTempFile ); | 219 | config->writeEntry( "LocalTempFile", mLocalTempFile ); |
217 | config->writeEntry( "RemoteFileName", mRemoteFileName ); | 220 | config->writeEntry( "RemoteFileName", mRemoteFileName ); |
218 | 221 | ||
219 | config->writeEntry( "PreSyncCommandAB",mPreSyncCommandAB ); | 222 | config->writeEntry( "PreSyncCommandAB",mPreSyncCommandAB ); |
220 | config->writeEntry( "PostSyncCommandAB", mPostSyncCommandAB ); | 223 | config->writeEntry( "PostSyncCommandAB", mPostSyncCommandAB ); |
221 | config->writeEntry( "LocalTempFileAB", mLocalTempFileAB ); | 224 | config->writeEntry( "LocalTempFileAB", mLocalTempFileAB ); |
222 | config->writeEntry( "RemoteFileNameAB", mRemoteFileNameAB ); | 225 | config->writeEntry( "RemoteFileNameAB", mRemoteFileNameAB ); |
223 | 226 | ||
224 | config->writeEntry( "PreSyncCommandPWM",mPreSyncCommandPWM ); | 227 | config->writeEntry( "PreSyncCommandPWM",mPreSyncCommandPWM ); |
225 | config->writeEntry( "PostSyncCommandPWM", mPostSyncCommandPWM ); | 228 | config->writeEntry( "PostSyncCommandPWM", mPostSyncCommandPWM ); |
226 | config->writeEntry( "LocalTempFilePWM", mLocalTempFilePWM ); | 229 | config->writeEntry( "LocalTempFilePWM", mLocalTempFilePWM ); |
227 | config->writeEntry( "RemoteFileNamePWM", mRemoteFileNamePWM ); | 230 | config->writeEntry( "RemoteFileNamePWM", mRemoteFileNamePWM ); |
228 | 231 | ||
229 | config->writeEntry( "PhoneDevice", mPhoneDevice ); | 232 | config->writeEntry( "PhoneDevice", mPhoneDevice ); |
230 | config->writeEntry( "PhoneConnection", mPhoneConnection ); | 233 | config->writeEntry( "PhoneConnection", mPhoneConnection ); |
231 | config->writeEntry( "PhoneModel", mPhoneModel ); | 234 | config->writeEntry( "PhoneModel", mPhoneModel ); |
232 | 235 | ||
233 | config->writeEntry( "IncludeInRingSync",mIncludeInRingSync ); | 236 | config->writeEntry( "IncludeInRingSync",mIncludeInRingSync ); |
234 | config->writeEntry( "IncludeInRingSyncAB",mIncludeInRingSyncAB ); | 237 | config->writeEntry( "IncludeInRingSyncAB",mIncludeInRingSyncAB ); |
235 | config->writeEntry( "IncludeInRingSyncPWM",mIncludeInRingSyncPWM ); | 238 | config->writeEntry( "IncludeInRingSyncPWM",mIncludeInRingSyncPWM ); |
236 | config->writeEntry( "ShowSummaryAfterSync", mShowSummaryAfterSync ); | 239 | config->writeEntry( "ShowSummaryAfterSync", mShowSummaryAfterSync ); |
237 | config->writeEntry( "AskForPreferences",mAskForPreferences ); | 240 | config->writeEntry( "AskForPreferences",mAskForPreferences ); |
238 | config->writeEntry( "WriteBackExisting",mWriteBackExisting ); | 241 | config->writeEntry( "WriteBackExisting",mWriteBackExisting ); |
239 | config->writeEntry( "WriteBackFuture",mWriteBackFuture ); | 242 | config->writeEntry( "WriteBackFuture",mWriteBackFuture ); |
240 | config->writeEntry( "WriteBackFile",mWriteBackFile ); | 243 | config->writeEntry( "WriteBackFile",mWriteBackFile ); |
241 | config->writeEntry( "WriteContactToSIM",mWriteContactToSIM ); | 244 | config->writeEntry( "WriteContactToSIM",mWriteContactToSIM ); |
242 | config->writeEntry( "SyncPrefs", mSyncPrefs ); | 245 | config->writeEntry( "SyncPrefs", mSyncPrefs ); |
243 | config->writeEntry( "WriteBackFutureWeeks", mWriteBackFutureWeeks); | 246 | config->writeEntry( "WriteBackFutureWeeks", mWriteBackFutureWeeks); |
244 | config->writeEntry( "IsLocalFileSync", mIsLocalFileSync ); | 247 | config->writeEntry( "IsLocalFileSync", mIsLocalFileSync ); |
245 | config->writeEntry( "IsPhoneSync", mIsPhoneSync ); | 248 | config->writeEntry( "IsPhoneSync", mIsPhoneSync ); |
246 | config->writeEntry( "IsPiSync", mIsPiSync ); | 249 | config->writeEntry( "IsPiSync", mIsPiSync ); |
250 | config->writeEntry( "IsKapiFile", mIsKapiFile ); | ||
247 | } | 251 | } |
248 | 252 | ||
diff --git a/libkdepim/ksyncprofile.h b/libkdepim/ksyncprofile.h index 6a68bd7..0a59111 100644 --- a/libkdepim/ksyncprofile.h +++ b/libkdepim/ksyncprofile.h | |||
@@ -1,185 +1,188 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | 3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> |
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 | #ifndef _KSYNCPROFILE_H | 20 | #ifndef _KSYNCPROFILE_H |
21 | #define _KSYNCPROFILE_H | 21 | #define _KSYNCPROFILE_H |
22 | 22 | ||
23 | #include <qptrlist.h> | 23 | #include <qptrlist.h> |
24 | #include <qcolor.h> | 24 | #include <qcolor.h> |
25 | #include <qfont.h> | 25 | #include <qfont.h> |
26 | #include <qstringlist.h> | 26 | #include <qstringlist.h> |
27 | #include <qobject.h> | 27 | #include <qobject.h> |
28 | #include <qstring.h> | 28 | #include <qstring.h> |
29 | 29 | ||
30 | #include <libkcal/syncdefines.h> | 30 | #include <libkcal/syncdefines.h> |
31 | 31 | ||
32 | 32 | ||
33 | 33 | ||
34 | class KConfig; | 34 | class KConfig; |
35 | 35 | ||
36 | 36 | ||
37 | class KSyncProfile : public QObject { | 37 | class KSyncProfile : public QObject { |
38 | public: | 38 | public: |
39 | KSyncProfile(); | 39 | KSyncProfile(); |
40 | ~KSyncProfile() ; | 40 | ~KSyncProfile() ; |
41 | 41 | ||
42 | KSyncProfile* clone(); | 42 | KSyncProfile* clone(); |
43 | void setDefault(); | 43 | void setDefault(); |
44 | void readConfig(KConfig *); | 44 | void readConfig(KConfig *); |
45 | void writeConfig(KConfig *); | 45 | void writeConfig(KConfig *); |
46 | void deleteConfig(KConfig *); | 46 | void deleteConfig(KConfig *); |
47 | 47 | ||
48 | void setRemotePw( const QString& n ) {mRemotePw = n;} | 48 | void setRemotePw( const QString& n ) {mRemotePw = n;} |
49 | QString getRemotePw( ) { return mRemotePw; } | 49 | QString getRemotePw( ) { return mRemotePw; } |
50 | void setRemotePwAB( const QString& n ) {mRemotePwAB = n;} | 50 | void setRemotePwAB( const QString& n ) {mRemotePwAB = n;} |
51 | QString getRemotePwAB( ) { return mRemotePwAB; } | 51 | QString getRemotePwAB( ) { return mRemotePwAB; } |
52 | void setRemotePwPWM( const QString& n ) {mRemotePwPWM = n;} | 52 | void setRemotePwPWM( const QString& n ) {mRemotePwPWM = n;} |
53 | QString getRemotePwPWM( ) { return mRemotePwPWM; } | 53 | QString getRemotePwPWM( ) { return mRemotePwPWM; } |
54 | 54 | ||
55 | void setRemoteIP( const QString& n ) {mRemoteIP = n;} | 55 | void setRemoteIP( const QString& n ) {mRemoteIP = n;} |
56 | QString getRemoteIP( ) { return mRemoteIP; } | 56 | QString getRemoteIP( ) { return mRemoteIP; } |
57 | void setRemoteIPAB( const QString& n ) {mRemoteIPAB = n;} | 57 | void setRemoteIPAB( const QString& n ) {mRemoteIPAB = n;} |
58 | QString getRemoteIPAB( ) { return mRemoteIPAB; } | 58 | QString getRemoteIPAB( ) { return mRemoteIPAB; } |
59 | void setRemoteIPPWM( const QString& n ) {mRemoteIPPWM = n;} | 59 | void setRemoteIPPWM( const QString& n ) {mRemoteIPPWM = n;} |
60 | QString getRemoteIPPWM( ) { return mRemoteIPPWM; } | 60 | QString getRemoteIPPWM( ) { return mRemoteIPPWM; } |
61 | 61 | ||
62 | void setRemotePort( const QString& n ) {mRemotePort = n;} | 62 | void setRemotePort( const QString& n ) {mRemotePort = n;} |
63 | QString getRemotePort( ) { return mRemotePort; } | 63 | QString getRemotePort( ) { return mRemotePort; } |
64 | void setRemotePortAB( const QString& n ) {mRemotePortAB = n;} | 64 | void setRemotePortAB( const QString& n ) {mRemotePortAB = n;} |
65 | QString getRemotePortAB( ) { return mRemotePortAB; } | 65 | QString getRemotePortAB( ) { return mRemotePortAB; } |
66 | void setRemotePortPWM( const QString& n ) {mRemotePortPWM = n;} | 66 | void setRemotePortPWM( const QString& n ) {mRemotePortPWM = n;} |
67 | QString getRemotePortPWM( ) { return mRemotePortPWM; } | 67 | QString getRemotePortPWM( ) { return mRemotePortPWM; } |
68 | 68 | ||
69 | void setPreSyncCommand( const QString& n ) {mPreSyncCommand = n;} | 69 | void setPreSyncCommand( const QString& n ) {mPreSyncCommand = n;} |
70 | QString getPreSyncCommand( ) { return mPreSyncCommand; } | 70 | QString getPreSyncCommand( ) { return mPreSyncCommand; } |
71 | void setPostSyncCommand( const QString& n ) {mPostSyncCommand = n;} | 71 | void setPostSyncCommand( const QString& n ) {mPostSyncCommand = n;} |
72 | QString getPostSyncCommand( ) { return mPostSyncCommand;} | 72 | QString getPostSyncCommand( ) { return mPostSyncCommand;} |
73 | void setLocalTempFile( const QString& n ) { mLocalTempFile= n;} | 73 | void setLocalTempFile( const QString& n ) { mLocalTempFile= n;} |
74 | QString getLocalTempFile( ) { return mLocalTempFile;} | 74 | QString getLocalTempFile( ) { return mLocalTempFile;} |
75 | void setRemoteFileName( const QString& n ) { mRemoteFileName = n;} | 75 | void setRemoteFileName( const QString& n ) { mRemoteFileName = n;} |
76 | QString getRemoteFileName( ) { return mRemoteFileName;} | 76 | QString getRemoteFileName( ) { return mRemoteFileName;} |
77 | 77 | ||
78 | void setPreSyncCommandAB( const QString& n ) {mPreSyncCommandAB = n;} | 78 | void setPreSyncCommandAB( const QString& n ) {mPreSyncCommandAB = n;} |
79 | QString getPreSyncCommandAB( ) { return mPreSyncCommandAB; } | 79 | QString getPreSyncCommandAB( ) { return mPreSyncCommandAB; } |
80 | void setPostSyncCommandAB( const QString& n ) {mPostSyncCommandAB = n;} | 80 | void setPostSyncCommandAB( const QString& n ) {mPostSyncCommandAB = n;} |
81 | QString getPostSyncCommandAB( ) { return mPostSyncCommandAB;} | 81 | QString getPostSyncCommandAB( ) { return mPostSyncCommandAB;} |
82 | void setLocalTempFileAB( const QString& n ) { mLocalTempFileAB= n;} | 82 | void setLocalTempFileAB( const QString& n ) { mLocalTempFileAB= n;} |
83 | QString getLocalTempFileAB( ) { return mLocalTempFileAB;} | 83 | QString getLocalTempFileAB( ) { return mLocalTempFileAB;} |
84 | void setRemoteFileNameAB( const QString& n ) { mRemoteFileNameAB = n;} | 84 | void setRemoteFileNameAB( const QString& n ) { mRemoteFileNameAB = n;} |
85 | QString getRemoteFileNameAB( ) { return mRemoteFileNameAB;} | 85 | QString getRemoteFileNameAB( ) { return mRemoteFileNameAB;} |
86 | 86 | ||
87 | void setPreSyncCommandPWM( const QString& n ) {mPreSyncCommandPWM = n;} | 87 | void setPreSyncCommandPWM( const QString& n ) {mPreSyncCommandPWM = n;} |
88 | QString getPreSyncCommandPWM( ) { return mPreSyncCommandPWM; } | 88 | QString getPreSyncCommandPWM( ) { return mPreSyncCommandPWM; } |
89 | void setPostSyncCommandPWM( const QString& n ) {mPostSyncCommandPWM = n;} | 89 | void setPostSyncCommandPWM( const QString& n ) {mPostSyncCommandPWM = n;} |
90 | QString getPostSyncCommandPWM( ) { return mPostSyncCommandPWM;} | 90 | QString getPostSyncCommandPWM( ) { return mPostSyncCommandPWM;} |
91 | void setLocalTempFilePWM( const QString& n ) { mLocalTempFilePWM= n;} | 91 | void setLocalTempFilePWM( const QString& n ) { mLocalTempFilePWM= n;} |
92 | QString getLocalTempFilePWM( ) { return mLocalTempFilePWM;} | 92 | QString getLocalTempFilePWM( ) { return mLocalTempFilePWM;} |
93 | void setRemoteFileNamePWM( const QString& n ) { mRemoteFileNamePWM = n;} | 93 | void setRemoteFileNamePWM( const QString& n ) { mRemoteFileNamePWM = n;} |
94 | QString getRemoteFileNamePWM( ) { return mRemoteFileNamePWM;} | 94 | QString getRemoteFileNamePWM( ) { return mRemoteFileNamePWM;} |
95 | 95 | ||
96 | void setPhoneDevice( const QString& n ) { mPhoneDevice = n;} | 96 | void setPhoneDevice( const QString& n ) { mPhoneDevice = n;} |
97 | QString getPhoneDevice( ) { return mPhoneDevice;} | 97 | QString getPhoneDevice( ) { return mPhoneDevice;} |
98 | void setPhoneConnection( const QString& n ) { mPhoneConnection = n;} | 98 | void setPhoneConnection( const QString& n ) { mPhoneConnection = n;} |
99 | QString getPhoneConnection( ) { return mPhoneConnection;} | 99 | QString getPhoneConnection( ) { return mPhoneConnection;} |
100 | void setPhoneModel( const QString& n ) { mPhoneModel = n;} | 100 | void setPhoneModel( const QString& n ) { mPhoneModel = n;} |
101 | QString getPhoneModel( ) { return mPhoneModel;} | 101 | QString getPhoneModel( ) { return mPhoneModel;} |
102 | /* | 102 | /* |
103 | void set( const QString& n ) { = n;} | 103 | void set( const QString& n ) { = n;} |
104 | QString get( ) { return ;} | 104 | QString get( ) { return ;} |
105 | */ | 105 | */ |
106 | 106 | ||
107 | void setName( const QString& n ) {mName = n;} | 107 | void setName( const QString& n ) {mName = n;} |
108 | QString getName( ) { return mName;} | 108 | QString getName( ) { return mName;} |
109 | void setShowSummaryAfterSync( bool b ) { mShowSummaryAfterSync = b;} | 109 | void setShowSummaryAfterSync( bool b ) { mShowSummaryAfterSync = b;} |
110 | bool getShowSummaryAfterSync( ) { return mShowSummaryAfterSync ;} | 110 | bool getShowSummaryAfterSync( ) { return mShowSummaryAfterSync ;} |
111 | void setAskForPreferences( bool b ) { mAskForPreferences= b;} | 111 | void setAskForPreferences( bool b ) { mAskForPreferences= b;} |
112 | bool getAskForPreferences( ) { return mAskForPreferences;} | 112 | bool getAskForPreferences( ) { return mAskForPreferences;} |
113 | void setWriteBackExisting( bool b ) { mWriteBackExisting = b;} | 113 | void setWriteBackExisting( bool b ) { mWriteBackExisting = b;} |
114 | bool getWriteBackExisting( ) { return mWriteBackExisting;} | 114 | bool getWriteBackExisting( ) { return mWriteBackExisting;} |
115 | void setWriteBackFuture( bool b ) { mWriteBackFuture = b;} | 115 | void setWriteBackFuture( bool b ) { mWriteBackFuture = b;} |
116 | bool getWriteBackFuture( ) { return mWriteBackFuture;} | 116 | bool getWriteBackFuture( ) { return mWriteBackFuture;} |
117 | void setWriteBackFile( bool b ) { mWriteBackFile= b;} | 117 | void setWriteBackFile( bool b ) { mWriteBackFile= b;} |
118 | bool getWriteBackFile( ) { return mWriteBackFile;} | 118 | bool getWriteBackFile( ) { return mWriteBackFile;} |
119 | void setWriteContactToSIM( bool b ) { mWriteContactToSIM= b;} | 119 | void setWriteContactToSIM( bool b ) { mWriteContactToSIM= b;} |
120 | bool getWriteContactToSIM( ) { return mWriteContactToSIM;} | 120 | bool getWriteContactToSIM( ) { return mWriteContactToSIM;} |
121 | void setIncludeInRingSync( bool b ) {mIncludeInRingSync = b;} | 121 | void setIncludeInRingSync( bool b ) {mIncludeInRingSync = b;} |
122 | bool getIncludeInRingSync( ) { return mIncludeInRingSync;} | 122 | bool getIncludeInRingSync( ) { return mIncludeInRingSync;} |
123 | void setIncludeInRingSyncAB( bool b ) {mIncludeInRingSyncAB = b;} | 123 | void setIncludeInRingSyncAB( bool b ) {mIncludeInRingSyncAB = b;} |
124 | bool getIncludeInRingSyncAB( ) { return mIncludeInRingSyncAB;} | 124 | bool getIncludeInRingSyncAB( ) { return mIncludeInRingSyncAB;} |
125 | void setIncludeInRingSyncPWM( bool b ) {mIncludeInRingSyncPWM = b;} | 125 | void setIncludeInRingSyncPWM( bool b ) {mIncludeInRingSyncPWM = b;} |
126 | bool getIncludeInRingSyncPWM( ) { return mIncludeInRingSyncPWM;} | 126 | bool getIncludeInRingSyncPWM( ) { return mIncludeInRingSyncPWM;} |
127 | void setSyncPrefs( int n ) { mSyncPrefs= n;} | 127 | void setSyncPrefs( int n ) { mSyncPrefs= n;} |
128 | int getSyncPrefs( ) { return mSyncPrefs;} | 128 | int getSyncPrefs( ) { return mSyncPrefs;} |
129 | void setWriteBackFutureWeeks( int n ) { mWriteBackFutureWeeks= n;} | 129 | void setWriteBackFutureWeeks( int n ) { mWriteBackFutureWeeks= n;} |
130 | int getWriteBackFutureWeeks( ) { return mWriteBackFutureWeeks;} | 130 | int getWriteBackFutureWeeks( ) { return mWriteBackFutureWeeks;} |
131 | void setIsLocalFileSync( bool b ) { mIsLocalFileSync= b;} | 131 | void setIsLocalFileSync( bool b ) { mIsLocalFileSync= b;} |
132 | bool getIsLocalFileSync( ) { return mIsLocalFileSync;} | 132 | bool getIsLocalFileSync( ) { return mIsLocalFileSync;} |
133 | void setIsPhoneSync( bool b ) { mIsPhoneSync= b;} | 133 | void setIsPhoneSync( bool b ) { mIsPhoneSync= b;} |
134 | bool getIsPhoneSync( ) { return mIsPhoneSync;} | 134 | bool getIsPhoneSync( ) { return mIsPhoneSync;} |
135 | void setIsPiSync( bool b ) { mIsPiSync= b;} | 135 | void setIsPiSync( bool b ) { mIsPiSync= b;} |
136 | bool getIsPiSync( ) { return mIsPiSync;} | 136 | bool getIsPiSync( ) { return mIsPiSync;} |
137 | void setIsKapiFile( bool b ) { mIsKapiFile= b;} | ||
138 | bool getIsKapiFile( ) { return mIsKapiFile;} | ||
137 | private: | 139 | private: |
138 | QString mName; | 140 | QString mName; |
139 | QString mPreSyncCommand; | 141 | QString mPreSyncCommand; |
140 | QString mPostSyncCommand; | 142 | QString mPostSyncCommand; |
141 | QString mLocalTempFile; | 143 | QString mLocalTempFile; |
142 | QString mRemoteFileName; | 144 | QString mRemoteFileName; |
143 | QString mPreSyncCommandAB; | 145 | QString mPreSyncCommandAB; |
144 | QString mPostSyncCommandAB; | 146 | QString mPostSyncCommandAB; |
145 | QString mLocalTempFileAB; | 147 | QString mLocalTempFileAB; |
146 | QString mRemoteFileNameAB; | 148 | QString mRemoteFileNameAB; |
147 | QString mPreSyncCommandPWM; | 149 | QString mPreSyncCommandPWM; |
148 | QString mPostSyncCommandPWM; | 150 | QString mPostSyncCommandPWM; |
149 | QString mLocalTempFilePWM; | 151 | QString mLocalTempFilePWM; |
150 | QString mRemoteFileNamePWM; | 152 | QString mRemoteFileNamePWM; |
151 | 153 | ||
152 | QString mRemotePw; | 154 | QString mRemotePw; |
153 | QString mRemoteIP; | 155 | QString mRemoteIP; |
154 | QString mRemotePort; | 156 | QString mRemotePort; |
155 | 157 | ||
156 | QString mRemotePwAB; | 158 | QString mRemotePwAB; |
157 | QString mRemoteIPAB; | 159 | QString mRemoteIPAB; |
158 | QString mRemotePortAB; | 160 | QString mRemotePortAB; |
159 | 161 | ||
160 | QString mRemotePwPWM; | 162 | QString mRemotePwPWM; |
161 | QString mRemoteIPPWM; | 163 | QString mRemoteIPPWM; |
162 | QString mRemotePortPWM; | 164 | QString mRemotePortPWM; |
163 | 165 | ||
164 | QString mPhoneDevice; | 166 | QString mPhoneDevice; |
165 | QString mPhoneConnection; | 167 | QString mPhoneConnection; |
166 | QString mPhoneModel; | 168 | QString mPhoneModel; |
167 | 169 | ||
168 | bool mIncludeInRingSync; | 170 | bool mIncludeInRingSync; |
169 | bool mIncludeInRingSyncAB; | 171 | bool mIncludeInRingSyncAB; |
170 | bool mIncludeInRingSyncPWM; | 172 | bool mIncludeInRingSyncPWM; |
171 | int mSyncPrefs; | 173 | int mSyncPrefs; |
172 | bool mWriteBackFile; | 174 | bool mWriteBackFile; |
173 | bool mWriteBackExisting; | 175 | bool mWriteBackExisting; |
174 | bool mWriteBackFuture; | 176 | bool mWriteBackFuture; |
175 | int mWriteBackFutureWeeks; | 177 | int mWriteBackFutureWeeks; |
176 | bool mAskForPreferences; | 178 | bool mAskForPreferences; |
177 | bool mShowSummaryAfterSync; | 179 | bool mShowSummaryAfterSync; |
178 | bool mIsLocalFileSync; | 180 | bool mIsLocalFileSync; |
179 | bool mIsPhoneSync; | 181 | bool mIsPhoneSync; |
180 | bool mWriteContactToSIM; | 182 | bool mWriteContactToSIM; |
181 | 183 | ||
182 | bool mIsPiSync; | 184 | bool mIsPiSync; |
185 | bool mIsKapiFile; | ||
183 | }; | 186 | }; |
184 | 187 | ||
185 | #endif | 188 | #endif |