ircadapterbase.h
1 //------------------------------------------------------------------------------
2 // ircadapterbase.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 __IRCADAPTERBASE_H__
24 #define __IRCADAPTERBASE_H__
25 
26 #include <QObject>
27 
28 
29 class IRCMessageClass;
30 class IRCNetworkAdapter;
31 class IRCNetworkEntity;
32 
37 class IRCAdapterBase : public QObject
38 {
39  Q_OBJECT
40 
41  public:
46  {
47  NetworkAdapter,
48  ChannelAdapter,
49  PrivAdapter
50  };
51 
55  virtual ~IRCAdapterBase()
56  {
57  emit terminating();
58  }
59 
63  virtual AdapterType adapterType() const = 0;
64 
79  virtual void doSendMessage(const QString& message, IRCAdapterBase* pOrigin) = 0;
80 
81  void emitError(const QString& strError)
82  {
83  emit error(strError);
84  }
85 
86  void emitFocusRequest()
87  {
88  emit focusRequest();
89  }
90 
91  void emitMessage(const QString& strMessage)
92  {
93  emit message(strMessage);
94  }
95 
96  void emitMessageWithClass(const QString& strMessage, const IRCMessageClass& messageClass)
97  {
98  emit messageWithClass(strMessage, messageClass);
99  }
100 
108  virtual IRCNetworkAdapter* network() = 0;
109  const IRCNetworkEntity &networkEntity() const;
110 
111  virtual QString recipient() const
112  {
113  return QString();
114  };
115 
119  virtual QString title() const = 0;
120 
121  public slots:
122  void emitMessageToAllChatBoxes(const QString &message, const IRCMessageClass &msgClass);
123 
124  void sendMessage(const QString& message)
125  {
126  doSendMessage(message, NULL);
127  }
128 
129  signals:
130  void error(const QString& error);
131 
135  void focusRequest();
136 
137  void message(const QString& message);
138  void messageWithClass(const QString& message, const IRCMessageClass& messageClass);
139  void messageToNetworksCurrentChatBox(const QString &message, const IRCMessageClass &msgClass);
140 
141  void terminating();
142 
148  void titleChange();
149 };
150 
151 #endif
Interprets communication between the client and the IRC server.
Provides an unified communication interface between a client and IRC network entities.
virtual AdapterType adapterType() const =0
Gets adapter type for this adapter instance.
virtual QString title() const =0
Gets title for this adapter.
void titleChange()
Can be called when the variable returned by title() might have changed and the application should be ...
AdapterType
Defines all possible types of IRC adapters.
void focusRequest()
Called when this adapter requests UI focus.
virtual IRCNetworkAdapter * network()=0
The idea of the adapter system is that each adapter is either a network or is a child of a network...
Data structure that describes and defines a connection to an IRC network or server.
virtual void doSendMessage(const QString &message, IRCAdapterBase *pOrigin)=0
Implement to handle and send a message to the IRC network entity.
virtual ~IRCAdapterBase()
Destructor emits terminating() signal.