summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.h
authorzautrix <zautrix>2005-02-24 02:01:08 (UTC)
committer zautrix <zautrix>2005-02-24 02:01:08 (UTC)
commit5af16f69232073d1fa46d2dea3774beaaafb00c5 (patch) (unidiff)
tree0790afdd906df50520ac4415a9d35b95107d4d48 /libkdepim/ksyncmanager.h
parent513496c67403deb04339cfc87143ed5554720e32 (diff)
downloadkdepimpi-5af16f69232073d1fa46d2dea3774beaaafb00c5.zip
kdepimpi-5af16f69232073d1fa46d2dea3774beaaafb00c5.tar.gz
kdepimpi-5af16f69232073d1fa46d2dea3774beaaafb00c5.tar.bz2
socket fixes
Diffstat (limited to 'libkdepim/ksyncmanager.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 810a515..bd3ecdc 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,227 +1,230 @@
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
33class QPopupMenu; 33class QPopupMenu;
34class KSyncProfile; 34class KSyncProfile;
35class KPimPrefs; 35class KPimPrefs;
36class QWidget; 36class QWidget;
37class KSyncManager; 37class KSyncManager;
38class KSyncInterface; 38class KSyncInterface;
39class QProgressBar; 39class QProgressBar;
40 40
41 41
42class KServerSocket : public QServerSocket 42class 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 deleteSocket();
58 void readClient(); 59 void readClient();
60 void displayErrorMessage();
59 void readBackFileFromSocket(); 61 void readBackFileFromSocket();
60 private : 62 private :
63 int mErrorMessage;
61 bool blockRC; 64 bool blockRC;
62 void send_file(); 65 void send_file();
63 void get_file(); 66 void get_file();
64 void end_connect(); 67 void end_connect();
65 void error_connect(); 68 void error_connect( QString );
66 QDialog* mSyncActionDialog; 69 QDialog* mSyncActionDialog;
67 QSocket* mSocket; 70 QSocket* mSocket;
68 QString mPassWord; 71 QString mPassWord;
69 QString mFileName; 72 QString mFileName;
70 QTime piTime; 73 QTime piTime;
71 QString piFileString; 74 QString piFileString;
72}; 75};
73 76
74class KCommandSocket : public QObject 77class KCommandSocket : public QObject
75{ 78{
76 Q_OBJECT 79 Q_OBJECT
77 public: 80 public:
78 enum state { successR, errorR, successW, errorW, errorTO, errorPW,quiet }; 81 enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN,quiet };
79 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 ); 82 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 );
80 void readFile( QString ); 83 void readFile( QString );
81 void writeFile( QString ); 84 void writeFile( QString );
82 void sendStop(); 85 void sendStop();
83 86
84 private slots : 87 private slots :
85 void sendFileRequest(); 88 void sendFileRequest();
86 89
87 signals: 90 signals:
88 void commandFinished( KCommandSocket*, int ); 91 void commandFinished( KCommandSocket*, int );
89 private slots: 92 private slots:
90 void startReadFileFromSocket(); 93 void startReadFileFromSocket();
91 void readFileFromSocket(); 94 void readFileFromSocket();
92 void deleteSocket(); 95 void deleteSocket();
93 void writeFileToSocket(); 96 void writeFileToSocket();
94 private : 97 private :
95 QWidget* tlw; 98 QWidget* tlw;
96 QSocket* mSocket; 99 QSocket* mSocket;
97 QString mPassWord; 100 QString mPassWord;
98 Q_UINT16 mPort; 101 Q_UINT16 mPort;
99 QString mHost; 102 QString mHost;
100 QString mFileName; 103 QString mFileName;
101 QTimer* mTimerSocket; 104 QTimer* mTimerSocket;
102 int mRetVal; 105 int mRetVal;
103 QTime mTime; 106 QTime mTime;
104 QString mFileString; 107 QString mFileString;
105 bool mFirst; 108 bool mFirst;
106 bool mFirstLine; 109 bool mFirstLine;
107}; 110};
108 111
109 112
110class KSyncManager : public QObject 113class KSyncManager : public QObject
111{ 114{
112 Q_OBJECT 115 Q_OBJECT
113 116
114 public: 117 public:
115 enum TargetApp { 118 enum TargetApp {
116 KOPI = 0, 119 KOPI = 0,
117 KAPI = 1, 120 KAPI = 1,
118 PWMPI = 2 }; 121 PWMPI = 2 };
119 122
120 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 123 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
121 ~KSyncManager() ; 124 ~KSyncManager() ;
122 125
123 void multiSync( bool askforPrefs ); 126 void multiSync( bool askforPrefs );
124 bool blockSave() { return mBlockSaveFlag; } 127 bool blockSave() { return mBlockSaveFlag; }
125 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 128 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
126 void setDefaultFileName( QString s) ; 129 void setDefaultFileName( QString s) ;
127 QString defaultFileName() { return mDefFileName ;} 130 QString defaultFileName() { return mDefFileName ;}
128 QString syncFileName(); 131 QString syncFileName();
129 void enableQuick( bool ask = true); 132 void enableQuick( bool ask = true);
130 133
131 bool syncWithDesktop () { return mSyncWithDesktop;} 134 bool syncWithDesktop () { return mSyncWithDesktop;}
132 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 135 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
133 QString getCurrentSyncName() { return mCurrentSyncName; } 136 QString getCurrentSyncName() { return mCurrentSyncName; }
134 137
135 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 138 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
136 void hideProgressBar(); 139 void hideProgressBar();
137 bool isProgressBarCanceled(); 140 bool isProgressBarCanceled();
138 141
139 // sync stuff 142 // sync stuff
140 QString mLocalMachineName; 143 QString mLocalMachineName;
141 QStringList mExternSyncProfiles; 144 QStringList mExternSyncProfiles;
142 QStringList mSyncProfileNames; 145 QStringList mSyncProfileNames;
143 bool mAskForPreferences; 146 bool mAskForPreferences;
144 bool mShowSyncSummary; 147 bool mShowSyncSummary;
145 bool mIsKapiFile; 148 bool mIsKapiFile;
146 bool mWriteBackExistingOnly; 149 bool mWriteBackExistingOnly;
147 int mSyncAlgoPrefs; 150 int mSyncAlgoPrefs;
148 bool mWriteBackFile; 151 bool mWriteBackFile;
149 int mWriteBackInFuture; 152 int mWriteBackInFuture;
150 int mWriteBackInPast; 153 int mWriteBackInPast;
151 QString mPhoneDevice; 154 QString mPhoneDevice;
152 QString mPhoneConnection; 155 QString mPhoneConnection;
153 QString mPhoneModel; 156 QString mPhoneModel;
154 QString mPassWordPiSync; 157 QString mPassWordPiSync;
155 QString mActiveSyncPort; 158 QString mActiveSyncPort;
156 QString mActiveSyncIP ; 159 QString mActiveSyncIP ;
157 QString mFilterInCal; 160 QString mFilterInCal;
158 QString mFilterOutCal; 161 QString mFilterOutCal;
159 QString mFilterInAB; 162 QString mFilterInAB;
160 QString mFilterOutAB; 163 QString mFilterOutAB;
161 static QDateTime mRequestedSyncEvent; 164 static QDateTime mRequestedSyncEvent;
162 165
163 signals: 166 signals:
164 void save(); 167 void save();
165 void request_file(); 168 void request_file();
166 void getFile( bool ); 169 void getFile( bool );
167 170
168 public slots: 171 public slots:
169 void slotSyncMenu( int ); 172 void slotSyncMenu( int );
170 void slotClearMenu( int action ); 173 void slotClearMenu( int action );
171 void deleteCommandSocket(KCommandSocket*s, int state); 174 void deleteCommandSocket(KCommandSocket*s, int state);
172 void readFileFromSocket(); 175 void readFileFromSocket();
173 void fillSyncMenu(); 176 void fillSyncMenu();
174 177
175 private: 178 private:
176 void syncPi(); 179 void syncPi();
177 KServerSocket * mServerSocket; 180 KServerSocket * mServerSocket;
178 KPimPrefs* mPrefs; 181 KPimPrefs* mPrefs;
179 QString mDefFileName; 182 QString mDefFileName;
180 QString mCurrentSyncDevice; 183 QString mCurrentSyncDevice;
181 QString mCurrentSyncName; 184 QString mCurrentSyncName;
182 void quickSyncLocalFile(); 185 void quickSyncLocalFile();
183 bool syncWithFile( QString fn , bool quick ); 186 bool syncWithFile( QString fn , bool quick );
184 void syncLocalFile(); 187 void syncLocalFile();
185 void syncPhone(); 188 void syncPhone();
186 void syncSharp(); 189 void syncSharp();
187 void syncKDE(); 190 void syncKDE();
188 bool syncExternalApplication(QString); 191 bool syncExternalApplication(QString);
189 int mCurrentSyncProfile ; 192 int mCurrentSyncProfile ;
190 void syncRemote( KSyncProfile* prof, bool ask = true); 193 void syncRemote( KSyncProfile* prof, bool ask = true);
191 bool edit_sync_options(); 194 bool edit_sync_options();
192 bool edit_pisync_options(); 195 bool edit_pisync_options();
193 int ringSync(); 196 int ringSync();
194 QString getPassword( ); 197 QString getPassword( );
195 bool mPisyncFinished; 198 bool mPisyncFinished;
196 bool mBlockSaveFlag; 199 bool mBlockSaveFlag;
197 QWidget* mParent; 200 QWidget* mParent;
198 KSyncInterface* mImplementation; 201 KSyncInterface* mImplementation;
199 TargetApp mTargetApp; 202 TargetApp mTargetApp;
200 QPopupMenu* mSyncMenu; 203 QPopupMenu* mSyncMenu;
201 QProgressBar* bar; 204 QProgressBar* bar;
202 bool mSyncWithDesktop; 205 bool mSyncWithDesktop;
203 206
204private slots: 207private slots:
205 void confSync(); 208 void confSync();
206 209
207 210
208}; 211};
209 212
210 213
211class KSyncInterface 214class KSyncInterface
212{ 215{
213 public : 216 public :
214 virtual void removeSyncInfo( QString syncProfile) = 0; 217 virtual void removeSyncInfo( QString syncProfile) = 0;
215 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; 218 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0;
216 virtual bool syncExternal(KSyncManager* manager, QString resource) 219 virtual bool syncExternal(KSyncManager* manager, QString resource)
217 { 220 {
218 // empty implementation, because some syncable applications do not 221 // empty implementation, because some syncable applications do not
219 // have an external(sharpdtm) syncmode, like pwmanager. 222 // have an external(sharpdtm) syncmode, like pwmanager.
220 return false; 223 return false;
221 } 224 }
222 225
223 226
224}; 227};
225 228
226 229
227#endif 230#endif