Huggle  build:^490^dce1e5c
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
networkirc.hpp
1 //This program is free software: you can redistribute it and/or modify
2 //it under the terms of the GNU General Public License as published by
3 //the Free Software Foundation, either version 3 of the License, or
4 //(at your option) any later version.
5 
6 //This program is distributed in the hope that it will be useful,
7 //but WITHOUT ANY WARRANTY; without even the implied warranty of
8 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 //GNU General Public License for more details.
10 
11 #ifndef NETWORKIRC_H
12 #define NETWORKIRC_H
13 
14 #include <QString>
15 #include <QtNetwork>
16 #include <QThread>
17 #include <QMutex>
18 
19 namespace Huggle
20 {
21  //! Namespace that contains IRC objects
22  namespace IRC
23  {
24  class Channel;
25  class User;
26  class NetworkIrc;
27 
28  //! Represent a channel on IRC network
29  class Channel
30  {
31  public:
32  Channel();
33  QString Name;
34  QList<User> Users;
35  };
36 
37  /*!
38  * \brief The User class represent a user of irc network
39  */
40  class User
41  {
42  public:
43  User(QString nick, QString ident, QString host);
44  User();
45  User(User *user);
46  User(const User &user);
47  QString Ident;
48  QString Nick;
49  QString Host;
50  };
51 
52  //! Represent a message on irc network sent either to a channel or to a user
53  class Message
54  {
55  public:
56  Message(QString text, User us);
57  Message(QString chan, QString text, User us);
58  Message();
59  Message(Message *ms);
60  Message(const Message &ms);
61  QString Channel;
62  QString Text;
63  User user;
64  };
65 
66  /*!
67  * \brief The NetworkIrc_th class is a network thread for Network Irc
68  */
69  class NetworkIrc_th : public QThread
70  {
71  Q_OBJECT
72  public:
73  NetworkIrc_th(QTcpSocket *socket);
74  ~NetworkIrc_th();
75  bool Running;
76  NetworkIrc *root;
77  void Line(QString line);
78  void ProcessPrivmsg(QString source, QString xx);
79  bool IsFinished();
80  protected:
81  void run();
82  private:
83  /*!
84  * \brief Pointer to a QT Socket that is handling the connection to irc server
85  * this object is managed by parent so don't delete it
86  */
87  QTcpSocket *s;
88  bool Stopped;
89  };
90 
91  /*!
92  * \brief The NetworkIrc provides connection to IRC servers
93  */
94  class NetworkIrc
95  {
96  public:
97  NetworkIrc(QString server, QString nick);
98  ~NetworkIrc();
99  //! Connect to server
100  void Connect();
101  /*!
102  * \brief IsConnected checks for connection
103  * \return When you are connected returns true
104  */
105  bool IsConnected();
106  bool IsConnecting();
107  void Disconnect();
108  void Join(QString name);
109  void Part(QString name);
110  void Data(QString text);
111  void Send(QString name, QString text);
112  void Exit();
113  QString Server;
114  QString Nick;
115  QString UserName;
116  QString Ident;
117  QMutex *messages_lock;
118  Message* GetMessage();
119  QStringList Channels;
120  int Port;
121  QList<Message> Messages;
122  private:
123  bool __Connected;
124  bool __IsConnecting;
125  QMutex *writer_lock;
126  NetworkIrc_th *NetworkThread;
127  /*!
128  * \brief Pointer to a QT Socket that is handling the connection to irc server owned by this class
129  */
130  QTcpSocket *s;
131  };
132  }
133 }
134 
135 #endif // NETWORKIRC_H
The NetworkIrc_th class is a network thread for Network Irc.
Definition: networkirc.hpp:69
QTcpSocket * s
Pointer to a QT Socket that is handling the connection to irc server this object is managed by parent...
Definition: networkirc.hpp:87
Represent a message on irc network sent either to a channel or to a user.
Definition: networkirc.hpp:53
bool IsConnected()
IsConnected checks for connection.
Definition: networkirc.cpp:55
The NetworkIrc provides connection to IRC servers.
Definition: networkirc.hpp:94
The User class represent a user of irc network.
Definition: networkirc.hpp:40
Represent a channel on IRC network.
Definition: networkirc.hpp:29
void Connect()
Connect to server.
Definition: networkirc.cpp:38
void Line(QString line)
Definition: networkirc.cpp:206
QTcpSocket * s
Pointer to a QT Socket that is handling the connection to irc server owned by this class...
Definition: networkirc.hpp:130