summaryrefslogtreecommitdiff
path: root/core/qws/transferserver.h
Unidiff
Diffstat (limited to 'core/qws/transferserver.h') (more/less context) (ignore whitespace changes)
-rw-r--r--core/qws/transferserver.h15
1 files changed, 8 insertions, 7 deletions
diff --git a/core/qws/transferserver.h b/core/qws/transferserver.h
index 1c5ab4b..82dae40 100644
--- a/core/qws/transferserver.h
+++ b/core/qws/transferserver.h
@@ -3,49 +3,50 @@
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qserversocket.h> 20#include <qserversocket.h>
21#include <qsocket.h> 21#include <qsocket.h>
22#include <qdir.h> 22#include <qdir.h>
23#include <qfile.h> 23#include <qfile.h>
24#include <qbuffer.h> 24#include <qbuffer.h>
25 25
26class QFileInfo; 26class QFileInfo;
27class OProcess; 27namespace Opie { namespace Core { class OProcess; } }
28
28class TransferServer : public QServerSocket 29class TransferServer : public QServerSocket
29{ 30{
30 Q_OBJECT 31 Q_OBJECT
31 32
32public: 33public:
33 TransferServer( Q_UINT16 port, QObject *parent = 0, const char* name = 0 ); 34 TransferServer( Q_UINT16 port, QObject *parent = 0, const char* name = 0 );
34 virtual ~TransferServer(); 35 virtual ~TransferServer();
35 36
36 void newConnection( int socket ); 37 void newConnection( int socket );
37}; 38};
38 39
39class SyncAuthentication : QObject 40class SyncAuthentication : QObject
40{ 41{
41 Q_OBJECT 42 Q_OBJECT
42 43
43public: 44public:
44 static int isAuthorized(QHostAddress peeraddress); 45 static int isAuthorized(QHostAddress peeraddress);
45 static bool checkPassword(const QString& pw); 46 static bool checkPassword(const QString& pw);
46 static bool checkUser(const QString& user); 47 static bool checkUser(const QString& user);
47 48
48 static QString serverId(); 49 static QString serverId();
49 static QString loginName(); 50 static QString loginName();
50 static QString ownerName(); 51 static QString ownerName();
51}; 52};
@@ -71,65 +72,65 @@ public:
71 void sendByteArray( const QByteArray& array, const QHostAddress& host, Q_UINT16 port ); 72 void sendByteArray( const QByteArray& array, const QHostAddress& host, Q_UINT16 port );
72 73
73 void retrieveFile( const QString fn ); 74 void retrieveFile( const QString fn );
74 void retrieveFile( const QString fn, const QHostAddress& host, Q_UINT16 port ); 75 void retrieveFile( const QString fn, const QHostAddress& host, Q_UINT16 port );
75 void retrieveGzipFile( const QString &fn ); 76 void retrieveGzipFile( const QString &fn );
76 void retrieveGzipFile( const QString &fn, const QHostAddress& host, Q_UINT16 port ); 77 void retrieveGzipFile( const QString &fn, const QHostAddress& host, Q_UINT16 port );
77 void retrieveByteArray(); 78 void retrieveByteArray();
78 void retrieveByteArray( const QHostAddress& host, Q_UINT16 port ); 79 void retrieveByteArray( const QHostAddress& host, Q_UINT16 port );
79 80
80 Mode dtpMode() { return mode; } 81 Mode dtpMode() { return mode; }
81 QByteArray buffer() { return buf.buffer(); } 82 QByteArray buffer() { return buf.buffer(); }
82 QString fileName() const { return file.name(); } 83 QString fileName() const { return file.name(); }
83 84
84 void setSocket( int socket ); 85 void setSocket( int socket );
85 86
86signals: 87signals:
87 void completed(); 88 void completed();
88 void failed(); 89 void failed();
89 90
90private slots: 91private slots:
91 void connectionClosed(); 92 void connectionClosed();
92 void connected(); 93 void connected();
93 void bytesWritten( int bytes ); 94 void bytesWritten( int bytes );
94 void readyRead(); 95 void readyRead();
95 void writeTargzBlock(OProcess *, char *, int); 96 void writeTargzBlock(Opie::Core::OProcess *, char *, int);
96 void targzDone(); 97 void targzDone();
97 98
98 void gzipTarBlock(OProcess *, char *, int); 99 void gzipTarBlock(Opie::Core::OProcess *, char *, int);
99 void tarExtractBlock(OProcess *, char *, int); 100 void tarExtractBlock(Opie::Core::OProcess *, char *, int);
100 void gunzipDone(); 101 void gunzipDone();
101 void extractTarDone(); 102 void extractTarDone();
102 103
103private: 104private:
104 105
105 unsigned long bytes_written; 106 unsigned long bytes_written;
106 Mode mode; 107 Mode mode;
107 QFile file; 108 QFile file;
108 QBuffer buf; 109 QBuffer buf;
109 OProcess *createTargzProc; 110 Opie::Core::OProcess *createTargzProc;
110 OProcess *retrieveTargzProc; 111 Opie::Core::OProcess *retrieveTargzProc;
111 OProcess *gzipProc; 112 Opie::Core::OProcess *gzipProc;
112}; 113};
113 114
114class ServerSocket : public QServerSocket 115class ServerSocket : public QServerSocket
115{ 116{
116 Q_OBJECT 117 Q_OBJECT
117 118
118public: 119public:
119 ServerSocket( Q_UINT16 port, QObject *parent = 0, const char* name = 0 ) 120 ServerSocket( Q_UINT16 port, QObject *parent = 0, const char* name = 0 )
120 : QServerSocket( port, 1, parent, name ) {} 121 : QServerSocket( port, 1, parent, name ) {}
121 122
122 void newConnection( int socket ) { emit newIncomming( socket ); } 123 void newConnection( int socket ) { emit newIncomming( socket ); }
123signals: 124signals:
124 void newIncomming( int socket ); 125 void newIncomming( int socket );
125}; 126};
126 127
127class ServerPI : public QSocket 128class ServerPI : public QSocket
128{ 129{
129 Q_OBJECT 130 Q_OBJECT
130 131
131 enum State { Connected, Wait_USER, Wait_PASS, Ready, Forbidden }; 132 enum State { Connected, Wait_USER, Wait_PASS, Ready, Forbidden };
132 enum Transfer { SendFile = 0, RetrieveFile = 1, SendByteArray = 2, RetrieveByteArray = 3 }; 133 enum Transfer { SendFile = 0, RetrieveFile = 1, SendByteArray = 2, RetrieveByteArray = 3 };
133 134
134public: 135public:
135 ServerPI( int socket, QObject *parent = 0, const char* name = 0 ); 136 ServerPI( int socket, QObject *parent = 0, const char* name = 0 );