automotive-message-broker  0.14.803
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
irccoms.h
1 /*
2  Copyright (C) 2012 Intel Corporation
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #ifndef COMMUNICATION_H
20 #define COMMUNICATION_H
21 #include <QObject>
22 #include <QVariant>
23 #include <QStringList>
24 #include <QSslError>
25 #include <map>
26 #include <QAbstractSocket>
27 
28 #include <IrcSession>
29 #include <IrcMessage>
30 
31 class IrcCommunication: public IrcSession
32 {
33  Q_OBJECT
34  Q_PROPERTY(QStringList channels READ channels WRITE setChannels)
35  Q_PROPERTY(bool ssl READ ssl WRITE setSsl)
36 public:
37  IrcCommunication(std::map<std::string, std::string> config, QObject* parent=0);
38  QStringList channels() { return mChannels; }
39  void setChannels(QStringList c) { mChannels = c; }
40 
41  void announceDequeue();
42 
43  bool ssl() { return isSecure(); }
44 
45 public Q_SLOTS:
46  void respond(QString target, QString msg);
47  void announce(QString);
48  void connect(QString host,int port, QString proxy, QString user, QString nick, QString pass);
49  void setSsl(bool use);
50  void setIgnoreInvalidCert(bool ignore);
51  void join(QString channel);
52 
53  void debugMessage(QString v) { qDebug()<<v; }
54 
55  void reconnect();
56 
57 private Q_SLOTS:
58  void onMessageReceived(IrcMessage*);
59  void sslError(QList<QSslError>);
60  void socketError(QAbstractSocket::SocketError);
61 
62 Q_SIGNALS:
63  void message(QString sender, QString prefix, QString codes);
64 
65 private:
66  QStringList announceQueue;
67  QStringList mChannels;
68 };
69 
70 #endif // COMMUNICATION_H