Communi 1.0.0
A cross-platform IRC client library written with Qt 4
include/irccommand.h
Go to the documentation of this file.
00001 /*
00002 * Copyright (C) 2008-2011 J-P Nurmi <jpnurmi@gmail.com>
00003 *
00004 * This library is free software; you can redistribute it and/or modify it
00005 * under the terms of the GNU Lesser General Public License as published by
00006 * the Free Software Foundation; either version 2 of the License, or (at your
00007 * option) any later version.
00008 *
00009 * This library is distributed in the hope that it will be useful, but WITHOUT
00010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00012 * License for more details.
00013 */
00014 
00015 #ifndef IRCCOMMAND_H
00016 #define IRCCOMMAND_H
00017 
00018 #include <IrcGlobal>
00019 #include <QtCore/qobject.h>
00020 #include <QtCore/qstringlist.h>
00021 
00022 class IrcCommandPrivate;
00023 
00024 class COMMUNI_EXPORT IrcCommand : public QObject
00025 {
00026     Q_OBJECT
00027     Q_PROPERTY(QStringList parameters READ parameters WRITE setParameters)
00028     Q_PROPERTY(Type type READ type WRITE setType)
00029     Q_ENUMS(Type)
00030 
00031 public:
00032     enum Type
00033     {
00034         Custom,
00035 
00036         // connection registration
00037         Nick,
00038         Quit,
00039 
00040         // channel operations
00041         Join,
00042         Part,
00043         Topic,
00044         Names,
00045         List,
00046         Invite,
00047         Kick,
00048 
00049         // mode operations
00050         Mode,
00051 
00052         // sending messages
00053         Message,
00054         Notice,
00055 
00056         // ctcp messages
00057         CtcpAction,
00058         CtcpRequest,
00059         CtcpReply,
00060 
00061         // user-based queries
00062         Who,
00063         Whois,
00064         Whowas,
00065 
00066         // miscellaneous commands
00067         Away,
00068         Quote
00069     };
00070 
00071     explicit IrcCommand(QObject* parent = 0);
00072     virtual ~IrcCommand();
00073 
00074     Type type() const;
00075     void setType(Type type);
00076 
00077     QStringList parameters() const;
00078     void setParameters(const QStringList& parameters);
00079 
00080     virtual QString toString() const;
00081 
00082     Q_INVOKABLE static IrcCommand* createAway(const QString& reason = QString());
00083     Q_INVOKABLE static IrcCommand* createCtcpAction(const QString& target, const QString& action);
00084     Q_INVOKABLE static IrcCommand* createCtcpReply(const QString& target, const QString& reply);
00085     Q_INVOKABLE static IrcCommand* createCtcpRequest(const QString& target, const QString& request);
00086     Q_INVOKABLE static IrcCommand* createInvite(const QString& user, const QString& channel);
00087     Q_INVOKABLE static IrcCommand* createJoin(const QString& channel, const QString& key = QString());
00088     Q_INVOKABLE static IrcCommand* createKick(const QString& channel, const QString& user, const QString& reason = QString());
00089     Q_INVOKABLE static IrcCommand* createList(const QString& channel, const QString& server = QString());
00090     Q_INVOKABLE static IrcCommand* createMessage(const QString& target, const QString& message);
00091     Q_INVOKABLE static IrcCommand* createMode(const QString& target, const QString& mode, const QString& arg = QString());
00092     Q_INVOKABLE static IrcCommand* createNames(const QString& channel);
00093     Q_INVOKABLE static IrcCommand* createNick(const QString& nick);
00094     Q_INVOKABLE static IrcCommand* createNotice(const QString& target, const QString& message);
00095     Q_INVOKABLE static IrcCommand* createPart(const QString& channel, const QString& reason = QString());
00096     Q_INVOKABLE static IrcCommand* createQuit(const QString& reason = QString());
00097     Q_INVOKABLE static IrcCommand* createQuote(const QStringList& parameters);
00098     Q_INVOKABLE static IrcCommand* createTopic(const QString& channel, const QString& topic = QString());
00099     Q_INVOKABLE static IrcCommand* createWho(const QString& mask);
00100     Q_INVOKABLE static IrcCommand* createWhois(const QString& user);
00101     Q_INVOKABLE static IrcCommand* createWhowas(const QString& user);
00102 
00103 private:
00104     QScopedPointer<IrcCommandPrivate> d_ptr;
00105     Q_DECLARE_PRIVATE(IrcCommand)
00106     Q_DISABLE_COPY(IrcCommand)
00107 };
00108 
00109 #ifndef QT_NO_DEBUG_STREAM
00110 COMMUNI_EXPORT QDebug operator<<(QDebug debug, const IrcCommand* command);
00111 #endif // QT_NO_DEBUG_STREAM
00112 
00113 #endif // IRCCOMMAND_H
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Defines