Work-in-progress: use progress bar
[quassel.git] / src / core / serverinfo.h
1 /***************************************************************************
2  *   Copyright (C) 2005/06 by The Quassel Team                             *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
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.                                   *
9  *                                                                         *
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.                          *
14  *                                                                         *
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  ***************************************************************************/
20
21 #ifndef _SERVERINFO_H_
22 #define _SERVERINFO_H_
23
24 #include <QString>
25 #include <QList>
26 #include <QHash>
27
28 #include "global.h"
29 #include "ircuser.h"
30
31 class ServerInfo : public QObject {
32   Q_OBJECT
33   
34   Q_PROPERTY(QString networkname READ networkname WRITE setNetworkname)
35   Q_PROPERTY(QString currentServer READ currentServer WRITE setCurrentServer)
36   Q_PROPERTY(QString ownNick READ ownNick WRITE setOwnNick)
37   Q_PROPERTY(QList<IrcUser *> ircUsers READ ircUsers)
38   
39 public:
40   ServerInfo(QObject *parent = 0);
41   ~ServerInfo();
42
43   void setNetworkname(const QString &networkname);
44   QString networkname() const;
45   
46   void setCurrentServer(const QString &currentServer);
47   QString currentServer() const;
48   
49   void setOwnNick(const QString &ownnick);
50   QString ownNick() const;
51   
52   QList<IrcUser *> ircUsers() const;
53   IrcUser *newIrcUser(const QString &hostmask);
54   IrcUser *ircUser(const QString &nickname) const;
55   
56   void setTopics(const QHash<QString, QString> &topics);
57   QHash<QString, QString> topics() const;
58   
59   void updateTopic(const QString &channel, const QString &topic);
60   QString topic(const QString &channel) const;
61   
62   void setSupports(const QHash<QString, QString> &supports);
63   QHash<QString, QString> supports() const;
64   QString supports(const QString &feature) const;
65   
66   bool isOwnNick(const QString &nick) const;
67   bool isOwnNick(const IrcUser &ircuser) const;
68   
69 private:
70   QString networkname_;
71   QString currentServer_;
72   QString ownNick_;
73   
74   //VarMap networkSettings;
75   //VarMap identity;
76   
77   QHash<QString, IrcUser *> ircUsers_;  // stores all known nicks for the server
78   QHash<QString, QString> topics_; // stores topics for each buffer
79   QHash<QString, QString> supports_;  // stores results from RPL_ISUPPORT
80 };
81
82 struct UnsupportedFeatureException : public Exception {};
83
84 #endif