00001 /********************************************************************** 00002 ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 00003 ** 00004 ** This file is part of the Qtopia Environment. 00005 ** 00006 ** This file may be distributed and/or modified under the terms of the 00007 ** GNU General Public License version 2 as published by the Free Software 00008 ** Foundation and appearing in the file LICENSE.GPL included in the 00009 ** packaging of this file. 00010 ** 00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00013 ** 00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00015 ** 00016 ** Contact info@trolltech.com if any conditions of this licensing are 00017 ** not clear to you. 00018 ** 00019 **********************************************************************/ 00020 #ifndef __qcopbridge_h__ 00021 #define __qcopbridge_h__ 00022 00023 #include <qserversocket.h> 00024 #include <qsocket.h> 00025 #include <qdir.h> 00026 #include <qfile.h> 00027 #include <qbuffer.h> 00028 00029 class QFileInfo; 00030 class QCopBridgePI; 00031 class QCopChannel; 00032 00033 class QCopBridge : public QServerSocket 00034 { 00035 Q_OBJECT 00036 00037 public: 00038 QCopBridge( Q_UINT16 port, QObject *parent = 0, const char* name = 0 ); 00039 virtual ~QCopBridge(); 00040 00041 void newConnection( int socket ); 00042 void closeOpenConnections(); 00043 00044 public slots: 00045 void connectionClosed( QCopBridgePI *pi ); 00046 void desktopMessage( const QCString &call, const QByteArray & ); 00047 00048 protected: 00049 void timerEvent( QTimerEvent * ); 00050 00051 private: 00052 QCopChannel *desktopChannel; 00053 QCopChannel *cardChannel; 00054 QList<QCopBridgePI> openConnections; 00055 bool sendSync; 00056 }; 00057 00058 00059 class QCopBridgePI : public QSocket 00060 { 00061 Q_OBJECT 00062 00063 enum State { Connected, Wait_USER, Wait_PASS, Ready, Forbidden }; 00064 00065 public: 00066 QCopBridgePI( int socket, QObject *parent = 0, const char* name = 0 ); 00067 virtual ~QCopBridgePI(); 00068 00069 void sendDesktopMessage( const QString &msg ); 00070 void startSync() { sendSync = TRUE; } 00071 00072 signals: 00073 void connectionClosed( QCopBridgePI *); 00074 00075 protected slots: 00076 void read(); 00077 void send( const QString& msg ); 00078 void process( const QString& command ); 00079 void connectionClosed(); 00080 00081 protected: 00082 void timerEvent( QTimerEvent *e ); 00083 00084 private: 00085 State state; 00086 Q_UINT16 peerport; 00087 QHostAddress peeraddress; 00088 bool connected; 00089 bool sendSync; 00090 }; 00091 00092 #endif
1.4.2