Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

remotecontrol.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** 
00003 ** Copyright (C) 2002 Yann Hodique <Yann.Hodique@lifl.fr>
00004 ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
00005 **
00006 ** This file is part of an example program for Qt.  This example
00007 ** program may be used, distributed and modified without limitation.
00008 **
00009 *****************************************************************************/
00010 
00011 #ifndef _REMOTECONTROL_H_
00012 #define _REMOTECONTROL_H_
00013 
00014 #include <qsocket.h>
00015 #include <qserversocket.h>
00016 #include <qapplication.h>
00017 #include <qtextbrowser.h>
00018 #include <qtextview.h>
00019 #include <qlabel.h>
00020 #include <qpushbutton.h>
00021 #include <qtextstream.h>
00022 #include <qmap.h>
00023 
00024 #include <stdlib.h>
00025 
00026 class QMtp;
00027 class ChatSession;
00028 
00029 /*
00030   The ClientSocket class provides a socket that is connected with a client.
00031   For every client that connects to the server, the server creates a new
00032   instance of this class.
00033 */
00034 class RemoteControlClientSocket : public QSocket {
00035     Q_OBJECT
00036 
00037 public:
00038     RemoteControlClientSocket( int sock, QObject *parent=0, const char *name=0 );
00039     ~RemoteControlClientSocket();
00040 
00041 signals:
00042     void logText( const QString& );
00043     void processText(const QString& );
00044 
00045 private slots:
00046     void readClient();
00047 
00048 private:
00049     int line;
00050 };
00051 
00052 
00053 /*
00054   The SimpleServer class handles new connections to the server. For every
00055   client that connects, it creates a new ClientSocket -- that instance is now
00056   responsible for the communication with that client.
00057 */
00058 class RemoteControlSimpleServer : public QServerSocket {
00059     Q_OBJECT
00060 
00061 public:
00062     RemoteControlSimpleServer( int port, QObject* parent=0 );
00063     ~RemoteControlSimpleServer();
00064 
00065 public slots:
00066     void newConnection( int socket );
00067 
00068 signals:
00069     void newConnect( RemoteControlClientSocket* );
00070 };
00071 
00072 
00073 /*
00074   The ServerInfo class provides a small GUI for the server. It also creates the
00075   SimpleServer and as a result the server.
00076 */
00077 class RemoteControlServerInfo : QObject {
00078     Q_OBJECT
00079 
00080     typedef QMap<QString, void(RemoteControlServerInfo::*)(RemoteControlClientSocket*,const QString&)> CommandMap;
00081     typedef QMap<ChatSession*,QValueList<RemoteControlClientSocket*> > SyncMap;
00082     
00083 public:
00084     RemoteControlServerInfo(QMtp *, int port, QTextBrowser *log, const QString & pass = QString::null);
00085     ~RemoteControlServerInfo();
00086 
00087 private slots:
00088     void newConnect( RemoteControlClientSocket *s );
00089     void connectionClosed();
00090     void processText(const QString & txt);
00091     void auth(const QString&);
00092     void display(const QString&);
00093 
00094     void listCommand(RemoteControlClientSocket*,const QString&);
00095     void commandsCommand(RemoteControlClientSocket*,const QString&);
00096     void exitCommand(RemoteControlClientSocket*,const QString&);
00097     void sendCommand(RemoteControlClientSocket*,const QString&);
00098     void synchroCommand(RemoteControlClientSocket*,const QString&);
00099     void desynchroCommand(RemoteControlClientSocket*,const QString&);
00100     void connectCommand(RemoteControlClientSocket*,const QString&);
00101     void disconnectCommand(RemoteControlClientSocket*,const QString&);
00102     void unknownCommand(RemoteControlClientSocket*,const QString&);
00103 
00104 private:
00105     QTextBrowser *infoText;
00106     QMap<int,RemoteControlClientSocket*> map;
00107     SyncMap sync_map;
00108     CommandMap commands;
00109 
00110     QString remote_pass;
00111     QMtp * m_mtp;
00112 };
00113 
00114 #endif

Generated on Sat May 10 15:09:28 2003 for qnet by doxygen1.3