/* * Copyright (C) 2016 Robert Ancell * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. See http://www.gnu.org/copyleft/gpl.html the full text of the * license. */ #ifndef IRC_CLIENT_H #define IRC_CLIENT_H #include #include enum UserMode { Away = 1 << 0, Present = 1 << 1, Invisible = 1 << 2, Visible = 1 << 3, ReceiveWallops = 1 << 4, IgnoreWallops = 1 << 5, DropOperator = 1 << 6, DropLocalOperator = 1 << 7, }; class IRCClient: public QObject { Q_OBJECT public: explicit IRCClient (QObject *parent = 0); Q_INVOKABLE void connectToServer (const QString &host, quint16 port); Q_INVOKABLE void connectToSslServer (const QString &host, quint16 port); Q_INVOKABLE void sendPassword (const QString& password); Q_INVOKABLE void sendSetNickname (const QString& nickname); Q_INVOKABLE void sendUserInformation (const QString& userName, bool receiveWallops, bool isInvisible, const QString& realName); Q_INVOKABLE void sendUserInformation (const QString& userName, const QString& realName); Q_INVOKABLE void sendSetOperator (const QString& userName, const QString& password); Q_INVOKABLE void sendSetUserMode (const QString& nickname, UserMode mode); Q_INVOKABLE void sendRegisterService (const QString& nickname, const QString& distribution, const QString& info); Q_INVOKABLE void sendQuit (const QString& message); Q_INVOKABLE void sendQuit (); Q_INVOKABLE void sendServerQuit (const QString& server, const QString& comment); Q_INVOKABLE void sendJoin (const QStringList& channels); Q_INVOKABLE void sendJoin (const QString& channel); Q_INVOKABLE void sendPart (const QStringList& channels, const QString& message); Q_INVOKABLE void sendPart (const QString& channel, const QString& message); Q_INVOKABLE void sendPart (const QString& channel); Q_INVOKABLE void sendPartAll (); Q_INVOKABLE void sendSetChannelMode (const QString& channel); Q_INVOKABLE void sendSetTopic (const QString& channel, const QString& topic); Q_INVOKABLE void sendGetTopic (const QString& channel); Q_INVOKABLE void sendGetNames (const QStringList& channels, const QString& target); Q_INVOKABLE void sendGetNames (const QStringList& channels); Q_INVOKABLE void sendListChannels (const QStringList& channels, const QString& target); Q_INVOKABLE void sendListChannels (const QStringList& channels); Q_INVOKABLE void sendListChannels (); Q_INVOKABLE void sendListChannel (const QString& channel, const QString& target); Q_INVOKABLE void sendListChannel (const QString& channel); Q_INVOKABLE void sendInvite (const QString& nickname, const QString& channel); Q_INVOKABLE void sendKick (const QStringList& channels, const QStringList& usernames, const QString& comment); Q_INVOKABLE void sendKick (const QString& channel, const QString& username, const QString& comment); Q_INVOKABLE void sendKick (const QString& channel, const QStringList& usernames, const QString& comment); Q_INVOKABLE void sendMessage (const QString& target, const QString& text); Q_INVOKABLE void sendNotice (const QString& target, const QString& text); Q_INVOKABLE void sendGetMOTD (const QString& target); Q_INVOKABLE void sendGetMOTD (); Q_INVOKABLE void sendListUsers (); Q_INVOKABLE void sendGetVersion (const QString& target); Q_INVOKABLE void sendGetVersion (); Q_INVOKABLE void sendGetStats (); Q_INVOKABLE void sendGetLinks (); Q_INVOKABLE void sendGetTime (const QString& target); Q_INVOKABLE void sendGetTime (); Q_INVOKABLE void sendConnect (const QString& targetServer, quint32 port, const QString& remoteServer); Q_INVOKABLE void sendTrace (const QString& target); Q_INVOKABLE void sendTrace (); Q_INVOKABLE void sendGetAdmin (const QString& target); Q_INVOKABLE void sendGetAdmin (); Q_INVOKABLE void sendGetServerInfo (const QString& target); Q_INVOKABLE void sendGetServerInfo (); Q_INVOKABLE void sendPing (const QString& server1, const QString& server2); Q_INVOKABLE void sendPing (const QString& server); Q_INVOKABLE void sendPong (const QString& server1, const QString& server2); Q_INVOKABLE void sendPong (const QString& server); Q_INVOKABLE void sendReloadConfiguration (); Q_INVOKABLE void sendShutdownServer (); Q_INVOKABLE void sendRestartServer (); signals: void commandReceived (const QString& prefix, const QString& command, const QStringList& params); void joinReceived (const QString& prefix, const QString& channel); void partReceived (const QString& prefix, const QString& channel, const QString& message); void setTopicReceived (const QString& prefix, const QString& channel, const QString& topic); void messageReceived (const QString& prefix, const QString& target, const QString& text); void pingReceived (const QString& prefix, const QString& server1, const QString& server2); void getTopicReplyReceived (const QString& prefix, const QString& channel, const QString& topic); void getNamesReplyReceived (const QString& prefix, const QString& channel, const QStringList& nicknames); private slots: void readData (); private: QTcpSocket *socket; QByteArray read_buffer; void sendCommand (const QString& command, const QStringList& parameters); void sendCommand (const QString& command, const QString& parameter); void sendCommand (const QString& command); }; #endif