ircclient.h
1 //------------------------------------------------------------------------------
2 // ircclient.h
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2010 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef __IRCCLIENT_H__
24 #define __IRCCLIENT_H__
25 
26 #include "socketsignalsadapter.h"
27 #include <QHostInfo>
28 #include <QTcpSocket>
29 #include <QTimer>
30 
31 class IRCClient : public QObject
32 {
33  Q_OBJECT
34 
35  public:
36  static const int MAX_MESSAGE_LENGTH = 510;
37  static const int SAFE_MESSAGE_LENGTH = 400;
38 
39  IRCClient();
40  ~IRCClient();
41 
42  void connect(const QString& address, unsigned short port);
43  void connectSocketSignals(SocketSignalsAdapter* pAdapter);
44  void disconnect();
45 
46  bool isConnected() const;
47 
48  bool sendMessage(const QString& message);
49  void setFakeRecvLag(int lagMs);
50 
51  signals:
58  void infoMessage(const QString& message);
59  void ircServerResponse(const QString& message);
60 
61  private:
62  QString hostName;
63  unsigned short port;
64  QTimer recvTimer;
65  QTcpSocket socket;
66 
67  private slots:
68  void receiveSocketData();
69  void receiveSocketDataDelayed();
70 
71 };
72 
73 #endif
void infoMessage(const QString &message)
These are the messages that IRCClient class sends to inform the upper layers of progress.