ircchanneladapter.h
1 //------------------------------------------------------------------------------
2 // ircchanneladapter.h
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library 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 GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2010 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #ifndef __IRCCHANNELADAPTER_H__
24 #define __IRCCHANNELADAPTER_H__
25 
26 #include "irc/ircchatadapter.h"
27 #include <QStringList>
28 
29 class IRCUserInfo;
30 class IRCUserList;
31 
36 {
37  Q_OBJECT
38 
39 public:
40  IRCChannelAdapter(IRCNetworkAdapter *pNetwork, const QString &recipient);
41  ~IRCChannelAdapter() override;
42 
43  AdapterType adapterType() const override
44  {
45  return ChannelAdapter;
46  }
47 
51  bool amIOperator() const;
52 
59  void appendNameToCachedList(const QString &name);
60 
65  void appendNamesToCachedList(const QStringList &names);
66 
76  void banUser(const QString &nickname, const QString &reason);
77 
83  void emitChatMessage(const QString &sender, const QString &content) override;
84 
85  bool hasUser(const QString &nickname);
86 
90  bool isOperator(const QString &nickname) const;
91 
101  void kickUser(const QString &nickname, const QString &reason);
102 
103 
109  void removeNameFromCachedList(const QString &name);
110 
114  void setHalfOp(const QString &nickname, bool bSet);
115 
121  void setOp(const QString &nickname, bool bSet);
122 
128  void setVoiced(const QString &nickname, bool bSet);
129 
134  void userChangesNickname(const QString &oldNickname, const QString &newNickname) override;
135  void userJoins(const QString &nickname, const QString &fullSignature) override;
136  void userLeaves(const QString &nickname, const QString &farewellMessage, IRCQuitType quitType) override;
137 
142  void userModeChanges(const QString &nickname, const QList<char> &addedFlags, const QList<char> &removedFlags) override;
143 
144 signals:
150  void myNicknameUsed();
151  void nameAdded(const IRCUserInfo &userInfo);
152  void nameListUpdated(const IRCUserList &names);
153  void nameRemoved(const IRCUserInfo &userInfo);
154  void nameUpdated(const IRCUserInfo &userInfo);
155 
156 private:
157  IRCUserList *users;
158 
167  bool addName(const QString &name);
168 };
169 
170 #endif
Interprets communication between the client and the IRC server.
void userLeaves(const QString &nickname, const QString &farewellMessage, IRCQuitType quitType) override
Use this to register the fact that user has left the chat.
Allows to perform operation on a list of users.
Definition: ircuserlist.h:42
void emitCachedNameListUpdated()
Emits cached list of names. This should be called when end of names list message is received for this...
Class type that is used for conversations within a channel.
void myNicknameUsed()
Emitted when nickname is used in a message.
void kickUser(const QString &nickname, const QString &reason)
Kicks user from the channel.
void userJoins(const QString &nickname, const QString &fullSignature) override
Use this to register the fact that user has joined the chat.
void removeNameFromCachedList(const QString &name)
Removes a name from the sortecd cachedNames list.
void setHalfOp(const QString &nickname, bool bSet)
Sets half op mode for given user.
void appendNamesToCachedList(const QStringList &names)
Appends a list of names to cachedNames list. This ensures that no duplicate names are found on the li...
void userChangesNickname(const QString &oldNickname, const QString &newNickname) override
bool amIOperator() const
Checks if this client is an operator on this channel.
Handles chatting through IRC.
AdapterType adapterType() const override
Gets adapter type for this adapter instance.
void banUser(const QString &nickname, const QString &reason)
Bans and kicks user from the channel.
void emitChatMessage(const QString &sender, const QString &content) override
Emits message() signal formatting it to present sender&#39;s message.
void setVoiced(const QString &nickname, bool bSet)
Sets voice mode for given user.
AdapterType
Defines all possible types of IRC adapters.
Holds information flags about given nickname.
Definition: ircuserinfo.h:35
void setOp(const QString &nickname, bool bSet)
Sets op mode for given user.
void userModeChanges(const QString &nickname, const QList< char > &addedFlags, const QList< char > &removedFlags) override
bool isOperator(const QString &nickname) const
Checks if user is an operator on this channel.
void appendNameToCachedList(const QString &name)
Appends a single name to the sorted cachedNames list.