Got rid of class Global, as promised. For now, the few global variables we still
[quassel.git] / src / core / serverinfo.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005-07 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 #include "serverinfo.h"
21
22 ServerInfo::ServerInfo(QObject *parent)
23   : QObject(parent) {
24 }
25
26 ServerInfo::~ServerInfo() {
27 }
28
29 void ServerInfo::setNetworkname(const QString &networkname) {
30   networkname_ = networkname;
31 }
32
33 QString ServerInfo::networkname() const {
34   return networkname_;
35 }
36
37 void ServerInfo::setCurrentServer(const QString &currentServer) {
38   currentServer_ = currentServer;
39 }
40
41 QString ServerInfo::currentServer() const {
42   return currentServer_;
43 }
44
45 void ServerInfo::setOwnNick(const QString &ownnick) {
46   ownNick_ = ownnick;
47 }
48
49 QString ServerInfo::ownNick() const {
50   return ownNick_;
51 }
52
53 QList<IrcUser *> ServerInfo::ircUsers() const {
54   return ircUsers_.values();
55 }
56
57
58 IrcUser *ServerInfo::newIrcUser(const QString &hostmask) {
59   IrcUser *ircuser = new IrcUser(hostmask);
60   return ircUsers_[ircuser->nick()] = ircuser;
61 }
62
63 IrcUser *ServerInfo::ircUser(const QString &nickname) const {
64   if(ircUsers_.contains(nickname))
65     return ircUsers_[nickname];
66   else
67     throw NoSuchNickException();
68 }
69
70 void ServerInfo::setTopics(const QHash<QString, QString> &topics) {
71   topics_ = topics;
72 }
73
74 QHash<QString, QString> ServerInfo::topics() const {
75   return topics_;
76 }
77
78 void ServerInfo::updateTopic(const QString &channel, const QString &topic) {
79   topics_[channel] = topic;
80 }
81
82 QString ServerInfo::topic(const QString &channel) const {
83   if(topics_.contains(channel))
84     return topics_[channel];
85   else
86     throw NoSuchChannelException();
87 }
88
89 void ServerInfo::setSupports(const QHash<QString, QString> &supports) {
90   supports_ = supports;
91 }
92
93 QHash<QString, QString> ServerInfo::supports() const {
94   return supports_;
95 }
96
97 QString ServerInfo::supports(const QString &feature) const {
98   if(supports_.contains(feature))
99     return supports_[feature];
100   else
101     throw UnsupportedFeatureException();
102 }
103
104 bool ServerInfo::isOwnNick(const QString &nick) const {
105   return (ownNick_.toLower() == nick.toLower());
106 }
107
108 bool ServerInfo::isOwnNick(const IrcUser &ircuser) const {
109   return (ircuser.nick().toLower() == ownNick_.toLower());
110 }
111
112