ircchatadapter.h
1 //------------------------------------------------------------------------------
2 // ircchatadapter.h
3 //------------------------------------------------------------------------------
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (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 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 __IRCCHATADAPTER_H__
24 #define __IRCCHATADAPTER_H__
25 
26 #include "irc/ircadapterbase.h"
27 #include <QStringList>
28 
29 class IRCNetworkAdapter;
30 
40 {
41  public:
42  enum IRCQuitType
43  {
44  ChannelPart,
45  NetworkKill,
46  NetworkQuit
47  };
48 
55  IRCChatAdapter(IRCNetworkAdapter* pNetwork, const QString& recipient);
56  virtual ~IRCChatAdapter();
57 
68  void doSendMessage(const QString& message, IRCAdapterBase* pOrigin);
69 
73  virtual void emitChatMessage(const QString& sender, const QString& content);
74 
76  {
77  return this->pNetwork;
78  }
79 
80  QString recipient() const { return this->recipientName; }
81 
86  void setNetwork(IRCNetworkAdapter* pNetwork);
87 
91  QString title() const;
92 
97  virtual void userChangesNickname(const QString& oldNickname, const QString& newNickname) = 0;
98 
102  virtual void userJoins(const QString& nickname, const QString& fullSignature) = 0;
103 
107  virtual void userLeaves(const QString& nickname, const QString& farewellMessage, IRCQuitType quitType) = 0;
108 
112  virtual void userModeChanges(const QString& nickname,
113  const QList<char> &addedFlags, const QList<char> &removedFlags) = 0;
114 
115  protected:
116  IRCNetworkAdapter* pNetwork;
117  QString recipientName;
118 
127  QString extractMessageLine(QStringList& words, int maxLength);
128 
129  void sendChatMessage(const QString& message);
130  void setRecipient(const QString& name);
131 };
132 
133 
134 #endif
Interprets communication between the client and the IRC server.
void setNetwork(IRCNetworkAdapter *pNetwork)
Sets IRCNetworkAdapter for this chat window. This adapter is not detached from the old network...
Provides an unified communication interface between a client and IRC network entities.
virtual void emitChatMessage(const QString &sender, const QString &content)
Emits message() signal formatting it to present sender's message.
Handles chatting through IRC.
virtual void userModeChanges(const QString &nickname, const QList< char > &addedFlags, const QList< char > &removedFlags)=0
Use this to register the fact that user MODE flags have changed.
IRCNetworkAdapter * network()
The idea of the adapter system is that each adapter is either a network or is a child of a network...
QString title() const
For chat adapters this will return recipientName.
virtual void userChangesNickname(const QString &oldNickname, const QString &newNickname)=0
Use this to register the fact that user has changed his/hers nickname.
IRCChatAdapter(IRCNetworkAdapter *pNetwork, const QString &recipient)
virtual void userJoins(const QString &nickname, const QString &fullSignature)=0
Use this to register the fact that user has joined the chat.
QString extractMessageLine(QStringList &words, int maxLength)
void doSendMessage(const QString &message, IRCAdapterBase *pOrigin)
virtual void userLeaves(const QString &nickname, const QString &farewellMessage, IRCQuitType quitType)=0
Use this to register the fact that user has left the chat.