Communi  3.7.0
A cross-platform IRC framework written with Qt
Loading...
Searching...
No Matches
irccommand.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 IRCCOMMAND_H
30#define IRCCOMMAND_H
31
32#include <IrcGlobal>
33#include <QtCore/qobject.h>
34#include <QtCore/qmetatype.h>
35#include <QtCore/qstringlist.h>
36
37IRC_BEGIN_NAMESPACE
38
39class IrcMessage;
40class IrcNetwork;
41class IrcConnection;
42class IrcCommandPrivate;
43
44class IRC_CORE_EXPORT IrcCommand : public QObject
45{
46 Q_OBJECT
47 Q_PROPERTY(IrcConnection* connection READ connection)
48 Q_PROPERTY(IrcNetwork* network READ network)
49 Q_PROPERTY(QStringList parameters READ parameters WRITE setParameters)
50 Q_PROPERTY(QByteArray encoding READ encoding WRITE setEncoding)
51 Q_PROPERTY(Type type READ type WRITE setType)
52 Q_ENUMS(Type)
53
54public:
91
92 explicit IrcCommand(QObject* parent = nullptr);
93 ~IrcCommand() override;
94
95 IrcConnection* connection() const;
96 IrcNetwork* network() const;
97
98 Type type() const;
99 void setType(Type type);
100
101 QStringList parameters() const;
102 void setParameters(const QStringList& parameters);
103
104 QByteArray encoding() const;
105 void setEncoding(const QByteArray& encoding);
106
107 virtual QString toString() const;
108
109 Q_INVOKABLE IrcMessage* toMessage(const QString& prefix, IrcConnection* connection) const;
110
111 Q_INVOKABLE static IrcCommand* createAdmin(const QString& server = QString());
112 Q_INVOKABLE static IrcCommand* createAway(const QString& reason = QString());
113 Q_INVOKABLE static IrcCommand* createCapability(const QString& subCommand, const QString& capability);
114 Q_INVOKABLE static IrcCommand* createCapability(const QString& subCommand, const QStringList& capabilities = QStringList());
115 Q_INVOKABLE static IrcCommand* createCtcpAction(const QString& target, const QString& action);
116 Q_INVOKABLE static IrcCommand* createCtcpReply(const QString& target, const QString& reply);
117 Q_INVOKABLE static IrcCommand* createCtcpRequest(const QString& target, const QString& request);
118 Q_INVOKABLE static IrcCommand* createInfo(const QString& server = QString());
119 Q_INVOKABLE static IrcCommand* createInvite(const QString& user, const QString& channel);
120 Q_INVOKABLE static IrcCommand* createJoin(const QString& channel, const QString& key = QString());
121 Q_INVOKABLE static IrcCommand* createJoin(const QStringList& channels, const QStringList& keys = QStringList());
122 Q_INVOKABLE static IrcCommand* createKick(const QString& channel, const QString& user, const QString& reason = QString());
123 Q_INVOKABLE static IrcCommand* createKnock(const QString& channel, const QString& message = QString());
124 Q_INVOKABLE static IrcCommand* createList(const QStringList& channels = QStringList(), const QString& server = QString());
125 Q_INVOKABLE static IrcCommand* createMessage(const QString& target, const QString& message);
126 Q_INVOKABLE static IrcCommand* createMode(const QString& target, const QString& mode = QString(), const QString& arg = QString());
127 Q_INVOKABLE static IrcCommand* createMonitor(const QString& command, const QString& target = QString());
128 Q_INVOKABLE static IrcCommand* createMonitor(const QString& command, const QStringList& targets);
129 Q_INVOKABLE static IrcCommand* createMotd(const QString& server = QString());
130 Q_INVOKABLE static IrcCommand* createNames(const QString& channel = QString(), const QString& server = QString());
131 Q_INVOKABLE static IrcCommand* createNames(const QStringList& channels, const QString& server = QString());
132 Q_INVOKABLE static IrcCommand* createNick(const QString& nick);
133 Q_INVOKABLE static IrcCommand* createNotice(const QString& target, const QString& notice);
134 Q_INVOKABLE static IrcCommand* createPart(const QString& channel, const QString& reason = QString());
135 Q_INVOKABLE static IrcCommand* createPart(const QStringList& channels, const QString& reason = QString());
136 Q_INVOKABLE static IrcCommand* createPing(const QString& argument);
137 Q_INVOKABLE static IrcCommand* createPong(const QString& argument);
138 Q_INVOKABLE static IrcCommand* createQuit(const QString& reason = QString());
139 Q_INVOKABLE static IrcCommand* createQuote(const QString& raw);
140 Q_INVOKABLE static IrcCommand* createQuote(const QStringList& parameters);
141 Q_INVOKABLE static IrcCommand* createStats(const QString& query, const QString& server = QString());
142 Q_INVOKABLE static IrcCommand* createTime(const QString& server = QString());
143 Q_INVOKABLE static IrcCommand* createTopic(const QString& channel, const QString& topic = QString());
144 Q_INVOKABLE static IrcCommand* createTrace(const QString& target = QString());
145 Q_INVOKABLE static IrcCommand* createUsers(const QString& server = QString());
146 Q_INVOKABLE static IrcCommand* createVersion(const QString& user = QString());
147 Q_INVOKABLE static IrcCommand* createWho(const QString& mask, bool operators = false);
148 Q_INVOKABLE static IrcCommand* createWhois(const QString& user);
149 Q_INVOKABLE static IrcCommand* createWhowas(const QString& user, int count = 1);
150
151private:
152 QScopedPointer<IrcCommandPrivate> d_ptr;
153 Q_DECLARE_PRIVATE(IrcCommand)
154 Q_DISABLE_COPY(IrcCommand)
155};
156
157#ifndef QT_NO_DEBUG_STREAM
158IRC_CORE_EXPORT QDebug operator<<(QDebug debug, IrcCommand::Type type);
159IRC_CORE_EXPORT QDebug operator<<(QDebug debug, const IrcCommand* command);
160#endif // QT_NO_DEBUG_STREAM
161
162IRC_END_NAMESPACE
163
164Q_DECLARE_METATYPE(IRC_PREPEND_NAMESPACE(IrcCommand*))
165Q_DECLARE_METATYPE(IRC_PREPEND_NAMESPACE(IrcCommand::Type))
166
167#endif // IRCCOMMAND_H
Provides the most common commands.
Definition irccommand.h:45
Type
Definition irccommand.h:55
@ Version
A version command (VERSION) is used to query user or server version.
Definition irccommand.h:85
@ Custom
A custom command.
Definition irccommand.h:62
@ Users
A users command (USERS) is used to query server users.
Definition irccommand.h:84
@ Invite
An invite command (INVITE) is used to invite users to a channel.
Definition irccommand.h:64
@ CtcpRequest
A CTCP request command is used to send a request.
Definition irccommand.h:61
@ Capability
A capability command (CAP) is used to manage connection capabilities.
Definition irccommand.h:58
@ Admin
An admin command (ADMIN) is used to query server admin info.
Definition irccommand.h:56
@ Away
An away command (AWAY) is used to set the away status.
Definition irccommand.h:57
@ Quit
A quit command (QUIT) is used to end a client connection.
Definition irccommand.h:78
@ Join
A join command (JOIN) is used to start listening a specific channel.
Definition irccommand.h:65
@ CtcpAction
A CTCP action command is used to send an action message to channels and users.
Definition irccommand.h:59
@ Kick
A kick command (KICK) is used to forcibly remove a user from a channel.
Definition irccommand.h:66
@ Knock
A knock command (KNOCK) is used to request channel invitation.
Definition irccommand.h:67
@ Who
A who command (WHO) is used to generate a query which returns a list of matching users.
Definition irccommand.h:86
@ Trace
A trace command (TRACE) is used to trace the connection path to a target.
Definition irccommand.h:83
@ Time
A time command (TIME) is used to query local server time.
Definition irccommand.h:81
@ Quote
A quote command is used to send a raw message to the server.
Definition irccommand.h:79
@ Notice
A notice command (NOTICE) is used to send notice messages to channels and users.
Definition irccommand.h:74
@ Info
An info command (INFO) is used to query server info.
Definition irccommand.h:63
@ Motd
A message of the day command (MOTD) is used to query the message of the day.
Definition irccommand.h:71
@ Names
A names command (NAMES) is used to list all nicknames on a channel.
Definition irccommand.h:72
@ CtcpReply
A CTCP reply command is used to send a reply to a request.
Definition irccommand.h:60
@ Whowas
A whowas command (WHOWAS) is used to query information about a user that no longer exists.
Definition irccommand.h:88
@ Nick
A nick command (NICK) is used to give user a nickname or change the previous one.
Definition irccommand.h:73
@ Stats
A stats command (STATS) is used to query server statistics.
Definition irccommand.h:80
@ Part
A part command (PART) causes the client to be removed from the channel.
Definition irccommand.h:75
@ Message
A message command (PRIVMSG) is used to send private messages to channels and users.
Definition irccommand.h:69
@ List
A list command (LIST) is used to list channels and their topics.
Definition irccommand.h:68
@ Whois
A whois command (WHOIS) is used to query information about a particular user.
Definition irccommand.h:87
@ Topic
A topic command (TOPIC) is used to change or view the topic of a channel.
Definition irccommand.h:82
@ Mode
A mode command (MODE) is used to change the mode of users and channels.
Definition irccommand.h:70
Provides means to establish a connection to an IRC server.
Definition ircconnection.h:49
The base class of all messages.
Definition ircmessage.h:48
Provides network information and capability management.
Definition ircnetwork.h:44