1 /***************************************************************************
2 * Copyright (C) 2005-07 by the Quassel IRC Team *
3 * devel@quassel-irc.org *
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. *
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. *
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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #ifndef _NETWORKINFO_H_
22 #define _NETWORKINFO_H_
25 #include <QStringList>
28 #include <QVariantMap>
36 class NetworkInfo : public QObject {
39 Q_PROPERTY(QString networkName READ networkName WRITE setNetworkName STORED false)
40 Q_PROPERTY(QString currentServer READ currentServer WRITE setCurrentServer STORED false)
41 Q_PROPERTY(QString myNick READ myNick WRITE setMyNick STORED false)
44 NetworkInfo(const uint &networkid, QObject *parent = 0);
45 //virtual ~NetworkInfo();
47 uint networkId() const;
48 bool initialized() const;
50 SignalProxy *proxy() const;
51 void setProxy(SignalProxy *proxy);
53 bool isMyNick(const QString &nick) const;
54 bool isMyNick(IrcUser *ircuser) const;
56 bool isChannelName(const QString &channelname) const;
58 QString prefixToMode(const QString &prefix);
59 QString prefixToMode(const QCharRef &prefix);
60 QString modeToPrefix(const QString &mode);
61 QString modeToPrefix(const QCharRef &mode);
63 QString networkName() const;
64 QString currentServer() const;
65 QString myNick() const;
66 QStringList nicks() const;
67 QStringList channels() const;
70 QString prefixModes();
72 bool supports(const QString ¶m) const;
73 QString support(const QString ¶m) const;
75 IrcUser *newIrcUser(const QString &hostmask);
76 IrcUser *ircUser(QString nickname) const;
77 QList<IrcUser *> ircUsers() const;
79 IrcChannel *newIrcChannel(const QString &channelname);
80 IrcChannel *ircChannel(QString channelname);
81 QList<IrcChannel *> ircChannels() const;
84 void setNetworkName(const QString &networkName);
85 void setCurrentServer(const QString ¤tServer);
86 void setMyNick(const QString &mynick);
88 void addSupport(const QString ¶m, const QString &value = QString());
89 void removeSupport(const QString ¶m);
91 inline void addIrcUser(const QString &hostmask) { newIrcUser(hostmask); }
92 void removeIrcUser(QString nick);
95 QVariantMap initSupports() const;
96 QStringList initIrcUsers() const;
97 QStringList initIrcChannels() const;
100 void initSetSupports(const QVariantMap &supports);
101 void initSetIrcUsers(const QStringList &hostmasks);
102 void initSetChannels(const QStringList &channels);
104 IrcUser *updateNickFromMask(const QString &mask);
106 // these slots are to keep the hashlists of all users and the
107 // channel lists up to date
108 void ircUserNickChanged(QString newnick);
109 void setInitialized();
112 void ircUserDestroyed();
113 void channelDestroyed();
114 void removeIrcUser(IrcUser *ircuser);
117 void networkNameSet(const QString &networkName);
118 void currentServerSet(const QString ¤tServer);
119 void myNickSet(const QString &mynick);
121 void supportAdded(const QString ¶m, const QString &value);
122 void supportRemoved(const QString ¶m);
124 void ircUserAdded(QString hostmask);
125 void ircChannelAdded(QString channelname);
127 void ircUserRemoved(QString nick);
130 void ircUserInitDone();
131 void ircChannelInitDone();
138 QString _networkName;
139 QString _currentServer;
142 QString _prefixModes;
144 QHash<QString, IrcUser *> _ircUsers; // stores all known nicks for the server
145 QHash<QString, IrcChannel *> _ircChannels; // stores all known channels
146 QHash<QString, QString> _supports; // stores results from RPL_ISUPPORT
148 //QVariantMap networkSettings;
149 //QVariantMap identity;
151 QPointer<SignalProxy> _proxy;
152 void determinePrefixes();