1 /***************************************************************************
2 * Copyright (C) 2005-2015 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 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
27 #include <QStringList>
28 #include <QVariantMap>
30 #include "syncableobject.h"
35 class IrcChannel : public SyncableObject
40 Q_PROPERTY(QString name READ name)
41 Q_PROPERTY(QString topic READ topic WRITE setTopic)
42 Q_PROPERTY(QString password READ password WRITE setPassword)
43 Q_PROPERTY(bool encrypted READ encrypted WRITE setEncrypted)
46 IrcChannel(const QString &channelname, Network *network);
49 bool isKnownUser(IrcUser *ircuser) const;
50 bool isValidChannelUserMode(const QString &mode) const;
52 inline QString name() const { return _name; }
53 inline QString topic() const { return _topic; }
54 inline QString password() const { return _password; }
55 inline bool encrypted() const { return _encrypted; }
56 inline Network *network() const { return _network; }
58 inline QList<IrcUser *> ircUsers() const { return _userModes.keys(); }
60 QString userModes(IrcUser *ircuser) const;
61 QString userModes(const QString &nick) const;
63 bool hasMode(const QChar &mode) const;
64 QString modeValue(const QChar &mode) const;
65 QStringList modeValueList(const QChar &mode) const;
66 QString channelModeString() const;
68 inline QTextCodec *codecForEncoding() const { return _codecForEncoding; }
69 inline QTextCodec *codecForDecoding() const { return _codecForDecoding; }
70 void setCodecForEncoding(const QString &codecName);
71 void setCodecForEncoding(QTextCodec *codec);
72 void setCodecForDecoding(const QString &codecName);
73 void setCodecForDecoding(QTextCodec *codec);
75 QString decodeString(const QByteArray &text) const;
76 QByteArray encodeString(const QString &string) const;
79 void setTopic(const QString &topic);
80 void setPassword(const QString &password);
81 void setEncrypted(bool encrypted);
83 void joinIrcUsers(const QList<IrcUser *> &users, const QStringList &modes);
84 void joinIrcUsers(const QStringList &nicks, const QStringList &modes);
85 void joinIrcUser(IrcUser *ircuser);
87 void part(IrcUser *ircuser);
88 void part(const QString &nick);
90 void setUserModes(IrcUser *ircuser, const QString &modes);
91 void setUserModes(const QString &nick, const QString &modes);
93 void addUserMode(IrcUser *ircuser, const QString &mode);
94 void addUserMode(const QString &nick, const QString &mode);
96 void removeUserMode(IrcUser *ircuser, const QString &mode);
97 void removeUserMode(const QString &nick, const QString &mode);
99 void addChannelMode(const QChar &mode, const QString &value);
100 void removeChannelMode(const QChar &mode, const QString &value);
103 QVariantMap initUserModes() const;
104 QVariantMap initChanModes() const;
107 void initSetUserModes(const QVariantMap &usermodes);
108 void initSetChanModes(const QVariantMap &chanModes);
111 void topicSet(const QString &topic); // needed by NetworkModel
112 void encryptedSet(bool encrypted);
113 // void passwordSet(const QString &password);
114 // void userModesSet(QString nick, QString modes);
115 // void userModeAdded(QString nick, QString mode);
116 // void userModeRemoved(QString nick, QString mode);
117 // void channelModeAdded(const QChar &mode, const QString &value);
118 // void channelModeRemoved(const QChar &mode, const QString &value);
120 void ircUsersJoined(QList<IrcUser *> ircusers);
121 // void ircUsersJoined(QStringList nicks, QStringList modes);
122 void ircUserParted(IrcUser *ircuser);
123 void ircUserNickSet(IrcUser *ircuser, QString nick);
124 void ircUserModeAdded(IrcUser *ircuser, QString mode);
125 void ircUserModeRemoved(IrcUser *ircuser, QString mode);
126 void ircUserModesSet(IrcUser *ircuser, QString modes);
128 void parted(); // convenience signal emitted before channels destruction
131 void ircUserDestroyed();
132 void ircUserNickSet(QString nick);
141 QHash<IrcUser *, QString> _userModes;
145 QTextCodec *_codecForEncoding;
146 QTextCodec *_codecForDecoding;
148 QHash<QChar, QStringList> _A_channelModes;
149 QHash<QChar, QString> _B_channelModes;
150 QHash<QChar, QString> _C_channelModes;
151 QSet<QChar> _D_channelModes;