1 /***************************************************************************
2 * Copyright (C) 2005-09 by the Quassel Project *
3 * devel@quassel-irc.org *
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. *
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. *
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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
27 #include <QStringList>
29 class Netsplit : public QObject
35 //! Add a user to the netsplit
36 /** Call this method if you noticed a netsplit.
37 * \note This method doesn't check if it really is a netsplit.
38 * \note Check with isNetsplit(const QString &quitMessage) before calling it!
40 * \param sender The sender string of the quitting user
41 * \param channels The channels that user shared with us
42 * \param msg The quit message
44 void userQuit(const QString &sender, const QStringList &channels, const QString &msg);
46 //! Remove a user from the netsplit
47 /** Call this method if a user joined after a netsplit occured.
50 * \param sender The sender string of the joined user
51 * \param channels The channels that user shares with us
52 * \return true if user was found in the netsplit
54 bool userJoined(const QString &sender, const QString &channel);
56 //! Check if a string matches the criteria for a netsplit
57 /** \param quitMessage The message to be checked
58 * \return true if the message is a netsplit
60 static bool isNetsplit(const QString &quitMessage);
63 //! A bulk-join of netsplitted users timed out
64 /** Whenever _joinTimer() times out, we consider the bulk-join to be finished and emit that signal
66 * \param channel The IRC channel
67 * \param users A list of all users that joined that channel
68 * \param quitMessage The Quitmessage and thus the servers that got split
70 void netsplitJoin(const QString &channel, const QStringList &users, const QString &quitMessage);
72 //! A bulk-quit of netsplitted users timed out
73 /** Whenever _quitTimer() times out, we consider the bulk-quit to be finished and emit that signal
75 * \param channel The IRC channel
76 * \param users A list of all users that quitted in that channel
77 * \param quitMessage The Quitmessage and thus the servers that got split
79 void netsplitQuit(const QString &channel, const QStringList &users, const QString &quitMessage);
81 //! The Netsplit is considered finished
82 /** This signal is emitted right after all netsplitJoin signals have been sent or whenever the
83 * internal timer signals a timeout.
84 * Simply delete the object and remove it from structures when you receive that signal.
94 QHash<QString, QStringList> _joins;
95 QHash<QString, QStringList> _quits;