94416a0929a29031357a33a5878765e01456611a
[quassel.git] / src / core / ircserverhandler.h
1 /***************************************************************************
2  *   Copyright (C) 2005-10 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  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifndef IRCSERVERHANDLER_H
22 #define IRCSERVERHANDLER_H
23
24 #include "corebasichandler.h"
25 #include "netsplit.h"
26
27 class IrcServerHandler : public CoreBasicHandler {
28   Q_OBJECT
29
30 public:
31   IrcServerHandler(CoreNetwork *parent);
32   ~IrcServerHandler();
33
34   void handleServerMsg(QByteArray rawMsg);
35
36 public slots:
37   void handleJoin(const QString &prefix, const QList<QByteArray> &params);
38   void handleMode(const QString &prefix, const QList<QByteArray> &params);
39   void handleNotice(const QString &prefix, const QList<QByteArray> &params);
40   void handlePing(const QString &prefix, const QList<QByteArray> &params);
41   void handlePrivmsg(const QString &prefix, const QList<QByteArray> &params);
42   void handleQuit(const QString &prefix, const QList<QByteArray> &params);
43   void handle324(const QString &prefix, const QList<QByteArray> &params);   // RPL_CHANNELMODEIS
44   void handle432(const QString &prefix, const QList<QByteArray> &params);   // ERR_ERRONEUSNICKNAME
45   void handle433(const QString &prefix, const QList<QByteArray> &params);   // ERR_NICKNAMEINUSE
46   void handle437(const QString &prefix, const QList<QByteArray> &params);   // ERR_UNAVAILRESOURCE
47
48   void defaultHandler(QString cmd, const QString &prefix, const QList<QByteArray> &params);
49
50 private slots:
51   //! Joins after a netsplit
52   /** This slot handles a bulk-join after a netsplit is over
53     * \param channel The channel the users joined
54     * \param users   The list of users that joind the channel
55     * \param modes   The list of modes the users get set
56     * \param quitMessage The message we received when the netsplit occured
57     */
58   void handleNetsplitJoin(const QString &channel, const QStringList &users, const QStringList &modes, const QString &quitMessage);
59
60   //! Quits after a netsplit
61   /** This slot handles a bulk-quit after a netsplit occured
62     * \param channel The channel the users quitted
63     * \param users   The list of users that got split
64     * \param quitMessage The message we received when the netsplit occured
65     */
66   void handleNetsplitQuit(const QString &channel, const QStringList &users, const QString &quitMessage);
67
68   //! Netsplit finished
69   /** This slot deletes the netsplit object that sent the finished() signal
70     */
71   void handleNetsplitFinished();
72
73   void handleEarlyNetsplitJoin(const QString &channel, const QStringList &users, const QStringList &modes);
74
75   //! Destroy any existing netsplits
76   /** This slot deletes all netsplit objects
77     * Used to get rid of existing netsplits on network reconnect
78     */
79   void destroyNetsplits();
80
81 private:
82   void tryNextNick(const QString &errnick, bool erroneus = false);
83   bool checkParamCount(const QString &methodName, const QList<QByteArray> &params, int minParams);
84
85   // holds the target for numeric replies or is invalid otherwise
86   inline const QString &target() const { return _target; }
87
88   bool _whois;
89   QString _target;
90
91   // structure to organize netsplits
92   // key: quit message
93   // value: the corresponding netsplit object
94   QHash<QString, Netsplit*> _netsplits;
95
96 #ifdef HAVE_QCA2
97   QByteArray decrypt(const QString &target, const QByteArray &message, bool isTopic = false);
98 #endif
99 };
100
101 #endif