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