Communi  3.0.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-2013 The Communi Project
3 *
4 * This library is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12 * License for more details.
13 */
14 
15 #ifndef IRCNETWORK_H
16 #define IRCNETWORK_H
17 
18 #include <IrcGlobal>
19 #include <QtCore/qobject.h>
20 #include <QtCore/qmetatype.h>
21 #include <QtCore/qstringlist.h>
22 #include <QtCore/qscopedpointer.h>
23 
24 IRC_BEGIN_NAMESPACE
25 
26 class IrcConnection;
27 class IrcNetworkPrivate;
28 
29 class IRC_CORE_EXPORT IrcNetwork : public QObject
30 {
31  Q_OBJECT
32  Q_PROPERTY(bool initialized READ isInitialized NOTIFY initialized)
33  Q_PROPERTY(QString name READ name NOTIFY nameChanged)
34  Q_PROPERTY(QStringList modes READ modes NOTIFY modesChanged)
35  Q_PROPERTY(QStringList prefixes READ prefixes NOTIFY prefixesChanged)
36  Q_PROPERTY(QStringList channelTypes READ channelTypes NOTIFY channelTypesChanged)
37  Q_PROPERTY(QStringList availableCapabilities READ availableCapabilities NOTIFY availableCapabilitiesChanged)
38  Q_PROPERTY(QStringList requestedCapabilities READ requestedCapabilities WRITE setRequestedCapabilities NOTIFY requestedCapabilitiesChanged)
39  Q_PROPERTY(QStringList activeCapabilities READ activeCapabilities NOTIFY activeCapabilitiesChanged)
40  Q_ENUMS(Limit ModeType)
41  Q_FLAGS(ModeTypes)
42 
43 public:
44  virtual ~IrcNetwork();
45 
46  bool isInitialized();
47 
48  QString name() const;
49 
50  QStringList modes() const;
51  QStringList prefixes() const;
52 
53  Q_INVOKABLE QString modeToPrefix(const QString& mode) const;
54  Q_INVOKABLE QString prefixToMode(const QString& prefix) const;
55 
56  QStringList channelTypes() const;
57 
58  Q_INVOKABLE bool isChannel(const QString& name) const;
59 
60  enum ModeType {
61  TypeA = 0x1,
62  TypeB = 0x2,
63  TypeC = 0x4,
64  TypeD = 0x8,
65  AllTypes = 0xf
66  };
67  Q_DECLARE_FLAGS(ModeTypes, ModeType)
68 
69  Q_INVOKABLE QStringList channelModes(IrcNetwork::ModeTypes types) const;
70 
71  enum Limit {
78  ModeCount
79  };
80 
81  Q_INVOKABLE int numericLimit(IrcNetwork::Limit limit) const;
82 
83  Q_INVOKABLE int modeLimit(const QString& mode) const;
84  Q_INVOKABLE int channelLimit(const QString& type) const;
85  Q_INVOKABLE int targetLimit(const QString& command) const;
86 
87  QStringList availableCapabilities() const;
88  QStringList requestedCapabilities() const;
89  QStringList activeCapabilities() const;
90 
91  Q_INVOKABLE bool hasCapability(const QString& capability) const;
92  Q_INVOKABLE bool isCapable(const QString& capability) const;
93 
94 public Q_SLOTS:
95  bool requestCapability(const QString& capability);
96  bool requestCapabilities(const QStringList& capabilities);
97  void setRequestedCapabilities(const QStringList& capabilities);
98 
99 Q_SIGNALS:
100  void initialized();
101  void nameChanged(const QString& name);
102  void modesChanged(const QStringList& modes);
103  void prefixesChanged(const QStringList& prefixes);
104  void channelTypesChanged(const QStringList& types);
105  void availableCapabilitiesChanged(const QStringList& capabilities);
106  void requestedCapabilitiesChanged(const QStringList& capabilities);
107  void activeCapabilitiesChanged(const QStringList& capabilities);
108  void requestingCapabilities();
109 
110 private:
111  friend class IrcProtocol;
112  friend class IrcConnection;
113  explicit IrcNetwork(IrcConnection* connection);
114 
116  Q_DECLARE_PRIVATE(IrcNetwork)
117  Q_DISABLE_COPY(IrcNetwork)
118 };
119 
120 #ifndef QT_NO_DEBUG_STREAM
121 IRC_CORE_EXPORT QDebug operator<<(QDebug debug, IrcNetwork::Limit limit);
122 IRC_CORE_EXPORT QDebug operator<<(QDebug debug, IrcNetwork::ModeType type);
123 IRC_CORE_EXPORT QDebug operator<<(QDebug debug, IrcNetwork::ModeTypes types);
124 IRC_CORE_EXPORT QDebug operator<<(QDebug debug, const IrcNetwork* network);
125 #endif // QT_NO_DEBUG_STREAM
126 
127 Q_DECLARE_OPERATORS_FOR_FLAGS(IrcNetwork::ModeTypes)
128 
129 IRC_END_NAMESPACE
130 
131 Q_DECLARE_METATYPE(IRC_PREPEND_NAMESPACE(IrcNetwork*))
132 
133 #endif // IRCNETWORK_H
The maximum nick name length.
Definition: ircnetwork.h:72
The maximum channel name length.
Definition: ircnetwork.h:73
The maximum message length.
Definition: ircnetwork.h:75
The maximum away reason length.
Definition: ircnetwork.h:77
Provides means to establish a connection to an IRC server.
Definition: ircconnection.h:32
The maximum kick reason length.
Definition: ircnetwork.h:76
The maximum channel topic length.
Definition: ircnetwork.h:74
Provides network information and capability management.
Definition: ircnetwork.h:29
ModeType
Definition: ircnetwork.h:60
Limit
Definition: ircnetwork.h:71