modernize: Reformat ALL the source... again!
[quassel.git] / src / common / irclisthelper.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2018 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 #pragma once
22
23 #include "common-export.h"
24
25 #include <utility>
26
27 #include "syncableobject.h"
28 #include "types.h"
29
30 /*
31  * This is a little helper to display channel lists of a network.
32  * The whole process is done in 3 steps:
33  *  1.) the client requests to issue a LIST command with requestChannelList()
34  *  2.) RPL_LIST fills on the core the list of available channels
35  *      when RPL_LISTEND is received the clients will be informed, that they can pull the data
36  *  3.) client pulls the data by calling requestChannelList again. receiving the data in receiveChannelList
37  */
38 class COMMON_EXPORT IrcListHelper : public SyncableObject
39 {
40     Q_OBJECT
41     SYNCABLE_OBJECT
42
43 public:
44     inline IrcListHelper(QObject* parent = nullptr)
45         : SyncableObject(parent)
46     {
47         setInitialized();
48     };
49
50     struct ChannelDescription
51     {
52         QString channelName;
53         quint32 userCount;
54         QString topic;
55         ChannelDescription(QString channelName_, quint32 userCount_, QString topic_)
56             : channelName(std::move(channelName_))
57             , userCount(userCount_)
58             , topic(std::move(topic_)){};
59     };
60
61 public slots:
62     inline virtual QVariantList requestChannelList(const NetworkId& netId, const QStringList& channelFilters)
63     {
64         REQUEST(ARG(netId), ARG(channelFilters));
65         return QVariantList();
66     }
67     inline virtual void receiveChannelList(const NetworkId&, const QStringList&, const QVariantList&){};
68     inline virtual void reportFinishedList(const NetworkId& netId) { SYNC(ARG(netId)) }
69     inline virtual void reportError(const QString& error) { SYNC(ARG(error)) }
70 };