My Project
blobiohandler.h
1/*
2 * This file is part of signon
3 *
4 * Copyright (C) 2009-2011 Nokia Corporation.
5 * Copyright (C) 2012-2016 Canonical Ltd.
6 *
7 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * version 2.1 as published by the Free Software Foundation.
12 *
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 */
23
24#ifndef BLOBIOHANDLER_H
25#define BLOBIOHANDLER_H
26
27#include <QObject>
28#include <QIODevice>
29#include <QVariantMap>
30#include <QSocketNotifier>
31
32namespace SignOn {
33
34class BlobIOHandler: public QObject
35{
36 Q_OBJECT
37
38public:
39 BlobIOHandler(QIODevice *inputChannel,
40 QIODevice *outputChannel,
41 QObject *parent = 0);
42 //sync call
43 bool sendData(const QVariantMap &map);
44 //async call
45 void receiveData(int expectedDataSize);
46
47 void setReadChannelSocketNotifier(QSocketNotifier *notifier);
48 bool isReading() const { return m_isReading; }
49
50public Q_SLOTS:
51 void readBlob();
52
53Q_SIGNALS:
54 void dataReceived(const QVariantMap &map);
55 void error();
56
57private:
58 void setReadNotificationEnabled(bool enable);
59
60 QByteArray variantMapToByteArray(const QVariantMap &map);
61 QVariantMap byteArrayToVariantMap(const QByteArray &array);
62 QVector<QByteArray> pageByteArray(const QByteArray &array);
63
64public:
65 QIODevice *m_readChannel;
66 QIODevice *m_writeChannel;
67 QByteArray m_blobBuffer;
68 QSocketNotifier *m_readNotifier;
69 int m_blobSize;
70 bool m_isReading;
71};
72
73}
74
75#endif //BLOBIOHANDLER_H
Error codes for ui interaction.