1 | /*********************************************************************
|
---|
2 | // created: 2012/03/01 - 14:06
|
---|
3 | // filename: TelnetClient.h
|
---|
4 | //
|
---|
5 | // author: Pierre Hudelaine
|
---|
6 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
7 | //
|
---|
8 | // version: $Id: $
|
---|
9 | //
|
---|
10 | // purpose: Create network socket if needed in Pacpus
|
---|
11 | //
|
---|
12 | *********************************************************************/
|
---|
13 |
|
---|
14 | #include <QTcpSocket>
|
---|
15 | #include <QHostAddress>
|
---|
16 |
|
---|
17 | #include "Pacpus/kernel/Log.h"
|
---|
18 | #include "Pacpus/kernel/ComponentBase.h"
|
---|
19 | #include "Pacpus/kernel/ComponentFactory.h"
|
---|
20 |
|
---|
21 | // Export macro for TelnetClient DLL for Windows only
|
---|
22 | #ifdef WIN32
|
---|
23 | # ifdef TelnetClient_EXPORTS
|
---|
24 | // make DLL
|
---|
25 | # define TelnetClient_API __declspec(dllexport)
|
---|
26 | # else
|
---|
27 | // use DLL
|
---|
28 | # define TelnetClient_API __declspec(dllimport)
|
---|
29 | # endif
|
---|
30 | #else
|
---|
31 | // On other platforms, simply ignore this
|
---|
32 | # define TelnetClient_API
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | class QByteArray;
|
---|
36 |
|
---|
37 | namespace pacpus {
|
---|
38 |
|
---|
39 |
|
---|
40 | class TelnetClient_API TelnetClient
|
---|
41 | : public QObject
|
---|
42 | , public ComponentBase
|
---|
43 | {
|
---|
44 | Q_OBJECT
|
---|
45 |
|
---|
46 | public:
|
---|
47 | /// Constructor
|
---|
48 | TelnetClient(QString name);
|
---|
49 |
|
---|
50 | /// Destructor
|
---|
51 | ~TelnetClient();
|
---|
52 | TelnetClient * getSocket() {return this;}
|
---|
53 |
|
---|
54 | public Q_SLOTS:
|
---|
55 | /// Slot de lecture des paquets envoys pour tests
|
---|
56 | void readPendingDatagrams();
|
---|
57 |
|
---|
58 | /// Slot d'envoie des paquets
|
---|
59 | //void sendDatagrams(QString frame);
|
---|
60 | //void sendDatagrams(QByteArray frame);
|
---|
61 |
|
---|
62 | Q_SIGNALS:
|
---|
63 | void newDatagram(QByteArray datagram);
|
---|
64 | void newQString(QString string);
|
---|
65 |
|
---|
66 | public slots:
|
---|
67 | void ConnectionMessage();
|
---|
68 |
|
---|
69 | protected:
|
---|
70 | // The 3 virtual methods relative to the ComponentBase inheritance
|
---|
71 | virtual void startActivity();
|
---|
72 | virtual void stopActivity();
|
---|
73 | virtual COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
|
---|
74 |
|
---|
75 | QTcpSocket * socket_;
|
---|
76 |
|
---|
77 | quint16 port_;
|
---|
78 | QHostAddress address_;
|
---|
79 |
|
---|
80 | };
|
---|
81 |
|
---|
82 | } // namespace pacpus
|
---|