Communi  3.4.0
A cross-platform IRC framework written with Qt
ircprotocol.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008-2015 The Communi Project
3 
4  You may use this file under the terms of BSD license as follows:
5 
6  Redistribution and use in source and binary forms, with or without
7  modification, are permitted provided that the following conditions are met:
8  * Redistributions of source code must retain the above copyright
9  notice, this list of conditions and the following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright
11  notice, this list of conditions and the following disclaimer in the
12  documentation and/or other materials provided with the distribution.
13  * Neither the name of the copyright holder nor the names of its
14  contributors may be used to endorse or promote products derived
15  from this software without specific prior written permission.
16 
17  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
21  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
29 #ifndef IRCPROTOCOL_H
30 #define IRCPROTOCOL_H
31 
32 #include <IrcGlobal>
33 #include <IrcConnection>
34 #include <QtCore/qset.h>
35 #include <QtCore/qhash.h>
36 #include <QtCore/qobject.h>
37 #include <QtCore/qscopedpointer.h>
38 #include <QtNetwork/qabstractsocket.h>
39 
40 IRC_BEGIN_NAMESPACE
41 
42 class IrcMessage;
43 class IrcProtocolPrivate;
44 
45 class IRC_CORE_EXPORT IrcProtocol : public QObject
46 {
47  Q_OBJECT
48  Q_PROPERTY(IrcConnection* connection READ connection)
49  Q_PROPERTY(QAbstractSocket* socket READ socket)
50 
51 public:
52  explicit IrcProtocol(IrcConnection* connection);
53  virtual ~IrcProtocol();
54 
55  IrcConnection* connection() const;
56  QAbstractSocket* socket() const;
57 
58  virtual void open();
59  virtual void close();
60 
61  virtual void read();
62  virtual bool write(const QByteArray& data);
63 
64 public Q_SLOTS:
65  void receiveMessage(IrcMessage* message);
66 
67 protected Q_SLOTS:
68  void setNickName(const QString& name);
69  void setStatus(IrcConnection::Status status);
70  void setInfo(const QHash<QString, QString>& info);
71  void setAvailableCapabilities(const QSet<QString>& capabilities);
72  void setActiveCapabilities(const QSet<QString>& capabilities);
73 
74 private:
75  QScopedPointer<IrcProtocolPrivate> d_ptr;
76  Q_DECLARE_PRIVATE(IrcProtocol)
77  Q_DISABLE_COPY(IrcProtocol)
78 
79  Q_PRIVATE_SLOT(d_func(), void _irc_pauseHandshake())
80  Q_PRIVATE_SLOT(d_func(), void _irc_resumeHandshake())
81 };
82 
83 IRC_END_NAMESPACE
84 
85 #endif // IRCPROTOCOL_H
Provides means to establish a connection to an IRC server.
Definition: ircconnection.h:48
Implements the IRC protocol and provides means for implementing support for custom protocols...
Definition: ircprotocol.h:45
The base class of all messages.
Definition: ircmessage.h:47