Quassel IRC  Pre-Release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
netsplit.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2015 by the Quassel Project *
3  * devel@quassel-irc.org *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) version 3. *
9  * *
10  * This program 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 *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #ifndef NETSPLIT_H
22 #define NETSPLIT_H
23 
24 #include <QTimer>
25 #include <QHash>
26 #include <QPair>
27 #include <QStringList>
28 
29 class Network;
30 
31 class Netsplit : public QObject
32 {
33  Q_OBJECT
34 public:
35  Netsplit(Network *network, QObject *parent = 0);
36 
37  inline Network *network() const { return _network; }
38 
40 
48  void userQuit(const QString &sender, const QStringList &channels, const QString &msg);
49 
51 
57  bool userJoined(const QString &sender, const QString &channel);
58 
60 
67  bool userAlreadyJoined(const QString &sender, const QString &channel);
68 
70 
76  void addMode(const QString &sender, const QString &channel, const QString &mode);
77 
79 
82  static bool isNetsplit(const QString &quitMessage);
83 
84 signals:
86 
94  void netsplitJoin(Network *net, const QString &channel, const QStringList &users, const QStringList &modes, const QString &quitMessage);
95 
97 
103  void earlyJoin(Network *net, const QString &channel, const QStringList &users, const QStringList &modes);
104 
106 
113  void netsplitQuit(Network *net, const QString &channel, const QStringList &users, const QString &quitMessage);
114 
116 
120  void finished();
121 
122 private slots:
123  void joinTimeout();
124  void quitTimeout();
125 
126 private:
128  QString _quitMsg;
129  // key: channel name
130  // value: senderstring, list of modes
131  QHash<QString, QPair<QStringList, QStringList> > _joins;
132  QHash<QString, QStringList> _quits;
133  QHash<QString, QStringList> _quitsWithMessageSent;
134  bool _sentQuit;
135  QTimer _joinTimer;
136  QTimer _quitTimer;
140 };
141 
142 
143 #endif // NETSPLIT_H