Communi  3.5.0
A cross-platform IRC framework written with Qt
ircnetwork.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008-2016 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 IRCNETWORK_H
30 #define IRCNETWORK_H
31 
32 #include <IrcGlobal>
33 #include <QtCore/qobject.h>
34 #include <QtCore/qmetatype.h>
35 #include <QtCore/qstringlist.h>
36 #include <QtCore/qscopedpointer.h>
37 
38 IRC_BEGIN_NAMESPACE
39 
40 class IrcConnection;
41 class IrcNetworkPrivate;
42 
43 class IRC_CORE_EXPORT IrcNetwork : public QObject
44 {
45  Q_OBJECT
46  Q_PROPERTY(bool initialized READ isInitialized NOTIFY initialized)
47  Q_PROPERTY(QString name READ name NOTIFY nameChanged)
48  Q_PROPERTY(QStringList modes READ modes NOTIFY modesChanged)
49  Q_PROPERTY(QStringList prefixes READ prefixes NOTIFY prefixesChanged)
50  Q_PROPERTY(QStringList channelTypes READ channelTypes NOTIFY channelTypesChanged)
51  Q_PROPERTY(QStringList statusPrefixes READ statusPrefixes NOTIFY statusPrefixesChanged)
52  Q_PROPERTY(QStringList availableCapabilities READ availableCapabilities NOTIFY availableCapabilitiesChanged)
53  Q_PROPERTY(QStringList requestedCapabilities READ requestedCapabilities WRITE setRequestedCapabilities NOTIFY requestedCapabilitiesChanged)
54  Q_PROPERTY(QStringList activeCapabilities READ activeCapabilities NOTIFY activeCapabilitiesChanged)
55  Q_ENUMS(Limit ModeType)
56  Q_FLAGS(ModeTypes)
57 
58 public:
59  virtual ~IrcNetwork();
60 
61  bool isInitialized();
62 
63  QString name() const;
64 
65  QStringList modes() const;
66  QStringList prefixes() const;
67 
68  Q_INVOKABLE QString modeToPrefix(const QString& mode) const;
69  Q_INVOKABLE QString prefixToMode(const QString& prefix) const;
70 
71  QStringList channelTypes() const;
72  QStringList statusPrefixes() const;
73 
74  Q_INVOKABLE bool isChannel(const QString& name) const;
75 
76  enum ModeType {
77  TypeA = 0x1,
78  TypeB = 0x2,
79  TypeC = 0x4,
80  TypeD = 0x8,
81  AllTypes = 0xf
82  };
83  Q_DECLARE_FLAGS(ModeTypes, ModeType)
84 
85  Q_INVOKABLE QStringList channelModes(IrcNetwork::ModeTypes types) const;
86 
87  enum Limit {
95  MonitorCount
96  };
97 
98  Q_INVOKABLE int numericLimit(IrcNetwork::Limit limit) const;
99 
100  Q_INVOKABLE int modeLimit(const QString& mode) const;
101  Q_INVOKABLE int channelLimit(const QString& type) const;
102  Q_INVOKABLE int targetLimit(const QString& command) const;
103 
104  QStringList availableCapabilities() const;
105  QStringList requestedCapabilities() const;
106  QStringList activeCapabilities() const;
107 
108  Q_INVOKABLE bool hasCapability(const QString& capability) const;
109  Q_INVOKABLE bool isCapable(const QString& capability) const;
110 
111 public Q_SLOTS:
112  bool requestCapability(const QString& capability);
113  bool requestCapabilities(const QStringList& capabilities);
114  void setRequestedCapabilities(const QStringList& capabilities);
115 
116 Q_SIGNALS:
117  void initialized();
118  void nameChanged(const QString& name);
119  void modesChanged(const QStringList& modes);
120  void prefixesChanged(const QStringList& prefixes);
121  void channelTypesChanged(const QStringList& types);
122  void statusPrefixesChanged(const QStringList& prefixes);
123  void availableCapabilitiesChanged(const QStringList& capabilities);
124  void requestedCapabilitiesChanged(const QStringList& capabilities);
125  void activeCapabilitiesChanged(const QStringList& capabilities);
126  void requestingCapabilities();
127 
128 private:
129  friend class IrcProtocol;
130  friend class IrcConnection;
131  explicit IrcNetwork(IrcConnection* connection);
132 
134  Q_DECLARE_PRIVATE(IrcNetwork)
135  Q_DISABLE_COPY(IrcNetwork)
136 };
137 
138 #ifndef QT_NO_DEBUG_STREAM
139 IRC_CORE_EXPORT QDebug operator<<(QDebug debug, IrcNetwork::Limit limit);
140 IRC_CORE_EXPORT QDebug operator<<(QDebug debug, IrcNetwork::ModeType type);
141 IRC_CORE_EXPORT QDebug operator<<(QDebug debug, IrcNetwork::ModeTypes types);
142 IRC_CORE_EXPORT QDebug operator<<(QDebug debug, const IrcNetwork* network);
143 #endif // QT_NO_DEBUG_STREAM
144 
145 Q_DECLARE_OPERATORS_FOR_FLAGS(IrcNetwork::ModeTypes)
146 
147 IRC_END_NAMESPACE
148 
149 Q_DECLARE_METATYPE(IRC_PREPEND_NAMESPACE(IrcNetwork*))
150 
151 #endif // IRCNETWORK_H
Provides means to establish a connection to an IRC server.
Definition: ircconnection.h:48
The maximum channel topic length.
Definition: ircnetwork.h:90
Provides network information and capability management.
Definition: ircnetwork.h:43
ModeType
Definition: ircnetwork.h:76
The maximum number of channel modes allowed per mode command.
Definition: ircnetwork.h:94
The maximum kick reason length.
Definition: ircnetwork.h:92
The maximum away reason length.
Definition: ircnetwork.h:93
Limit
Definition: ircnetwork.h:87
Implements the IRC protocol and provides means for implementing support for custom protocols...
Definition: ircprotocol.h:45
The maximum message length.
Definition: ircnetwork.h:91
The maximum channel name length.
Definition: ircnetwork.h:89
The maximum nick name length.
Definition: ircnetwork.h:88