X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fnetworkinfo.h;fp=src%2Fcommon%2Fnetworkinfo.h;h=6f2ab48251ec67a93d6ed016e2dd9b2898a12ee1;hp=0000000000000000000000000000000000000000;hb=902c95728306e5ba115de84800fc8d5d239c9d62;hpb=06a46322b6107fe4a38c310a6292cc1ef3330950 diff --git a/src/common/networkinfo.h b/src/common/networkinfo.h new file mode 100644 index 00000000..6f2ab482 --- /dev/null +++ b/src/common/networkinfo.h @@ -0,0 +1,151 @@ +/*************************************************************************** + * Copyright (C) 2005/06 by The Quassel Team * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _NETWORKINFO_H_ +#define _NETWORKINFO_H_ + +#include +#include +#include +#include +#include +#include + +class SignalProxy; +class Synchronizer; +class IrcUser; +class IrcChannel; + + +class NetworkInfo : public QObject { + Q_OBJECT + + Q_PROPERTY(QString networkName READ networkName WRITE setNetworkName STORED false) + Q_PROPERTY(QString currentServer READ currentServer WRITE setCurrentServer STORED false) + Q_PROPERTY(QString myNick READ myNick WRITE setMyNick STORED false) + +public: + NetworkInfo(const uint &networkid, SignalProxy *proxy, QObject *parent = 0); + // virtual ~NetworkInfo(); + + uint networkId() const; + bool initialized() const; + Synchronizer *synchronizer(); + + bool isMyNick(const QString &nick) const; + bool isMyNick(IrcUser *ircuser) const; + + bool isChannelName(const QString &channelname) const; + + QString prefixToMode(const QString &prefix); + QString prefixToMode(const QCharRef &prefix); + QString modeToPrefix(const QString &mode); + QString modeToPrefix(const QCharRef &mode); + + QString networkName() const; + QString currentServer() const; + QString myNick() const; + QStringList nicks() const; + QStringList channels() const; + + QString prefixes(); + QString prefixModes(); + + bool supports(const QString ¶m) const; + QString support(const QString ¶m) const; + + IrcUser *newIrcUser(const QString &hostmask); + IrcUser *ircUser(const QString &nickname) const; + QList ircUsers() const; + + IrcChannel *newIrcChannel(const QString &channelname); + IrcChannel *ircChannel(const QString &channelname); + QList ircChannels() const; + +public slots: + void setNetworkName(const QString &networkName); + void setCurrentServer(const QString ¤tServer); + void setMyNick(const QString &mynick); + + void addSupport(const QString ¶m, const QString &value = QString()); + void removeSupport(const QString ¶m); + + inline void addIrcUser(const QString &hostmask) { newIrcUser(hostmask); } + + //init geters + QVariantMap initSupports() const; + QStringList initIrcUsers() const; + QStringList initIrcChannels() const; + + //init seters + void initSetSupports(const QVariantMap &supports); + void initSetIrcUsers(const QStringList &hostmasks); + void initSetChannels(const QStringList &channels); + + IrcUser *updateNickFromMask(const QString &mask); + + // these slots are to keep the hashlists of all users and the + // channel lists up to date + void ircUserNickChanged(QString newnick); + + void ircUserDestroyed(); + void channelDestroyed(); + + void setInitialized(); + +signals: + void networkNameSet(const QString &networkName); + void currentServerSet(const QString ¤tServer); + void myNickSet(const QString &mynick); + + void supportAdded(const QString ¶m, const QString &value = QString()); + void supportRemoved(const QString ¶m); + + void ircUserAdded(QString hostmask); + void ircChannelAdded(QString channelname); + + void initDone(); + void ircUserInitDone(); + void ircChannelInitDone(); + +private: + uint _networkId; + bool _initialized; + + QString _myNick; + QString _networkName; + QString _currentServer; + + QString _prefixes; + QString _prefixModes; + + QHash _ircUsers; // stores all known nicks for the server + QHash _ircChannels; // stores all known channels + QHash _supports; // stores results from RPL_ISUPPORT + + //QVariantMap networkSettings; + //QVariantMap identity; + + QPointer _synchronizer; + + void determinePrefixes(); +}; + +#endif