Communi  3.4.0
A cross-platform IRC framework written with Qt
ircbuffer.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 IRCBUFFER_H
30 #define IRCBUFFER_H
31 
32 #include <Irc>
33 #include <IrcGlobal>
34 #include <QtCore/qobject.h>
35 #include <QtCore/qvariant.h>
36 #include <QtCore/qmetatype.h>
37 #include <QtCore/qscopedpointer.h>
38 
39 IRC_BEGIN_NAMESPACE
40 
41 class IrcChannel;
42 class IrcCommand;
43 class IrcMessage;
44 class IrcNetwork;
45 class IrcConnection;
46 class IrcBufferModel;
47 class IrcBufferPrivate;
48 
49 class IRC_MODEL_EXPORT IrcBuffer : public QObject
50 {
51  Q_OBJECT
52  Q_PROPERTY(QString title READ title NOTIFY titleChanged)
53  Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
54  Q_PROPERTY(QString prefix READ prefix WRITE setPrefix NOTIFY prefixChanged)
55  Q_PROPERTY(IrcConnection* connection READ connection CONSTANT)
56  Q_PROPERTY(IrcNetwork* network READ network CONSTANT)
57  Q_PROPERTY(IrcBufferModel* model READ model CONSTANT)
58  Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
59  Q_PROPERTY(bool channel READ isChannel CONSTANT)
60  Q_PROPERTY(bool sticky READ isSticky WRITE setSticky NOTIFY stickyChanged)
61  Q_PROPERTY(bool persistent READ isPersistent WRITE setPersistent NOTIFY persistentChanged)
62  Q_PROPERTY(QVariantMap userData READ userData WRITE setUserData NOTIFY userDataChanged)
63 
64 public:
65  Q_INVOKABLE explicit IrcBuffer(QObject* parent = 0);
66  virtual ~IrcBuffer();
67 
68  QString title() const;
69  QString name() const;
70  QString prefix() const;
71 
72  bool isChannel() const;
73  Q_INVOKABLE IrcChannel* toChannel();
74 
75  IrcConnection* connection() const;
76  IrcNetwork* network() const;
77  IrcBufferModel* model() const;
78 
79  virtual bool isActive() const;
80 
81  bool isSticky() const;
82  void setSticky(bool sticky);
83 
84  bool isPersistent() const;
85  void setPersistent(bool persistent);
86 
87  QVariantMap userData() const;
88  void setUserData(const QVariantMap& data);
89 
90  Q_INVOKABLE bool sendCommand(IrcCommand* command);
91 
92 public Q_SLOTS:
93  void setName(const QString& name);
94  void setPrefix(const QString& prefix);
95  void receiveMessage(IrcMessage* message);
96  virtual void close(const QString& reason = QString());
97 
98 Q_SIGNALS:
99  void titleChanged(const QString& title);
100  void nameChanged(const QString& name);
101  void prefixChanged(const QString& name);
102  void messageReceived(IrcMessage* message);
103  void destroyed(IrcBuffer* buffer);
104  void activeChanged(bool active);
105  void stickyChanged(bool sticky);
106  void persistentChanged(bool persistent);
107  void userDataChanged(const QVariantMap& data);
108 
109 protected:
110  IrcBuffer(IrcBufferPrivate& dd, QObject* parent);
111 
112  QScopedPointer<IrcBufferPrivate> d_ptr;
113  Q_DECLARE_PRIVATE(IrcBuffer)
114  Q_DISABLE_COPY(IrcBuffer)
115 };
116 
117 #ifndef QT_NO_DEBUG_STREAM
118 IRC_MODEL_EXPORT QDebug operator<<(QDebug debug, const IrcBuffer* buffer);
119 #endif // QT_NO_DEBUG_STREAM
120 
121 IRC_END_NAMESPACE
122 
123 Q_DECLARE_METATYPE(IRC_PREPEND_NAMESPACE(IrcBuffer*))
124 Q_DECLARE_METATYPE(QList<IRC_PREPEND_NAMESPACE(IrcBuffer*)>)
125 
126 #endif // IRCBUFFER_H
Provides means to establish a connection to an IRC server.
Definition: ircconnection.h:48
Provides network information and capability management.
Definition: ircnetwork.h:43
Keeps track of buffer status.
Definition: ircbuffer.h:49
Keeps track of channel status.
Definition: ircchannel.h:40
Keeps track of buffers.
Definition: ircbuffermodel.h:46
Provides the most common commands.
Definition: irccommand.h:43
The base class of all messages.
Definition: ircmessage.h:47