X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fnetwork.h;h=704d67aacb4c918499aad65093e46a94c0bb597c;hp=84e86998fcb8f60d47cb1554ce5374e1ee7fe25c;hb=79fbcfb49f7cc92a89f0158ebac1a3006a559e8a;hpb=a5dfcc8ecf8b81025d24b3c5c816169e3e030ea4 diff --git a/src/common/network.h b/src/common/network.h index 84e86998..704d67aa 100644 --- a/src/common/network.h +++ b/src/common/network.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * + * Copyright (C) 2005-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -24,12 +24,14 @@ #include #include #include +#include #include #include #include #include #include "types.h" +#include "util.h" #include "syncableobject.h" #include "signalproxy.h" @@ -93,12 +95,21 @@ public: uint port; QString password; bool useSsl; - Server() : port(0), useSsl(false) {} - Server(const QString &host, uint port, const QString &password, bool useSsl) - : host(host), port(port), password(password), useSsl(useSsl) {} + int sslVersion; + + bool useProxy; + int proxyType; + QString proxyHost; + uint proxyPort; + QString proxyUser; + QString proxyPass; - static Server fromVariant(const QVariant &variant); - QVariant toVariant() const; + Server() : port(6667), useSsl(false), sslVersion(0), useProxy(false), proxyType(QNetworkProxy::Socks5Proxy), proxyHost("localhost"), proxyPort(8080) {} + Server(const QString &host, uint port, const QString &password, bool useSsl) + : host(host), port(port), password(password), useSsl(useSsl), sslVersion(0), + useProxy(false), proxyType(QNetworkProxy::Socks5Proxy), proxyHost("localhost"), proxyPort(8080) {} + bool operator==(const Server &other) const; + bool operator!=(const Server &other) const; }; typedef QList ServerList; @@ -136,7 +147,6 @@ public: QStringList nicks() const; inline QStringList channels() const { return _ircChannels.keys(); } inline const ServerList &serverList() const { return _serverList; } - QVariantList variantServerList() const; inline bool useRandomServer() const { return _useRandomServer; } inline const QStringList &perform() const { return _perform; } inline bool useAutoIdentify() const { return _useAutoIdentify; } @@ -193,6 +203,10 @@ public: inline bool autoAwayActive() const { return _autoAwayActive; } inline void setAutoAwayActive(bool active) { _autoAwayActive = active; } + static QStringList presetNetworks(bool onlyDefault = false); + static QStringList presetDefaultChannels(const QString &networkName); + static NetworkInfo networkInfoFromPreset(const QString &networkName); + public slots: void setNetworkName(const QString &networkName); void setCurrentServer(const QString ¤tServer); @@ -226,12 +240,12 @@ public slots: //init geters QVariantMap initSupports() const; - inline QVariantList initServerList() const { return variantServerList(); } + inline QVariantList initServerList() const { return toVariantList(serverList()); } virtual QVariantMap initIrcUsersAndChannels() const; //init seters void initSetSupports(const QVariantMap &supports); - void initSetServerList(const QVariantList &serverList); + inline void initSetServerList(const QVariantList &serverList) { _serverList = fromVariantList(serverList); } virtual void initSetIrcUsersAndChannels(const QVariantMap &usersAndChannels); IrcUser *updateNickFromMask(const QString &mask); @@ -340,12 +354,17 @@ private: bool _autoAwayActive; // when this is active handle305 and handle306 don't trigger any output + static QString _networksIniPath; + friend class IrcUser; friend class IrcChannel; }; //! Stores all editable information about a network (as opposed to runtime state). struct NetworkInfo { + // set some default values, note that this does not initialize e.g. name and id + NetworkInfo(); + NetworkId networkId; QString networkName; IdentityId identity; @@ -355,8 +374,7 @@ struct NetworkInfo { QByteArray codecForEncoding; QByteArray codecForDecoding; - // Server entry: QString "Host", uint "Port", QString "Password", bool "UseSSL" - QVariantList serverList; + Network::ServerList serverList; bool useRandomServer; QStringList perform; @@ -378,7 +396,11 @@ struct NetworkInfo { QDataStream &operator<<(QDataStream &out, const NetworkInfo &info); QDataStream &operator>>(QDataStream &in, NetworkInfo &info); QDebug operator<<(QDebug dbg, const NetworkInfo &i); - Q_DECLARE_METATYPE(NetworkInfo) +QDataStream &operator<<(QDataStream &out, const Network::Server &server); +QDataStream &operator>>(QDataStream &in, Network::Server &server); +QDebug operator<<(QDebug dbg, const Network::Server &server); +Q_DECLARE_METATYPE(Network::Server) + #endif