Communi  3.0.0
A cross-platform IRC framework written with Qt
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Macros Groups Pages
irccommand.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 IRCCOMMAND_H
16 #define IRCCOMMAND_H
17 
18 #include <IrcGlobal>
19 #include <QtCore/qobject.h>
20 #include <QtCore/qmetatype.h>
21 #include <QtCore/qstringlist.h>
22 
23 IRC_BEGIN_NAMESPACE
24 
25 class IrcMessage;
26 class IrcConnection;
27 class IrcCommandPrivate;
28 
29 class IRC_CORE_EXPORT IrcCommand : public QObject
30 {
31  Q_OBJECT
32  Q_PROPERTY(QStringList parameters READ parameters WRITE setParameters)
33  Q_PROPERTY(QByteArray encoding READ encoding WRITE setEncoding)
34  Q_PROPERTY(Type type READ type WRITE setType)
35  Q_ENUMS(Type)
36 
37 public:
38  enum Type {
59  Ping,
60  Pong,
69  Who,
71  Whowas
72  };
73 
74  explicit IrcCommand(QObject* parent = 0);
75  virtual ~IrcCommand();
76 
77  Type type() const;
78  void setType(Type type);
79 
80  QStringList parameters() const;
81  void setParameters(const QStringList& parameters);
82 
83  QByteArray encoding() const;
84  void setEncoding(const QByteArray& encoding);
85 
86  virtual QString toString() const;
87 
88  Q_INVOKABLE IrcMessage* toMessage(const QString& prefix, IrcConnection* connection) const;
89 
90  Q_INVOKABLE static IrcCommand* createAdmin(const QString& server = QString());
91  Q_INVOKABLE static IrcCommand* createAway(const QString& reason = QString());
92  Q_INVOKABLE static IrcCommand* createCapability(const QString& subCommand, const QString& capability);
93  Q_INVOKABLE static IrcCommand* createCapability(const QString& subCommand, const QStringList& capabilities = QStringList());
94  Q_INVOKABLE static IrcCommand* createCtcpAction(const QString& target, const QString& action);
95  Q_INVOKABLE static IrcCommand* createCtcpReply(const QString& target, const QString& reply);
96  Q_INVOKABLE static IrcCommand* createCtcpRequest(const QString& target, const QString& request);
97  Q_INVOKABLE static IrcCommand* createInfo(const QString& server = QString());
98  Q_INVOKABLE static IrcCommand* createInvite(const QString& user, const QString& channel);
99  Q_INVOKABLE static IrcCommand* createJoin(const QString& channel, const QString& key = QString());
100  Q_INVOKABLE static IrcCommand* createJoin(const QStringList& channels, const QStringList& keys = QStringList());
101  Q_INVOKABLE static IrcCommand* createKick(const QString& channel, const QString& user, const QString& reason = QString());
102  Q_INVOKABLE static IrcCommand* createKnock(const QString& channel, const QString& message = QString());
103  Q_INVOKABLE static IrcCommand* createList(const QStringList& channels = QStringList(), const QString& server = QString());
104  Q_INVOKABLE static IrcCommand* createMessage(const QString& target, const QString& message);
105  Q_INVOKABLE static IrcCommand* createMode(const QString& target, const QString& mode = QString(), const QString& arg = QString());
106  Q_INVOKABLE static IrcCommand* createMotd(const QString& server = QString());
107  Q_INVOKABLE static IrcCommand* createNames(const QString& channel = QString(), const QString& server = QString());
108  Q_INVOKABLE static IrcCommand* createNames(const QStringList& channels, const QString& server = QString());
109  Q_INVOKABLE static IrcCommand* createNick(const QString& nick);
110  Q_INVOKABLE static IrcCommand* createNotice(const QString& target, const QString& notice);
111  Q_INVOKABLE static IrcCommand* createPart(const QString& channel, const QString& reason = QString());
112  Q_INVOKABLE static IrcCommand* createPart(const QStringList& channels, const QString& reason = QString());
113  Q_INVOKABLE static IrcCommand* createPing(const QString& argument);
114  Q_INVOKABLE static IrcCommand* createPong(const QString& argument);
115  Q_INVOKABLE static IrcCommand* createQuit(const QString& reason = QString());
116  Q_INVOKABLE static IrcCommand* createQuote(const QString& raw);
117  Q_INVOKABLE static IrcCommand* createQuote(const QStringList& parameters);
118  Q_INVOKABLE static IrcCommand* createStats(const QString& query, const QString& server = QString());
119  Q_INVOKABLE static IrcCommand* createTime(const QString& server = QString());
120  Q_INVOKABLE static IrcCommand* createTopic(const QString& channel, const QString& topic = QString());
121  Q_INVOKABLE static IrcCommand* createTrace(const QString& target = QString());
122  Q_INVOKABLE static IrcCommand* createUsers(const QString& server = QString());
123  Q_INVOKABLE static IrcCommand* createVersion(const QString& user = QString());
124  Q_INVOKABLE static IrcCommand* createWho(const QString& mask, bool operators = false);
125  Q_INVOKABLE static IrcCommand* createWhois(const QString& user);
126  Q_INVOKABLE static IrcCommand* createWhowas(const QString& user, int count = 1);
127 
128 private:
130  Q_DECLARE_PRIVATE(IrcCommand)
131  Q_DISABLE_COPY(IrcCommand)
132 };
133 
134 #ifndef QT_NO_DEBUG_STREAM
135 IRC_CORE_EXPORT QDebug operator<<(QDebug debug, IrcCommand::Type type);
136 IRC_CORE_EXPORT QDebug operator<<(QDebug debug, const IrcCommand* command);
137 #endif // QT_NO_DEBUG_STREAM
138 
139 IRC_END_NAMESPACE
140 
141 Q_DECLARE_METATYPE(IRC_PREPEND_NAMESPACE(IrcCommand*))
142 Q_DECLARE_METATYPE(IRC_PREPEND_NAMESPACE(IrcCommand::Type))
143 
144 #endif // IRCCOMMAND_H
A CTCP reply command is used to send a reply to a request.
Definition: irccommand.h:43
A users command (USERS) is used to query server users.
Definition: irccommand.h:67
Provides the most common commands.
Definition: irccommand.h:29
A kick command (KICK) is used to forcibly remove a user from a channel.
Definition: irccommand.h:49
A part command (PART) causes the client to be removed from the channel.
Definition: irccommand.h:58
A trace command (TRACE) is used to trace the connection path to a target.
Definition: irccommand.h:66
A list command (LIST) is used to list channels and their topics.
Definition: irccommand.h:51
A capability command (CAP) is used to manage connection capabilities.
Definition: irccommand.h:41
A time command (TIME) is used to query local server time.
Definition: irccommand.h:64
A CTCP action command is used to send an action message to channels and users.
Definition: irccommand.h:42
Provides means to establish a connection to an IRC server.
Definition: ircconnection.h:32
The base class of all messages.
Definition: ircmessage.h:32
Type
Definition: irccommand.h:38
An away command (AWAY) is used to set the away status.
Definition: irccommand.h:40
A message command (PRIVMSG) is used to send private messages to channels and users.
Definition: irccommand.h:52
A join command (JOIN) is used to start listening a specific channel.
Definition: irccommand.h:48
A version command (VERSION) is used to query user or server version.
Definition: irccommand.h:68
A who command (WHO) is used to generate a query which returns a list of matching users.
Definition: irccommand.h:69
A names command (NAMES) is used to list all nicknames on a channel.
Definition: irccommand.h:55
A custom command.
Definition: irccommand.h:45
A mode command (MODE) is used to change the mode of users and channels.
Definition: irccommand.h:53
A message of the day command (MOTD) is used to query the message of the day.
Definition: irccommand.h:54
An info command (INFO) is used to query server info.
Definition: irccommand.h:46
A knock command (KNOCK) is used to request channel invitation.
Definition: irccommand.h:50
A topic command (TOPIC) is used to change or view the topic of a channel.
Definition: irccommand.h:65
An admin command (ADMIN) is used to query server admin info.
Definition: irccommand.h:39
A stats command (STATS) is used to query server statistics.
Definition: irccommand.h:63
A notice command (NOTICE) is used to send notice messages to channels and users.
Definition: irccommand.h:57
A whois command (WHOIS) is used to query information about a particular user.
Definition: irccommand.h:70
A quit command (QUIT) is used to end a client connection.
Definition: irccommand.h:61
An invite command (INVITE) is used to invite users to a channel.
Definition: irccommand.h:47
A CTCP request command is used to send a request.
Definition: irccommand.h:44
A nick command (NICK) is used to give user a nickname or change the previous one. ...
Definition: irccommand.h:56
A quote command is used to send a raw message to the server.
Definition: irccommand.h:62