-rw-r--r-- | libkdepim/ksyncmanager.h | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 71d17e9..32c6557 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h | |||
@@ -1,167 +1,169 @@ | |||
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 <q3socket.h> |
28 | #include <qdatetime.h> | 28 | #include <qdatetime.h> |
29 | #include <qserversocket.h> | 29 | #include <q3serversocket.h> |
30 | #include <qtextstream.h> | 30 | #include <q3textstream.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qprogressdialog.h> | 32 | #include <q3progressdialog.h> |
33 | //Added by qt3to4: | ||
34 | #include <Q3PopupMenu> | ||
33 | #include <kdialog.h> | 35 | #include <kdialog.h> |
34 | 36 | ||
35 | class QPopupMenu; | 37 | class Q3PopupMenu; |
36 | class KSyncProfile; | 38 | class KSyncProfile; |
37 | class KPimPrefs; | 39 | class KPimPrefs; |
38 | class QWidget; | 40 | class QWidget; |
39 | class KSyncManager; | 41 | class KSyncManager; |
40 | class KSyncInterface; | 42 | class KSyncInterface; |
41 | class QProgressBar; | 43 | class Q3ProgressBar; |
42 | 44 | ||
43 | 45 | ||
44 | class KServerSocket : public QServerSocket | 46 | class KServerSocket : public Q3ServerSocket |
45 | { | 47 | { |
46 | Q_OBJECT | 48 | Q_OBJECT |
47 | 49 | ||
48 | public: | 50 | public: |
49 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); | 51 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); |
50 | 52 | ||
51 | void newConnection ( int socket ) ; | 53 | void newConnection ( int socket ) ; |
52 | void setFileName( QString fn ) {mFileName = fn;}; | 54 | void setFileName( QString fn ) {mFileName = fn;}; |
53 | signals: | 55 | signals: |
54 | void file_received( bool ); | 56 | void file_received( bool ); |
55 | void request_file(); | 57 | void request_file(); |
56 | void file_received( bool, const QString &); | 58 | void file_received( bool, const QString &); |
57 | void request_file(const QString &); | 59 | void request_file(const QString &); |
58 | void saveFile(); | 60 | void saveFile(); |
59 | void endConnect(); | 61 | void endConnect(); |
60 | private slots: | 62 | private slots: |
61 | void waitForSocketFinish(); | 63 | void waitForSocketFinish(); |
62 | void discardClient(); | 64 | void discardClient(); |
63 | void deleteSocket(); | 65 | void deleteSocket(); |
64 | void readClient(); | 66 | void readClient(); |
65 | void displayErrorMessage(); | 67 | void displayErrorMessage(); |
66 | void readBackFileFromSocket(); | 68 | void readBackFileFromSocket(); |
67 | private : | 69 | private : |
68 | int mPendingConnect; | 70 | int mPendingConnect; |
69 | QString mResource; | 71 | QString mResource; |
70 | int mErrorMessage; | 72 | int mErrorMessage; |
71 | bool blockRC; | 73 | bool blockRC; |
72 | void send_file(); | 74 | void send_file(); |
73 | void get_file(); | 75 | void get_file(); |
74 | void end_connect(); | 76 | void end_connect(); |
75 | void error_connect( QString ); | 77 | void error_connect( QString ); |
76 | QDialog* mSyncActionDialog; | 78 | QDialog* mSyncActionDialog; |
77 | QSocket* mSocket; | 79 | Q3Socket* mSocket; |
78 | QString mPassWord; | 80 | QString mPassWord; |
79 | QString mFileName; | 81 | QString mFileName; |
80 | QTime piTime; | 82 | QTime piTime; |
81 | QString piFileString; | 83 | QString piFileString; |
82 | }; | 84 | }; |
83 | 85 | ||
84 | class KCommandSocket : public QObject | 86 | class KCommandSocket : public QObject |
85 | { | 87 | { |
86 | Q_OBJECT | 88 | Q_OBJECT |
87 | public: | 89 | public: |
88 | enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet }; | 90 | enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet }; |
89 | KCommandSocket (QString remoteResource, QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 ); | 91 | KCommandSocket (QString remoteResource, QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 ); |
90 | void readFile( QString ); | 92 | void readFile( QString ); |
91 | void writeFile( QString ); | 93 | void writeFile( QString ); |
92 | void sendStop(); | 94 | void sendStop(); |
93 | 95 | ||
94 | private slots : | 96 | private slots : |
95 | void sendFileRequest(); | 97 | void sendFileRequest(); |
96 | void updateConnectDialog(); | 98 | void updateConnectDialog(); |
97 | 99 | ||
98 | signals: | 100 | signals: |
99 | void commandFinished( KCommandSocket*, int ); | 101 | void commandFinished( KCommandSocket*, int ); |
100 | private slots: | 102 | private slots: |
101 | void startReadFileFromSocket(); | 103 | void startReadFileFromSocket(); |
102 | void readFileFromSocket(); | 104 | void readFileFromSocket(); |
103 | void deleteSocket(); | 105 | void deleteSocket(); |
104 | void writeFileToSocket(); | 106 | void writeFileToSocket(); |
105 | private : | 107 | private : |
106 | QString mRemoteResource; | 108 | QString mRemoteResource; |
107 | int mConnectCount; | 109 | int mConnectCount; |
108 | int mConnectMax; | 110 | int mConnectMax; |
109 | KProgressDialog mConnectProgress; | 111 | KProgressDialog mConnectProgress; |
110 | QWidget* tlw; | 112 | QWidget* tlw; |
111 | QSocket* mSocket; | 113 | Q3Socket* mSocket; |
112 | QString mPassWord; | 114 | QString mPassWord; |
113 | Q_UINT16 mPort; | 115 | Q_UINT16 mPort; |
114 | QString mHost; | 116 | QString mHost; |
115 | QString mFileName; | 117 | QString mFileName; |
116 | QTimer* mTimerSocket; | 118 | QTimer* mTimerSocket; |
117 | int mRetVal; | 119 | int mRetVal; |
118 | QTime mTime; | 120 | QTime mTime; |
119 | QString mFileString; | 121 | QString mFileString; |
120 | bool mFirst; | 122 | bool mFirst; |
121 | bool mFirstLine; | 123 | bool mFirstLine; |
122 | }; | 124 | }; |
123 | 125 | ||
124 | 126 | ||
125 | class KSyncManager : public QObject | 127 | class KSyncManager : public QObject |
126 | { | 128 | { |
127 | Q_OBJECT | 129 | Q_OBJECT |
128 | 130 | ||
129 | public: | 131 | public: |
130 | enum TargetApp { | 132 | enum TargetApp { |
131 | KOPI = 0, | 133 | KOPI = 0, |
132 | KAPI = 1, | 134 | KAPI = 1, |
133 | PWMPI = 2 }; | 135 | PWMPI = 2 }; |
134 | 136 | ||
135 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); | 137 | KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, Q3PopupMenu* syncmenu); |
136 | ~KSyncManager() ; | 138 | ~KSyncManager() ; |
137 | 139 | ||
138 | void multiSync( bool askforPrefs ); | 140 | void multiSync( bool askforPrefs ); |
139 | bool blockSave() { return mBlockSaveFlag; } | 141 | bool blockSave() { return mBlockSaveFlag; } |
140 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } | 142 | void setBlockSave(bool sa) { mBlockSaveFlag = sa; } |
141 | void setDefaultFileName( QString s) ; | 143 | void setDefaultFileName( QString s) ; |
142 | QString defaultFileName() { return mDefFileName ;} | 144 | QString defaultFileName() { return mDefFileName ;} |
143 | QString syncFileName(); | 145 | QString syncFileName(); |
144 | void enableQuick( bool ask = true); | 146 | void enableQuick( bool ask = true); |
145 | 147 | ||
146 | bool syncWithDesktop () { return mSyncWithDesktop;} | 148 | bool syncWithDesktop () { return mSyncWithDesktop;} |
147 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } | 149 | QString getCurrentSyncDevice() { return mCurrentSyncDevice; } |
148 | QString getCurrentSyncName() { return mCurrentSyncName; } | 150 | QString getCurrentSyncName() { return mCurrentSyncName; } |
149 | 151 | ||
150 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); | 152 | void showProgressBar(int percentage, QString caption = QString::null, int total=100); |
151 | void hideProgressBar(); | 153 | void hideProgressBar(); |
152 | bool isProgressBarCanceled(); | 154 | bool isProgressBarCanceled(); |
153 | 155 | ||
154 | // sync stuff | 156 | // sync stuff |
155 | QString mLocalMachineName; | 157 | QString mLocalMachineName; |
156 | QStringList mExternSyncProfiles; | 158 | QStringList mExternSyncProfiles; |
157 | QStringList mSyncProfileNames; | 159 | QStringList mSyncProfileNames; |
158 | bool mAskForPreferences; | 160 | bool mAskForPreferences; |
159 | bool mShowSyncSummary; | 161 | bool mShowSyncSummary; |
160 | bool mIsKapiFile; | 162 | bool mIsKapiFile; |
161 | bool mWriteBackExistingOnly; | 163 | bool mWriteBackExistingOnly; |
162 | int mSyncAlgoPrefs; | 164 | int mSyncAlgoPrefs; |
163 | bool mWriteBackFile; | 165 | bool mWriteBackFile; |
164 | int mWriteBackInFuture; | 166 | int mWriteBackInFuture; |
165 | int mWriteBackInPast; | 167 | int mWriteBackInPast; |
166 | QString mPhoneDevice; | 168 | QString mPhoneDevice; |
167 | QString mPhoneConnection; | 169 | QString mPhoneConnection; |
@@ -190,59 +192,59 @@ class KSyncManager : public QObject | |||
190 | void readFileFromSocket(); | 192 | void readFileFromSocket(); |
191 | void fillSyncMenu(); | 193 | void fillSyncMenu(); |
192 | 194 | ||
193 | private: | 195 | private: |
194 | void syncPi(); | 196 | void syncPi(); |
195 | KServerSocket * mServerSocket; | 197 | KServerSocket * mServerSocket; |
196 | KPimPrefs* mPrefs; | 198 | KPimPrefs* mPrefs; |
197 | QString mDefFileName; | 199 | QString mDefFileName; |
198 | QString mCurrentSyncDevice; | 200 | QString mCurrentSyncDevice; |
199 | QString mCurrentSyncName; | 201 | QString mCurrentSyncName; |
200 | void quickSyncLocalFile(); | 202 | void quickSyncLocalFile(); |
201 | bool syncWithFile( QString fn , bool quick ); | 203 | bool syncWithFile( QString fn , bool quick ); |
202 | void syncLocalFile(); | 204 | void syncLocalFile(); |
203 | void syncPhone(); | 205 | void syncPhone(); |
204 | void syncSharp(); | 206 | void syncSharp(); |
205 | void syncKDE(); | 207 | void syncKDE(); |
206 | void syncOL(); | 208 | void syncOL(); |
207 | bool syncExternalApplication(QString); | 209 | bool syncExternalApplication(QString); |
208 | int mCurrentSyncProfile ; | 210 | int mCurrentSyncProfile ; |
209 | void syncRemote( KSyncProfile* prof, bool ask = true); | 211 | void syncRemote( KSyncProfile* prof, bool ask = true); |
210 | bool edit_sync_options(); | 212 | bool edit_sync_options(); |
211 | bool edit_pisync_options(); | 213 | bool edit_pisync_options(); |
212 | int ringSync(); | 214 | int ringSync(); |
213 | QString getPassword( ); | 215 | QString getPassword( ); |
214 | bool mPisyncFinished; | 216 | bool mPisyncFinished; |
215 | QStringList mSpecificResources; | 217 | QStringList mSpecificResources; |
216 | QString mCurrentResourceLocal; | 218 | QString mCurrentResourceLocal; |
217 | QString mCurrentResourceRemote; | 219 | QString mCurrentResourceRemote; |
218 | bool mBlockSaveFlag; | 220 | bool mBlockSaveFlag; |
219 | QWidget* mParent; | 221 | QWidget* mParent; |
220 | KSyncInterface* mImplementation; | 222 | KSyncInterface* mImplementation; |
221 | TargetApp mTargetApp; | 223 | TargetApp mTargetApp; |
222 | QPopupMenu* mSyncMenu; | 224 | Q3PopupMenu* mSyncMenu; |
223 | QProgressBar* bar; | 225 | Q3ProgressBar* bar; |
224 | bool mSyncWithDesktop; | 226 | bool mSyncWithDesktop; |
225 | 227 | ||
226 | private slots: | 228 | private slots: |
227 | void displayErrorPort(); | 229 | void displayErrorPort(); |
228 | void confSync(); | 230 | void confSync(); |
229 | 231 | ||
230 | 232 | ||
231 | }; | 233 | }; |
232 | 234 | ||
233 | 235 | ||
234 | class KSyncInterface | 236 | class KSyncInterface |
235 | { | 237 | { |
236 | public : | 238 | public : |
237 | virtual void removeSyncInfo( QString syncProfile) = 0; | 239 | virtual void removeSyncInfo( QString syncProfile) = 0; |
238 | virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0; | 240 | virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0; |
239 | virtual bool syncExternal(KSyncManager* /*manager*/, QString /*resource*/) | 241 | virtual bool syncExternal(KSyncManager* /*manager*/, QString /*resource*/) |
240 | { | 242 | { |
241 | // empty implementation, because some syncable applications do not | 243 | // empty implementation, because some syncable applications do not |
242 | // have an external(sharpdtm) syncmode, like pwmanager. | 244 | // have an external(sharpdtm) syncmode, like pwmanager. |
243 | return false; | 245 | return false; |
244 | } | 246 | } |
245 | }; | 247 | }; |
246 | 248 | ||
247 | 249 | ||
248 | #endif | 250 | #endif |