ircchatadapter.h
1 //------------------------------------------------------------------------------
2 // ircchatadapter.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 __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() override;
57 
68  void doSendMessage(const QString &message, IRCAdapterBase *pOrigin) override;
69 
73  virtual void emitChatMessage(const QString &sender, const QString &content);
74 
76  {
77  return this->pNetwork;
78  }
79 
80  QString recipient() const override
81  {
82  return this->recipientName;
83  }
84 
89  void setNetwork(IRCNetworkAdapter *pNetwork);
90 
94  QString title() const override;
95 
100  virtual void userChangesNickname(const QString &oldNickname, const QString &newNickname) = 0;
101 
105  virtual void userJoins(const QString &nickname, const QString &fullSignature) = 0;
106 
110  virtual void userLeaves(const QString &nickname, const QString &farewellMessage, IRCQuitType quitType) = 0;
111 
115  virtual void userModeChanges(const QString &nickname,
116  const QList<char> &addedFlags, const QList<char> &removedFlags) = 0;
117 
118 protected:
119  IRCNetworkAdapter *pNetwork;
120  QString recipientName;
121 
130  QString extractMessageLine(QStringList &words, int maxLength);
131 
132  void sendChatMessage(const QString &message);
133  void setRecipient(const QString &name);
134 };
135 
136 
137 #endif