1 /***************************************************************************
2 * Copyright (C) 2005/06 by The Quassel 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) any later version. *
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>
37 class NetworkInfo : public QObject {
40 Q_PROPERTY(QString networkName READ networkName WRITE setNetworkName STORED false)
41 Q_PROPERTY(QString currentServer READ currentServer WRITE setCurrentServer STORED false)
42 Q_PROPERTY(QString myNick READ myNick WRITE setMyNick STORED false)
45 NetworkInfo(const uint &networkid, SignalProxy *proxy, QObject *parent = 0);
46 // virtual ~NetworkInfo();
48 uint networkId() const;
49 bool initialized() const;
50 Synchronizer *synchronizer();
52 bool isMyNick(const QString &nick) const;
53 bool isMyNick(IrcUser *ircuser) const;
55 bool isChannelName(const QString &channelname) const;
57 QString prefixToMode(const QString &prefix);
58 QString prefixToMode(const QCharRef &prefix);
59 QString modeToPrefix(const QString &mode);
60 QString modeToPrefix(const QCharRef &mode);
62 QString networkName() const;
63 QString currentServer() const;
64 QString myNick() const;
65 QStringList nicks() const;
66 QStringList channels() const;
69 QString prefixModes();
71 bool supports(const QString ¶m) const;
72 QString support(const QString ¶m) const;
74 IrcUser *newIrcUser(const QString &hostmask);
75 IrcUser *ircUser(const QString &nickname) const;
76 QList<IrcUser *> ircUsers() const;
78 IrcChannel *newIrcChannel(const QString &channelname);
79 IrcChannel *ircChannel(const QString &channelname);
80 QList<IrcChannel *> ircChannels() const;
83 void setNetworkName(const QString &networkName);
84 void setCurrentServer(const QString ¤tServer);
85 void setMyNick(const QString &mynick);
87 void addSupport(const QString ¶m, const QString &value = QString());
88 void removeSupport(const QString ¶m);
90 inline void addIrcUser(const QString &hostmask) { newIrcUser(hostmask); }
93 QVariantMap initSupports() const;
94 QStringList initIrcUsers() const;
95 QStringList initIrcChannels() const;
98 void initSetSupports(const QVariantMap &supports);
99 void initSetIrcUsers(const QStringList &hostmasks);
100 void initSetChannels(const QStringList &channels);
102 IrcUser *updateNickFromMask(const QString &mask);
104 // these slots are to keep the hashlists of all users and the
105 // channel lists up to date
106 void ircUserNickChanged(QString newnick);
108 void ircUserDestroyed();
109 void channelDestroyed();
111 void setInitialized();
114 void networkNameSet(const QString &networkName);
115 void currentServerSet(const QString ¤tServer);
116 void myNickSet(const QString &mynick);
118 void supportAdded(const QString ¶m, const QString &value = QString());
119 void supportRemoved(const QString ¶m);
121 void ircUserAdded(QString hostmask);
122 void ircChannelAdded(QString channelname);
125 void ircUserInitDone();
126 void ircChannelInitDone();
133 QString _networkName;
134 QString _currentServer;
137 QString _prefixModes;
139 QHash<QString, IrcUser *> _ircUsers; // stores all known nicks for the server
140 QHash<QString, IrcChannel *> _ircChannels; // stores all known channels
141 QHash<QString, QString> _supports; // stores results from RPL_ISUPPORT
143 //QVariantMap networkSettings;
144 //QVariantMap identity;
146 QPointer<Synchronizer> _synchronizer;
148 void determinePrefixes();