2019-09-08 18:06:43 +02:00
|
|
|
#pragma once
|
|
|
|
|
2019-09-09 22:26:14 +02:00
|
|
|
#include <rapidjson/rapidjson.h>
|
2019-09-08 18:06:43 +02:00
|
|
|
#include <common/SignalVector.hpp>
|
|
|
|
|
2019-09-09 22:26:14 +02:00
|
|
|
#include "providers/irc/IrcChannel2.hpp"
|
|
|
|
#include "providers/irc/IrcServer.hpp"
|
|
|
|
|
2019-09-08 18:06:43 +02:00
|
|
|
class QAbstractTableModel;
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
|
|
|
struct IrcConnection_ {
|
|
|
|
QString host;
|
|
|
|
int port;
|
|
|
|
bool ssl;
|
|
|
|
|
|
|
|
QString user;
|
|
|
|
QString nick;
|
|
|
|
QString password;
|
|
|
|
|
|
|
|
int id;
|
|
|
|
|
|
|
|
// makes an IrcConnection with a unique id
|
|
|
|
static IrcConnection_ unique();
|
|
|
|
};
|
|
|
|
|
|
|
|
class Irc
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Irc();
|
|
|
|
|
|
|
|
static Irc &getInstance();
|
|
|
|
|
|
|
|
UnsortedSignalVector<IrcConnection_> connections;
|
|
|
|
QAbstractTableModel *newConnectionModel(QObject *parent);
|
|
|
|
|
2019-09-09 22:26:14 +02:00
|
|
|
IrcServer *getServerOfChannel(Channel *channel);
|
|
|
|
ChannelPtr getOrAddChannel(int serverId, QString name);
|
|
|
|
|
2019-09-08 18:06:43 +02:00
|
|
|
signals:
|
|
|
|
void connectionUpdated(int id);
|
2019-09-09 22:26:14 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Servers have a unique id.
|
|
|
|
// When a server gets changed it gets removed and then added again.
|
|
|
|
// So we store the channels of that server in abandonedChannels_ temporarily.
|
|
|
|
// Or if the server got removed permanently then it's still stored there.
|
|
|
|
std::unordered_map<int, std::unique_ptr<IrcServer>> servers_;
|
|
|
|
std::unordered_map<int, std::vector<std::weak_ptr<Channel>>>
|
|
|
|
abandonedChannels_;
|
2019-09-08 18:06:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace chatterino
|