LibIrcClient-Qt: include/ircsession.h Source File

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

# include/ircsession.h

    00001 /*
    00002 * Copyright (C) 2008-2009 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 IRC_SESSION_H
    00016 #define IRC_SESSION_H
    00017
    00018 #include <ircglobal.h>
    00019 #include <QObject>
    00020
    00021 QT_FORWARD_DECLARE_CLASS(QAbstractSocket)
    00022 QT_FORWARD_DECLARE_CLASS(QStringList)
    00023
    00024 namespace Irc
    00025 {
    00026     class Buffer;
    00027     class SessionPrivate;
    00028
    00029     class IRC_EXPORT Session : public QObject
    00030     {
    00031         Q_OBJECT
    00032         Q_PROPERTY(QStringList autoJoinChannels READ autoJoinChannels WRITE setAutoJoinChannels)
    00033         Q_PROPERTY(int autoReconnectDelay READ autoReconnectDelay WRITE setAutoReconnectDelay)
    00034         Q_PROPERTY(QByteArray encoding READ encoding WRITE setEncoding)
    00035         Q_PROPERTY(QString host READ host WRITE setHost)
    00036         Q_PROPERTY(QString ident READ ident WRITE setIdent)
    00037         Q_PROPERTY(QString nick READ nick WRITE setNick)
    00038         Q_PROPERTY(Options options READ options WRITE setOptions)
    00039         Q_PROPERTY(QString password READ password WRITE setPassword)
    00040         Q_PROPERTY(quint16 port READ port WRITE setPort)
    00041         Q_PROPERTY(QString realName READ realName WRITE setRealName)
    00042         Q_PROPERTY(QStringList supportedCapabilities READ supportedCapabilities)
    00043         Q_PROPERTY(QStringList enabledCapabilities READ enabledCapabilities)
    00044         Q_FLAGS(Options)
    00045         Q_ENUMS(Option)
    00046
    00047     public:
    00048         Session(QObject* parent = 0);
    00049         ~Session();
    00050
    00051         QStringList autoJoinChannels() const;
    00052         void addAutoJoinChannel(const QString& channel);
    00053         void removeAutoJoinChannel(const QString& channel);
    00054         void setAutoJoinChannels(const QStringList& channels);
    00055
    00056         int autoReconnectDelay() const;
    00057         void setAutoReconnectDelay(int seconds);
    00058
    00059         QByteArray encoding() const;
    00060         void setEncoding(const QByteArray& encoding);
    00061
    00062         QString ident() const;
    00063         void setIdent(const QString& ident);
    00064
    00065         QString nick() const;
    00066         void setNick(const QString& nick);
    00067
    00068         QString password() const;
    00069         void setPassword(const QString& password);
    00070
    00071         QString realName() const;
    00072         void setRealName(const QString& realName);
    00073
    00074         QString host() const;
    00075         void setHost(const QString& host);
    00076
    00077         quint16 port() const;
    00078         void setPort(quint16 port);
    00079
    00080         enum Option
    00081         {
    00082             NoOptions = 0x0,
    00083             StripNicks = 0x1,
    00084             EchoMessages = 0x2
    00085         };
    00086         Q_DECLARE_FLAGS(Options, Option)
    00087
    00088         Options options() const;
    00089         void setOptions(Options options);
    00090
    00091         QAbstractSocket* socket() const;
    00092         void setSocket(QAbstractSocket* socket);
    00093
    00094         QList<Buffer*> buffers() const;
    00095         Buffer* buffer(const QString& receiver = QString()) const;
    00096         Buffer* addBuffer(const QString& receiver);
    00097
    00098         Buffer* defaultBuffer() const;
    00099         void setDefaultBuffer(Buffer* buffer);
    00100
    00101         QStringList supportedCapabilities() const;
    00102         QStringList enabledCapabilities() const;
    00103         bool capabilityEnabled(const QString& name) const;
    00104
    00105     public Q_SLOTS:
    00106         void connectToServer(const QString& hostName = QString(), quint16 port = 6667);
    00107         void reconnectToServer();
    00108         void disconnectFromServer();
    00109
    00110         bool raw(const QString& message);
    00111         bool motd();
    00112         bool join(const QString& channel, const QString& key = QString());
    00113         bool part(const QString& channel, const QString& reason = QString());
    00114         bool quit(const QString& reason = QString());
    00115         bool names(const QString& channel);
    00116         bool list(const QString& channel = QString());
    00117         bool whois(const QString& nick);
    00118         bool whowas(const QString& nick);
    00119         bool mode(const QString& target, const QString& mode = QString());
    00120         bool topic(const QString& channel, const QString& topic = QString());
    00121         bool invite(const QString& nick, const QString& channel);
    00122         bool kick(const QString& nick, const QString& channel, const QString& reason = QString());
    00123         bool message(const QString& receiver, const QString& message);
    00124         bool notice(const QString& receiver, const QString& notice);
    00125         bool ctcpAction(const QString& receiver, const QString& action);
    00126         bool ctcpRequest(const QString& nick, const QString& request);
    00127         bool ctcpReply(const QString& nick, const QString& reply);
    00128
    00129         void requestCapabilities(const QStringList& capabilities);
    00130         void clearCapabilities();
    00131
    00132 #ifndef IRC_NO_DEPRECATED
    00133         // TODO: for backwards compatibility, to be removed in 1.0
    00134         Q_DECL_DEPRECATED bool sendRaw(const QString& message);
    00135         Q_DECL_DEPRECATED bool cmdJoin(const QString& channel, const QString& key = QString());
    00136         Q_DECL_DEPRECATED bool cmdPart(const QString& channel, const QString& reason = QString());
    00137         Q_DECL_DEPRECATED bool cmdQuit(const QString& reason = QString());
    00138         Q_DECL_DEPRECATED bool cmdNames(const QString& channel);
    00139         Q_DECL_DEPRECATED bool cmdList(const QString& channel = QString());
    00140         Q_DECL_DEPRECATED bool cmdWhois(const QString& nick);
    00141         Q_DECL_DEPRECATED bool cmdMode(const QString& target, const QString& mode = QString());
    00142         Q_DECL_DEPRECATED bool cmdTopic(const QString& channel, const QString& topic = QString());
    00143         Q_DECL_DEPRECATED bool cmdInvite(const QString& nick, const QString& channel);
    00144         Q_DECL_DEPRECATED bool cmdKick(const QString& nick, const QString& channel, const QString& reason = QString());
    00145         Q_DECL_DEPRECATED bool cmdMessage(const QString& receiver, const QString& message);
    00146         Q_DECL_DEPRECATED bool cmdNotice(const QString& receiver, const QString& notice);
    00147         Q_DECL_DEPRECATED bool cmdCtcpAction(const QString& receiver, const QString& action);
    00148         Q_DECL_DEPRECATED bool cmdCtcpRequest(const QString& nick, const QString& request);
    00149         Q_DECL_DEPRECATED bool cmdCtcpReply(const QString& nick, const QString& reply);
    00150 #endif // IRC_NO_DEPRECATED
    00151
    00152     Q_SIGNALS:
    00153         void connected();
    00154         void welcomed();
    00155         void reconnecting();
    00156         void disconnected();
    00157
    00158         void bufferAdded(Irc::Buffer* buffer);
    00159         void bufferRemoved(Irc::Buffer* buffer);
    00160
    00161         void capabilitiesListed(const QStringList& capabilities);
    00162         void capabilitiesAcked(const QStringList& capabilities);
    00163         void capabilitiesNotAcked(const QStringList& capabilities);
    00164
    00165 #ifndef IRC_NO_DEPRECATED
    00166         // TODO: for backwards compatibility, to be removed in 1.0
    00167         Q_DECL_DEPRECATED void msgJoined(const QString& origin, const QString& channel);
    00168         Q_DECL_DEPRECATED void msgParted(const QString& origin, const QString& channel, const QString& message);
    00169         Q_DECL_DEPRECATED void msgQuit(const QString& origin, const QString& message);
    00170         Q_DECL_DEPRECATED void msgNickChanged(const QString& origin, const QString& nick);
    00171         Q_DECL_DEPRECATED void msgModeChanged(const QString& origin, const QString& receiver, const QString& mode, const QString& args);
    00172         Q_DECL_DEPRECATED void msgTopicChanged(const QString& origin, const QString& channel, const QString& topic);
    00173         Q_DECL_DEPRECATED void msgInvited(const QString& origin, const QString& receiver, const QString& channel);
    00174         Q_DECL_DEPRECATED void msgKicked(const QString& origin, const QString& channel, const QString& nick, const QString& message);
    00175         Q_DECL_DEPRECATED void msgMessageReceived(const QString& origin, const QString& receiver, const QString& message);
    00176         Q_DECL_DEPRECATED void msgNoticeReceived(const QString& origin, const QString& receiver, const QString& notice);
    00177         Q_DECL_DEPRECATED void msgCtcpRequestReceived(const QString& origin, const QString& request);
    00178         Q_DECL_DEPRECATED void msgCtcpReplyReceived(const QString& origin, const QString& reply);
    00179         Q_DECL_DEPRECATED void msgCtcpActionReceived(const QString& origin, const QString& receiver, const QString& action);
    00180         Q_DECL_DEPRECATED void msgNumericMessageReceived(const QString& origin, uint code, const QStringList& params);
    00181         Q_DECL_DEPRECATED void msgUnknownMessageReceived(const QString& origin, const QStringList& params);
    00182 #endif // IRC_NO_DEPRECATED
    00183
    00184     protected:
    00185         virtual Buffer* createBuffer(const QString& receiver);
    00186
    00187     private:
    00188         SessionPrivate* const d_ptr;
    00189         Q_DECLARE_PRIVATE(Session)
    00190         Q_DISABLE_COPY(Session)
    00191
    00192         Q_PRIVATE_SLOT(d_func(), void _q_connected())
    00193         Q_PRIVATE_SLOT(d_func(), void _q_disconnected())
    00194         Q_PRIVATE_SLOT(d_func(), void _q_reconnect())
    00195         Q_PRIVATE_SLOT(d_func(), void _q_error())
    00196         Q_PRIVATE_SLOT(d_func(), void _q_state(QAbstractSocket::SocketState))
    00197         Q_PRIVATE_SLOT(d_func(), void _q_readData())
    00198
    00199 #ifndef IRC_NO_DEPRECATED
    00200         // TODO: for backwards compatibility, to be removed in 1.0
    00201         Q_PRIVATE_SLOT(d_func(), void _q_joined(const QString&));
    00202         Q_PRIVATE_SLOT(d_func(), void _q_parted(const QString&, const QString&));
    00203         Q_PRIVATE_SLOT(d_func(), void _q_quit(const QString&, const QString&));
    00204         Q_PRIVATE_SLOT(d_func(), void _q_nickChanged(const QString&, const QString&));
    00205         Q_PRIVATE_SLOT(d_func(), void _q_modeChanged(const QString&, const QString&, const QString&));
    00206         Q_PRIVATE_SLOT(d_func(), void _q_topicChanged(const QString&, const QString&));
    00207         Q_PRIVATE_SLOT(d_func(), void _q_invited(const QString&, const QString&, const QString&));
    00208         Q_PRIVATE_SLOT(d_func(), void _q_kicked(const QString&, const QString&, const QString&));
    00209         Q_PRIVATE_SLOT(d_func(), void _q_messageReceived(const QString&, const QString&));
    00210         Q_PRIVATE_SLOT(d_func(), void _q_noticeReceived(const QString&, const QString&));
    00211         Q_PRIVATE_SLOT(d_func(), void _q_ctcpRequestReceived(const QString&, const QString&));
    00212         Q_PRIVATE_SLOT(d_func(), void _q_ctcpReplyReceived(const QString&, const QString&));
    00213         Q_PRIVATE_SLOT(d_func(), void _q_ctcpActionReceived(const QString&, const QString&));
    00214         Q_PRIVATE_SLOT(d_func(), void _q_numericMessageReceived(const QString&, uint code, const QStringList&));
    00215         Q_PRIVATE_SLOT(d_func(), void _q_unknownMessageReceived(const QString&, const QStringList&));
    00216 #endif // IRC_NO_DEPRECATED
    00217
    00218         friend class Buffer;
    00219         friend class BufferPrivate;
    00220     };
    00221 }
    00222
    00223 #ifndef QT_NO_DEBUG_STREAM
    00224 IRC_EXPORT QDebug operator<<(QDebug debug, const Irc::Session* session);
    00225 #endif // QT_NO_DEBUG_STREAM
    00226
    00227 Q_DECLARE_OPERATORS_FOR_FLAGS(Irc::Session::Options)
    00228
    00229 #endif // IRC_SESSION_H