1 /***************************************************************************
2 * Copyright (C) 2005-08 by the Quassel Project *
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>
32 #include "syncableobject.h"
39 class NetworkInfo : public SyncableObject {
42 Q_PROPERTY(QString networkName READ networkName WRITE setNetworkName STORED false)
43 Q_PROPERTY(QString currentServer READ currentServer WRITE setCurrentServer STORED false)
44 Q_PROPERTY(QString myNick READ myNick WRITE setMyNick STORED false)
47 NetworkInfo(const uint &networkid, QObject *parent = 0);
48 //virtual ~NetworkInfo();
50 NetworkId networkId() const;
51 bool initialized() const;
53 SignalProxy *proxy() const;
54 void setProxy(SignalProxy *proxy);
56 bool isMyNick(const QString &nick) const;
57 bool isMyNick(IrcUser *ircuser) const;
59 bool isChannelName(const QString &channelname) const;
61 QString prefixToMode(const QString &prefix);
62 QString prefixToMode(const QCharRef &prefix);
63 QString modeToPrefix(const QString &mode);
64 QString modeToPrefix(const QCharRef &mode);
66 QString networkName() const;
67 QString currentServer() const;
68 QString myNick() const;
69 QStringList nicks() const;
70 QStringList channels() const;
73 QString prefixModes();
75 bool supports(const QString ¶m) const;
76 QString support(const QString ¶m) const;
78 IrcUser *newIrcUser(const QString &hostmask);
79 IrcUser *newIrcUser(const QByteArray &hostmask);
80 IrcUser *ircUser(QString nickname) const;
81 IrcUser *ircUser(const QByteArray &nickname) const;
82 QList<IrcUser *> ircUsers() const;
84 IrcChannel *newIrcChannel(const QString &channelname);
85 IrcChannel *newIrcChannel(const QByteArray &channelname);
86 IrcChannel *ircChannel(QString channelname);
87 IrcChannel *ircChannel(const QByteArray &channelname);
89 QList<IrcChannel *> ircChannels() const;
91 QTextCodec *codecForEncoding() const;
92 QTextCodec *codecForDecoding() const;
93 void setCodecForEncoding(const QString &codecName);
94 void setCodecForEncoding(QTextCodec *codec);
95 void setCodecForDecoding(const QString &codecName);
96 void setCodecForDecoding(QTextCodec *codec);
98 QString decodeString(const QByteArray &text) const;
99 QByteArray encodeString(const QString string) const;
102 void setNetworkName(const QString &networkName);
103 void setCurrentServer(const QString ¤tServer);
104 void setMyNick(const QString &mynick);
106 void addSupport(const QString ¶m, const QString &value = QString());
107 void removeSupport(const QString ¶m);
109 inline void addIrcUser(const QString &hostmask) { newIrcUser(hostmask); }
110 void removeIrcUser(QString nick);
113 QVariantMap initSupports() const;
114 QStringList initIrcUsers() const;
115 QStringList initIrcChannels() const;
118 void initSetSupports(const QVariantMap &supports);
119 void initSetIrcUsers(const QStringList &hostmasks);
120 void initSetChannels(const QStringList &channels);
122 IrcUser *updateNickFromMask(const QString &mask);
124 // these slots are to keep the hashlists of all users and the
125 // channel lists up to date
126 void ircUserNickChanged(QString newnick);
127 void setInitialized();
130 void ircUserDestroyed();
131 void channelDestroyed();
132 void removeIrcUser(IrcUser *ircuser);
135 void networkNameSet(const QString &networkName);
136 void currentServerSet(const QString ¤tServer);
137 void myNickSet(const QString &mynick);
139 void supportAdded(const QString ¶m, const QString &value);
140 void supportRemoved(const QString ¶m);
142 void ircUserAdded(QString hostmask);
143 void ircChannelAdded(QString channelname);
145 void ircUserRemoved(QString nick);
148 void ircUserInitDone();
149 void ircChannelInitDone();
156 QString _networkName;
157 QString _currentServer;
160 QString _prefixModes;
162 QHash<QString, IrcUser *> _ircUsers; // stores all known nicks for the server
163 QHash<QString, IrcChannel *> _ircChannels; // stores all known channels
164 QHash<QString, QString> _supports; // stores results from RPL_ISUPPORT
166 //QVariantMap networkSettings;
167 //QVariantMap identity;
169 QPointer<SignalProxy> _proxy;
170 void determinePrefixes();
172 QTextCodec *_codecForEncoding;
173 QTextCodec *_codecForDecoding;