No new features here... (adding/testing of new files)
[quassel.git] / src / common / ircuser.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
21 #include "ircuser.h"
22 #include "util.h"
23
24 IrcUser::IrcUser(QObject *parent)
25   : QObject(parent) {
26 }
27
28 IrcUser::IrcUser(const QString &hostmask, QObject *parent) 
29   : QObject(parent),
30     nick_(nickFromMask(hostmask)),
31     user_(userFromMask(hostmask)),
32     host_(hostFromMask(hostmask)) {
33 }
34
35 IrcUser::~IrcUser() {
36 }
37
38 void IrcUser::setUser(const QString &user) {
39   user_ = user;
40 }
41
42 QString IrcUser::user() const {
43   return user_;
44 }
45
46 void IrcUser::setHost(const QString &host) {
47   host_ = host;
48 }
49
50 QString IrcUser::host() const {
51   return host_;
52 }
53
54 void IrcUser::setNick(const QString &nick) {
55   nick_ = nick;
56 }
57
58 QString IrcUser::nick() const {
59   return nick_;
60 }
61
62 void IrcUser::setUsermodes(const QSet<QString> &usermodes) {
63   usermodes_ = usermodes;
64 }
65
66 QSet<QString> IrcUser::usermodes() const {
67   return usermodes_;
68 }
69
70 void IrcUser::setChannelmode(const QString &channel, const QSet<QString> &channelmode) {
71   if(channelmodes_.contains(channel))
72     channelmodes_[channel] |= channelmode;
73   else
74     channelmodes_[channel] = channelmode;
75 }
76
77 QSet<QString> IrcUser::channelmode(const QString &channel) const {
78   if(channelmodes_.contains(channel))
79     throw NoSuchChannelException();
80   else
81     return QSet<QString>();
82 }
83
84 void IrcUser::updateChannelmode(const QString &channel, const QString &channelmode, bool add) {
85   if(add)
86     addChannelmode(channel, channelmode);
87   else
88     removeChannelmode(channel, channelmode);
89 }
90
91 void IrcUser::addChannelmode(const QString &channel, const QString &channelmode) {
92   if(!channelmodes_.contains(channel))
93     channelmodes_[channel] = QSet<QString>();
94   channelmodes_[channel] << channelmode;
95 }
96
97 void IrcUser::removeChannelmode(const QString &channel, const QString &channelmode) {
98   if(channelmodes_.contains(channel))
99     channelmodes_[channel].remove(channelmode);
100 }
101
102 QStringList IrcUser::channels() const {
103   return channelmodes_.keys();
104 }
105
106 void IrcUser::joinChannel(const QString &channel) {
107   if(!channelmodes_.contains(channel))
108     channelmodes_[channel] = QSet<QString>();
109 }
110
111 void IrcUser::partChannel(const QString &channel) {
112   channelmodes_.remove(channel);
113 }