1 | /*************************************************************************** |
2 | * Copyright (C) 2013 by Volker Krause <vkrause@kde.org> * |
3 | * * |
4 | * This program is free software; you can redistribute it and/or modify * |
5 | * it under the terms of the GNU Library General Public License as * |
6 | * published by the Free Software Foundation; either version 2 of the * |
7 | * License, or (at your option) any later version. * |
8 | * * |
9 | * This program 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 * |
12 | * GNU General Public License for more details. * |
13 | * * |
14 | * You should have received a copy of the GNU Library General Public * |
15 | * License along with this program; if not, write to the * |
16 | * Free Software Foundation, Inc., * |
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * |
18 | ***************************************************************************/ |
19 | |
20 | #ifndef SESSION_H |
21 | #define SESSION_H |
22 | |
23 | #include <QObject> |
24 | #include <QLocalSocket> |
25 | #include <QTime> |
26 | |
27 | class QIODevice; |
28 | class QSocketNotifier; |
29 | |
30 | /** ASAP CLI session. */ |
31 | class Session : public QObject |
32 | { |
33 | Q_OBJECT |
34 | public: |
35 | explicit Session(const QString &input, QObject *parent = 0); |
36 | ~Session(); |
37 | |
38 | void printStats() const; |
39 | |
40 | public Q_SLOTS: |
41 | void connectToHost(); |
42 | |
43 | Q_SIGNALS: |
44 | void disconnected(); |
45 | |
46 | private Q_SLOTS: |
47 | void inputAvailable(); |
48 | void serverDisconnected(); |
49 | void serverError(QLocalSocket::LocalSocketError socketError); |
50 | void serverRead(); |
51 | |
52 | private: |
53 | QIODevice *m_input; |
54 | QIODevice *m_session; |
55 | QSocketNotifier *m_notifier; |
56 | |
57 | QTime m_connectionTime; |
58 | qint64 m_receivedBytes; |
59 | qint64 m_sentBytes; |
60 | }; |
61 | |
62 | #endif // SESSION_H |
63 | |