First check-in of the Qtopia build system. See qtopia-build/README.
[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     Q_ASSERT(false); // FIXME: exception disabled for qtopia testing
81   else
82     return QSet<QString>();
83 }
84
85 void IrcUser::updateChannelmode(const QString &channel, const QString &channelmode, bool add) {
86   if(add)
87     addChannelmode(channel, channelmode);
88   else
89     removeChannelmode(channel, channelmode);
90 }
91
92 void IrcUser::addChannelmode(const QString &channel, const QString &channelmode) {
93   if(!channelmodes_.contains(channel))
94     channelmodes_[channel] = QSet<QString>();
95   channelmodes_[channel] << channelmode;
96 }
97
98 void IrcUser::removeChannelmode(const QString &channel, const QString &channelmode) {
99   if(channelmodes_.contains(channel))
100     channelmodes_[channel].remove(channelmode);
101 }
102
103 QStringList IrcUser::channels() const {
104   return channelmodes_.keys();
105 }
106
107 void IrcUser::joinChannel(const QString &channel) {
108   if(!channelmodes_.contains(channel))
109     channelmodes_[channel] = QSet<QString>();
110 }
111
112 void IrcUser::partChannel(const QString &channel) {
113   channelmodes_.remove(channel);
114 }