Communi  1.1.0
A cross-platform IRC client library written with Qt 4
 All Classes Files Functions Enumerations Enumerator Properties Macros Groups Pages
irccommand.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2008-2012 J-P Nurmi <jpnurmi@gmail.com>
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/qstringlist.h>
21 
22 class IrcCommandPrivate;
23 
24 class COMMUNI_EXPORT IrcCommand : public QObject
25 {
26  Q_OBJECT
27  Q_PROPERTY(QStringList parameters READ parameters WRITE setParameters)
28  Q_PROPERTY(QByteArray encoding READ encoding WRITE setEncoding)
29  Q_PROPERTY(Type type READ type WRITE setType)
30  Q_ENUMS(Type)
31 
32 public:
33  enum Type
34  {
36 
37  // connection registration
40 
41  // channel operations
49 
50  // mode operations
52 
53  // sending messages
56 
57  // ctcp messages
61 
62  // user-based queries
63  Who,
66 
67  // miscellaneous commands
69  Quote
70  };
71 
72  explicit IrcCommand(QObject* parent = 0);
73  virtual ~IrcCommand();
74 
75  Type type() const;
76  void setType(Type type);
77 
78  QStringList parameters() const;
79  void setParameters(const QStringList& parameters);
80 
81  QByteArray encoding() const;
82  void setEncoding(const QByteArray& encoding);
83 
84  virtual QString toString() const;
85 
86  Q_INVOKABLE static IrcCommand* createAway(const QString& reason = QString());
87  Q_INVOKABLE static IrcCommand* createCtcpAction(const QString& target, const QString& action);
88  Q_INVOKABLE static IrcCommand* createCtcpReply(const QString& target, const QString& reply);
89  Q_INVOKABLE static IrcCommand* createCtcpRequest(const QString& target, const QString& request);
90  Q_INVOKABLE static IrcCommand* createInvite(const QString& user, const QString& channel);
91  Q_INVOKABLE static IrcCommand* createJoin(const QString& channel, const QString& key = QString());
92  Q_INVOKABLE static IrcCommand* createKick(const QString& channel, const QString& user, const QString& reason = QString());
93  Q_INVOKABLE static IrcCommand* createList(const QString& channel, const QString& server = QString());
94  Q_INVOKABLE static IrcCommand* createMessage(const QString& target, const QString& message);
95  Q_INVOKABLE static IrcCommand* createMode(const QString& target, const QString& mode, const QString& arg = QString());
96  Q_INVOKABLE static IrcCommand* createNames(const QString& channel);
97  Q_INVOKABLE static IrcCommand* createNick(const QString& nick);
98  Q_INVOKABLE static IrcCommand* createNotice(const QString& target, const QString& message);
99  Q_INVOKABLE static IrcCommand* createPart(const QString& channel, const QString& reason = QString());
100  Q_INVOKABLE static IrcCommand* createQuit(const QString& reason = QString());
101  Q_INVOKABLE static IrcCommand* createQuote(const QStringList& parameters);
102  Q_INVOKABLE static IrcCommand* createTopic(const QString& channel, const QString& topic = QString());
103  Q_INVOKABLE static IrcCommand* createWho(const QString& mask);
104  Q_INVOKABLE static IrcCommand* createWhois(const QString& user);
105  Q_INVOKABLE static IrcCommand* createWhowas(const QString& user);
106 
107 private:
108  QScopedPointer<IrcCommandPrivate> d_ptr;
109  Q_DECLARE_PRIVATE(IrcCommand)
110  Q_DISABLE_COPY(IrcCommand)
111 };
112 
113 #ifndef QT_NO_DEBUG_STREAM
114 COMMUNI_EXPORT QDebug operator<<(QDebug debug, const IrcCommand* command);
115 #endif // QT_NO_DEBUG_STREAM
116 
117 #endif // IRCCOMMAND_H