123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- /*
- * Connection.h
- * nirc
- *
- * Created by Niklas Bölter on 02.02.10.
- * Copyright 2010 Frubar Corporation.
- *
- *
- * 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 2 of the License, or
- * (at your option) any later version.
- *
- *
- *
- */
- #ifndef NIRC_CONNECTION_H
- #define NIRC_CONNECTION_H
- #include <QObject>
- #include <QSslSocket>
- #include <QSslError>
- #include <QString>
- #include <QStringList>
- #include <QQueue>
- #include <QHostInfo>
- #include <QTimer>
- #include <QDebug>
- struct ConnectionSettings {
- int id;
- QString host;
- quint16 port;
- QString name;
- bool isSSL;
- bool ignoreSSLErrors;
- };
- class Connection : public QObject
- {
- Q_OBJECT
- public:
- Connection(int cid);
- int getID();
- void open(ConnectionSettings settings);
- void splitLines();
- bool hasLines();
- void sendLine(QString line);
- QString nextLine();
- private:
- int id;
- bool ssl;
- bool ignoreSSLErrors;
- QSslSocket *socket;
- QString readBuffer;
- QByteArray writeBuffer;
- QQueue<QString> lines;
- private slots:
- void sendBuffer();
- void readyRead();
- void encrypted();
- void connected();
- void disconnected();
- void socketError();
- void sslErrors(QList<QSslError> error);
- signals:
- void dataReady(int cid);
- void connected(int cid);
- void disconnected(int cid);
- void message(int cid, QString msg);
- };
- #endif
|