Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

qcopbridge.h

Go to the documentation of this file.
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 <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     /* can not or anymore :) */
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

Generated on Sat Nov 5 16:15:31 2005 for OPIE by  doxygen 1.4.2