author | zautrix <zautrix> | 2004-10-27 12:27:39 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-27 12:27:39 (UTC) |
commit | 2f3396d84d2f3c92e1e0e420d677892c1f9c0778 (patch) (unidiff) | |
tree | 1ebab5dc6d00cb09720789897ce2c86df05cc9ab /libkdepim | |
parent | f73d249579d52d7aeaacde2dcb23abeb42f9ee95 (diff) | |
download | kdepimpi-2f3396d84d2f3c92e1e0e420d677892c1f9c0778.zip kdepimpi-2f3396d84d2f3c92e1e0e420d677892c1f9c0778.tar.gz kdepimpi-2f3396d84d2f3c92e1e0e420d677892c1f9c0778.tar.bz2 |
completed KDE AB sync. but will it work ...?
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 22 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 2 |
2 files changed, 23 insertions, 1 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index e09050e..17e6c75 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -142,160 +142,162 @@ void KSyncManager::fillSyncMenu() | |||
142 | for ( i = 0; i < prof.count(); ++i ) { | 142 | for ( i = 0; i < prof.count(); ++i ) { |
143 | mSyncMenu->insertItem( prof[i], 1000+i ); | 143 | mSyncMenu->insertItem( prof[i], 1000+i ); |
144 | clearMenu->insertItem( prof[i], 1000+i ); | 144 | clearMenu->insertItem( prof[i], 1000+i ); |
145 | if ( i == 2 ) | 145 | if ( i == 2 ) |
146 | mSyncMenu->insertSeparator(); | 146 | mSyncMenu->insertSeparator(); |
147 | } | 147 | } |
148 | QDir app_dir; | 148 | QDir app_dir; |
149 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 149 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
150 | if ( mTargetApp == PWMPI) { | 150 | if ( mTargetApp == PWMPI) { |
151 | mSyncMenu->removeItem( 1000 ); | 151 | mSyncMenu->removeItem( 1000 ); |
152 | clearMenu->removeItem( 1000 ); | 152 | clearMenu->removeItem( 1000 ); |
153 | } | 153 | } |
154 | #ifndef DESKTOP_VERSION | 154 | #ifndef DESKTOP_VERSION |
155 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 155 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
156 | mSyncMenu->removeItem( 1000 ); | 156 | mSyncMenu->removeItem( 1000 ); |
157 | clearMenu->removeItem( 1000 ); | 157 | clearMenu->removeItem( 1000 ); |
158 | } | 158 | } |
159 | #endif | 159 | #endif |
160 | mSyncMenu->removeItem( 1002 ); | 160 | mSyncMenu->removeItem( 1002 ); |
161 | clearMenu->removeItem( 1002 ); | 161 | clearMenu->removeItem( 1002 ); |
162 | } | 162 | } |
163 | void KSyncManager::slotClearMenu( int action ) | 163 | void KSyncManager::slotClearMenu( int action ) |
164 | { | 164 | { |
165 | QString syncDevice; | 165 | QString syncDevice; |
166 | if ( action > 999 ) { | 166 | if ( action > 999 ) { |
167 | syncDevice = mSyncProfileNames[action - 1000] ; | 167 | syncDevice = mSyncProfileNames[action - 1000] ; |
168 | } | 168 | } |
169 | 169 | ||
170 | 170 | ||
171 | 171 | ||
172 | int result = 0; | 172 | int result = 0; |
173 | QString sd; | 173 | QString sd; |
174 | if ( syncDevice.isEmpty() ) | 174 | if ( syncDevice.isEmpty() ) |
175 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); | 175 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); |
176 | else | 176 | else |
177 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); | 177 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); |
178 | 178 | ||
179 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, | 179 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, |
180 | 0, 1 ); | 180 | 0, 1 ); |
181 | if ( result ) | 181 | if ( result ) |
182 | return; | 182 | return; |
183 | mImplementation->removeSyncInfo( syncDevice ); | 183 | mImplementation->removeSyncInfo( syncDevice ); |
184 | } | 184 | } |
185 | void KSyncManager::slotSyncMenu( int action ) | 185 | void KSyncManager::slotSyncMenu( int action ) |
186 | { | 186 | { |
187 | qDebug("syncaction %d ", action); | 187 | qDebug("syncaction %d ", action); |
188 | if ( action == 5000 ) | 188 | if ( action == 5000 ) |
189 | return; | 189 | return; |
190 | mSyncWithDesktop = false; | ||
190 | if ( action == 0 ) { | 191 | if ( action == 0 ) { |
191 | 192 | ||
192 | // seems to be a Qt2 event handling bug | 193 | // seems to be a Qt2 event handling bug |
193 | // syncmenu.clear causes a segfault at first time | 194 | // syncmenu.clear causes a segfault at first time |
194 | // when we call it after the main event loop, it is ok | 195 | // when we call it after the main event loop, it is ok |
195 | // same behaviour when calling OM/Pi via QCOP for the first time | 196 | // same behaviour when calling OM/Pi via QCOP for the first time |
196 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 197 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
197 | //confSync(); | 198 | //confSync(); |
198 | 199 | ||
199 | return; | 200 | return; |
200 | } | 201 | } |
201 | if ( action == 1 ) { | 202 | if ( action == 1 ) { |
202 | multiSync( true ); | 203 | multiSync( true ); |
203 | return; | 204 | return; |
204 | } | 205 | } |
205 | if ( action == 2 ) { | 206 | if ( action == 2 ) { |
206 | enableQuick(); | 207 | enableQuick(); |
207 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 208 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
208 | return; | 209 | return; |
209 | } | 210 | } |
210 | if ( action == 3 ) { | 211 | if ( action == 3 ) { |
211 | delete mServerSocket; | 212 | delete mServerSocket; |
212 | mServerSocket = 0; | 213 | mServerSocket = 0; |
213 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 214 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
214 | return; | 215 | return; |
215 | } | 216 | } |
216 | 217 | ||
217 | if (blockSave()) | 218 | if (blockSave()) |
218 | return; | 219 | return; |
219 | 220 | ||
220 | setBlockSave(true); | 221 | setBlockSave(true); |
221 | bool silent = false; | 222 | bool silent = false; |
222 | if ( action == 999 ) { | 223 | if ( action == 999 ) { |
223 | //special mode for silent syncing | 224 | //special mode for silent syncing |
224 | action = 1000; | 225 | action = 1000; |
225 | silent = true; | 226 | silent = true; |
226 | } | 227 | } |
227 | 228 | ||
228 | mCurrentSyncProfile = action - 1000 ; | 229 | mCurrentSyncProfile = action - 1000 ; |
229 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; | 230 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
230 | mCurrentSyncName = mLocalMachineName ; | 231 | mCurrentSyncName = mLocalMachineName ; |
231 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 232 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
232 | KSyncProfile* temp = new KSyncProfile (); | 233 | KSyncProfile* temp = new KSyncProfile (); |
233 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); | 234 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
234 | temp->readConfig(&config); | 235 | temp->readConfig(&config); |
235 | if (silent) { | 236 | if (silent) { |
236 | mAskForPreferences = false; | 237 | mAskForPreferences = false; |
237 | mShowSyncSummary = false; | 238 | mShowSyncSummary = false; |
238 | mWriteBackFile = true; | 239 | mWriteBackFile = true; |
239 | mSyncAlgoPrefs = 2;// take newest | 240 | mSyncAlgoPrefs = 2;// take newest |
240 | } | 241 | } |
241 | else { | 242 | else { |
242 | mAskForPreferences = temp->getAskForPreferences(); | 243 | mAskForPreferences = temp->getAskForPreferences(); |
243 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 244 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
244 | mWriteBackFile = temp->getWriteBackFile(); | 245 | mWriteBackFile = temp->getWriteBackFile(); |
245 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 246 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
246 | } | 247 | } |
247 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 248 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
248 | mIsKapiFile = temp->getIsKapiFile(); | 249 | mIsKapiFile = temp->getIsKapiFile(); |
249 | mWriteBackInFuture = 0; | 250 | mWriteBackInFuture = 0; |
250 | if ( temp->getWriteBackFuture() ) | 251 | if ( temp->getWriteBackFuture() ) |
251 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 252 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
252 | 253 | ||
253 | if ( action == 1000 ) { | 254 | if ( action == 1000 ) { |
255 | mIsKapiFile = false; | ||
254 | #ifdef DESKTOP_VERSION | 256 | #ifdef DESKTOP_VERSION |
255 | syncKDE(); | 257 | syncKDE(); |
256 | #else | 258 | #else |
257 | syncSharp(); | 259 | syncSharp(); |
258 | #endif | 260 | #endif |
259 | 261 | ||
260 | } else if ( action == 1001 ) { | 262 | } else if ( action == 1001 ) { |
261 | syncLocalFile(); | 263 | syncLocalFile(); |
262 | 264 | ||
263 | } else if ( action == 1002 ) { | 265 | } else if ( action == 1002 ) { |
264 | mWriteBackFile = false; | 266 | mWriteBackFile = false; |
265 | mAskForPreferences = false; | 267 | mAskForPreferences = false; |
266 | mShowSyncSummary = false; | 268 | mShowSyncSummary = false; |
267 | mSyncAlgoPrefs = 3; | 269 | mSyncAlgoPrefs = 3; |
268 | quickSyncLocalFile(); | 270 | quickSyncLocalFile(); |
269 | 271 | ||
270 | } else if ( action >= 1003 ) { | 272 | } else if ( action >= 1003 ) { |
271 | if ( temp->getIsLocalFileSync() ) { | 273 | if ( temp->getIsLocalFileSync() ) { |
272 | switch(mTargetApp) | 274 | switch(mTargetApp) |
273 | { | 275 | { |
274 | case (KAPI): | 276 | case (KAPI): |
275 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 277 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
276 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 278 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
277 | break; | 279 | break; |
278 | case (KOPI): | 280 | case (KOPI): |
279 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 281 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
280 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 282 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
281 | break; | 283 | break; |
282 | case (PWMPI): | 284 | case (PWMPI): |
283 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 285 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
284 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 286 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
285 | break; | 287 | break; |
286 | default: | 288 | default: |
287 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 289 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
288 | break; | 290 | break; |
289 | 291 | ||
290 | } | 292 | } |
291 | } else { | 293 | } else { |
292 | if ( temp->getIsPhoneSync() ) { | 294 | if ( temp->getIsPhoneSync() ) { |
293 | mPhoneDevice = temp->getPhoneDevice( ) ; | 295 | mPhoneDevice = temp->getPhoneDevice( ) ; |
294 | mPhoneConnection = temp->getPhoneConnection( ); | 296 | mPhoneConnection = temp->getPhoneConnection( ); |
295 | mPhoneModel = temp->getPhoneModel( ); | 297 | mPhoneModel = temp->getPhoneModel( ); |
296 | syncPhone(); | 298 | syncPhone(); |
297 | } else if ( temp->getIsPiSync() ) { | 299 | } else if ( temp->getIsPiSync() ) { |
298 | if ( mTargetApp == KAPI ) { | 300 | if ( mTargetApp == KAPI ) { |
299 | mPassWordPiSync = temp->getRemotePwAB(); | 301 | mPassWordPiSync = temp->getRemotePwAB(); |
300 | mActiveSyncPort = temp->getRemotePortAB(); | 302 | mActiveSyncPort = temp->getRemotePortAB(); |
301 | mActiveSyncIP = temp->getRemoteIPAB(); | 303 | mActiveSyncIP = temp->getRemoteIPAB(); |
@@ -837,101 +839,119 @@ QString KSyncManager::getPassword( ) | |||
837 | QDialog dia ( mParent, "input-dialog", true ); | 839 | QDialog dia ( mParent, "input-dialog", true ); |
838 | QLineEdit lab ( &dia ); | 840 | QLineEdit lab ( &dia ); |
839 | lab.setEchoMode( QLineEdit::Password ); | 841 | lab.setEchoMode( QLineEdit::Password ); |
840 | QVBoxLayout lay( &dia ); | 842 | QVBoxLayout lay( &dia ); |
841 | lay.setMargin(7); | 843 | lay.setMargin(7); |
842 | lay.setSpacing(7); | 844 | lay.setSpacing(7); |
843 | lay.addWidget( &lab); | 845 | lay.addWidget( &lab); |
844 | dia.setFixedSize( 230,50 ); | 846 | dia.setFixedSize( 230,50 ); |
845 | dia.setCaption( i18n("Enter password") ); | 847 | dia.setCaption( i18n("Enter password") ); |
846 | QPushButton pb ( "OK", &dia); | 848 | QPushButton pb ( "OK", &dia); |
847 | lay.addWidget( &pb ); | 849 | lay.addWidget( &pb ); |
848 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 850 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
849 | dia.show(); | 851 | dia.show(); |
850 | int res = dia.exec(); | 852 | int res = dia.exec(); |
851 | if ( res ) | 853 | if ( res ) |
852 | retfile = lab.text(); | 854 | retfile = lab.text(); |
853 | dia.hide(); | 855 | dia.hide(); |
854 | qApp->processEvents(); | 856 | qApp->processEvents(); |
855 | return retfile; | 857 | return retfile; |
856 | 858 | ||
857 | } | 859 | } |
858 | 860 | ||
859 | 861 | ||
860 | void KSyncManager::confSync() | 862 | void KSyncManager::confSync() |
861 | { | 863 | { |
862 | static KSyncPrefsDialog* sp = 0; | 864 | static KSyncPrefsDialog* sp = 0; |
863 | if ( ! sp ) { | 865 | if ( ! sp ) { |
864 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 866 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
865 | } | 867 | } |
866 | sp->usrReadConfig(); | 868 | sp->usrReadConfig(); |
867 | #ifndef DESKTOP_VERSION | 869 | #ifndef DESKTOP_VERSION |
868 | sp->showMaximized(); | 870 | sp->showMaximized(); |
869 | #else | 871 | #else |
870 | sp->show(); | 872 | sp->show(); |
871 | #endif | 873 | #endif |
872 | sp->exec(); | 874 | sp->exec(); |
873 | QStringList oldSyncProfileNames = mSyncProfileNames; | 875 | QStringList oldSyncProfileNames = mSyncProfileNames; |
874 | mSyncProfileNames = sp->getSyncProfileNames(); | 876 | mSyncProfileNames = sp->getSyncProfileNames(); |
875 | mLocalMachineName = sp->getLocalMachineName (); | 877 | mLocalMachineName = sp->getLocalMachineName (); |
876 | int ii; | 878 | int ii; |
877 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { | 879 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { |
878 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) | 880 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) |
879 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); | 881 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); |
880 | } | 882 | } |
881 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 883 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
882 | } | 884 | } |
883 | void KSyncManager::syncKDE() | 885 | void KSyncManager::syncKDE() |
884 | { | 886 | { |
887 | mSyncWithDesktop = true; | ||
885 | emit save(); | 888 | emit save(); |
886 | switch(mTargetApp) | 889 | switch(mTargetApp) |
887 | { | 890 | { |
888 | case (KAPI): | 891 | case (KAPI): |
889 | 892 | { | |
893 | #ifdef DESKTOP_VERSION | ||
894 | QString command = qApp->applicationDirPath () + "/kdeabdump"; | ||
895 | #else | ||
896 | QString command = "kdeabdump"; | ||
897 | #endif | ||
898 | if ( ! QFile::exists ( command ) ) | ||
899 | command = "kdeabdump"; | ||
900 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; | ||
901 | system ( command.latin1()); | ||
902 | if ( syncWithFile( fileName,true ) ) { | ||
903 | if ( mWriteBackFile ) { | ||
904 | command += " --read"; | ||
905 | system ( command.latin1()); | ||
906 | } | ||
907 | } | ||
908 | |||
909 | } | ||
890 | break; | 910 | break; |
891 | case (KOPI): | 911 | case (KOPI): |
892 | { | 912 | { |
893 | #ifdef DESKTOP_VERSION | 913 | #ifdef DESKTOP_VERSION |
894 | QString command = qApp->applicationDirPath () + "/kdecaldump"; | 914 | QString command = qApp->applicationDirPath () + "/kdecaldump"; |
895 | #else | 915 | #else |
896 | QString command = "kdecaldump"; | 916 | QString command = "kdecaldump"; |
897 | #endif | 917 | #endif |
898 | if ( ! QFile::exists ( command ) ) | 918 | if ( ! QFile::exists ( command ) ) |
899 | command = "kdecaldump"; | 919 | command = "kdecaldump"; |
900 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | 920 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; |
901 | system ( command.latin1()); | 921 | system ( command.latin1()); |
902 | if ( syncWithFile( fileName,true ) ) { | 922 | if ( syncWithFile( fileName,true ) ) { |
903 | if ( mWriteBackFile ) { | 923 | if ( mWriteBackFile ) { |
904 | command += " --read"; | 924 | command += " --read"; |
905 | system ( command.latin1()); | 925 | system ( command.latin1()); |
906 | } | 926 | } |
907 | } | 927 | } |
908 | 928 | ||
909 | } | 929 | } |
910 | break; | 930 | break; |
911 | case (PWMPI): | 931 | case (PWMPI): |
912 | 932 | ||
913 | break; | 933 | break; |
914 | default: | 934 | default: |
915 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 935 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
916 | break; | 936 | break; |
917 | 937 | ||
918 | } | 938 | } |
919 | } | 939 | } |
920 | 940 | ||
921 | void KSyncManager::syncSharp() | 941 | void KSyncManager::syncSharp() |
922 | { | 942 | { |
923 | 943 | ||
924 | if ( ! syncExternalApplication("sharp") ) | 944 | if ( ! syncExternalApplication("sharp") ) |
925 | qDebug("ERROR sync sharp "); | 945 | qDebug("ERROR sync sharp "); |
926 | } | 946 | } |
927 | 947 | ||
928 | bool KSyncManager::syncExternalApplication(QString resource) | 948 | bool KSyncManager::syncExternalApplication(QString resource) |
929 | { | 949 | { |
930 | 950 | ||
931 | emit save(); | 951 | emit save(); |
932 | 952 | ||
933 | if ( mAskForPreferences ) | 953 | if ( mAskForPreferences ) |
934 | if ( !edit_sync_options()) { | 954 | if ( !edit_sync_options()) { |
935 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 955 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
936 | return false; | 956 | return false; |
937 | } | 957 | } |
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 2af891b..6da0ee4 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h | |||
@@ -77,138 +77,140 @@ class KCommandSocket : public QObject | |||
77 | enum state { successR, errorR, successW, errorW, errorTO, quiet }; | 77 | enum state { successR, errorR, successW, errorW, errorTO, quiet }; |
78 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); | 78 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); |
79 | void readFile( QString ); | 79 | void readFile( QString ); |
80 | void writeFile( QString ); | 80 | void writeFile( QString ); |
81 | void sendStop(); | 81 | void sendStop(); |
82 | 82 | ||
83 | signals: | 83 | signals: |
84 | void commandFinished( KCommandSocket*, int ); | 84 | void commandFinished( KCommandSocket*, int ); |
85 | private slots: | 85 | private slots: |
86 | void startReadFileFromSocket(); | 86 | void startReadFileFromSocket(); |
87 | void readFileFromSocket(); | 87 | void readFileFromSocket(); |
88 | void deleteSocket(); | 88 | void deleteSocket(); |
89 | void writeFileToSocket(); | 89 | void writeFileToSocket(); |
90 | private : | 90 | private : |
91 | QSocket* mSocket; | 91 | QSocket* mSocket; |
92 | QString mPassWord; | 92 | QString mPassWord; |
93 | Q_UINT16 mPort; | 93 | Q_UINT16 mPort; |
94 | QString mHost; | 94 | QString mHost; |
95 | QString mFileName; | 95 | QString mFileName; |
96 | QTimer* mTimerSocket; | 96 | QTimer* mTimerSocket; |
97 | int mRetVal; | 97 | int mRetVal; |
98 | QTime mTime; | 98 | QTime mTime; |
99 | QString mFileString; | 99 | QString mFileString; |
100 | bool mFirst; | 100 | bool mFirst; |
101 | }; | 101 | }; |
102 | 102 | ||
103 | 103 | ||
104 | class KSyncManager : public QObject | 104 | class KSyncManager : public QObject |
105 | { | 105 | { |
106 | Q_OBJECT | 106 | Q_OBJECT |
107 | 107 | ||
108 | public: | 108 | public: |
109 | enum TargetApp { | 109 | enum TargetApp { |
110 | KOPI = 0, | 110 | KOPI = 0, |
111 | KAPI = 1, | 111 | KAPI = 1, |
112 | PWMPI = 2 }; | 112 | PWMPI = 2 }; |
113 | 113 | ||
114 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); | 114 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); |
115 | ~KSyncManager() ; | 115 | ~KSyncManager() ; |
116 | 116 | ||
117 | void multiSync( bool askforPrefs ); | 117 | void multiSync( bool askforPrefs ); |
118 | bool blockSave() { return mBlockSaveFlag; } | 118 | bool blockSave() { return mBlockSaveFlag; } |
119 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } | 119 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } |
120 | void setDefaultFileName( QString s) { mDefFileName = s ;} | 120 | void setDefaultFileName( QString s) { mDefFileName = s ;} |
121 | QString defaultFileName() { return mDefFileName ;} | 121 | QString defaultFileName() { return mDefFileName ;} |
122 | QString syncFileName(); | 122 | QString syncFileName(); |
123 | void enableQuick( bool ask = true); | 123 | void enableQuick( bool ask = true); |
124 | 124 | ||
125 | bool syncWithDesktop () { return mSyncWithDesktop;} | ||
125 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } | 126 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } |
126 | QString getCurrentSyncName() { return mCurrentSyncName; } | 127 | QString getCurrentSyncName() { return mCurrentSyncName; } |
127 | 128 | ||
128 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); | 129 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); |
129 | void hideProgressBar(); | 130 | void hideProgressBar(); |
130 | bool isProgressBarCanceled(); | 131 | bool isProgressBarCanceled(); |
131 | 132 | ||
132 | // sync stuff | 133 | // sync stuff |
133 | QString mLocalMachineName; | 134 | QString mLocalMachineName; |
134 | QStringList mExternSyncProfiles; | 135 | QStringList mExternSyncProfiles; |
135 | QStringList mSyncProfileNames; | 136 | QStringList mSyncProfileNames; |
136 | bool mAskForPreferences; | 137 | bool mAskForPreferences; |
137 | bool mShowSyncSummary; | 138 | bool mShowSyncSummary; |
138 | bool mIsKapiFile; | 139 | bool mIsKapiFile; |
139 | bool mWriteBackExistingOnly; | 140 | bool mWriteBackExistingOnly; |
140 | int mSyncAlgoPrefs; | 141 | int mSyncAlgoPrefs; |
141 | bool mWriteBackFile; | 142 | bool mWriteBackFile; |
142 | int mWriteBackInFuture; | 143 | int mWriteBackInFuture; |
143 | QString mPhoneDevice; | 144 | QString mPhoneDevice; |
144 | QString mPhoneConnection; | 145 | QString mPhoneConnection; |
145 | QString mPhoneModel; | 146 | QString mPhoneModel; |
146 | QString mPassWordPiSync; | 147 | QString mPassWordPiSync; |
147 | QString mActiveSyncPort; | 148 | QString mActiveSyncPort; |
148 | QString mActiveSyncIP ; | 149 | QString mActiveSyncIP ; |
149 | static QDateTime mRequestedSyncEvent; | 150 | static QDateTime mRequestedSyncEvent; |
150 | 151 | ||
151 | signals: | 152 | signals: |
152 | void save(); | 153 | void save(); |
153 | void request_file(); | 154 | void request_file(); |
154 | void getFile( bool ); | 155 | void getFile( bool ); |
155 | 156 | ||
156 | public slots: | 157 | public slots: |
157 | void slotSyncMenu( int ); | 158 | void slotSyncMenu( int ); |
158 | void slotClearMenu( int action ); | 159 | void slotClearMenu( int action ); |
159 | void deleteCommandSocket(KCommandSocket*s, int state); | 160 | void deleteCommandSocket(KCommandSocket*s, int state); |
160 | void readFileFromSocket(); | 161 | void readFileFromSocket(); |
161 | void fillSyncMenu(); | 162 | void fillSyncMenu(); |
162 | 163 | ||
163 | private: | 164 | private: |
164 | void syncPi(); | 165 | void syncPi(); |
165 | KServerSocket * mServerSocket; | 166 | KServerSocket * mServerSocket; |
166 | KPimPrefs* mPrefs; | 167 | KPimPrefs* mPrefs; |
167 | QString mDefFileName; | 168 | QString mDefFileName; |
168 | QString mCurrentSyncDevice; | 169 | QString mCurrentSyncDevice; |
169 | QString mCurrentSyncName; | 170 | QString mCurrentSyncName; |
170 | void quickSyncLocalFile(); | 171 | void quickSyncLocalFile(); |
171 | bool syncWithFile( QString fn , bool quick ); | 172 | bool syncWithFile( QString fn , bool quick ); |
172 | void syncLocalFile(); | 173 | void syncLocalFile(); |
173 | void syncPhone(); | 174 | void syncPhone(); |
174 | void syncSharp(); | 175 | void syncSharp(); |
175 | void syncKDE(); | 176 | void syncKDE(); |
176 | bool syncExternalApplication(QString); | 177 | bool syncExternalApplication(QString); |
177 | int mCurrentSyncProfile ; | 178 | int mCurrentSyncProfile ; |
178 | void syncRemote( KSyncProfile* prof, bool ask = true); | 179 | void syncRemote( KSyncProfile* prof, bool ask = true); |
179 | bool edit_sync_options(); | 180 | bool edit_sync_options(); |
180 | bool edit_pisync_options(); | 181 | bool edit_pisync_options(); |
181 | int ringSync(); | 182 | int ringSync(); |
182 | QString getPassword( ); | 183 | QString getPassword( ); |
183 | bool mPisyncFinished; | 184 | bool mPisyncFinished; |
184 | bool mBlockSaveFlag; | 185 | bool mBlockSaveFlag; |
185 | QWidget* mParent; | 186 | QWidget* mParent; |
186 | KSyncInterface* mImplementation; | 187 | KSyncInterface* mImplementation; |
187 | TargetApp mTargetApp; | 188 | TargetApp mTargetApp; |
188 | QPopupMenu* mSyncMenu; | 189 | QPopupMenu* mSyncMenu; |
189 | QProgressBar* bar; | 190 | QProgressBar* bar; |
191 | bool mSyncWithDesktop; | ||
190 | 192 | ||
191 | private slots: | 193 | private slots: |
192 | void confSync(); | 194 | void confSync(); |
193 | 195 | ||
194 | 196 | ||
195 | }; | 197 | }; |
196 | 198 | ||
197 | 199 | ||
198 | class KSyncInterface | 200 | class KSyncInterface |
199 | { | 201 | { |
200 | public : | 202 | public : |
201 | virtual void removeSyncInfo( QString syncProfile) = 0; | 203 | virtual void removeSyncInfo( QString syncProfile) = 0; |
202 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; | 204 | virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; |
203 | virtual bool syncExternal(KSyncManager* manager, QString resource) | 205 | virtual bool syncExternal(KSyncManager* manager, QString resource) |
204 | { | 206 | { |
205 | // empty implementation, because some syncable applications do not | 207 | // empty implementation, because some syncable applications do not |
206 | // have an external(sharpdtm) syncmode, like pwmanager. | 208 | // have an external(sharpdtm) syncmode, like pwmanager. |
207 | return false; | 209 | return false; |
208 | } | 210 | } |
209 | 211 | ||
210 | 212 | ||
211 | }; | 213 | }; |
212 | 214 | ||
213 | 215 | ||
214 | #endif | 216 | #endif |