00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __qcopbridge_h__
00021 #define __qcopbridge_h__
00022
00023 #include <qtopia/global.h>
00024 #include <qserversocket.h>
00025 #include <qsocket.h>
00026 #include <qdir.h>
00027 #include <qfile.h>
00028 #include <qbuffer.h>
00029
00030 class QFileInfo;
00031 class QCopBridgePI;
00032 class QCopChannel;
00033 class QTimer;
00034
00035 class QCopBridge : public QServerSocket
00036 {
00037 Q_OBJECT
00038
00039 public:
00040
00041 enum Mode { Qtopia1_7= 0x01, Sharp = 0x02, IntelliSync = 0x04 };
00042 QCopBridge( Q_UINT16 port, QObject *parent = 0, const char* name = 0 );
00043 virtual ~QCopBridge();
00044
00045 void newConnection( int socket );
00046 void closeOpenConnections();
00047 void authorizeConnections();
00048
00049 public slots:
00050 void closed( QCopBridgePI *pi );
00051 void desktopMessage( const QCString &call, const QByteArray & );
00052
00053 signals:
00054 void connectionClosed( const QHostAddress & );
00055
00056 protected:
00057 void timerEvent( QTimerEvent * );
00058 void sendDesktopMessageOld( const QCString&, const QByteArray& );
00059
00060 private:
00061 QCopChannel *desktopChannel;
00062 QCopChannel *cardChannel;
00063 QList<QCopBridgePI> openConnections;
00064 bool sendSync;
00065 Mode m_mode;
00066 };
00067
00068
00069 class QCopBridgePI : public QSocket
00070 {
00071 Q_OBJECT
00072
00073 enum State { Connected, Wait_USER, Wait_PASS, Ready, Forbidden };
00074
00075 public:
00076 QCopBridgePI( int socket, QObject *parent = 0, const char* name = 0 );
00077 virtual ~QCopBridgePI();
00078
00079 void sendDesktopMessage( const QString &msg );
00080 void sendDesktopMessage( const QCString &msg, const QByteArray& );
00081 void startSync() { sendSync = TRUE; }
00082 bool verifyAuthorised();
00083
00084 signals:
00085 void connectionClosed( QCopBridgePI *);
00086
00087 protected slots:
00088 void read();
00089 void send( const QString& msg );
00090 void process( const QString& command );
00091 void myConnectionClosed();
00092
00093 private:
00094 State state;
00095 Q_UINT16 peerport;
00096 QHostAddress peeraddress;
00097 bool sendSync;
00098 QTimer *timer;
00099 };
00100
00101 #endif