Communi  3.3.0
A cross-platform IRC framework written with Qt
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Macros Groups Pages
ircnetwork.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008-2014 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 availableCapabilities READ availableCapabilities NOTIFY availableCapabilitiesChanged)
52  Q_PROPERTY(QStringList requestedCapabilities READ requestedCapabilities WRITE setRequestedCapabilities NOTIFY requestedCapabilitiesChanged)
53  Q_PROPERTY(QStringList activeCapabilities READ activeCapabilities NOTIFY activeCapabilitiesChanged)
54  Q_ENUMS(Limit ModeType)
55  Q_FLAGS(ModeTypes)
56 
57 public:
58  virtual ~IrcNetwork();
59 
60  bool isInitialized();
61 
62  QString name() const;
63 
64  QStringList modes() const;
65  QStringList prefixes() const;
66 
67  Q_INVOKABLE QString modeToPrefix(const QString& mode) const;
68  Q_INVOKABLE QString prefixToMode(const QString& prefix) const;
69 
70  QStringList channelTypes() const;
71 
72  Q_INVOKABLE bool isChannel(const QString& name) const;
73 
74  enum ModeType {
75  TypeA = 0x1,
76  TypeB = 0x2,
77  TypeC = 0x4,
78  TypeD = 0x8,
79  AllTypes = 0xf
80  };
81  Q_DECLARE_FLAGS(ModeTypes, ModeType)
82 
83  Q_INVOKABLE QStringList channelModes(IrcNetwork::ModeTypes types) const;
84 
85  enum Limit {
92  ModeCount
93  };
94 
95  Q_INVOKABLE int numericLimit(IrcNetwork::Limit limit) const;
96 
97  Q_INVOKABLE int modeLimit(const QString& mode) const;
98  Q_INVOKABLE int channelLimit(const QString& type) const;
99  Q_INVOKABLE int targetLimit(const QString& command) const;
100 
101  QStringList availableCapabilities() const;
102  QStringList requestedCapabilities() const;
103  QStringList activeCapabilities() const;
104 
105  Q_INVOKABLE bool hasCapability(const QString& capability) const;
106  Q_INVOKABLE bool isCapable(const QString& capability) const;
107 
108 public Q_SLOTS:
109  bool requestCapability(const QString& capability);
110  bool requestCapabilities(const QStringList& capabilities);
111  void setRequestedCapabilities(const QStringList& capabilities);
112 
113 Q_SIGNALS:
114  void initialized();
115  void nameChanged(const QString& name);
116  void modesChanged(const QStringList& modes);
117  void prefixesChanged(const QStringList& prefixes);
118  void channelTypesChanged(const QStringList& types);
119  void availableCapabilitiesChanged(const QStringList& capabilities);
120  void requestedCapabilitiesChanged(const QStringList& capabilities);
121  void activeCapabilitiesChanged(const QStringList& capabilities);
122  void requestingCapabilities();
123 
124 private:
125  friend class IrcProtocol;
126  friend class IrcConnection;
127  explicit IrcNetwork(IrcConnection* connection);
128 
130  Q_DECLARE_PRIVATE(IrcNetwork)
131  Q_DISABLE_COPY(IrcNetwork)
132 };
133 
134 #ifndef QT_NO_DEBUG_STREAM
135 IRC_CORE_EXPORT QDebug operator<<(QDebug debug, IrcNetwork::Limit limit);
136 IRC_CORE_EXPORT QDebug operator<<(QDebug debug, IrcNetwork::ModeType type);
137 IRC_CORE_EXPORT QDebug operator<<(QDebug debug, IrcNetwork::ModeTypes types);
138 IRC_CORE_EXPORT QDebug operator<<(QDebug debug, const IrcNetwork* network);
139 #endif // QT_NO_DEBUG_STREAM
140 
141 Q_DECLARE_OPERATORS_FOR_FLAGS(IrcNetwork::ModeTypes)
142 
143 IRC_END_NAMESPACE
144 
145 Q_DECLARE_METATYPE(IRC_PREPEND_NAMESPACE(IrcNetwork*))
146 
147 #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:88
Provides network information and capability management.
Definition: ircnetwork.h:43
ModeType
Definition: ircnetwork.h:74
The maximum kick reason length.
Definition: ircnetwork.h:90
The maximum away reason length.
Definition: ircnetwork.h:91
Limit
Definition: ircnetwork.h:85
Implements the IRC protocol and provides means for implementing support for custom protocols...
Definition: ircprotocol.h:45
The maximum message length.
Definition: ircnetwork.h:89
The maximum channel name length.
Definition: ircnetwork.h:87
The maximum nick name length.
Definition: ircnetwork.h:86