The complete source code of IdealIRC http://www.idealirc.org/
 
 
 
 
idealirc/IConfig/ServerMgr.h

66 lines
2.0 KiB

/*
* IdealIRC - Internet Relay Chat client
* Copyright (C) 2021 Tom-Andre Barstad.
* This software is licensed under the Software Attribution License.
* See LICENSE for more information.
*/
#ifndef SERVERMGR_H
#define SERVERMGR_H
#include <QObject>
#include <QStringList>
#include <QHash>
#include "IniFile.h"
/**
* @brief Manages servers.ini
* @details
* This class is from IdealIRC 0.x series and is going to be removed/replaced at any time.
*/
class ServerMgr : public QObject
{
Q_OBJECT
public:
explicit ServerMgr(QObject *parent = nullptr);
// All networks in a string list (Also counts in the NONE network)
QStringList networkList();
// All servers from a network in a hash map <"name","server:port|passwd">
QHash<QString,QString> serverList(const QString& network = "NONE");
// Return default server of given network (The "NONE" network have no default!) - returns empty if no default server is set.
QString defaultServer(const QString& network);
// Add new network to servers.ini - returns false if network exist
bool addNetwork(const QString& name);
// Rename a network - returns false if new network name already exist
bool renameNetwork(const QString& o_name, const QString& n_name);
// Delete network
void delNetwork(const QString& name, bool keep_servers = false);
// Add (or update) a server to network - returns false if network doesn't exsist
bool addServer(const QString& name, const QString& host /*host:port*/, const QString& pw = "", const QString& network = "NONE");
// Delete a server from network
void delServer(const QString& name, const QString& network = "NONE");
// Check of we have the given network name
bool hasNetwork(const QString& name);
// Check if we have the given server name inside the network
bool hasServer(const QString& name, const QString& network = "NONE");
// Get server details
QString getServerDetails(const QString& name, const QString& network = "NONE");
private:
IniFile ini;
};
#endif // SERVERMGR_H